当我使用\cite[something with spaces]{ref}
inside时\sout{...}
,会出现错误。对于article
文档类,用 替换空格会有所帮助~
。但是,这对文档类没有帮助elsarticle
。请参阅下面的最小工作示例:
\documentclass{elsarticle}
% \documentclass{article}
\usepackage{ulem}
\begin{document}
text
\cite{lamport}
\cite[p.10]{lamport}
\cite[p. 10]{lamport}
\cite[p.~10]{lamport}
\sout{text}
\sout{\cite{lamport}}
\sout{\cite[p.10]{lamport}}
% \sout{\cite[p. 10]{lamport}} % Fails with elsarticle and article
% \sout{\cite[p.~10]{lamport}} % Fails with elsarticle only
\begin{thebibliography}{9}
\bibitem{lamport}
Leslie Lamport,
\textit{\LaTeX: a document preparation system},
Addison Wesley, Massachusetts,
2nd edition,
1994.
\end{thebibliography}
\end{document}
因为article
我得到了
! Argument of \UL@word has an extra }.
而elsarticle
我得到
! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup
\egroup \UL@putbox \fi \if...
这是错误吗ulem
?如果有人知道快速修复方法,我将不胜感激。
亲切的问候。
答案1
虽然我在发帖前尝试寻找答案,但直到发帖后才找到。请参阅ulem 与 \cite 中的多个条目不兼容我希望ulem
没有这个问题,但一个快速解决方法似乎是添加\cite
一个\mbox
:
\sout{\mbox{\cite[p. 10]{lamport}}} % Fails with elsarticle and article
\sout{\mbox{\cite[p.~10]{lamport}}} % Fails with elsarticle only
答案2
只需将花括号括起来p. 10
:
\documentclass{elsarticle}
% \documentclass{article}
\usepackage{ulem}
\begin{document}
\sout{\cite[{p. 10}]{lamport}}
\begin{thebibliography}{9}
\bibitem{lamport}
Leslie Lamport,
\textit{\LaTeX: a document preparation system},
Addison Wesley, Massachusetts,
2nd edition,
1994.
\end{thebibliography}
\end{document}