2

I am facing difficulty to get the outputs First i want to replace a character "_" in the email id called ab_c@email.com for which i used \StrSubstitute{#1}{_}{\textunderscore} and second to get hyperlink for email i used \href but both these two commands do not work simultaneously. So how can achived so that i can replace and fet hyperlink. Below is my MWE which i tried so far.

\documentclass[a4paper]{article}
\usepackage{hyperref}
\usepackage{xstring}

\usepackage[T1]{fontenc}
\usepackage{textcomp}

\newcommand{\Email}[1]{
 Email: \href{\StrSubstitute{#1}{_}{\textunderscore}}{\StrSubstitute{#1}{_}{\textunderscore}}
}

\begin{document}

  \Email{ab_c@email.com}


\end{document}
2

First of all, you don't want to do the substitution in the first argument; next, you can't use \StrSubstitute in the argument.

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage{xstring}
\usepackage{hyperref}

\newcommand{\Email}[1]{%
 Email: %
 \StrSubstitute{#1}{_}{\textunderscore}[\temp]%
 \href{mailto:#1}{\temp}%
}

\begin{document}

  \Email{ab_c@example.com}

\end{document}

enter image description here

Don't forget to protect the end of lines.

| improve this answer | |
  • Its working. How can remove the border line which comes up around the email ID @egreg – Biki Teron Oct 30 '19 at 14:19
  • @BikiTeron I get no border, because I don't use Adobe Acrobat Reader. It's added by some PDF viewers. – egreg Oct 30 '19 at 14:22
  • Ok, it may depending upon the application which we used. Thank you so much @egreg – Biki Teron Oct 30 '19 at 14:23
  • @BikiTeron I guess you can remove it with \hypersetup{pdfborder={0 0 0}} – egreg Oct 30 '19 at 14:31
  • Yes, also we can use the option as hidelinks as \usepackage[hidelinks]{hyperref} @egreg – Biki Teron Oct 30 '19 at 15:23

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.