2

I would like for my citation style to be Harvard.

I am using the following:

\documentclass[conference]{IEEEtran}
\usepackage[comma]{natbib}
\usepackage{url}
\begin{document}

foo \citep{vitz_history_2016}

\bibliographystyle{IEEEtran}
\bibliography{references}
\end{document}

Citation from example in the .bib file:

@online{vitz_history_2016,
    year = {2016},
    title = {History of the Periodic Table},
    url = {https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table},
    titleaddon = {Chemistry {LibreTexts}},
    author = {Vitz, Ed and Moore, John and Shorb, Justin and Prat-Resina, Xavier and Wendorff, Tim and Hahn, Adam},
    urldate = {2019-11-25},
    date = {2016-05-26},
    langid = {english},
    file = {fname}
}

In a two column layout this produces: agsm

I normally create documents using \cite{author} and \bibliographystyle{IEEEtran} and so by including \usepackage{url} URLs are displayed correctly: ieeetran

I would like for the same reference to appear as the second example but use a Harvard style citation as in the first example.

Any help would be much appreciated!

  • 1
    Have you tried loading the xurl package instead of the url package? – Mico Dec 7 '19 at 16:46
  • Please show the bib entry in question. In particular, how is the URL string marked up? – Mico Dec 7 '19 at 16:48
  • The fact that the M in Ancillary_Materials appears as a subscript makes me think that the URL is for some reason not typeset with \url (as one would usually expect), but instead as normal text. This is particularly odd since your load the url package, which defines \url. When I try to run your code I get an error, since the style IEEEtran is incompatible with natbib. If you want to use natbib you need to load the style IEEEtranN (but you should know that natbib should not be used for IEEE submissions). – moewe Dec 7 '19 at 19:43
  • 1
    @Mico agsm uses \harvardurl around URLs, which natbib defines as \newcommand\harvardurl[1]{\textbf{URL:} \textit{#1}}, so one might want to try something like \renewcommand\harvardurl{\textbf{URL:} \url}. I would try to avoid putting \url{...} around the URL in the url field if at all possible. – moewe Dec 8 '19 at 8:26
  • 1
    If it is only two-column typesetting you are after, you could also use \documentclass[twocolumn]{article} instead of \documentclass[conference]{IEEEtran}. I usually recommend to avoid customised publisher classes if one is not submitting to the publisher, since those classes can sometimes be harder to customise or may load package that one doesn't need or that are incompatible with packages one would like to use. (BTW: The 'you should know' in my comment above meant 'I should tell you, if I recommend IEEEtranN', not that you should know without being told.) – moewe Dec 8 '19 at 8:36
2

There seem to be several issues.

  • Since you're using the IEEEtran document class, using the IEEEtran bibliography style along with the natbib package should be used exclusively in conjunction with the \cite and \citep commands; both will generate numeric-style citation call-outs. \citet isn't really usable with the IEEEtran bibliography style.

  • If you wish to use the natbib package along with the IEEEtran document class, you should probably be using the IEEEtranN bibliography style. (The N in IEEEtranN stands for natbib...) With this setup, \cite and \citep will still produce numeric-style call-outs, but \citet now "works" too, in the sense that it creates author-number style citation call-outs. Try as you might, though, you won't get this setup to produce author-year style, aka "harvard-style" and "agsm-style", citation call-outs.

    That said, I will echo @moewe's comment: Most (all?!) journals that require the use of the IEEEtran document class employ numeric style citation call-outs; they will probably reject submissions that employ author-number or author-year style citation call-outs.

  • Just in case this wasn't a typo: The proper syntax is \citep{<some_key>}, not \citep(<some_key>).

enter image description here

\documentclass[conference]{IEEEtran}

\begin{filecontents}[overwrite]{mybib.bib}
@online{vitz_history_2016,
    year = {2016},
    title = {History of the Periodic Table},
    url = {https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table},
    titleaddon = {Chemistry {LibreTexts}},
    author = {Vitz, Ed and Moore, John and Shorb, Justin and Prat-Resina, Xavier and Wendorff, Tim and Hahn, Adam},
    urldate = {2019-11-25},
    date = {2016-05-26},
    langid = {english},
    file = {fname}
}
\end{filecontents}

\usepackage[numbers,comma]{natbib}
\bibliographystyle{IEEEtranN} % not 'IEEEtran'
\usepackage{xurl}
\usepackage[colorlinks,allcolors=blue]{hyperref} % just for this example

\begin{document}
foo \citep{vitz_history_2016} % not "\citep(author)"

bar \citet{vitz_history_2016}
\bibliography{mybib}
\end{document}

Addendum: I can actually reproduce the awful-looking non-linebroken URL string, with subscripts in place of underscores, shown in your first screenshot if I replace \bibliographystyle{IEEEtranN} with \bibliographystyle{agsm}. The agsm style is quite old and and uses a macro called \harvardurl, which does not take the same precautions as \url does when typesetting URL strings; these precautions pertain to TeX-special characters, such as _ and %, which may occur in a URL string. (Many thanks to @moewe for pointing this out to me!)

If you must use the agsm bibliography style, then, there are two ways to proceed: First, you could provide the instruction

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

after \bibliographystyle{agsm}. Second, you could change

url = {https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table},

to

url = {\url{https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table}}, 

Of course, both methods assume that you've loaded a suitable package -- url and xurl come to mind -- that defines a "real" \url macro.

Incidentally, if you wish to use the agsm bibliography style, you should load the har2nat package, not the natbib package directly. Why? The agsm bib style is part of the harvard citation management package, which comes with some specialized commands. The har2nat package (a) loads the natbib package and (b) "translates" the harvard-specific macros into macros recognized by the natbib package. This is especially useful if you wish to use the hyperref package in your document: hyperref is fully compatible with the natbib package, but less so with the harvard package.

enter image description here

\documentclass[conference]{IEEEtran}

\begin{filecontents}[overwrite]{mybib.bib}
@online{vitz_history_2016,
    year = {2016},
    title = {History of the Periodic Table},
    url = {\url{https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table}},
    titleaddon = {Chemistry {LibreTexts}},
    author = {Vitz, Ed and Moore, John and Shorb, Justin and Prat-Resina, Xavier and Wendorff, Tim and Hahn, Adam},
    urldate = {2019-11-25},
    date = {2016-05-26},
    langid = {english},
    file = {fname}
}
\end{filecontents}

\usepackage{har2nat} % not 'natbib' directly
\bibliographystyle{agsm}
\usepackage{xurl}
\usepackage[colorlinks,allcolors=blue]{hyperref} 

\begin{document}
foo \citep{vitz_history_2016} % not "\citep(author)"

bar \citet{vitz_history_2016}
\bibliography{mybib}
\end{document}
| improve this answer | |
  • 1
    Thank you so much for your detailed response. I have used har2nat, xurl, and agsm which has produced the desired formatting. To reiterate my previous comment, this isn't meant for submission but just a simple to use template to pass on to another who's LaTeX ability is even more limited than mine! I have corrected the typo. – macourtney7 Dec 8 '19 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.