忽略参考书目条目中的可选参数

忽略参考书目条目中的可选参数

我有一长串的参考文献,例如:

\bibitem[optionalarg]{label} Text of the reference

当我编译源代码时,这使得引用的参考资料像[optionalarg]在文本中一样出现,而不是以数字的形式出现[X]

有没有办法告诉 BibTeX 忽略该可选参数?

这是一个显示我的问题的最小例子:

\documentclass[12pt]{amsart}

\begin{document}

\title[Short title]{Long title}

\maketitle

This is a minimal example of what I wouldn't like (see \cite{ref1}). And of what I would like (see \cite{ref2}).

\begin{thebibliography}{00}
    \bibitem[Author1 and Author2(2013)]{ref1}
    Author1, I., \& Author2, I. (2013). Some title. \emph{Some journal}, X: xx--yy.
    \bibitem{ref2}
    Author3, I., \& Author4, I. (2013). Some other title. \emph{Some other journal}, X: xx--yy.
\end{thebibliography}

\end{document}

答案1

您可以通过在序言中添加以下内容来重新定义\bibitem[<opt>]{<key>}为忽略:[<opt>]

\let\oldbibitem\bibitem% Copy \bibitem into \oldbibitem
\renewcommand{\bibitem}[2][]{\oldbibitem{#2}}% Redefine \bibitem to only use mandatory arg

上述代码\bibitem在重新定义之前进行存储,仅传递强制参数并忽略任何可选参数。

在此处输入图片描述

\documentclass[12pt]{amsart}

\let\oldbibitem\bibitem
\renewcommand{\bibitem}[2][]{\oldbibitem{#2}}

\begin{document}

\title[Short title]{Long title}

\maketitle

This is a minimal example of what I wouldn't like (see \cite{ref1}). And of what I would like (see \cite{ref2}).

\begin{thebibliography}{00}
  \bibitem[Author1 and Author2(2013)]{ref1}
    Author1, I., \& Author2, I. (2013). Some title. \emph{Some journal}, X: xx--yy.
  \bibitem{ref2}
    Author3, I., \& Author4, I. (2013). Some other title. \emph{Some other journal}, X: xx--yy.
\end{thebibliography}

\end{document}

相关内容