Generalhyperref and cite

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
meena
Posts: 9
Joined: Fri Jul 31, 2009 10:02 am

hyperref and cite

Post by meena »

Hi,

I am writing my theis and I want to create hyperref for the sections, figures, etc., Other than citations hyperref works for sections, figures... I googled enough to solve the problem, but all in vain. This is how my permeable looks like

Code: Select all

\documentclass[a4paper,12pt]{report}
\usepackage{a4wide, graphicx, textcomp, cite}
\usepackage[latin1]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage{pdfpages}
\usepackage[titletoc]{appendix} 
\usepackage{float}
\usepackage{fancyhdr}
\usepackage[style=super,header=plain,number=none,border=none,cols=2,hypertoc=true,
hyper=true]{glossary}
\usepackage[pagebackref=true,pdfauthor={Meena}]{hyperref}
\usepackage{cite}
\makeglossary
\setlength{\descriptionwidth}{0.8\textwidth}
\setlength{\headheight}{15pt}

\pagestyle{fancy}
Am I doing something wrong here? Please somebody help me!!

Thanks in advance,

Meena

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

hyperref and cite

Post by localghost »

The hyperref package apart from only a few exceptions should be loaded as the very last package.


Best regards
Thorsten
meena
Posts: 9
Joined: Fri Jul 31, 2009 10:02 am

Re: hyperref and cite

Post by meena »

Hi Thorsten,

I tried that too, didn't work out :(
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

hyperref and cite

Post by gmedina »

Hi meena,

your problem comes (as localghost suggested) from the order in which you are loading the packages. Please notice that you load the cite package twice: the first time, before hyperref, in this line:

Code: Select all

\usepackage{a4wide, graphicx, textcomp, cite}
and the second time, after hyperref, in this line:

Code: Select all

\usepackage{cite}
The cite package must be loaded after hyperref. Thus, to solve your problem, suppress the cite package from the list of the first line that I mentioned; i.e., use

Code: Select all

\usepackage{a4wide, graphicx, textcomp}
and then load hyperref and cite in the following order:

Code: Select all

\usepackage[pagebackref=true,pdfauthor={Meena}]{hyperref}
\usepackage{cite}
By the way, the a4wide package is obsolete and shouldn't be used anymore. The l2tabu document contains useful information about this and some other obsolete packages/commands.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
meena
Posts: 9
Joined: Fri Jul 31, 2009 10:02 am

Re: hyperref and cite

Post by meena »

Hi gmedina,

Thanks a lot :) I did not realize that I was loading the cite package twice. Thank you for the suggestions (a4wide) too.
meena
Posts: 9
Joined: Fri Jul 31, 2009 10:02 am

Re: hyperref and cite

Post by meena »

Hi,

When I use the hyperref and cite package, the citations are no longer compressed

e.g. instead of 1-4 it appear as 1,2,3,4.

Is it normal? Is there any way to fix it?

Thanks in advance
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

hyperref and cite

Post by localghost »

A complete and compilable minimal working example (MWE) would be very helpful to see the problem.
meena
Posts: 9
Joined: Fri Jul 31, 2009 10:02 am

Re: hyperref and cite

Post by meena »

Hi,

I attached an example source file and the output file. I have a separate bib file which I could not load here. In the output file, citations look like this [1,2,3] but I want [1-3].

Any suggestions :?:

Thanks in advance
Attachments
test.pdf
output
(29.89 KiB) Downloaded 708 times
test.tex
Source file
(1009 Bytes) Downloaded 686 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

hyperref and cite

Post by localghost »

It doesn't work for me either with cite. But it works with natbib. See the MWE below.

Code: Select all

\begin{filecontents*}{xmpl.bib}
@BOOK{knuth84,
  author={Donald Ervin Knuth},
  title={The \TeX book},
  year={1984},
  publisher={Addison-Wesley}
}
@BOOK{lamport94,
  author={Leslie Lamport},
  title={\LaTeX\ - A Document Preparation System},
  note={User's Guide and Reference Manual},
  year={1994},
  publisher={Addison-Wesley},
  edition={Second}
}
@BOOK{mitgoo04,
  author={Frank Mittelbach and Michel Goossens},
  title={The \LaTeX\ Companion},
  year={2004},
  publisher={Addison-Wesley},
  edition={Second}
}
@BOOK{goomit07,
  author={Michel Goossens and Frank Mittelbach and Sebastian Rahtz and Denis Roegel and Herbert Voss},
  title={The \LaTeX\ Graphics Companion},
  year={2007},
  publisher={Addison-Wesley},
  edition={Second}
}
\end{filecontents*}
\documentclass[12pt,a4paper,english]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage[sort&compress]{natbib}
\usepackage{hyperref}

\begin{document}
  \cite{knuth84,lamport94,mitgoo04,goomit07}

  \bibliographystyle{unsrt}
  \bibliography{xmpl}
\end{document}
Post Reply