3

I am facing difficulty to get the outputs First i want to replace a character "_" in the email id called [email protected] 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{[email protected]}


\end{document}

1 Answer 1

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{[email protected]}

\end{document}

enter image description here

Don't forget to protect the end of lines.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .