13

I'm using the multibib package but cannot get links to work with it and hyperref. Is this combination possible? A sample document follows:

If I add a \usepackage{natbib} in the preamble then links do work, but the custom labeling provided by multibib is removed. For example, without natbib the citations are [F3] and [B2] and no links. With natbib, citations are (3) and (2) and do link.

The multibib documentation (PDF) has a section (3) on how to handle packages which modify \@citex, but I am not sure how to use the information there to solve this problem.

% multibiblinktest.tex

\documentclass[10pt,letter]{article}

\usepackage[labeled,resetlabels]{multibib}
\newcites{F}{Foo}
\newcites{B}{Bar}

\usepackage{hyperref}
\hypersetup{
  colorlinks = true,
  linkcolor=blue,   % color of internal links
  citecolor=blue,   % color of links to bibliography
  urlcolor=blue,    % color of external links
  pagebackref=true,
  implicit=false,
  bookmarks=true,
  bookmarksopen=true,
  pdfdisplaydoctitle=true
}

% \usepackage{natbib} % links work, citations not formatted by multibib...

\begin{document}

\nociteF{ref1}
\nociteF{ref2}
\nociteB{ref3}

A link to \citeF{ref4} and \citeB{ref5} goes here.

\bibliographystyleF{unsrt}
\bibliographyF{test.bib}

\bibliographystyleB{unsrt}
\bibliographyB{test.bib}

\end{document}

And the bibliography file:

% test.bib
@Article {ref1, author = Author1, title = Title1, year = 2010}
@Article {ref2, author = Author2, title = Title2, year = 2010}
@Article {ref3, author = Author3, title = Title3, year = 2010}
@Article {ref4, author = Author4, title = Title4, year = 2010}
@Article {ref5, author = Author5, title = Title5, year = 2010}

And to compile the document:

pdflatex multibiblinktest
pdflatex multibiblinktest
pdflatex multibiblinktest
bibtex F
bibtex B
pdflatex multibiblinktest
pdflatex multibiblinktest
pdflatex multibiblinktest
open multibiblinktest.pdf
lockstep
  • 250,273
mankoff
  • 2,756
  • I'm not setting multibib, hyperref, and natbib as requirements to solve this issue. A different package than multibib, if it provides the desired result, would be acceptable. – mankoff Aug 28 '10 at 21:04
  • 1
    Is biblatex a possibility for you? – Joseph Wright Aug 28 '10 at 22:00
  • biblatex is a possibility. I have installed it. I have not found a simple tutorial on how to replace bibtex with biblatex, nor how to do something as complex as what I am trying to do with multibib... – mankoff Aug 28 '10 at 23:12

4 Answers4

2

You are using a standard BibTeX style with natbib. You should be using the unsrtnat style rather than unsrt as you are using the natbib package.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • That does not seem to have a positive effect on the issue. Links are created, but multibib labeling is now ignored. – mankoff Aug 29 '10 at 15:04
1

In case anyone is still lurking here to look for a solution like I was.

I managed to get the desired behavior using a combination of natbib and multibib commands and some spacing wizardry from this answer:

  • \citeF{} makes sure that multibib to the correct citation. Otherwise there would be a question mark.
  • \cite[F][]{} adds the letter F before the number as explained in the natbib reference sheet
  • Combined, your citation should look like \citeF[F][]{my_citation_2024}.

Minimal example from the question. Don't forget to add the spacing hack in the preamble.

% multibiblinktest.tex

\documentclass[10pt,letter]{article}

% add natbib before multibib to get square brackets \usepackage{natbib}

% used to remove space between letter and number \makeatletter \def\NAT@spacechar{} \makeatother

\usepackage{hyperref} \hypersetup{ colorlinks = true, linkcolor=blue, % color of internal links citecolor=blue, % color of links to bibliography urlcolor=blue, % color of external links pagebackref=true, implicit=false, bookmarks=true, bookmarksopen=true, pdfdisplaydoctitle=true }

\usepackage[labeled,resetlabels]{multibib} \newcites{F}{Foo} \newcites{B}{Bar}

\begin{document}

\nociteF{ref1} \nociteF{ref2} \nociteB{ref3}

% The formatting \citeF[F][] is the key A link to \cite[F][]{ref4} and \citeB[B][]{ref5} goes here.

\bibliographystyleF{unsrt} \bibliographyF{test.bib}

\bibliographystyleB{unsrt} \bibliographyB{test.bib}

\end{document}

enter image description here

The only difference would be that the letters are not colored and linking as well.

0

I have changed the line:

\usepackage[labeled,resetlabels]{multibib}

to

\usepackage[labeled]{multibib}

And it seems to work without natbib.

Make sure you keep multibib before hyperref!

Dima
  • 12,427
  • 8
  • 40
  • 53
  • I'm using TeXLive 2010 pretest..... I dunno if that mater. – Dima Aug 28 '10 at 23:52
  • The numbering is weird though. F1, F2, F3, B4, B5..... – Dima Aug 28 '10 at 23:53
  • Not a workable solution for me due to the numbering being messed up.

    Also, when I use the code I included above but remove the "resetlabels", I do not get links.

    My version: $ pdflatex --version pdfTeX 3.1415926-1.40.9-2.2 (Web2C 7.5.7) kpathsea version 3.5.7 Copyright 2008 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).

    – mankoff Aug 29 '10 at 00:05
  • I'm using texlive "0.20080816-3" installed via fink, which provides pdflatex version shown above. – mankoff Aug 29 '10 at 00:06
  • Mine is pdfTeX 3.1415926-1.40.11-2.2 (TeX Live 2010) but I really have no clue which one of the bunch is the culprit. – Dima Aug 29 '10 at 14:31
  • OK I've upgraded to texlive 2010 pretest, and I get the behavior you describe, which is the same behavior I get with texlive 2008 (fink). I can get links with natbib, or without natbib (no "resetlabels"), but they aren't useful multibib-themed links. – mankoff Aug 30 '10 at 15:18
0

I use multibib and hyperref. I experienced that if I load multibib before hyperref the links of \cite are gone, but other links to pages, footnotes, images etc. stay. For me loading hyperref before multibib works.

doncherry
  • 54,637
knut
  • 43