[pdftex] hyperref and cite
Aiko Huckauf
Aiko.Huckauf at epost.de
Sun Jan 14 14:08:44 CET 2001
BD> What was the small additional workaround, as I have to do the same for
BD> my thesis.
BD> thanks
BD> barney
Hallo Barney,
the workaround consists of 99 lines of source code. The way I got
things to work is as follows:
1) In my document preamble I use
\usepackage[square,comma,numbers,sort&compress]{natbib}
\usepackage{mynatbib}
where "mynatbib" is the following text:
% Begin of mynatbib.sty %
\makeatletter
\AtBeginDocument{\def\NAT at sort{2}}
\def\NAT at citexnum[#1][#2]#3{%
\NAT at sort@cites{#3}%
\let\@citea\@empty
\@cite{\def\NAT at num{-1}\let\NAT at last@yr\relax\let\NAT at nm\@empty
\@for\@citeb:=\NAT at cite@list\do
{\edef\@citeb{\expandafter\@firstofone\@citeb}%
\if at filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\@ifundefined{b@\@citeb\@extra at b@citeb}{%
{\reset at font\bfseries?}
\NAT at citeundefined\PackageWarning{natbib}%
{Citation `\@citeb' on page \thepage \space undefined}}%
{\let\NAT at last@num\NAT at num\let\NAT at last@nm\NAT at nm
\NAT at parse{\@citeb}%
\ifNAT at longnames\@ifundefined{bv@\@citeb\@extra at b@citeb}{%
\let\NAT at name=\NAT at all@names
\global\@namedef{bv@\@citeb\@extra at b@citeb}{}}{}%
\fi
\ifNAT at full\let\NAT at nm\NAT at all@names\else
\let\NAT at nm\NAT at name\fi
\ifNAT at swa
\ifnum\NAT at ctype>1\relax\@citea
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
\ifnum\NAT at ctype=2\relax\NAT at test{\NAT at ctype}%
\else\NAT at alias
\fi\hyper at natlinkend\else
\ifnum\NAT at sort>1
\begingroup\catcode`\_=8
\ifcat _\ifnum\z@<0\NAT at num _\else A\fi
\global\let\NAT at nm=\NAT at num \else \gdef\NAT at nm{-2}\fi
\ifcat _\ifnum\z@<0\NAT at last@num _\else A\fi
\global\@tempcnta=\NAT at last@num \global\advance\@tempcnta by\@ne
\else \global\@tempcnta\m at ne\fi
\endgroup
\ifnum\NAT at nm=\@tempcnta
\ifx\NAT at last@yr\relax
% \edef\NAT at last@yr{\@citea \mbox{\noexpand\citenumfont{\NAT at num}}}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\edef\NAT at last@yr{\@citea \mbox{\noexpand
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
\noexpand\citenumfont\NAT at num%
\hyper at natlinkend}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\else
%
\edef\NAT at last@yr{--\penalty\@m\mbox{\noexpand\citenumfont{\NAT at num}}}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\edef\NAT at last@yr{--\penalty\@m\mbox{\noexpand
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
\noexpand\citenumfont\NAT at num%
\hyper at natlinkend}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\fi
\else
% \NAT at last@yr \@citea \mbox{\citenumfont{\NAT at num}}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NAT at last@yr \@citea \mbox{%
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
\citenumfont{\NAT at num}%
\hyper at natlinkend}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\NAT at last@yr\relax
\fi
\else
\@citea \mbox{\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
{\citenumfont{\NAT at num}}\hyper at natlinkend}%
\fi
\fi
\def\@citea{\NAT at sep\penalty\@m\NAT at space}%
\else
\ifcase\NAT at ctype\relax
\ifx\NAT at last@nm\NAT at nm \NAT at yrsep\penalty\@m\NAT at space\else
\@citea \NAT at test{1}\ \NAT@@open
\if*#1*\else#1\ \fi\fi \NAT at mbox{%
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
{\citenumfont{\NAT at num}}\hyper at natlinkend}%
\def\@citea{\NAT@@close\NAT at sep\penalty\@m\ }%
\or\@citea
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
\NAT at test{\NAT at ctype}\hyper at natlinkend
\def\@citea{\NAT at sep\penalty\@m\ }%
\or\@citea
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
\NAT at test{\NAT at ctype}\hyper at natlinkend
\def\@citea{\NAT at sep\penalty\@m\ }%
\or\@citea
\hyper at natlinkstart{\@citeb\@extra at b@citeb}%
\NAT at alias\hyper at natlinkend
\def\@citea{\NAT at sep\penalty\@m\ }%
\fi
\fi
}}%
\ifnum\NAT at sort>1\relax\NAT at last@yr\fi
\ifNAT at swa\else\ifnum\NAT at ctype=0\if*#2*\else
\NAT at cmt#2\fi \NAT@@close\fi\fi}{#1}{#2}}
\makeatother
% End of mynatbib.sty %
I got this code from Jens Berger <jberger at gmx.net>, whose homepage is
http://userpage.fu-berlin.de/~jberger, and I saved the text as
"mynatbib.sty" in a folder where pdfLaTeX could find it.
Without this code one gets sorted, but not compressed references. At
present, I haven't got enough time to understand why; I'm happy that
things work and don't think about the reasons.
2) Within my document, I used
\bibliographystyle{unsrt}
\bibliography{Literatur/Dissertation}
"Dissertation.bib" is my literature database, which is set up in a
very uncommon manner. I think this is the reason, why I have to use
"unsrt" instead of "unsrtnat": With "unsrtnat" it doesn't work in my
case, but perhaps it does in your case.
Good luck!
Aiko
More information about the pdftex
mailing list