I have this code borrowed from a similar stack thread
\newcounter{susis}
\newcommand{\myHyperlink}[2]{%
\refstepcounter{susis}\label{susislink#1}%
\ifcsname r@susistarget#1\endcsname
\hyperlink{#1}{\textcolor{blue}{#2}}%
\else
\hyperlink{#1}{\textcolor{red}{#2}}%
\fi
}
\newcommand{\myHypertarget}[2]{%
\refstepcounter{susis}\label{susistarget#1}%
\ifcsname r@susislink#1\endcsname
\hypertarget{#1}{\textcolor{teal}{#2}}%
\else
\hypertarget{#1}{\fbox{\textcolor{red}{#2}}}%
\fi
}
And it works when I run \myHyperlink{Hello}{Hello}. However, when I try to do \myHyperlink{\lor}{\lor} (logical OR symbol), it says: Missing \endcsname inserted. <to be read again> \lor.
How would I fix this error?
Additional info: I'm trying to target and link math operators. It works with normal hypertarget and hyperlink, but I want to include the additional feature: if the link refers to an undeclared target, it would display in red text instead of blue.


\loris math expression, so it should be in math environment:$\lor$. if this influence on working of your hyper links, i cant test (you not provide complete small document beginning with\documentclass{...}and ending with\end{document}) – Zarko Feb 04 '18 at 05:39