# # and other characters in a url

How do I place the url:

https://en.wikipedia.org/wiki/Ugarit#/media/File:Ugarit_02.jpg

into a PDF:

\href{https://en.wikipedia.org/wiki/Ugarit#/media/File:Ugarit_02.jpg}{Loris Romito}


I end up with errors like this, which are not overly helpful:

618: Illegal parameter number in definition of \iterate.

• Welcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Your code works for me so the problem is in something else that you are doing and we have to guess what that is. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. Cutting your code down to a MWE may well reveal what your problem actually is. – user30471 Apr 27 '17 at 0:15
• @Andrew The code should NOT compile in this case. It should produce the error the OP wants help with. – cfr Apr 27 '17 at 1:07
• @cfr True...my standard comment for this says this but, with edits, it was too long to fix in the comment box so I deleted this clause... – user30471 Apr 27 '17 at 2:45
• Try \#' It's what I use in \href. – John Kormylo Apr 27 '17 at 3:38
• @Jacob: When I try your code snippet as-is in a minimal example, I get no error and the URL is properly sourced when I click on the hyperlinked text. So, perhaps you need to provide more information for us to replicate the issue... – Werner Apr 27 '17 at 6:15

You are using the \href in the argument of some other command. This will break as \href no longer can change the catcode of the #. The exact error message depends on the outer command, but will normally report an Illegal parameter. In such cases you can excape the #:

\documentclass{article}
\usepackage{hyperref}
\begin{document}

%works fine:
\href{https://en.wikipedia.org/wiki/Ugarit#/media/File:Ugarit_02.jpg}{Loris Romito}

%fails:
%\textbf{\href{https://en.wikipedia.org/wiki/Ugarit#/media/File:Ugarit_02.jpg}{Loris Romito}}

%workaround: escape the #:
\textbf{\href{https://en.wikipedia.org/wiki/Ugarit\#/media/File:Ugarit_02.jpg}{Loris Romito}}

\end{document}


You can try with "url" or "breakurl" package and the tag is \url{...}, all the special characters are allowed for web link. And these packages having support with "hyperref" package...

• That does not solve the problem of the question: he already uses a command allowing special characters in urls as you can see in hyperref's \href macro. But try this: \documentclass{article} \usepackage{url} \begin{document} \textbf{\url{http://www.foo.de/#bla}}} \end{document} and you'll see that \url` has the same problem when used inside another macro… – cgnieder Apr 28 '17 at 8:23