General ⇒ how to make an \underrightarrow in \caption
-
- Posts: 1
- Joined: Fri Jan 11, 2008 1:25 pm
how to make an \underrightarrow in \caption
I have the following code to input a picture
\begin{figure}
\begin{center}
\includegraphics[width=8cm]{pics/notinward2}
\caption{blablabla}
which works fine.
then I have the following code to make an arrow below the letter x
$\underrightarrow{x}$
which works fine as well. Now I want to have this x with the arrow below in the \caption of the figure.
so I write
\begin{figure}
\begin{center}
\includegraphics[width=8cm]{pics/notinward2}
\caption{blablabla $\underrightarrow{x}$}
but this gives me 4 error messages, which say
illegal parameter number in definition of reserved\@
<to be read again>
What am I doing wrong? how can I do what I want?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
how to make an \underrightarrow in \caption
Tipically, commands with optional arguments are fragile. This is why the following code fails:
\section{\framebox[12em]{Section title}}
However, we can protect \framebox and solve the problem:
\section{\protect\framebox[12em]{Section title}}
So, coming back to your problem, it seems that \underrightarrow is fragile. It suffices to protect it.