This is related to this question

Special character in url link

but is specific to DOIs and does not involve unicode characters.

I have to use strange DOIs like this


So, I need to able to build a command like


That is, I need a valid URL in the first argument to \href based on a DOI which includes invalid characters as URL.

We can assume that there is an external command that escapes invalid characters in a URL:

$ urlencode '10.1175/1520-0485(1986)016<1929:CTWOTE>2.0.CO;2'

If I knew how to call an external program and catch its standard output, I would be able to build such a LaTeX command.

Or maybe somebody already has a solution.

If urlencode can be used from within LaTeX, it would serve as a solution to the unicode character problem, too.

By the way, a URL with invalid characters still works on Adobe Reader, but it doesn't on Apple's PDF viewer and other PDF viewers that use Webkit (so I was told). I suspect that Apple wouldn't fix it because the URL is invalid after all.

  • 2
    you could use the doi package. Commented Oct 13, 2021 at 7:31
  • @UlrikeFischer Ah, so simple! Thanks! I'll modify the title and the contents of my question because the solution is specific to DOI, not general to include all invalid URLs.
    – Ryo
    Commented Oct 13, 2021 at 8:54

1 Answer 1


It turns out that the doi package already provides such a command as described in the question (although I don't know whether it's actually expanded into an \href command or not). Thank you to @UrlikeFischer .

You just \usepackage{doi} in the preamble:

{URL including percent encoding}\\
{URL including invalid characters}\\

This is to demonstrate that the hyperlinks to invalid URLs don't work on Apple's PDF viewers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .