1

Background:

So basically, I would like to have a hyperlink to an email address. That email address, however, should not be fixed at the moment. It should be changeable.

So I tried to achieve that by defining the email as a new command, and then use it inside hyperref command.

But it doesn't seem to work. Latex gave me an error: undefined control sequence.

\documentclass{article}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=red}
\newcommand{\emailaddress}{jxhyctc@163.com}
\begin{document}

\href{mailto:\emailaddress}{\emailadrress}


\end{document}

Any help is greatly appreciated.

2
  • By the way, for the MWE you can leave out the lines which import graphicx, tikz, etc. and even the hypersetup line, because they are not necessary to get the issue across. Jun 16, 2021 at 9:12
  • Sorry, I will amend it shortly
    – jxhyc
    Jun 16, 2021 at 10:12

1 Answer 1

2

Check your spelling :)

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{tikz}
\hypersetup{colorlinks=true, linkcolor=red}

\newcommand{\emailaddress}{jxhyctc@163.com}
\begin{document}

\href{mailto:\emailaddress}{\emailaddress} % 'address', not 'adrress'


\end{document}
2
  • I am so embarrased by my mistake:)
    – jxhyc
    Jun 16, 2021 at 10:15
  • Happens to the best of us! (Admittedly it even took me a while to notice it.) Jun 16, 2021 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.