# LaTeX – Getting the Harvard Citation Style to work – Cite URLs properly.

The Harvard LaTeX citation package is a requirement for many people when writing research documents or academic theses.

However, the sample LaTeX document harvard.tex that comes with the Harvard citation package available at the CTAN TeX Archive Network does not compile correctly as provided.  This can be somewhat frustrating for many authors, especially those who are quite new to LaTeX.  In attempting to resolve this problem I have developed several solutions which required modifications to the Harvard style file harvard.sty or to the referenced bibliography file harvard.bib. None of these solutions I found to be satisfactory as they are not portable – that is, copying the LaTeX text document to another computer or platform would result is the same problem and require the same fix to be implemented numerous times.

I finally developed a solution that requires modifications to the LaTeX text document only and thus is portable and requires no changes to the underlying latex installation or configuration style files.  I shall begin by outlining the problem as it appears followed by the solution.

### Recreating the Problem

2. Extract to a folder of your choice.  E.g.:  C:\temp\harvard
3. Open up the sample LaTeX document harvard.tex from within your LaTeX editor.  I am using the open source TeXnicCenter IDE.
4. Attempt to build the document.  You should see an error message similar to the following at the end of your build log.
5. LaTeX-Result: 19 Error(s), 24 Warning(s), 4 Bad Box(es), 0 Pages.

6. We are only concerned with eliminating the errors in this post. Normally, the best approach to eliminating errors is to deal with the first error reported as this may be the source of many subsequent errors.
7. The first error reported is somewhat cryptic:
8. Paragraph ended before \ltx@LocalAppendToMacro was complete. <to be read again> \par 1.6445 }{}

9. The errors are generated due to several expectations that exist in the harvard.sty file.  However, all of these shall be resolved in the solution specified below.

### Implementing the Solution

Ensure you have the sample harvard.tex open in your LaTeX editor.

1. Insert the following two lines immediately before the line containing \usepackage{harvard}
\usepackage{html} \usepackage{url} 
2. Insert the following line immediately before the line beginning with \title
\renewcommand{\harvardurl}{URL: \url}
3. Build your document (at least twice to ensure bibliographic references are resolved) and it should compile without any errors.  Well Done! You may now cite references using the Harvard style in your LaTeX documents.

## 30 comments on “LaTeX – Getting the Harvard Citation Style to work – Cite URLs properly.”

1. […] you are having issues citing URLs with the Harvard package (which is very likely) follow the link to theseekersquill and let the posted solution save your […]

2. Christian says:

Thanks a lot for this post, it really saved my day. After working without any problems with the harvard package up to today I included an url in the bib-file and hence compilation wasn’t possible anymore. I undid the changes but the error remained. But thanks to you I can get back to work now. I cite this post in my own blog to spread the word. Thanks!

3. Malachi says:

What a solution! worked excellent – I must admit I am a newbie with LaTex and have just been spending hours trying to figure out how to use the harvard package properly and was getting warnings thrown and references not referenced properly.Thanks!

4. Jason says:

Thanks for the solution! It just saved me some hours!

5. Malachi says:

Thanks once again for the solution. I have one query regarding Bad Box alerts when I build which is related to the urls in the reference section do you know of a solution to resolve this? Or should I just ignore these? as they appear to render correctly.

• theseekersquill says:

Hi Malachi,

I am surprised that you find bad boxes generated. However, replace the solution I originally posted with the following three steps and you should nolonger have bad boxes.

Step 1. In your LaTeX document preamble (after \documentclass{xxxx}, insert:

 \usepackage{html} \usepackage{url} \usepackage[dcucite]{harvard}

Step 2. Insert the following line immediately before the line beginning with \title

\renewcommand{\harvardurl}{\url}

Step 3. Assuming you are using a bibtex file, replace the “url” entry with a “note” entry as indicated in the following example:
@MANUAL{xml, title = {{Extensible Markup Language (XML) 1.0 (Fifth Edition)}}, author = {{World Wide Web Consortium}}, edition = {{W3C Recommendation}}, month = {{November}}, year = {2008}, note = {Online Resource \url{http://www.w3.org/TR/xml/}}, owner = {theseekersquill}, timestamp = {2009.11.23} }

• Malachi says:

Thank you for such a detailed reply – The problem was due to URLS spanning more then one line which it rendered correctly so I am going to just ignore these warnings.

• diana says:

Thanks for the info, very useful. Saved hours to compile the citation harvard in Latex 😀

6. Jose Augusto says:

Thanks for the solution. I am using the IFAC style. I only needed to insert the first two lines (marked below). I use MikTeX 2.8.
However, in another computer with MikTeX 2.7, I didn’t run into this problem…

\documentclass{ifacmtg}
\bibliographystyle{ifac}
\usepackage{html} % <==
\usepackage{url} % <==
\usepackage[dcucite]{harvard}
\usepackage{times}
\usepackage[pdftex]{graphicx}
…………..

7. Steve says:

This is an absolute lifesaver. Thank you so much for this post.

8. Fabio Valeri says:

Thank you very very very much for this solution.

9. Igor says:

Indeed a lifesaver – what an excellent solution!
Spared me yet another few hours of frustration, thanks a lot!

10. niloba says:

It doesn’t work form me, I really don’t know what happen help me !!!

11. lilabelle13@yahoo.com says:

Thank you very much for providing this solution! I already considered changing back to Miktex 2.7… Thanks!

12. Jim says:

Another thanks from me. Error messages like these leave me clueless, I appreciate the help!

13. […] LaTeX – ¿Tiene problemas con el estilo Harvard? Agosto 8, 2010 Posted by psirusteam in Estadística. trackback The Harvard LaTeX citation package is a requirement for many people when writing research documents or academic theses. However, the sample LaTeX document harvard.tex that comes with the Harvard citation package available at the CTAN TeX Archive Network does not compile correctly as provided.  This can be somewhat frustrating for many authors, especially those who are quite new to LaTeX.  In attempting to resolve this problem I have developed sev … Read More […]

14. mr wobble says:

thanks a ton. i was pulling my hair out over this.

15. Ivette says:

You saved my life!
Thanks!

16. Tajoshini says:

Hi,

After I applying the recommended solution to get rid of the problem, I am getting a new error as follows:
Latex error: missing \begin{document}

Taj

17. Haitham says:

18. David says:

Thank you so much for the detailed solution: it works perfectly. One question: I now have the URLs listed in the reference page. Do you know how I can get them off? I use harvard package with agsm bibliographystyle, Miktex 2.9. Thank you !

19. JCorzo says:

This is a perfect solution. i didn’t have to use the second tail of the solution

20. Jean-Pierre says:

Thank you for your effort in putting this page together. After all efforts I am not able to get the webpage reference working. I assume that the problem goes with the installation of the harvard package.
Any help is appreciated!

My system: Mac book pro December 2008
System: 10.7.3
Latex: MacTex with TexShop 2.4.3

When following the steps suggested here I get an error message that the html package cannot be found

\usepackage{html}

when deleting the last line I get a huge error message which I cannot copy. Screenshot via email if needed.

As soon as I delete the line

\renewcommand{\harvardurl}{URL: \url}

I can typeset the document – but the website reference does not work…

• theseekersquill says:

Hi Jean-Pierre,

I am not sure if you are working from your own file or from the harvard sample tex file. Thus, the first suggestion is to verify you can successfully build the sample harvard latex file.

To that end:
I recommend you follows steps 1 to 4 inclusive specified under Recreating the Problem. Then follow all of the steps under Implementing the Solution, and report back here if you are successful or not at building the sample harvard LaTeX file.

I have just dowloaded the harvard ctan package and completed all the steps I am asking of you and it works for me.

Independently, the second suggestion I have for you is to verify you indeed have the html LaTeX package installed?

Please report back here with the results obtained after following the above two suggestions. I hope it works for you 🙂

• Carlos says:

I can concur that this trick doesn’t work on Mac OSX with TextShop as such. Although, TeXLive Utility didn’t work either straight out of the package, so I guess one has to dig a bit deeper. For the time being, my solution is just not to use web pages as a source… Works like a charm!

21. Katrin says:

Thank you very much! I just spend almost two hours with the message “Tex capacity exceeded, sorry [input stack size=5000]”. I figured out it had to do with the url in my bibtex data, but I couldn’t find anywhere how to get around the problem (didn’t find anything in the harvard documentation or anywhere else). Thanks for the solution!!!

22. I am asking if anyone can help me to cite using the Harvard style the result should be ….Robson(1998:23) the \citep{Robson1998}[23] results in …Robson(1998) [23]…. or \cite{Robson1998}[23] results in ….(Robson 1998) [23]…I want the first format ….Robson(1998:23).

23. Johnk180 says:

When I originally commented I clicked the Notify me when new comments are added checkbox and now every time a comment is added I get 4 emails using the same comment. Is there any way you may take away me from that service? Thanks! bkbdfabgbdge

24. Johnk739 says:

Hahahahahahaha, this politics related YouTube video is really so comical, I loved it. Thanks in favor of sharing this. fdkebbebeeee

25. unemployment says:

Why people still use to read news papers when in this technological world all is available on net?