\cite{}
我的手艺中有许多空的命令,例如:
\cite{ }
\cite{ , , }
\cite{,}
这会让编译器疯狂。
如何让编译器跳过这个检查?
答案1
以下忽略所有空的項目。
\documentclass{article}
\makeatletter
\def\@citex[#1]#2{\leavevmode
\let\@citea\@empty
\@cite{\@for\@citeb:=#2\do
{\@citea\def\@citea{,\penalty\@m\ }%
\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
\expandafter\ifx\expandafter\relax\@citeb\relax\else%% Test if empty
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\@cite@ofmt{\csname b@\@citeb\endcsname}}%
\fi}}{#1}}
\makeatother
\begin{document}
foo\cite{ } % ignored
bar\cite{ , , } % ignored
baz\cite{,} % ignored
\cite{foo}
\end{document}