mdwref.dtx: Make the `\xref' command robust.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 25 Jul 2022 21:45:29 +0000 (22:45 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 25 Jul 2022 21:45:29 +0000 (22:45 +0100)
Otherwise it doesn't work very well in figure captions and suchlike.

mdwref.dtx

index acfcd44..1a40fb3 100644 (file)
 % We're meant to typeset a reference.  The first job is to see whether
 % there's an optional argument.  If so, grab it; otherwise |\relax| will do.
 %    \begin{macrocode}
-\def\xref{\@ifnextchar[\xref@{\xref@[\relax]}}
+\DeclareRobustCommand\xref{\@ifnextchar[\xref@{\xref@[\relax]}}
 \def\xref@[#1]#2{\xref@@{#1}#2:\q@delim:\q@delim:\q@delim\q@delim}
 %    \end{macrocode}
 % Right; now we abuse \TeX's argument parser to pick apart the reference