Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I often like to use hyperref to make references to theorems and articles in the bibliography clickable. However, I noticed that when I use bibunits, I can only click on links to theorems, not on links to articles in the bibliography.

Here is a minimal example

\documentclass[a4paper,11pt]{article}
\usepackage{bibunits}
\usepackage{hyperref}

\begin{document}

\defaultbibliography{mybib}
\defaultbibliographystyle{plain}

\begin{bibunit}
my reference \cite{book1}.
\putbib
\end{bibunit}

\end{document}

Is there any way to solve this? Thanks!

share|improve this question
    
When you use bibunits, it is possible for one unique bibliography entry to appear more than once in different bibliography lists. So there is a possibility of having two separate destinations for a single link. In this case that the destination is not unique, Hyperref simply gaves up and does not create any link for bibliography. –  Aydin Feb 20 '13 at 14:32
add comment

1 Answer

A solution was provided comp.text.tex archive at derkeiler. I want to save the solution and so I provided this CW.

% arara: pdflatex 
% arara: bibtex: {files: [bu1,bu2]}
% arara: pdflatex
% arara: pdflatex
% package arara at http://ctan.org/pkg/arara
\documentclass[a4paper,11pt]{article}
\usepackage{bibunits}
\usepackage{hyperref}
 \makeatletter
\def\hyper@natlinkstart#1{%
  \Hy@backout{#1}%
  \hyper@linkstart{cite}{cite.\@bibunitname.#1}%
%                             ^^^^^^^^^^^^^^
  \def\hyper@nat@current{#1}%
}

\def\hyper@natlinkbreak#1#2{%
  \hyper@linkend#1\hyper@linkstart{cite}{cite.\@bibunitname.#2}%
%                                             ^^^^^^^^^^^^^^
}

\def\hyper@natanchorstart#1{%
  \hyper@anchorstart{cite.\@bibunitname.#1}%
%                         ^^^^^^^^^^^^^^
}

\def\bibcite#1#2{%
  \@newl@bel{b}{#1}{\hyper@@link[cite]{}{cite.\@bibunitname.#1}{#2}}%
%                                             ^^^^^^^^^^^^^^
}%

\def\@lbibitem[#1]#2{%
  \@skiphyperreftrue
  \H@item[\hyper@anchorstart{cite.\@bibunitname.#2}%
%                                 ^^^^^^^^^^^^^^
  \@BIBLABEL{#1}\hyper@anchorend\hfill]%
  \@skiphyperreffalse
  \if@filesw
    \begingroup
      \let\protect\noexpand
      \immediate\write\@auxout{%
        \string\bibcite{#2}{#1}%
      }%
    \endgroup
  \fi
  \ignorespaces
}%

\def\@bibitem#1{%
  \@skiphyperreftrue\H@item\@skiphyperreffalse
  \hyper@anchorstart{cite.\@bibunitname.#1}\relax\hyper@anchorend
%                         ^^^^^^^^^^^^^^
  \if@filesw
    \begingroup
      \let\protect\noexpand
      \immediate\write\@auxout{%
        \string\bibcite{#1}{\the\value{\@listctr}}%
      }%
    \endgroup
  \fi
  \ignorespaces
}%

\def\@citex[#1]#2{%
  \let\@citea\@empty
  \@cite{%
    \@for\@citeb:=#2\do{%
      \@citea
      \def\@citea{,\penalty\@m\ }%
      \edef\@citeb{\expandafter\@firstofone\@citeb}%
      \if@filesw
        \immediate\write\@auxout{\string\citation{\@citeb}}%
      \fi
      \@ifundefined{b@\@citeb}{%
        \mbox{\reset@font\bfseries ?}%
        \G@refundefinedtrue
        \@latex@warning{%
          Citation `\@citeb' on page \thepage \space undefined%
        }%
      }{%
        \hyper@natlinkstart{#2}%
%       ^^^^^^^^^^^^^^^^^^^^^^^^
            \hbox{\csname b@\@citeb\endcsname}%
        \hyper@natlinkend%
%       ^^^^^^^^^^^^^^^^^^
      }%
    }%
  }{#1}%
}%

\makeatother

\begin{document}

\defaultbibliography{xampl}
\defaultbibliographystyle{plain}

\begin{bibunit}
my reference \cite{article-full}.
\putbib
\end{bibunit}
\clearpage
\begin{bibunit}
my reference \cite{article-full}.
\putbib
\end{bibunit}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.