cleveref
的\cref
命令非常适合自动将前缀(如 fig(s.)、section(s)、eq(s.) 等)添加到交叉引用中。不幸的是,它(本身)不提供用于引用的此功能?
我正在寻找一个\ccite
行为如下的命令:
\ccite{ref1}
-”参考。~[1]”\ccite{ref1,ref5,ref11}
-”参考文献~[1,5,11]”
可以biblatex
用来实现这个吗?或者可以扩展以支持引用?如果没有,是否有另一个提供此功能且与和cleveref
兼容的包?这是一个 MWE:biblatex
cleveref
\documentclass{article}
\usepackage{hyperref,cleveref}
\usepackage[backend=biber,sorting=none,citestyle=numeric-comp]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
Early on, Herrmann showed in ref.~\cite{herrmann} that grass is green.
A collaborative research effort was later able to demonstrate in refs.~\cite{bertram,doody,gillies,glashow} that the sky is blue.
\printbibliography
\end{document}
答案1
您可以更改\cite
命令或创建一个自动添加“ref.”或“refs.”的新命令:
\documentclass{article}
\usepackage{hyperref,cleveref}
\usepackage[backend=biber,sorting=none,citestyle=numeric-comp]{biblatex}
\addbibresource{biblatex-examples.bib}
\NewBibliographyString{refname}
\NewBibliographyString{refsname}
\DefineBibliographyStrings{english}{%
refname = {ref\adddot},
refsname = {refs\adddot}
}
\DeclareCiteCommand{\cite}
{%
\ifnum\thecitetotal=1
\bibstring{refname}%
\else%
\bibstring{refsname}%
\fi%
\addspace\bibopenbracket%
\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}%
\usebibmacro{postnote}%
\bibclosebracket}
\renewrobustcmd*{\Cite}{\bibsentence\cite}
\begin{document}
In sentence \cite{herrmann}.
In sentence \cite{bertram,doody,gillies,glashow}.
\Cite{herrmann} at start of sentence.
\Cite{bertram,doody,gillies,glashow} at start of sentence.
\printbibliography
\end{document}