I'm writing a macro that takes a string and it returns an href
based on that string. The string could have 150 different values. My question is how to write this in an efficient way. Using pdflatex
.
Here's what I've got right now, shortened to two conditions for explanation:
\documentclass{article}
\usepackage{hyperref}
\newcommand{\myref}[1]{%
\ifnum\pdfstrcmp{#1}{aaa}=0%
\href{example.com/aaa}{my aaa link}
\fi
\ifnum\pdfstrcmp{#1}{bbb}=0%
\href{example.com/bbb}{my bbb link}
\fi
}
\begin{document}
Here is \myref{aaa}.
\end{document}
But of course once I get a success (#1=aaa
, say), I'm still testing the other 149 conditions for no reason. How to code this efficiently?
\href{example.com/<string>}{my <string> link}
?