As the title says, I am very confused about how hyperref (and also the url package) handle escaping in the argument. The documentation says that hyperref "makes use of the url package", with an important difference: "[m]ost importantly the hyperref \url expands commands." To me that sounds good, but I am quite baffled about using the core LaTeX escaping commands in the argument. Here's an approximately minimal working example (where "working" means "successfully compiling"):
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\begin{document}
\noindent\raggedright \url{https://example.org/foo/{}bar} \break
\url{https://example.org/\{leftbrace} \break
\url{https://example.org/\}rightbrace} \break
\url{https://example.org/\$dollar1} \break
\url{https://example.org/$dollar2} (Only the unescaped dollar sign works?) \break
\url{https://example.org/\&ersand1} \break
\url{https://example.org/&ersand2} (Both ampersands work?) \break
\url{https://example.org/%percent1} (Not a line-ending comment?) \break
\url{https://example.org/\%percent2} \break
\url{https://example.org/\^{}circumflex} \break
\url{https://example.org/^circumflex} (Both circumflexes work?) \break
\url{https://example.org/\~{}tilde} \break
\url{https://example.org/~tilde} (... but only the unescaped tilde works?) \break
\url{https://example.org/\textbackslash{}backslash} \break
\url{https://example.org/\backslash} \break
\url{https://example.org/\tilde} \break
%\url{https://example.org/\s} (Uncommenting this line causes compilation to fail.) \break
\url{https://example.org/\\backslash} (Both unescaped and strangely-escaped backslash work, and also some other weird things are happening here.) \break
\end{document}
With this result:
I don't really know exactly how hyperref expects to process each of these input cases, but the cases seem quite inconsistent with each other and the documentation I quoted above. Could someone help me understand how these cases should work, and whether any of them indicate a bug in this package? In addition to these cases, if you uncomment the line starting with %\url{https://example.org/\s}, compilation fails.
As the title says, I am very confused about how
hyperref(and also theurlpackage) handle escaping in the argument. The documentation says thathyperref"makes use of the url package", with an important difference: "[m]ost importantly the hyperref\urlexpands commands." To me that sounds good, but I am quite baffled about using the core LaTeX escaping commands in the argument. Here's an approximately minimal working example (where "working" means "successfully compiling"):With this result:
I don't really know exactly how
hyperrefexpects to process each of these input cases, but the cases seem quite inconsistent with each other and the documentation I quoted above. Could someone help me understand how these cases should work, and whether any of them indicate a bug in this package? In addition to these cases, if you uncomment the line starting with%\url{https://example.org/\s}, compilation fails.