2

For example

\footnote{\verb+https://en.wikipedia.org/wiki/Constitution_of_France+}

treats _ as meaning a subscript and produces o as a subscript of n and F as a subscript of f.

1
  • 1
    yes. that is known. Use the url package and its \urldef command instead. Sep 28, 2020 at 17:38

2 Answers 2

2

As a general answer the memoir class (a superset of book, report, article) has a \verbfootnote macro which lets you include verbatin material in a footnote.

% verbfprob.tex  SE 564552
\documentclass{memoir}
\begin{document}
Some text%
\verbfootnote{Footnote with a \verb!verbatim entry! as shown}
followed by more text.
\end{document}
0

\verb does not work in the arguments to any command. The simplest approach is to use \texttt and explicitly escape special characters, e.g.,

\footnote{\texttt{https://en.wikipedia.org/wiki/Constitution\_of\_France}} 

although there isn't a simple escape for a backslash so maybe not so simple as you desire.

I have to admit I'm not crazy about the memoir class solution. It feels to me that memoir includes a lot of functionality that really should be in packages rather than the document class.

For URLs, there is the url package as mentioned by Ulrike Fischer in the comment on your question. This has the advantage that it incorporates line breaking in a fashion that we would expect for URLs while \verb and the \texttt solution above do not. To do this, you would, somewhere before your footnote do something along the lines of

\urldef{\frenchconst}\url{https://en.wikipedia.org/wiki/Constitution_of_France}

and then in your footnote you could write

\footnote{\frenchconst}
2
  • You say that "\verb does not work in the arguments to any command" but the memoir class, which you dislike, disproves that. Also Knuth's footnote macro can include \verb text in its argument. One of the ideas behind memoir was to reduce the number of packages for most documents. Sep 29, 2020 at 18:05
  • The separation of concerns between classes and packages was intentional. There are a lot of bad classes (and packages) on CTAN. imho. A well-designed document (and document class) would require changing absolutely nothing before \begin{document} to change classes. memoir bundles a lot of stuff that would be better unbundled. \verbfootnote does not actually allow \verb in an argument, it uses \aftergroup trickery to make it look like it does.
    – Don Hosek
    Sep 29, 2020 at 19: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.