LaTeX 中的编号和字母引用

LaTeX 中的编号和字母引用

一段时间以来,维基百科有一个非常好的引用系统,其中使用相同参考的多个实例1在文本中被指示为,但从参考书目部分反向链接为1a1b等。

我想知道是否有任何软件包在 LaTeX 中提供同样的功能。我只找到了 biblatex 和 natbib,它们都没有这样的引用方案。

小样:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore[1] et dolore magna aliqua。 Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat。 Duis aute irure dolor[2] 谴责它,因为 voluptate velit esse cillum dolore eu fugiat nulla pariatur[1]。除非你不自觉地贪婪,否则你就有罪了,因为你没有做错任何事,你就没有权利做任何事[1]。

[1 a,b,c] Lorem ipsum dolor sit amet

[2] 以精英为主体,以现代方式

即所有 1 都链接到同一行,但从该行开始,每个 1 都通过一个字母链接回去。或者,您可以查看参考书目和引用样式本文

请帮助我根据此主干获取此功能的 MWE:

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{jobname.bib}
@book{ref1,
title = {Book's title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
date = {2005},
}
@book{ref2,
title = {Book's title},
author = {A. U. Thor},
location = {The City},
publisher = {Publisher},
date = {2005},
}
\end{filecontents}

\usepackage[style=ieee,backend=bibtex]{biblatex}
\bibliography{jobname}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit\cite{ref1}, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat\cite{ref2}. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui\cite{ref1} officia deserunt mollit anim id est laborum.
\printbibliography
\end{document}

答案1

使用 BibLateX

可以使用\AtEveryCiteKey它插入锚点并保存每个引用命令中的反向引用。然后,您可以使用 BibLateX 的格式化功能在参考书目条目中的某个位置附加反向引用列表。

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{jobname.bib}
@book{ref1,
title = {Book's title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
date = {2005},
}
@book{ref2,
title = {Book's title},
author = {A. U. Thor},
location = {The City},
publisher = {Publisher},
date = {2005},
}
\end{filecontents}

\usepackage[style=ieee,backend=bibtex]{biblatex}
\bibliography{jobname}

\usepackage[colorlinks]{hyperref} % If needed

\makeatletter
\newcounter{backref@bref}
\AtEveryCitekey{% Appends a target for hyperlink, and setups backref
    \stepcounter{backref@bref}%
        \ifhyperref{%
            \Hy@raisedlink{\hypertarget{bref.\thebackref@bref}{}}%
        }{}%
        \listcsxadd{bref@\abx@field@entrykey}{bref.\thebackref@bref}%
}
\AfterEndPreamble{% Needs to wait until hyperref is loaded
\DeclareFieldFormat{labelnumberwidth}{%
    \printtext[brackets]{#1% Label number
    \setcounter{backref@bref}{0}%
    \renewcommand*{\do}[1]{
        \stepcounter{backref@bref}%
        \ifhyperref{\hyperlink{##1}{\alph{backref@bref}}}%
        {\alph{backref@bref}}%
    }%
    \dolistcsloop{bref@\abx@field@entrykey}% List of back refs
    }%
}}
\makeatother

\begin{document}
Lorem ipsum sit amet, consectetur adipiscing elit\cite{ref1}, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat\cite{ref2}. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui\cite{ref1} officia deserunt mollit anim id est laborum.
\printbibliography
\end{document}

渲染

使用 BibTeX 和hyperref/backref

这里有一种方法可以做到这一点,使用hyperref带有选项的包。它只是通过增加计数器backref来打印出反向引用。a,b,...

\makeatletter
\newcounter{backref@bref} %Define new counter
\long\def\hyper@letters@backref#1#2#3{ %Defines new backref printer
    \stepcounter{backref@bref}%
    \hyperlink{#3}{\alph{backref@bref}}% Shows backref@bref as a letter
}
\let\backrefxxx\hyper@letters@backref %Selects printer
\renewcommand{\backref}[1]{%
    \setcounter{backref@bref}{0} %Reset the counter at each ref
    [#1\ ]%
}
\makeatother

要将 backref 放入参考标签内(例如在维基百科中),我想您必须挂接到\bibitem

另请注意,此backref包旨在打印后面引用的章节或页码,这比编号更好a,b..特别是当您计划打印该文档时。

相关内容