bibtex 和 hyperref 的新命令中出现奇怪的错误

bibtex 和 hyperref 的新命令中出现奇怪的错误

我在使用 newcommand 和 bibtex 时遇到了一个非常奇怪的问题,因为我希望某些引文的颜色不同。我在下面创建了一个 MWE,其中包含我想要做的事情。基本上,我有两个命令 citeRedColored 和 citeBlueColored,它们应该使用各自的颜色来制作引文。这两个命令的定义完全相同。但是,citeBlueColored 工作正常,但 citeRedColored 总是输出错误

“超出 TeX 容量,抱歉 [输入堆栈大小=5000]。 \font@name ->”

我真的很迷茫,正如你所见,这两个功能完全相同......

非常感谢你的帮助 !

\documentclass[11pt]{article}
\usepackage{hyperref}

\hypersetup{colorlinks,citecolor={green}} 

\newcommand{\citeRedColored}[1]{\hypersetup{citecolor=red}\cite{‌#1}\hypersetup{citecolor=green}}
\newcommand{\citeBlueColored}[1]{\hypersetup{citecolor=blue}\cite{#1}\hypersetup{citecolor=green}}
\title{My file}
\author{}
\begin{document}

\maketitle

\cite{paper1} was published later than \cite{paper2} 
\\ 
\citeRedColored{paper1} was published later than \citeRedColored{paper2} 
\\
\citeBlueColored{paper1} was published later than \citeBlueColored{paper2} 

\bibliographystyle{unsrt}
\bibliography{references}

\end{document}

以下是文件 references.bib:

@article{paper1,
    title = {WordNet: a lexical database for English},
    year = {1995},
    journal = {Communications of the ACM},
    author = {Miller, George A.},
    doi = {10.1145/219717.219748},
    number = {11},
    month = {11},
    pages = {39--41},
    volume = {38},
    publisher = {ACM}
}

@article{paper2,
    title = {Real-time computer vision with OpenCV},
    year = {2012},
    journal = {Communications of the ACM},
    author = {Pulli, Kari and Baksheev, Anatoly and Kornyakov, Kirill and Eruhimov, Victor},
    doi = {10.1145/2184319.2184337},
    number = {6},
    month = {6},
    pages = {61},
    volume = {55},
    publisher = {ACM}
}

答案1

你的定义包含了一个不可见的空间:其实它是这样的:

 \cite{U+200C#1}

其中 U+200C 是零宽度连接符,pdflatex 会因此而受阻。最好删除整个命令并重新输入。

相关内容