当脚注在同一行时,如何中断 URL?

当脚注在同一行时,如何中断 URL?

问题同一行的脚注表明使用 是个好主意\usepackage[para]{footmisc}。但是,这似乎不适用于 URL:

\documentclass{article} 
\usepackage{hyperref}
\usepackage[para]{footmisc}
\begin{document} 
test\footnote{\url{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}
\end{document}

undesired result

给定的 URL 是不是换行(但脚注 2 和 3 在同一行)。如果没有加载 footmisc,则 URL 会完美换行。如果我想使用 URL 相邻的脚注,该怎么办?

更复杂的例子(以下答案https://tex.stackexchange.com/a/56706/9075):

\documentclass{article} 
\usepackage[para]{footmisc}
\usepackage{hyperref}

\def\myurl#1{\setbox0\vbox{\hsize.5\maxdimen
\url{#1}\par
\global\setbox1\lastbox}\unhbox1 }

\begin{document} 

test\footnote{\myurl{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}

ODE\footnote{\myurl{http://ode.apache.org/}}). 
SOAP/http\footnote{\myurl{http://www.w3.org/TR/soap12-part2/}} 
\end{document}

输出如下:

unexpected result

我想将脚注 2 和 3 放在同一行

答案1

为了使其para自动工作,您需要修改版本的\url

enter image description here

正如评论中所述,第一个版本在每个 url 后添加了 parfillskip glue,并填充到行尾,此版本将其删除。

\documentclass{article} 
\usepackage[para]{footmisc}
\usepackage{hyperref}

\def\myurl#1{\setbox0\vbox{\hsize.5\maxdimen
\url{#1}\par
\setbox0\lastbox
\global\setbox1\hbox{\unhbox0\unskip\unskip\unpenalty}}\unhbox1 }

\begin{document} 
test\footnote{\myurl{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}

ODE\footnote{\myurl{http://ode.apache.org/}}). 
SOAP/http\footnote{\myurl{http://www.w3.org/TR/soap12-part2/}} 
\end{document}

答案2

如果删除[para]选项footmisc,一切都会顺利进行。

\documentclass{article}
\usepackage{footmisc}
\usepackage{hyperref}
\begin{document}
test\footnote{\url{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}
\end{document}

enter image description here

编辑:如果你想保留 footmisc 的 para 选项,我们可以将选项传递[obeyspaces,spaces]给 url(由 加载hyperref)并在需要换行的地方留出一个空格。由于 footmisc 之间存在选项冲突,我们将其传递给 documentclass。

\documentclass[obeyspaces,spaces]{article}
\usepackage[para]{footmisc}
\usepackage{hyperref}
\begin{document}
test\footnote{\url{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/ long/long/long/long/long/long}}
\end{document}

相关内容