8

When I add a URL with TeX-special characters—such as % in the example below—to a footnote, it does not work.

\documentclass{article}

\usepackage{hyperref}
\usepackage{xurl}

\begin{document}

1\footnote{\url{https://tex.stackexchange.com/questions/700246/how-to-output-the-%cf%84%ce%b5%cf%87%ce%bd%ce%b9%ce%ba%ce%ae-symbol}}

\end{document}

I have tried to use the xurl package, but I still could not make it work. It works fine in ConTeXt, but it did not work in a footnote. Am I missing something? What should I do to make it work?

2 Answers 2

9

Section 2, entitled "Defining a defined-url", of the user guide of the url package explains that if a URL string that contains TeX-special characters is supposed to be typeset in a footnote, it is necessary to create a "defined URL", via an \urldef instruction.

This detour is necessary because of a limitation in TeX's footnote-typesetting machinery. (As you probably know, TeX was invented long before the world wide web and the associated notion of URLs came along; as such, URL strings can contain some TeX-special characters which can create havoc if the URL strings occur in the argument of \footnote.) The \urldef device gets around this limitation.

enter image description here

\documentclass{article}
\usepackage{xurl} % 'xurl' package loads 'url' package automatically
% Here comes the '\urldef' instruction:
\urldef\urlA\url{https://tex.stackexchange.com/questions/700246/how-to-output-the-%cf%84%ce%b5%cf%87%ce%bd%ce%b9%ce%ba%ce%ae-symbol}

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

\setlength\textheight{1.5cm} % just for this example

\begin{document}
aaa\footnote{\urlA}
\end{document}
4

The question title in stackexchange urls is more or less just decoration. The link still works if you just have the question number:

\documentclass{article}

\usepackage{hyperref}
\usepackage{xurl}

\begin{document}
1\footnote{\url{https://tex.stackexchange.com/questions/700246}}
\end{document}
1
  • 1
    Thank you for your time and patient. is it possible to make the special charactors work in footnote? I still wonder why the footnote could not work with these special chactors. this action just ignore the issue not fixed it.
    – Dolphin
    Dec 2, 2023 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .