2

I want to add a footnote in my document. Unfortunately this does not always work. For example I have the following two documents: Document1:

\listfiles
\documentclass[oneside,12pt]{scrartcl}
\usepackage[ngerman]{babel}
%\usepackage{amsmath}
\usepackage[fixamsmath,disallowspaces]{mathtools}
\begin{document}
Test \footnote{http://www.erneuerbare-energien.de/EE/Redaktion/DE/Dossier/eeg.html?cms_docId=72462}


\end{document}

Document2:

\listfiles
\documentclass[oneside,12pt]{scrartcl}
\usepackage[ngerman]{babel}
%\usepackage{amsmath}
\usepackage[fixamsmath,disallowspaces]{mathtools}
\begin{document}
Test\footnote{http://www.bmwi.de/DE/Themen/Energie/Europaische-und-internationale-Energiepolitik/europaeische-energiepolitik.html}


\end{document}

For document 1 I get 8 errors while compiling and no output PDF is produced whereas for document 2 I do not get a singel error and the output PDF looks like it should.

  • 1
    For the first I get the expected ! Missing $ inserted. because of the _ in the URL, the second runs without problems. You should add \usepackage{url} or \usepackage{hyperref} and use \url{http://...} for the URLs. – cgnieder Aug 11 '15 at 14:19
  • Welcome to TeX.sx, by the way :) – cgnieder Aug 11 '15 at 14:20
  • 2
    You say the output of the second example "looks like it should". In fact, the line break LaTeX found is terrible, with the first line being seriously underfull. Better to encase the URL-like string in a \url wrapper. – Mico Aug 11 '15 at 14:31
2

In both of your examples, the easiest fix is to load the url package with the option hyphens, viz.

\usepackage[hyphens]{url}    

and to encase the material the footnotes in \url{...} directives, i.e., to write

Test \footnote{\url{http://www.erneuerbare-energien.de/EE/Redaktion/DE/Dossier/eeg.html?cms_docId=72462}}

and

Test\footnote{\url{http://www.bmwi.de/DE/Themen/Energie/Europaische-und-internationale-Energiepolitik/europaeische-energiepolitik.html}}

The \url wrappers (i) do a good job of finding line breaks in long URL-like strings and (ii) remove the special meanings of characters such as _, ^, &, and #.

The following screenshot shows the two footnotes generated by the proposed course of action.

enter image description here

\documentclass[oneside,12pt]{scrartcl}
\usepackage[ngerman]{babel}
%\usepackage{amsmath}
\usepackage[fixamsmath,disallowspaces]{mathtools}
\usepackage[hyphens]{url}
\begin{document}
Test.\footnote{\url{http://www.erneuerbare-energien.de/EE/Redaktion/DE/Dossier/eeg.html?cms_docId=72462}}

Test.\footnote{\url{http://www.bmwi.de/DE/Themen/Energie/Europaische-und-internationale-Energiepolitik/europaeische-energiepolitik.html}}
\end{document}

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.