1

I'm relatively new to Latex and tried to include an URL into my bibliography. Whenever I try to open it from the PDF unfortunately the link does not work (I guess because it thinks there's a space where the line break is)

\documentclass[12pt] {article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{stackengine}
\usepackage{tabularx}
\usepackage{tikz}
\usepackage{url}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,decorations.pathreplacing}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[toc,page]{appendix}

\linespread{1.35}
\begin{document}

Author (2017): ``titel,''. Retrieved from: {\url{http://tex.stackexchange.com}} [Accessed: 1 January 2000]

\end{document}

Many thanks for your help in advance!

  • 1
    If you want the link to be clickable then use hyperref. I think now what you are seeing is your PDF previewer trying to be smart and guessing that this is an URL attempting to making it clickable, and as you mention, getting confused by the line break. – daleif Sep 13 '17 at 12:46
2

You should load both the url and the hyperref packages. The former provides tool to format URL strings visually. The latter packge provides the machinery to create hyperlinks.

Oh, since you're loading the setspace package, you might as well replace \linespread{1.35} with \setstretch{1.35}.

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{setspace,amsmath,amssymb,graphicx}
\usepackage{caption,stackengine,tabularx,tikz}
\usetikzlibrary{arrows,positioning,decorations.pathreplacing}
\usepackage[toc,page]{appendix}

\usepackage[hyphens,spaces]{url}
\usepackage[colorlinks,urlcolor=blue]{hyperref}

\setstretch{1.35}

\begin{document}

\begin{thebibliography}{9}

\bibitem{auth:17} Author (2017): ``Title.'' 
    Retrieved from: \url{http://tex.stackexchange.com} 
   [Accessed: 1 January 2017].

\end{thebibliography}

\end{document}
  • Thanks for your help! When I use the hyperref package, my table of content disappears. – Helena Sep 13 '17 at 13:04
  • 1
    Did you rerun latex twice after adding the hyperref package? – Mico Sep 13 '17 at 13:07
  • 1
    No, I didn't! Thank you very much! It's working now (both the url and the table of content). Thanks!! – Helena Sep 13 '17 at 13:08

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.