Skip to navigation

LaTeX: using apacite and hyperref in the same document

The latest (4.0) version of apacite no longer conflicts with the
package hyperref, but you must load hyperref before
apacite
.

That is, the preamble of your document should look something like this:

\documentclass{article}
... other packages etc ...
\usepackage{hyperref}
\usepackage{apacite}
\begin{document}
... 

At least, that is the only way it worked for me. When I had apacite
loaded first, LaTeX would hang on the second run, with an error
message along these lines:

! Undefined control sequence.
\hyper@@link ->\let \Hy@reserved@a
...

16 Responses to “LaTeX: using apacite and hyperref in the same document”

  1. Stan Says:

    Thanks for the trick !! No more latex errors when I put apacite package afeter hyperref. I don’t know if the apacite author is aware about that but it should be included in the apacite manual !

  2. Thomas Laue Says:

    I can’t believe how simply my problems would go away. I’ve had compile errors and the ‘year’ portion of all citations messed up. Months of research, reading manuals. HUNDREDS of tabs, reading each one to find out what my strange apacite error was all about. Only after a lot of experimenting that I find it was related to hyperref … and then, finally, googling those two commands, I found your site.

    You’ve really saved me a lot of wasted time. Thank you so much.

    Thomas i Canberra.

  3. Franny Says:

    Have been sweating all afternoon over why suddenly the year part of all apacite citations disappeared, searched for all kinds of incompatibilities problems for apacite and miketex 2.9 – and now it turns out that in the newer version of apacite package the required order of package loading between apacite and hyperref is just reversed compared to the older version (which was in my old miktex distribution)..

    THANKS!

  4. Doug Says:

    Hi,

    I’m encountering the very same problem. Unfortunately, this solution does not work for me.

    I do have a workable solution, but it is very inconvenient. Fortunately, I only need to generate a PDF with hyperref included when I share a document with other people, so I can live with my workaround. However, I would love to get it fixed if anyone has any suggestions. Moreover, given that it’s somewhat convoluted, might actually help a more knowledgeable LaTeX person better diagnose the problem. Plus, perhaps someone else might find this workaround helpful.

    This workaround is both necessary and functional for MiKTeX on WinXP SP3 and for Texlive 2009 on Ubuntu 10.04 LTS (Texlive 2009 as distributed by Ubuntu, not downloaded from the TUG website) as of 2011-02-09.

    The workaround is as follows:

    1. Comment out the \usepackage{hyperref} line.
    2. Comment out anything that depends on hyperref (in my case, the \hypersetup entry and several \pdfbookmark entries).
    3. Run pdflatex mydoc.tex; run bibtex mydoc.bib; run pdflatex mydoc.tex two more times. This generates a clean PDF, without any PDF bookmarks or references.
    4. Uncomment (i.e., re-enable) my \usepackage{hyperref} and \hypersetup{} lines, as well as in my case several \pdfbookmark lines. In other words, in this step 4, undo the commenting done in step 2.
    5. Run, ONLY ONCE, pdflatex mydoc.tex.

    At this point, I have a clean PDF, with hypertext references, but NONE of my bookmarks show up. So, continue with the following steps:

    6. Step 5 will have generated a mydoc.out file. KEEP THIS .out file, but DELETE all other intermediate files generated. In my case, this means deleting all files with the following extensions, which I do as follows: rm -f *.dvi *.aux *.bbl *.blg *.log *.fff *.ttt (note that not all of these necessarily get generated, most notable *.dvi; this is simply a line that I have in a Makefile).
    7. REPEAT steps 1-5.

    At this point, I have a correctly formated PDF file, having used both apacite and hyperref together, and my PDF correctly creates links from footnote numbers to the corresponding footnotes, links from in-text citations to the corresponding reference entries in the bibliography, and nested bookmarks for all my \section, \subsection, \subsubsetion, etc. and \pdfbookmark entries.

    It’s quite nice, after all is said and done. However, it is a major pain, in particular step 7, that is, having to repeate ALL PREVIOUS STEPS just because steps 1-5 are needed to generate a .out file. Fortunately, if I don’t add, change, or delete any bookmarks or sections/subsection/etc., I can just keep the .out file around and I only have to run steps 1-5 once. This isn’t beneficial that often, though, because (obviously) document structure (i.e., sections) and bookmarks can change a lot. So, I just don’t generate a hyperref-enabled version that often — only when I absolutely must.

    I hope this is helpful to someone and, ideally, I hope it helps someone help me get the problem fixed.

    Cheers,
    Doug

  5. Doug Says:

    CORRECTION: Step 3 should read: … “This generates a clean PDF, without any PDF bookmarks or _hypertext_links_.]

    ALSO: Just FYI, I have cross-posted this to http://www.latex-community.org/forum/viewtopic.php?f=19&t=5723&start=0

  6. Doug Says:

    BLOODY HELL: Apologies, the cross-posting link should have been: http://www.latex-community.org/forum/viewtopic.php?f=46&t=9079

  7. Rickard Says:

    Thank you! One irritating problem have finally ended.
    Btw, for those of you who uses Linux, I would recommend gummi.

  8. Roger Says:

    Thanks so much for posting this…I could not get this to work with my school’s style file and now it works beautifully. I have been corresponding with Erik Meijer and will pass this information on to him.

  9. PDStranger Says:

    Don’t know if this helps anyone but it took me a while to figure out if you want to use this with apa.cls you need to suppress loading apacite using the noapacite option.
    e.g. \documentclass[noapacite]{apa}
    Then load hyperref first followed by apacite
    e.g. \usepackage{hyperref}
    \usepackage{apacite}
    \begin{document}

  10. PhDuStUdEnTaNdLaTeX Says:

    Thank you very much! I lost hours trying to fix the problem with the bibliography! Gee, isn’t it annoying when the solution is so simple… Just invert two packages! Thank you allllot! :)

  11. Notes on APA Formatting and Citations in LaTeX « Many Inquiries Says:

    […] with it today, and couldn’t get lower than 6 errors each time I compiled. I looked online: http://promberger.info/linux/2009/03/18/latex-using-apacite-and-hyperref-in-the-same-document/ and found that the answer is that the hyperref package should come before the apacite package […]

  12. Zain Says:

    Thanks a lot !!! It worked … been trying to fix the error for over 2 hours … :)

  13. anne Says:

    thanks so so much!! works perfectly… and i wasted almost wasted a whole day on this, while solution was so close and simple^^

  14. nick Says:

    man, thanks sooo much. i was searching for the reason or different errors for days. when i fixed this it all worked. finally. thanks heaps!

  15. BM Says:

    this is an amazing post! a pity that i saw it after hours of fighting with latex! :)

  16. myname Says:

    Thaks a lot, you saved me a lot of trouble.
    *Facepalm LaTEX*