[latexrefman-discuss] \protect, Mysterious error about missing closing round bracket

Vincent Belaïche vincent.belaiche at domain.hid
Tue Feb 9 18:58:15 CET 2016


Feedback below...

Le 09/02/2016 00:31, Karl Berry a écrit :
>     but the simple silly home-made command which I
>     was proposing also is fragile
>
> Yes, I understand.
>
>     I acknowledge that \MyFragileCmd above may be a bit out-of-scope
>
> Right.  We don't want to get into \ifx.
>
>     when \newcommand* is used to define a command with an optional
>     argument, then it automatically robustify the command.
>
> Interesting.  
>
>     Probably we should also some day speak about robustification and
>     indicate that \newcommand behaves this way.
>
> Yes.
>
>     Is that something TeXLive does too ?
>
> Well, I didn't try it, but I'd be shocked if it was MiKTeX-specific.
> Surely this is done in the LaTeX code.  Basically all that TL and MiKTeX
> do is redistribute it, not change it.  -k
>
>

Back to your 2016-02-06T01:07 suggestion to use verbatim in the example,
sorry, could you be more specific, as I did not manage to build any
working example using verbatim text.

I have made below another funny example, that could be useful if you
have a very long caption and you want it abbreviated in the LOF. If you
remove the \protect the trick does not work because the \ifinfig...\fi
get expanded before writing to the .lof file.

--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
\documentclass{article}
\newif\ifinfig
\begin{document}
\infigfalse
\listoffigures
\infigtrue
\begin{figure}
   ...
  \caption{The caption \protect\ifinfig below figure\protect\else in LOF\protect\fi}
\end{figure}
\end{document}
--8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----

VBR,
	Vincent




More information about the latexrefman mailing list