复杂数字式引文标注

复杂数字式引文标注

我使用该软件包cleveref生成交叉引用,例如“图 4”,而不仅仅是“4”,并且“图”一词也可以点击。但是,cleveref不会创建引文标注。

我想知道如何才能\cite{einstein}生成“参考 1”而不是“1”,并且“参考”一词也可以点击。谢谢您的帮助。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage[style=nejm, backend=biber]{biblatex}
\addbibresource{sample.bib}

\begin{document}
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's 
book \cite{dirac} are physics related items. 

\printbibliography

\end{document}

参考书目文件(sample.bib):

@article{einstein,
    author =       "Albert Einstein",
    title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
    [{On} the electrodynamics of moving bodies]",
    journal =      "Annalen der Physik",
    volume =       "322",
    number =       "10",
    pages =        "891--921",
    year =         "1905",
    DOI =          "http://dx.doi.org/10.1002/andp.19053221004",
    keywords =     "physics"
}

@book{dirac,
    title={The Principles of Quantum Mechanics},
    author={Paul Adrien Maurice Dirac},
    isbn={9780198520115},
    series={International series of monographs on physics},
    year={1981},
    publisher={Clarendon Press},
    keywords = {physics}
}

答案1

biblatex-nejm基于numeric-compnumeric-comp修改起来相当复杂,所以我们需要相当多的代码。

Reference\addspace这个想法是在所有块之前添加\printfield{labelprefix}\printfield{labelnumber}

\documentclass[12pt,twoside]{article}
\usepackage[spanish,es-noquoting]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{hyperref}
\usepackage[style=nejm, backend=biber]{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter
\renewbibmacro*{cite:comp:comp}{%
  \ifboolexpr{
    ( test {\iffieldundef{labelprefix}} and test {\ifundef\cbx@lastprefix} )
    or
    test {\iffieldequals{labelprefix}{\cbx@lastprefix}}
  }
    {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}}
       {\savefield{entrykey}{\cbx@lastkey}%
        \savefield{labelnumber}{\cbx@lastnumber}%
        \addtocounter{cbx@tempcnta}{1}}
       {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}-1}
          {}
          {\usebibmacro{cite:dump}%
           \ifnumgreater{\value{cbx@tempcntb}}{-1}
             {\multicitedelim}
             {}%
           \printtext[bibhyperref]{%
             Reference\addspace
             \printfield{labelprefix}%
             \printfield{labelnumber}}}}}
    {\usebibmacro{cite:comp:end}}%
  \setcounter{cbx@tempcntb}{\thefield{labelnumber}}%
  \savefield{labelprefix}{\cbx@lastprefix}}

\renewbibmacro*{cite:comp:end}{%
  \usebibmacro{cite:dump}%
  \ifnumgreater{\value{cbx@tempcntb}}{-1}
    {\multicitedelim}
    {}%
  \printtext[bibhyperref]{%
    Reference\addspace
    \printfield{labelprefix}%
    \printfield{labelnumber}}}

\renewbibmacro*{cite:dump}{%
  \ifnumgreater{\value{cbx@tempcnta}}{0}
    {\ifnumgreater{\value{cbx@tempcnta}}{1}
       {\bibrangedash}
       {\multicitedelim}%
     \bibhyperref[\cbx@lastkey]{%
       Reference\addspace
       \ifdef\cbx@lastprefix
         {\printtext[labelprefix]{\cbx@lastprefix}}
         {}%
       \printtext[labelnumber]{\cbx@lastnumber}}}
    {}%
  \setcounter{cbx@tempcnta}{0}%
  \global\undef\cbx@lastprefix}
\makeatother

\begin{document}
In particular we can cite \cite{sigfridsson} but could also be \cite{geer} or anything \cite{sigfridsson,nussbaum,geer}.

In particular we can cite \cite{sigfridsson} but could also be \cite{nussbaum} or anything.

In particular we can cite \cite{worman} but could also be \cite{geer} or anything \cite{sigfridsson,nussbaum,geer,knuth:ct:a}.

\printbibliography
\end{document}

在此处输入图片描述

相关内容