
一段時間以來,維基百科有一個非常好的引用系統,其中使用相同引用的多個實例在文本中表示為1
,但從參考書目部分反向連結為1a
、1b
等。
我想知道 LaTeX 中是否有任何套件提供相同的功能。我只能找到 biblatex 和 natbib,它們都沒有這樣的引用方案。
小樣:
Lorem ipsum dolor sat amet,consectetur adipiscing elit,sed do eiusmod tempor incididunt ut laboure[1] et dolore magna aliqua。 Ut enim ad minim veniam, quis nostrud exeritation ullamco labouris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor[2] in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur[1]。例外的是,如果您不這樣做,則必須承擔責任,否則將導致動物死亡[1]。
[1 a,b,c] Lorem ipsum dolor sat amet
[2] Consectetur adipiscing elit, sed do eiusmod tempo
其中所有 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..
,特別是如果您打算列印該文件。