答案1
BibTeX 的一个简单方法是使用包\IfSubStr
中的方法xstring
来检查参数是否包含逗号,然后打印參考或者裁判因此。
\documentclass{article}
\usepackage{xstring}
\newcommand{\ccite}[1]{%
\IfSubStr{#1}{,}{refs.~}{ref.~}\cite{#1}%
}
\newcommand{\Ccite}[1]{%
\IfSubStr{#1}{,}{Refs.~}{Ref.~}\cite{#1}%
}
\begin{document}
See \ccite{manual-full} and \ccite{inbook-minimal,incollection-minimal}.
\Ccite{manual-full} is interesting. \Ccite{inbook-minimal,incollection-minimal} not so much.
\bibliographystyle{plain}
\bibliography{xampl}
\end{document}
答案2
变体Marijn 的回答没有包:我们检查参数是否是长度大于 1 的 clist(逗号分隔列表)。
\documentclass{article}
\ExplSyntaxOn
\NewDocumentCommand{\ccite}{m}
{
\dv_ccite:nn { r } { #1 }
}
\NewDocumentCommand{\Ccite}{m}
{
\dv_ccite:nn { R } { #1 }
}
\cs_new_protected:Nn \dv_ccite:nn
{
#1ef % #1 is either r or R
\int_compare:nT { \clist_count:n { #2 } > 1 } { s } % if more than one, print s
.\nobreakspace
\cite{#2}
}
\ExplSyntaxOff
\begin{document}
See \ccite{manual-full} and \ccite{inbook-minimal,incollection-minimal}.
\Ccite{manual-full} is interesting. \Ccite{inbook-minimal,incollection-minimal} not so much.
\bibliographystyle{plain}
\bibliography{xampl}
\end{document}
另一方面,我从未见过以“ref.”开头的引文标记。