巧妙引用命令

巧妙引用命令

cleveref\cref命令非常适合自动将前缀(如 fig(s.)、section(s)、eq(s.) 等)添加到交叉引用中。不幸的是,它(本身)不提供用于引用的此功能?

我正在寻找一个\ccite行为如下的命令:

  • \ccite{ref1}-”参考。~[1]”
  • \ccite{ref1,ref5,ref11}-”参考文献~[1,5,11]”

可以biblatex用来实现这个吗?或者可以扩展以支持引用?如果没有,是否有另一个提供此功能且与和cleveref兼容的包?这是一个 MWE:biblatexcleveref

\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}

在此处输入图片描述

相关内容