0

I am looking for a way to reference literature including url. For instance my BibTex keys look like this:

@misc{UnitedNationsGeneralAssembly.2015,
 author = {{United Nations General Assembly}},
 year = {2015},
 title = {Sustainable Development Goals},
 url = {\url{https://sustainabledevelopment.un.org/}}
}

The citing in the text should be: (United Nations General Assembly, 2015) and in the references:

United Nations General Assembly, 2015. Sustainable Development Goals. https://sustainabledevelopment.un.org/

Right now I'm using \documentclass{report} and \bibliographystyle{apalike}, but the url doesn't show up. What can I do about that?

Mico
  • 506,678
  • 1
    Welcome to TeX SX! Could you consider using biblatex? It has an apa style and is easier to customise, as it uses a LaTeX syntax. Furthermore, it defines the @online entry type. – Bernard Jan 26 '20 at 11:11
  • Just in case you're not familiar with biblatex, maybe this answer here might help you, it nicley explains the advantages biblatex can have (as well as advantages of biber over bibtex). – TivV Jan 26 '20 at 11:42

1 Answers1

2

The apalike bibliography style is very old. In fact, it is so very old that it predates the notion that URL strings might ever show up in a bibliographic entry. As a result, the apalike bib style simply ignores the url field.

What to do? Simply change

 url = {\url{https://sustainabledevelopment.un.org/}}

to

 note = {\url{https://sustainabledevelopment.un.org/}}

Of course, do be sure to load the url or, better still, the xurl package. (By the way, if url were a recognized field, then it would be a syntax error to encase the URL string in a \url directive. The syntactically correct way to write the field would be url = {https://sustainabledevelopment.un.org/}.)

Owing to its advanced age, the apalike bib style does not implement the current APA guidelines and requirements regarding the formatting of bibliographic entries. If the bibliography of your document needs to conform to modern APA guidelines, and if you want to stick with a BibTeX-based approach, do consider employing the apacite bibliography style and the apacite package.


A full MWE (minimum working example) and its output:

enter image description here

\documentclass{article}
\begin{filecontents}[overwrite]{mybib.bib}
@misc{UnitedNationsGeneralAssembly.2015,
 author = {{United Nations General Assembly}},
 year   = {2015},
 title  = {Sustainable Development Goals},
 note   = {\url{https://sustainabledevelopment.un.org/}}
}
\end{filecontents}

\usepackage[round]{natbib} % for \citep macro
\bibliographystyle{apalike}

\usepackage{xurl}
\usepackage[colorlinks,allcolors=blue]{hyperref} % optional

\begin{document}
\citep{UnitedNationsGeneralAssembly.2015}
\bibliography{mybib}
\end{document}

Addendum: As @moewe has pointed out in a comment, the apacite bib style and eponymous LaTeX package implement the guidelines of the 6th edition of the APA manual. Importantly, the 6th edition has been superseded by the 7th edition within the past year or so. If you need to be truly current in your adherence to APA guidelines, you'll need to switch from apacite to biblatex. (Put differently, the apacite package hasn't been updated yet to reflect the changes between the 6th and 7th editions.)

To make the MWE given above work with biblatex and biber, you need to load the biblatex package, with the option style=apa (and with the option natbib in case you wish to use \citet and \citep to create citation call-outs) and employ \addbibresource and \printbibliography statements.

enter image description here

\documentclass{article}
\begin{filecontents}[overwrite]{mybib.bib}
@misc{UnitedNationsGeneralAssembly.2015,
 author = {{United Nations General Assembly}},
 year   = {2015},
 title  = {Sustainable Development Goals},
 url    = {https://sustainabledevelopment.un.org/}
}
\end{filecontents}

\usepackage[style=apa, natbib]{biblatex}
\addbibresource{mybib.bib}

\usepackage{xurl} % allow line breaks in URL strings at arbitrary locations
\usepackage[colorlinks,allcolors=blue]{hyperref} % optional

\begin{document}
\citep{UnitedNationsGeneralAssembly.2015}
\printbibliography
\end{document}
Mico
  • 506,678