latexspecial-charactershref

ignore % character in href


I want to use \href to shorten an url. My current document looks like this:

\documentclass[11pt]{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[colorlinks=true,urlcolor=Blue]{hyperref}
...
\begin{document}
\href{https://www.flickr.com/search/?safe_search=1&license=2%2C3%2C4%2C5%2C6%2C9&dimension_search_mode=min&height=640&width=640&media=photos}{https://www.flickr.com/search/?license=2%2C3%2C4%2C5%2C6%2C9}
\end{document}

My desired output is an url https://www.flickr.com/search/?license=2%2C3%2C4%2C5%2C6%2C9 that, when clicked on, links to the long link.

Currently, latex interprets the % in the url as the start of comments and doesn't show the url at all.


Solution

  • I tested it in TeXstudio on Ubuntu and it seems to work, when you put a backslash in front of the %. % => \%

    \documentclass[11pt]{article}
    \usepackage[dvipsnames]{xcolor}
    \usepackage[colorlinks=true,urlcolor=Blue]{hyperref}
    ...
    \begin{document}
    \href{https://www.flickr.com/search/?safe_search=1&license=2\%2C3\%2C4\%2C5\%2C6\%2C9&dimension_search_mode=min&height=640&width=640&media=photos}{https://www.flickr.com/search/?license=2\%2C3\%2C4\%2C5\%2C6\%2C9}
    \end{document}