Discussion:
hyperref+bibunits+babel
(too old to reply)
Michael Zedler
2006-01-20 09:26:41 UTC
Permalink
Hello,

how can I get hyperref to create hyperlinks to the bibliography when
bibunits and babel are used? The patch proposed in
<***@gmx.net> makes bibunits+hyperref work, but not
bibunits+babel+hyperref.

\listfiles
\documentclass{book}
\usepackage[ngerman,english]{babel}
\usepackage{bibunits}
\usepackage[sort]{cite}
\usepackage[colorlinks]{hyperref}
\makeatletter
\def\***@natlinkstart#1{%
\***@backout{#1}%
\***@linkstart{cite}{cite.\@bibunitname.#1}%
% ^^^^^^^^^^^^^^
\def\***@nat@current{#1}%
}

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

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

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

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

\def\@bibitem#1{%
\@skiphyperreftrue\***@item\@skiphyperreffalse
\***@anchorstart{cite.\@bibunitname.#1}\relax\***@anchorend
% ^^^^^^^^^^^^^^
\***@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}%
\***@filesw
\immediate\write\@auxout{\string\citation{\@citeb}}%
\fi
\@ifundefined{b@\@citeb}{%
\mbox{\***@font\bfseries ?}%
\***@refundefinedtrue
\@***@warning{%
Citation `\@citeb' on page \thepage \space undefined%
}%
}{%
\***@natlinkstart{#2}%
% ^^^^^^^^^^^^^^^^^^^^^^^^
\hbox{\csname b@\@citeb\endcsname}%
\***@natlinkend%
% ^^^^^^^^^^^^^^^^^^
}%
}%
}{#1}%
}%

\makeatother

\begin{document}
\bibliographyunit[\chapter]
\bibliography*{EMCEbib}
\bibliographystyle*{ieeetr}
\makeatletter
\let\stdthebibliography\thebibliography
\renewcommand{\thebibliography}{%
\let\chapter\section
\renewcommand{\@mkboth}[2]{}
\stdthebibliography}
\makeatother
\chapter{first}
Hallo \cite{Rayleigh1897} \putbib
\chapter{second}
Hallo \cite{Abraham1983} \putbib
\end{document}

-- EMCEbib.bib
@BOOK{Abraham1983,
author = "Ralph Abraham and Jerrold E. Marsden and Tudor Ratiu",
title = "Manifolds, Tensor Analysis and Applications",
publisher = "Addison-Wesley",
address = "London",
year = 1983 }
@BOOK{Abramowitz1993,
author = "M.~Abramowitz and I.A.~Stegun",
title = "Handbook of Mathematical Functions with Formulas, Graphs
and Mathematical Tables",
publisher = "Dover",
address = "New York",
year = 1965 }
--
*File List*
book.cls 2004/02/16 v1.4f Standard LaTeX document class
bk10.clo 2004/02/16 v1.4f Standard LaTeX file (size option)
babel.sty 2005/05/21 v3.8g The Babel package
ngermanb.ldf 2004/02/20 v2.6m new German support from the babel system
english.ldf 2005/03/30 v3.3o English support from the babel system
bibunits.sty 2004/05/12 v2.4 Multiple bibliographies in one document.
cite.sty 2003/11/04 v 4.01
hyperref.sty 2003/11/30 v6.74m Hypertext links for LaTeX
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
pd1enc.def 2003/11/30 v6.74m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg 2003/03/08 v1.0 MiKTeX 'hyperref' configuration
url.sty 2005/06/27 ver 3.2 Verb mode for urls, etc.
hypertex.def 2003/11/30 v6.74m Hyperref driver for HyperTeX specials
color.sty 1999/02/16 v1.0i Standard LaTeX Color (DPC)
color.cfg 2005/12/29 v1.1 MiKTeX 'color' configuration
dvips.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
dvipsnam.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
nameref.sty 2003/12/03 v2.21 Cross-referencing by name of section
bu1.bbl
bu2.bbl
***********

thanks in advance,
Michael
Ralf Stubner
2006-01-20 22:29:33 UTC
Permalink
Post by Michael Zedler
how can I get hyperref to create hyperlinks to the bibliography when
bibunits and babel are used?
If you use natbib instead of cite, everything works fine out of the box:

\listfiles
\begin{filecontents}{EMCEbib.bib}
@BOOK{Abraham1983,
author = "Ralph Abraham and Jerrold E. Marsden and Tudor Ratiu",
title = "Manifolds, Tensor Analysis and Applications",
publisher = "Addison-Wesley",
address = "London",
year = 1983 }
@BOOK{Abramowitz1993,
author = "M.~Abramowitz and I.A.~Stegun",
title = "Handbook of Mathematical Functions with Formulas, Graphs
and Mathematical Tables",
publisher = "Dover",
address = "New York",
year = 1965 }
\end{filecontents}
\documentclass{book}
\usepackage[ngerman,english]{babel}
\usepackage{bibunits}
\usepackage[sort,square]{natbib}
\usepackage[colorlinks]{hyperref}

\begin{document}
\bibliographyunit[\chapter]
\bibliography*{EMCEbib}
\bibliographystyle*{ieeetr}
\makeatletter
\let\stdthebibliography\thebibliography
\renewcommand{\thebibliography}{%
\let\chapter\section
\renewcommand{\@mkboth}[2]{}
\stdthebibliography}
\makeatother
\chapter{first}
Hallo \cite{Abramowitz1993} \putbib
\chapter{second}
Hallo \cite{Abraham1983} \putbib
\end{document}


cheerio
ralf
Michael Zedler
2006-01-20 22:53:18 UTC
Permalink
Post by Michael Zedler
how can I get hyperref to create hyperlinks to the bibliography when
bibunits and babel are used?
Ah, thanks! Three issues:
- When multiple citations are set, a space is set after the separator
(it looks like [1,\,2]). It mustn't do so in order to avoid different
page breaks.

- If several chapters cite the same reference a hyperlink is generated
to the first occurrence, not to the bibliography accompanying the chapter.

- It doesn't work with latex+dvips, I get
<inserted text>
\par
l.37 Hallo \cite{Abraham1983,Abramowitz1993}
\putbib
\listfiles
\begin{filecontents}{EMCEbib.bib}
@BOOK{Abraham1983,
author = "Ralph Abraham and Jerrold E. Marsden and Tudor Ratiu",
title = "Manifolds, Tensor Analysis and Applications",
publisher = "Addison-Wesley",
address = "London",
year = 1983 }
@BOOK{Abramowitz1993,
author = "M.~Abramowitz and I.A.~Stegun",
title = "Handbook of Mathematical Functions with Formulas, Graphs
and Mathematical Tables",
publisher = "Dover",
address = "New York",
year = 1965 }
\end{filecontents}
\documentclass{book}
\usepackage[ngerman,english]{babel}
\usepackage{bibunits}
\usepackage[sort&compress,comma,square]{natbib}
\usepackage[colorlinks,dvips]{hyperref}

\begin{document}
\bibliographyunit[\chapter]
\bibliography*{EMCEbib}
\bibliographystyle*{ieeetr}
\makeatletter
\let\stdthebibliography\thebibliography
\renewcommand{\thebibliography}{%
\let\chapter\section
\renewcommand{\@mkboth}[2]{}
\stdthebibliography}
\makeatother
\chapter{first}
Hallo \cite{Abramowitz1993} \putbib
\chapter{second}
Hallo \cite{Abraham1983,Abramowitz1993} \putbib
\end{document}

Thanks again for looking into this,
Michael
Ralf Stubner
2006-01-20 23:59:21 UTC
Permalink
Post by Michael Zedler
- When multiple citations are set, a space is set after the
separator (it looks like [1,\,2]). It mustn't do so in order to avoid
different page breaks.
Actually natbib.sty uses a space between the entires. With

\let\***@space\,

I get an output similar to cite.sty, but you can also use a different
length or

\let\***@space\relax

This redefintion has to occur after \begin{document}.
Post by Michael Zedler
- If several chapters cite the same reference a hyperlink is
generated to the first occurrence, not to the bibliography
accompanying the chapter.
\def\***@natlinkstart#1{%
\***@backout{#1}%
\***@linkstart{cite}{cite.\@bibunitname.#1}%
\def\***@nat@current{#1}%
}
\def\***@natlinkbreak#1#2{%
\***@linkend#1\***@linkstart{cite}{cite.\@bibunitname.#2}%
}
\def\***@natanchorstart#1{%
\***@raisedlink{\***@anchorstart{cite.\@bibunitname.#1}}%
}

Seems to help here.
Post by Michael Zedler
- It doesn't work with latex+dvips, I get
<inserted text>
\par
l.37 Hallo \cite{Abraham1983,Abramowitz1993}
\putbib
Did you run LaTeX more than once? I only see this on the first run after
switching from cite.sty to natbib.sty.

cheerio
ralf
Michael Zedler
2006-01-21 08:35:11 UTC
Permalink
Post by Ralf Stubner
Post by Michael Zedler
- It doesn't work with latex+dvips, I get
<inserted text>
\par
l.37 Hallo \cite{Abraham1983,Abramowitz1993}
\putbib
Did you run LaTeX more than once? I only see this on the first run after
switching from cite.sty to natbib.sty.
The other two issues are fine now, thanks. Did you copy the example from
my posting? With

\usepackage[sort,comma,square]{natbib}
\usepackage[colorlinks]{hyperref}

everything is fine, but the 'sort&compress' option raises an error when
latex is used, pdflatex works fine.

Cheers,
Michael
Ralf Stubner
2006-01-21 11:43:35 UTC
Permalink
Post by Michael Zedler
but the 'sort&compress' option raises an error
when latex is used, pdflatex works fine.
I missed the 'sort&compress' option in your previous message (you ought
to mention such subtle changes ;-), but I still get no error:

\listfiles
\begin{filecontents}{EMCEbib.bib}
@BOOK{Abraham1983,
author = "Ralph Abraham and Jerrold E. Marsden and Tudor Ratiu",
title = "Manifolds, Tensor Analysis and Applications",
publisher = "Addison-Wesley",
address = "London",
year = 1983 }
@BOOK{Abramowitz1993,
author = "M.~Abramowitz and I.A.~Stegun",
title = "Handbook of Mathematical Functions with Formulas, Graphs and Mathematical Tables",
publisher = "Dover",
address = "New York",
year = 1965 }
\end{filecontents}
\documentclass{book}
\usepackage[ngerman,english]{babel}
\usepackage{bibunits}
\usepackage[sort&compress,square,comma]{natbib}
\usepackage[colorlinks]{hyperref}

\makeatletter
\def\***@natlinkstart#1{%
\***@backout{#1}%
\***@linkstart{cite}{cite.\@bibunitname.#1}%
\def\***@nat@current{#1}%
}
\def\***@natlinkbreak#1#2{%
\***@linkend#1\***@linkstart{cite}{cite.\@bibunitname.#2}%
}
\def\***@natanchorstart#1{%
\***@raisedlink{\***@anchorstart{cite.\@bibunitname.#1}}%
}
\makeatother

\begin{document}

\bibliographyunit[\chapter]
\bibliography*{EMCEbib}
\bibliographystyle*{ieeetr}

\makeatletter
\let\***@space\,

\let\stdthebibliography\thebibliography
\renewcommand{\thebibliography}{%
\let\chapter\section
\renewcommand{\@mkboth}[2]{}
\stdthebibliography}
\makeatother

\chapter{first}
Hallo \cite{Abramowitz1993} \putbib
\chapter{second}
Hallo \cite{Abraham1983,Abramowitz1993} \putbib
\end{document}


*File List*
book.cls 2004/02/16 v1.4f Standard LaTeX document class
bk10.clo 2004/02/16 v1.4f Standard LaTeX file (size option)
babel.sty 2004/11/20 v3.8d The Babel package
ngermanb.ldf 2004/02/20 v2.6m new German support from the babel system
english.ldf 2004/06/14 v3.3o English support from the babel system
bibunits.sty 2004/05/12 v2.4 Multiple bibliographies in one document.
natbib.sty 2003/06/06 7.1 (PWD)
hyperref.sty 2003/11/30 v6.74m Hypertext links for LaTeX
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
pd1enc.def 2003/11/30 v6.74m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive and teTeX
url.sty 2004/03/15 ver 3.1 Verb mode for urls, etc.
hdvips.def 2003/11/30 v6.74m Hyperref driver for dvips
pdfmark.def 2003/11/30 v6.74m Hyperref definitions for pdfmark specials
color.sty 1999/02/16 v1.0i Standard LaTeX Color (DPC)
color.cfg 2005/02/03 v1.3 color configuration of teTeX/TeXLive
dvips.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
dvipsnam.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
nameref.sty 2003/12/03 v2.21 Cross-referencing by name of section


BTW, the combination of natbib with 'sort&compress' and hyperref used to
require hypernat.sty. That way the '3' in [3-6] would link to reference
[3], while the '6' links to reference [6]. I am not sure if this is
still the case.

cheerio
ralf
Michael Zedler
2006-01-21 13:13:56 UTC
Permalink
Post by Ralf Stubner
natbib.sty 2003/06/06 7.1 (PWD)
url.sty 2004/03/15 ver 3.1 Verb mode for urls, etc.
My versions seem to be too recent ;-)

natbib.sty 2006/01/12 7.2 (PWD)
url.sty 2005/06/27 ver 3.2 Verb mode for urls, etc.

Using pdflatex in pdf mode everything works as expected, no hypernat.sty
needed. I'll file a bug report. Can you send me your version by mail,
please?

Cheers,
Michael

Loading...