Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\overrightarrow macro in \caption

1,011 views
Skip to first unread message

Pirouz Djoharian

unread,
Nov 3, 2007, 6:08:14 AM11/3/07
to
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 \reserved@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

unread,
Nov 3, 2007, 6:30:23 AM11/3/07
to
+ "Pirouz Djoharian" <Pirouz.D...@free.fr>:

> \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 \reserved@a.

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

Robin Fairbairns

unread,
Nov 3, 2007, 7:13:30 AM11/3/07
to
"Pirouz Djoharian" <Pirouz.D...@free.fr> writes:
>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) :
>[...]

>
>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 \z@skip \halign {##\crcr $\mathsurround \z@ \relax \setbox \z@ \hbox {\color@begingroup -\color@endgroup }\ht \z@ \z@ \dp \z@ \z@ \box \z@ \mkern -7mu\cleaders \hbox {$\mkern -2mu\relax \setbox \z@ \hbox {\color@begingroup -\color@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

unread,
Nov 4, 2007, 11:06:16 AM11/4/07
to
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.

.


cong...@gmail.com

unread,
Apr 14, 2015, 8:39:00 PM4/14/15
to
I met the same problem, and it was solved by your suggestion on adding \protect, thank you so much!

wangp...@gmail.com

unread,
Jan 18, 2018, 10:51:53 AM1/18/18
to
在 2007年11月3日星期六 UTC+1上午11:08:14,Pirouz Djoharian写道:
Thank you very much, It help me fix the same problem.
0 new messages