I am trying to define a label from a string with blanks to use with hyperref. But I get an error. The example below does not compile if the two lines with comments are uncommented. Is there a remedy for this?
\documentclass{article}
\usepackage{xstring}
\usepackage{color}
\usepackage{hyperref}
\def\animal{zebra with stripes}
\def\mylabel{\StrSubstitute{\animal}{ }{}}
\def\thelabel{zebrawithstripes}
\begin{document}
\hypertarget{\thelabel}{\noindent Here is a zebra.} \\
Go to \hyperlink{\thelabel}{\textcolor{blue}{\animal}}.\\
%\hypertarget{\mylabel}{\noindent Here is a zebra.} \\
%Go to \hyperlink{\mylabel}{\textcolor{blue}{\animal}}.\\
\mylabel
\end{document}
\let \@xs@assign \@xs@expand@and@assign \@xs@StrSubstitute@zebra with stripes– John Kormylo Mar 03 '18 at 03:52