I use a custom command \blink for Martin Scharrer's code to have blue underlined links in a beamer presentation. \blink uses his command \blurl in a \href command. It works, however, I cannot use my custom command \blink with a URL which contains a #. This compiles with an error:
\documentclass{beamer}
\usepackage{ulem}
% Colored links https://tex.stackexchange.com/questions/23208/i-cannot-get-a-properly-underlined-hyperlink-in-blue
\useunder{\uline}{\ulined}{}%
\DeclareUrlCommand{\blurl}{\def\UrlFont{\color{blue}\ulined}}
\providecommand{\blink}[2]{\href{#1}{\blurl{#2}}}
\begin{document}
\begin{frame}[fragile]
\frametitle{Nasty Link}
\blink{https://docs.python.org/3.7/library/stdtypes.html#string-methods}{string methods}
\end{frame}
\end{document}
Error:
! Illegal parameter number in definition of \Hy@tempa.
<to be read again>
s
l.2 ...dtypes.html#string-methods}{string methods}
I have tried to replace the # in the URL with %23 (I escaped the % sign in latetex code). That version compiled well, but it seems that the site I'm linking to does not accept %23 instead of #, so the clickable link in the resulting document does not meet the goal.
When I don't use my custom command \blink and do it like
\href{https://docs.python.org/3.7/library/stdtypes.html#string-methods}{\blurl{href with blurl}}
then the document compiles well and the link works. How do I have to improve my \blink command so that it can handle URLs with a # and possibly other Latex control characters?
#as\#it seems to work fine – BambOo Sep 02 '18 at 08:44hyperrefpackage. Bug reports are off-topic for this site. Please consider contacting the package's maintainer by email and asking him why\blink{https://docs.#.zzz}{string methods}generates an error whereas\href{https://docs.#.zzz}{\blurl{string methods}}does not. – Mico Sep 02 '18 at 11:14