0

我在序言中将\quan宏定义为一致地排版数量(复制如下),它工作正常……除了在 pdflatex 抱怨我有一个未定义的控制序列并崩溃的图形标题中。

如何修改宏以使其在字幕环境中工作?

谢谢!

\let\unitsep=\,     % Inserted at spaces in second arg, separates units (A s)
\let\numunitsep=\;  % Separator between number and unit (12.3 V)
\makeatletter
\def\quan#1{\ifmmode \let\@shiftmath=\relax \else \let\@shiftmath=$\fi
\@shiftmath \uppercase{\def\@quanarg{#1}}%
\expandafter\@quannum\@quanarg E\@noexp\@end \futurelet\@nextchar\@quanunit}
\def\@quannum#1E#2\@end{\@quanmant#1\@end \ifx\@noexp#2 \else \@quanexp#2\fi}
\def\@quanmant#1{\ifx#1\@end \let\@next=\relax \else
\if,#1\mathord,\else #1\fi \let\@next=\@quanmant \fi \@next}
\def\@quanexp#1E\@noexp{\times 10^{#1}}
\def\@quanunit{\if[\@nextchar
\def\@next[##1]{\numunitsep\mathrm{##1}\endgroup\@shiftmath}%
\begingroup\@quanspace \else \let\@next=\@shiftmath \fi \@next}
{\catcode`\ =\active\gdef\@quanspace{\catcode`\ =\active\let =\unitsep}}
\makeatother
4

1 回答 1

1

这有点无法回答,但它可能会siunitx用于此目的。

至于为什么字幕中可能出现问题,请记住字幕是写入.lof.lot文件的,因此您必须担心宏的脆弱性或其他问题。这个问题的根源是宏在被写出之前被扩展,这意味着当它们最终执行时——当它们在下一次运行时从文件中读入时——它们不一定表现得像一个可能的那样期望(我以前被这个弄糊涂了)。(我并不是说这绝对是你的问题,但你在动人的争论中提到失败意味着这是我首先要看的地方)。

于 2010-08-28T14:07:35.447 回答