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.

In my current work, I cannot seem to get the packages harvard and hyperref to work together properly.

A small example:

\documentclass[12pt,a4paper]{scrreprt}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{times}
\usepackage[hyphens]{url}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{listings}
\usepackage{fancyhdr}
\usepackage{cite}

\usepackage{harvard}
\citationmode{abbr}
\bibliographystyle{dcu}

\usepackage{setspace}
\onehalfspacing

\usepackage[pdfborder={0 0 0},pdftitle={the document title},pdfauthor={the author}]{hyperref}
\hypersetup{colorlinks=false}


\begin{document}
test
\end{document}

The error message I get is:

! LaTeX Error: Missing \begin{document}.

in the line right after \usepackage[...]{hyperref}.

As soon as I either remove the harvard package, the document compiles flawlessly. The same happens when I remove the hyperref package.

What bugs me: When I remove the options from \usepackage[...]{hyperref}, it also works.

Does anybody know what problem I am facing?

EDIT:

Sometimes, reading the error log in more detail helps. Seems, that missing \begin{document} was not the root cause, but rather the error further down in the log:

! LaTeX Error: Option clash for package hyperref.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.43
The package hyperref has already been loaded with options:
[pdftex]
There has now been an attempt to load it with options
[pdfborder={0 0 0},pdftitle={the document title},pdfauthor={the author}]
Adding the global options:
pdftex,pdfborder={0 0 0},pdftitle={the document title},pdfauthor={the author}
to your \documentclass declaration may fix this.

I have no idea why, but the package seems to be loaded automatically, when I use pdflatex to compile my document. I ended up using

\usepackage{hyperref}

\hypersetup{colorlinks=false}
\hypersetup{pdfborder={0 0 0}}
\hypersetup{pdftitle={\thetitle}}
\hypersetup{pdfauthor={\theauthor}}

EDIT 2

As per Marco Daniel's request:

*File List*
scrreprt.cls 2009/07/24 v3.04a KOMA-Script document class (report)
scrkbase.sty 2009/07/24 v3.04a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
scrbase.sty 2009/07/24 v3.04a KOMA-Script package (KOMA-Script-independent
basics and keyval usage)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty 2009/03/25 v3.03 KOMA-Script package (loading files)
tocbasic.sty 2009/06/08 v3.03b KOMA-Script package (handling toc-files)
scrsize12pt.clo 2009/07/24 v3.04a KOMA-Script font size class option (12pt)
typearea.sty 2009/07/24 v3.04a KOMA-Script package (type area)
inputenc.sty 2008/03/30 v1.1d Input encoding file
utf8x.def 2004/10/17 UCS: Input encoding UTF-8
ucs.sty 2004/10/17 UCS: Unicode input support
uni-global.def 2004/10/17 UCS: Unicode global data
times.sty 2005/04/12 PSNFSS-v9.2a (SPQR)
url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc.
xcolor.sty 2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg 2007/01/18 v1.5 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)
graphicx.sty 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2009/08/28 v1.8 graphics configuration of TeX Live
rotating.sty 2009/03/28 v2.16a rotated objects in LaTeX
ifthen.sty 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
listings.sty 2007/02/22 1.4 (Carsten Heinz)
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
listings.cfg 2007/02/22 1.4 listings configuration
fancyhdr.sty
cite.sty 2009/08/29 v 5.2
harvard.sty
html.sty 1999/07/19 v1.38 hypertext commands for latex2html (nd, hws, rr
m)
setspace.sty 2000/12/01 6.7 Contributed and Supported LaTeX2e package
hyperref.sty 2009/10/09 v6.79a Hypertext links for LaTeX
ifpdf.sty 2009/04/10 v2.0 Provides the ifpdf switch (HO)
ifvtex.sty 2008/11/04 v1.4 Switches for detecting VTeX and its modes (HO)
ifxetex.sty 2009/01/23 v0.5 Provides ifxetex conditional
hycolor.sty 2009/10/02 v1.5 Code for color options of hyperref/bookmark (HO
)
xcolor-patch.sty 2009/10/02 xcolor patch
pd1enc.def 2009/10/09 v6.79a Hyperref: PDFDocEncoding definition (HO)
etexcmds.sty 2007/12/12 v1.2 Prefix for e-TeX command names (HO)
infwarerr.sty 2007/09/09 v1.2 Providing info/warning/message (HO)
hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
kvoptions.sty 2009/08/13 v3.4 Keyval support for LaTeX options (HO)
kvsetkeys.sty 2009/07/30 v1.5 Key value parser with default handler support
(HO)
bitset.sty 2007/09/28 v1.0 Data type bit set (HO)
intcalc.sty 2007/09/27 v1.1 Expandable integer calculations (HO)
bigintcalc.sty 2007/11/11 v1.1 Expandable big integer calculations (HO)
pdftexcmds.sty 2009/09/23 v0.6 LuaTeX support for pdfTeX utility functions (
HO)
ifluatex.sty 2009/04/17 v1.2 Provides the ifluatex switch (HO)
ltxcmds.sty 2009/08/05 v1.0 Some LaTeX kernel commands for general use (HO)
atbegshi.sty 2008/07/31 v1.9 At begin shipout hook (HO)
hdvips.def 2009/10/09 v6.79a Hyperref driver for dvips
pdfmark.def 2009/10/09 v6.79a Hyperref definitions for pdfmark specials
ot1ptm.fd 2001/06/04 font definitions for OT1/ptm.
ucsencs.def 2003/11/29 Fixes to fontencodings LGR, T3
nameref.sty 2007/05/29 v2.31 Cross-referencing by name of section
refcount.sty 2008/08/11 v3.1 Data extraction from references (HO)
minimalbeispiel.out
minimalbeispiel.out
share|improve this question
    
Here you go. Thanks again for the effort! –  Dan Soap Nov 9 '11 at 21:05
    
Please compare my file list with your file list. You see you need an update of all you packages. –  Marco Daniel Nov 9 '11 at 21:14
    
I'm using the packaged latex environment that is shipped with Ubuntu 11.10, I don't really want to mess with this installation. I'm glad it works (more or less, hence the question ;-) ) –  Dan Soap Nov 9 '11 at 21:14
    
Without the installation of TeX Live 2011 you must install all packages and the dependencies manual. See (help.ubuntu.com/community/LaTeX#TeX_Live) –  Marco Daniel Nov 9 '11 at 21:15
2  
If I try with TeX Live 2009 the example does not compile, but by a different reason. However it's an updated 2009, not the distribution coming with Ubuntu that's frozen as of October 2009; I suspect that at the time harvard and hyperref were indeed incompatible, probably because there's a package html.sty that harvard loads. –  egreg Nov 9 '11 at 21:22
show 2 more comments

3 Answers

I can't answer your question directly, but I can suggest a workaround that is just about fail-safe: Instead of loading the harvard bibliography citation manager, load both the natbib and har2nat packages. Natbib is known to work very well with hyperref, and the har2nat package "translates" all harvard-type citation commands into equivalent natbib-type citation commands. That way, you can keep using all of your harvard-style citation commands, but they'll be processed by natbib from now on. :-)

Before you (re)run latex and bibtex on your latex file, you should probably delete the various auxiliary files, as they contain information in "harvard"-style rather than "natbib"-style directives.

I made this switch (from harvard to natbib, with help from the har2nat package) a couple of years ago, after I ran into problems caused by interactions with hyperref -- more or less the same problems as you describe in your posting. I've not experienced these problems since then. :-)

Some additional comments about your document's preamble, not related to the harvard-hyperref interaction issue:

  • The times package is obsolete; consider loading mathptmx.
  • You needn't load the cite package if you load either the harvard or the natbib package. (Both packages redefine LaTeX's \cite command, disabling whatever functionality is provided by the cite package.)
  • The command \hypersetup{colorlinks=false} is unnecessary since you've already specified the option pdfborder=... when loading the hyperref package.
share|improve this answer
    
I tried this and it works. Without using harvard it compiles well. But I'm curious: What advantages does natbib have over harvard? –  Dan Soap Nov 9 '11 at 21:25
1  
Delighted to learn that the suggested method works for you! I'd say the main advantage of using the natbib instead of harvard is its great inter-operability with hyperref! :-) In addition, natbib provides a few more commands that aren't provided by harvard. Natbib was created after harvard had been around, and it consciously was designed to provide all of harvard's capabilities natively while also providing some new commands. –  Mico Nov 9 '11 at 21:31
add comment

EDIT: The OP uses TeX Live 2009 which was installed by synaptic. In the wiki of ubuntu community you can read the following note:

As of October 2011 the texlive package that ships with Ubuntu (TeX Live 2009) is lagging more than two years behind the current TeX Live release (TeX Live 2011). If you don't have big space constraints and want the latest version of TeX Live, you can install it directly from the TeX Live website (this does not interfere with the packages in Ubuntu).


I got no errors with your example. Some hints:

  1. Please have a look at this answer: Avoiding utf8x
  2. Don't use the package ucs which is loaded by utf8x per default
  3. You don't need to load the package url. hyperref do the job.

Here my file list to compare:

 *File List*
scrreprt.cls    2011/06/16 v3.09a KOMA-Script document class (report)
scrkbase.sty    2011/06/16 v3.09a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
 scrbase.sty    2011/06/16 v3.09a KOMA-Script package (KOMA-Script-independent 
basics and keyval usage)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty    2011/03/09 v3.09 KOMA-Script package (loading files)
tocbasic.sty    2011/05/30 v3.09a KOMA-Script package (handling toc-files)
scrsize12pt.clo    2011/06/16 v3.09a KOMA-Script font size class option (12pt)
typearea.sty    2011/06/16 v3.09a KOMA-Script package (type area)
inputenc.sty    2008/03/30 v1.1d Input encoding file
    utf8.def    2008/04/05 v1.1m UTF-8 support for inputenc
   t1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  ot1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  omsenc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
   times.sty    2005/04/12 PSNFSS-v9.2a (SPQR) 
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/message (HO)
 ltxcmds.sty    2011/04/18 v1.20 LaTeX kernel commands for general use (HO)
dvipsnam.def    1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
rotating.sty    2009/03/28 v2.16a rotated objects in LaTeX
  ifthen.sty    2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
listings.sty    2007/02/22 1.4 (Carsten Heinz)
 lstmisc.sty    2007/02/22 1.4 (Carsten Heinz)
listings.cfg    2007/02/22 1.4 listings configuration
fancyhdr.sty    
    cite.sty    2010/09/10  v 5.3
 harvard.sty    
setspace.sty    2000/12/01 6.7 Contributed and Supported LaTeX2e package
hyperref.sty    2011/10/01 v6.82j Hypertext links for LaTeX
hobsub-hyperref.sty    2011/04/23 v1.4 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2011/04/23 v1.4 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2011/04/23 v1.4 Subsetting bundle oberdiek (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Switches for detecting VTeX and its modes (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable integer calculations (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
etexcmds.sty    2011/02/16 v1.5 Prefix for e-TeX command names (HO)
kvsetkeys.sty    2011/04/07 v1.13 Key value parser (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Defining keys (HO)
pdftexcmds.sty    2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO)
pdfescape.sty    2011/04/04 v1.12 Provides string conversions (HO)
bigintcalc.sty    2011/01/30 v1.2 Expandable big integer calculations (HO)
  bitset.sty    2011/01/30 v1.1 Data type bit set (HO)
uniquecounter.sty    2011/01/30 v1.2 Provides unlimited unique counter (HO)
letltxmacro.sty    2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
 hopatch.sty    2011/01/30 v1.0 Wrapper for package hooks (HO)
xcolor-patch.sty    2011/01/30 xcolor patch
atveryend.sty    2011/04/23 v1.7 Hooks at very end of document (HO)
atbegshi.sty    2011/01/30 v1.15 At begin shipout hook (HO)
refcount.sty    2010/12/01 v3.2 Data extraction from references (HO)
 hycolor.sty    2011/01/30 v1.7 Color options of hyperref/bookmark (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
kvoptions.sty    2010/12/23 v3.10 Keyval support for LaTeX options (HO)
  pd1enc.def    2011/10/01 v6.82j Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
     url.sty    2006/04/12  ver 3.3  Verb mode for urls, etc.
 hpdftex.def    2011/10/01 v6.82j Hyperref driver for pdfTeX
rerunfilecheck.sty    2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
  ot1ptm.fd    2001/06/04 font definitions for OT1/ptm.
supp-pdf.mkii
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Managing graphics extensions (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
 nameref.sty    2010/04/30 v2.40 Cross-referencing by name of section
gettitlestring.sty    2010/12/03 v1.4 Cleanup title references (HO)
    test.out
    test.out
 ***********
share|improve this answer
    
Thanks for the reply, however this was not my case here. When I removed ucs and utf8x, I still got the same error. –  Dan Soap Nov 9 '11 at 20:40
    
@Cassy: Please put the command \listfiles to your header and than you will find the file list in the log-file. –  Marco Daniel Nov 9 '11 at 20:43
    
Thanks again. See my own answer regarding pdflatex. Obviously, it's not a matter of the packages, but rather of the calling program. –  Dan Soap Nov 9 '11 at 20:47
    
Nothing special: \newcommand{\thetitle}{here be the title} I just forgot to remove this from the second snippet –  Dan Soap Nov 9 '11 at 20:57
add comment

The harvard package loads the html package, if it exists, which loads hyperref. From harvard.sty:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{harvard}
\RequirePackage{ifthen}
\IfFileExists{html.sty}{\RequirePackage{html}
...

Possible solutions:

  • Instead of loading hyperref with options yourself, you could use \hypersetup. This is recommended.
  • In this and similar cases one could use \PassOptionsToPackage{...}{packagename}.
  • Another option is specifiying hyperref options to the document class, which would be inherited. I would not prefer that generally, as further packages might be affected.
  • Deinstalling html.sty and deactivating auto package installation
  • Putting a dummy html.sty into your document folder could fix it, however it would be bad to have different style files with the same name - just to mention it and suggesting not to do it.

Note, hyperref should be loaded at the end of the preamble, with some exceptions, so load harvard in the same sense like hyperref at the end of the preamble to avoid problems.

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.