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?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
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.