如何使 \autocites 像 \supercite 一样使用方括号和分组

如何使 \autocites 像 \supercite 一样使用方括号和分组

我找到了如何用\supercite方括号分组 Biblatex supercite 带方括号和分组

所以我添加了 biblatex 包的选项autocite=superscript,并得到了这个 MWE:

\documentclass{article}

\usepackage[autocite=superscript,citestyle=numeric-comp]{biblatex}


\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}%
  \bibopenbracket}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}\bibclosebracket}

\usepackage{filecontents}

\begin{filecontents}{test.bib}
@book{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@book{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@article{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}

\addbibresource{test.bib}

\begin{document}

We are citing \autocites{A01}{B02}{C03} and \autocites{A01}{C03} and \autocites*{A01}{B02}.

\printbibliography

\end{document}

但数字没有分组。我得到的[1],[2],[3]是 而不是[1-3]

答案1

这里的问题有两个方面。

  1. 您可以通过将括号移到包装器命令而不是前置和后置代码中并对多引用命令执行相同的操作来获得更好的结果。

  2. multicite 命令不会对不同组的引用进行排序或压缩。另请参阅https://github.com/plk/biblatex/issues/817(如链接讨论中的最后一篇文章所示,存在一些不太优雅的解决方法)。

目前我所能提供的是

\documentclass{article}

\usepackage[style=numeric-comp, autocite=superscript]{biblatex}

\newrobustcmd*{\mkbibbracketedsuperscript}[1]{%
  \mkbibsuperscript{\mkbibbrackets{#1}}}

\DeclareCiteCommand{\supercite}[\mkbibbracketedsuperscript]
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

\DeclareMultiCiteCommand{\supercites}[\mkbibbracketedsuperscript]
  {\supercite}{\supercitedelim}

\addbibresource{biblatex-examples.bib}

\begin{document}
We are citing \autocites{sigfridsson}{worman}{nussbaum} and \autocites{sigfridsson}{nussbaum} and \autocites*{sigfridsson}{worman}.

We are citing \autocite{sigfridsson,worman,nussbaum} and \autocite{sigfridsson,nussbaum} and \autocite*{sigfridsson,worman}.

\printbibliography
\end{document}

在此处输入图片描述

相关内容