我正在编辑一份 latex 文档。我需要在文本中引用多个参考文献。通常,我使用命令\cite{paper1, paper2}
来获取文本,例如[1, 2]但在最近的一份新文件中,我得到了[1,2],逗号后没有空格。我不知道为什么。希望能得到一些帮助。
示例代码是
\documentclass{iosart2c}
\usepackage[numbers]{natbib}
\cite{paper1, paper2}
\begin{thebibliography}{10}
\bibitem{paper1}
Author1 and author2.
\newblock title.
\newblock In {\em Proceedings of ACL}, pages 100--102, Baltimore, Maryland,
June 2014. Association for Computational Linguistics.
\bibitem{paper2}
Author1 and author2.
\newblock title.
\newblock In {\em Proceedings of ACL}, pages 100--102, Baltimore, Maryland,
June 2014. Association for Computational Linguistics.
\end{thebibliography}
答案1
该类包含以下代码(添加了行号以供参考):
696 \def\@citex[#1]#2{%
697 \let\@citea\@empty
698 \@cite{\@for\@citeb:=#2\do
699 {\@citea\def\@citea{,\penalty\@m\hskip.1pt}%
700 \edef\@citeb{\expandafter\@firstofone\@citeb}%
701 \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
702 \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
703 \G@refundefinedtrue
704 \@latex@warning
705 {Citation `\@citeb' on page \thepage \space undefined}}%
706 {\hbox{\csname b@\@citeb\endcsname}}}}{#1}}
相关位在第 699 行:定义
\def\@citea{,\penalty\@m\hskip.1pt}
意味着多个引用将以逗号分隔,后面跟着 0.1pt(约 0.03mm 或 0.0014in)的不可中断空格。
标准 LaTeX 代码具有
\def\@citea{,\penalty\@m\ }
因此是不可破坏的正常单词间空间。该类也在寻找natbib
,如果包已加载,它会发出
\def\set@NAT@space{\def\NAT@space{\hskip.1\p@}}
重新建立与没有时相同的间距natbib
。
因此,您看到的行为是类开发人员的精确选择。
如果您想覆盖它,您可以,但您会惹恼文字编辑:这样的类别只应用于提交给 IOS Press 期刊的文章。
\documentclass{iosart2c}
\usepackage[numbers]{natbib}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@citex}{\hskip.1pt}{\ }{}{} % when natbib is not loaded
\patchcmd{\set@natbib}{\hskip.1\p@}{\ }{}{} % for natbib
\makeatother
\begin{document}
\cite{paper1, paper2}
\begin{thebibliography}{10}
\bibitem{paper1}
Author1 and author2.
\newblock title.
\newblock In {\em Proceedings of ACL}, pages 100--102, Baltimore, Maryland,
June 2014. Association for Computational Linguistics.
\bibitem{paper2}
Author1 and author2.
\newblock title.
\newblock In {\em Proceedings of ACL}, pages 100--102, Baltimore, Maryland,
June 2014. Association for Computational Linguistics.
\end{thebibliography}
\end{document}