我想将网页链接写入脚注。使用该hyperref
包,除非链接中有%
符号,否则此操作可以正常工作。这是 MWE(不起作用):
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref} % clickable links
\author{Hans Wurst}
\title{Some amazing title}
\begin{document}
\maketitle
\begin{abstract}
An abstract with some footnote\footnote{\href{https://tex.stackexchange.com/}{tex.stackexchange}} which should contain a link to a webpage. Unfortunately, a link in a footnote\footnote{\href{https://somepage.com/Documents%20}{bla}} containing a \% does not work.
\end{abstract}
\end{document}
非常感谢有关如何解决此问题的任何想法。
答案1
问题在于 位于\href
脚注中。因此, 的 catcode在吸收其参数%
时固定为 14 \footnote
,然后\href
才能在脚注中施展自己的 catcode 魔法。到那时,再想挽回损失就太晚了。
%
解决方案。在脚注调用之前将 catcode 更改为 12(之后再将其改回)。
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref} % clickable links
\author{Hans Wurst}
\title{Some amazing title}
\begin{document}
\maketitle
\begin{abstract}
An abstract with some footnote\footnote{\href{https://tex.stackexchange.com/}
{tex.stackexchange}} which should contain a link to a webpage. Unfortunately,
a link in a footnote\catcode`\%=12 \footnote
{\href{https://somepage.com/Documents%20On%20file}{bla}} \catcode`\%=14
containing a \% does not work.% A COMMENT??
\end{abstract}
\end{document}