带有 # 作为脚注的 url

带有 # 作为脚注的 url

似乎在编译 pdf 时,内部的符号#\url产生\footnote错误。这是由平均能量损失以下。

\documentclass[12pt,twoside]{report}
\usepackage{booktabs}
\usepackage[headheight=18pt,a4paper, width=150mm, top=25mm, bottom=25mm, bindingoffset=6mm, headsep=18pt]{geometry}
\usepackage[spanish,es-noquoting]{babel}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage[hyphens]{url}
\renewcommand{\thefootnote}{\alph{footnote}}
\usepackage{csquotes} 
\usepackage[numbers, super]{natbib}
\usepackage{notoccite}
\usepackage[version=3]{mhchem}
\usepackage{chemmacros}
\chemsetup{
  formula = chemformula ,
  modules = all
}
\usepackage{hyperref}


\begin{document}
 \footnote{\url{https://chemicalize.com/#/calculation}} 
\end{document}

输出:

! Illegal parameter number in definition of \Hy@tempa.
<to be read again>
/
l.20 ...rl{https://chemicalize.com/#/calculation}}
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.
! Illegal parameter number in definition of \Hy@tempa.
<to be read again>

我搜索了类似的帖子,#但什么也没找到。有什么帮助吗?

答案1

在脚注前定义 url 为\urldef

\documentclass[12pt,twoside]{report}
\usepackage{hyperref}

\begin{document}
\urldef\urlchem\url{https://chemicalize.com/#/calculation}

\footnote{\urlchem}
\end{document}

在此处输入图片描述

答案2

我在使用 Overleaf 时遇到了类似的问题,一个简单的解决方法是用“\”转义“#”。

参见示例:

\footnote{Some constrains apply, see \url{https://developers.google.com/analytics/devguides/reporting/realtime/v3/devguide\#constraints}}.

相关内容