[texhax] illegal parameter

Heiko Oberdiek heiko.oberdiek at googlemail.com
Fri Jul 1 20:38:48 CEST 2011


On Fri, Jul 01, 2011 at 01:03:03PM -0400, Barbara Beeton wrote:

>     I am confused about the error I am getting in the following.
>     (I have commented out the file calls and the code which seems irrelevant to the problem.
>     I defined the macro \ve to replace \vec, since the latter puts a tiny arrow above even a long expression.
>     I presume this is the source of the problem, but I have used \ve millions of times with no such problem.)
>     The error points to the caption line (near the end of the figure->center environment, six lines before the end of the code.
> 
> i haven't tested this, but i suspect the
> problem may be the use of non-robust
> commands in the caption.  try putting
> \protect before each of them:
> 
>   \caption{$\protect\vu+(\protect\vv+\protect\vw)$(dashed)
>     $=(\protect\vu+\protect\vv)+\protect\vw$ (dotted)}

Yes that's the reason and solution.
 
>     \newcommand{\ve}[1]{\ensuremath{\overrightarrow{#1}}}
>     
>     \newcommand{\vu}{\ve{u}}
>     \newcommand{\vv}{\ve{v}}
>     \newcommand{\vw}{\ve{w}}

Instead of using \protect everywhere, \ve can be made robust:

  \newcommand*{\ve}[1]{%
    \protect\ensuremath{\protect\overrightarrow{#1}}%
  }

or

  \newcommand*{\ve}{}% test if \ve is undefined
  \DeclareRobustCommand*{\ve}[1]{%
    \ensuremath{\overrightarrow{#1}}%
  }%

Yours sincerely
  Heiko Oberdiek


More information about the texhax mailing list