3

For a while now, wikipedia has a really nice citation system, where multiple instances where the same reference is used are indicated as, say 1 in the text, but are back-linked from the bibliography section as 1a, 1b, etc.

I am wondering if there is any package offering this same functionality in LaTeX. I was only able to find biblatex and natbib, none of which have such a citation scheme.

Mockup:

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] in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur[1]. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum[1].

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

[2] Consectetur adipiscing elit, sed do eiusmod tempo

whereby all 1's link to the same line, but from that line, each one of them is linked back to by one letter. Alternatively, you can look at the bibliography and citation style of this article.

Please help me get a MWE of this functionality based on this backbone:

\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}
2
  • I'm not sure I quite follow: could you include a mock-up of the output you want?
    – Joseph Wright
    Commented Feb 19, 2015 at 13:13
  • hope this is clearer now.
    – TheChymera
    Commented Feb 19, 2015 at 13:29

1 Answer 1

5

Using BibLateX

It is possible to use \AtEveryCiteKey to insert an anchor and save the backref at each cite command. Then you can use BibLateX's formatting capabilities to append a list of backreference somewhere in the bibliography entries.

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

rendering

Using BibTeX and hyperref/backref

Here is a way to do it, using the hyperref package with the backref option. It simply prints out the backrefs using a,b,... by incrementing a counter.

\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

To put the backref inside the reference label, such as in wikipedia, I guess you'd have to hook into \bibitem.

Also, note that this backref package is designed to print the section or page numbers of the back references, which is better than the a,b.. numbering, especially if you plan to print the document.

4
  • how should I use this code? I just added it to the header, and it did not change how my multi-referenced bibliography entries were displayed.
    – TheChymera
    Commented Feb 20, 2015 at 14:45
  • You didn't provide a MWE, so I don't know what packages you are using, but (as I mentionned in my answer), you have to use the hyperref package, with \usepackage[backref]{hyperref}. I use bibtex though, so it might not work with your particular document. Commented Feb 20, 2015 at 14:51
  • Could you provide a MWE based on the tex code I used as an example in my latest edit?
    – TheChymera
    Commented Feb 20, 2015 at 16:01
  • @TheChymera I did not see that you used BibLatex. See the updated answer. I left the BibTex version, as it might help someone else. Commented Mar 5, 2015 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .