Skip to content

documentation: percent character needs escaping in nested \href #249

@bastistician

Description

@bastistician

hyperref/doc/hyperref-doc.tex

Lines 1276 to 1277 in d656e81

special characters \# and \~{} do \emph{not} need to be escaped in any
way (unless the command is used in the argument of another command).

It seems that the tilde does not need to be escaped in \href URLs, even if used as an argument of another command.
For example, the following minimal LaTeX document compiles fine:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\emph{\href{https://example.org/~a}{tilde}}
\end{document}

However, the hash and percent symbols do need to be escaped in that case.
For example, the following fails, but would work with backslash-escaped percent or without the \emph:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\emph{\href{https://example.org/a%20b}{space}}
\end{document}
Runaway argument?
{\href {https://example.org/a\end {document} 
! File ended while scanning use of \emph .

Could this be a typo in the documentation referenced at the top?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions