Discussion:
\overrightarrow macro in \caption
(too old to reply)
Pirouz Djoharian
2007-11-03 10:08:14 UTC
Permalink
Hello evryone
I have a error message when I put a \overrightarrow in a \caption macro.
Here is an example to illustrate the problem (compiled with tetex (debian)
and miktex (wndows) :

\documentclass{article}
\begin{document}
\begin{figure}
\caption{vector $\overrightarrow{OM}$}
\end{figure}
\end{document}

the error message (from out.log) :
! Illegal parameter number in definition of \***@a.
<to be read again>
\crcr
l.6 \caption{vector $\overrightarrow{OM}$}
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

The .dvi is however properly created.
Does anyone have any idea or explanation ?
Thanks in advance
Harald Hanche-Olsen
2007-11-03 10:30:23 UTC
Permalink
Post by Pirouz Djoharian
\documentclass{article}
\begin{document}
\begin{figure}
\caption{vector $\overrightarrow{OM}$}
\end{figure}
\end{document}
Put \protect in front of \overrightarrow.
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
c***@gmail.com
2015-04-15 00:38:50 UTC
Permalink
I met the same problem, and it was solved by your suggestion on adding \protect, thank you so much!
Robin Fairbairns
2007-11-03 11:13:30 UTC
Permalink
Post by Pirouz Djoharian
I have a error message when I put a \overrightarrow in a \caption macro.
Here is an example to illustrate the problem (compiled with tetex (debian)
\documentclass{article}
\begin{document}
\begin{figure}
\caption{vector $\overrightarrow{OM}$}
\end{figure}
\end{document}
[...]
The .dvi is however properly created.
Does anyone have any idea or explanation ?
you have already had an explanation.

the error arose when writing the entry in the .aux file (writing to
the list of figures is a two-stage process). looking at the .aux, i
see

\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces vector $\vbox {\mathsurround \z@ \everycr {}\tabskip \***@skip \halign {##\crcr $\mathsurround \z@ \relax \setbox \z@ \hbox {\***@begingroup -\***@endgroup }\ht \z@ \z@ \dp \z@ \z@ \box \z@ \mkern -7mu\cleaders \hbox {$\mkern -2mu\relax \setbox \z@ \hbox {\***@begingroup -\***@endgroup }\ht \z@ \z@ \dp \z@ \z@ \box \z@ \mkern -2mu$}\hfill \mkern -7mu\mathord \rightarrow $\crcr \noalign {\kern -\p@ \prevdepth -\@m \p@ } $\hfil \displaystyle {OM}\hfil $\crcr }}$}}{1}}

which is pretty comprehensively silly, as well as being wrong.
--
Robin Fairbairns, Cambridge
Pirouz
2007-11-04 16:06:16 UTC
Permalink
Thank you for your answers.
Indeed the \protect allows to bypass the problem.
The problem arises because \overrightarrow is a fragile macro
inside a moving one.

.
w***@gmail.com
2018-01-18 15:51:46 UTC
Permalink
在 2007年11月3日星期六 UTC+1上午11:08:14,Pirouz Djoharian写道:
Post by Pirouz Djoharian
Hello evryone
I have a error message when I put a \overrightarrow in a \caption macro.
Here is an example to illustrate the problem (compiled with tetex (debian)
\documentclass{article}
\begin{document}
\begin{figure}
\caption{vector $\overrightarrow{OM}$}
\end{figure}
\end{document}
<to be read again>
\crcr
l.6 \caption{vector $\overrightarrow{OM}$}
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.
The .dvi is however properly created.
Does anyone have any idea or explanation ?
Thanks in advance
Thank you very much, It help me fix the same problem.

Loading...