I have a number of papers that include my email on the cover of the paper, and need to find a solution to \input my email address using \href. This way I will be able to edit my email once, and then get the most updated email address in all my papers every time I compile the file.

Is it possible to do something like this?


Thanks guys.

  • 5
    you could but why make it so complicated, rather than \href{mailto:\myemail}{\myemail} together with a myemail.sty that you can put in your input path with just one line: \def\myemail{[email protected]} Jul 4, 2017 at 16:29
  • 1
    If you are trying to remove the space that TeX adds after the sheer contents of your file (because it adds an end-of-line marker), \unskip cannot be used for this purpose in the first argument of \href. In principle, the problem could be cured by setting \endlinechar = -1, but it is much more simple to act as @DavidCarlisle suggests (but replacing \def with \newcommand*, I’d say…).
    – GuM
    Jul 4, 2017 at 16:34

2 Answers 2


This solution uses plain TeX I/O commands.

[email protected]


\newcommand{\readfile}[1]% #1 = filename
  \read\fid to\filetext
  \loop\ifx\empty\filetext\relax% skip over comments
    \read\fid to\filetext


Solution that fetches the mail address from a file to a macro via package catchfile:

[email protected]


% \endlinechar=-1 suppresses spaces by line ends

\href{mailto:\TheMailAddress}{John Doe $\langle$\TheMailAddress$\rangle$}


  • Just for curiosity: how do you make the screenshots with transparent background? Jul 4, 2017 at 18:46
  • @samcarter Usually, I convert to PDF, crop it, and run it through ghostscript's device pngalpha. Here, I have used the device png16m and used Gimp's "Colorize to alpha", because the current installed ghostscript (9.19) creates ugly artefacts at the edges. Jul 4, 2017 at 18:54
  • @samcarter I guess that it's not a screnshot. Rather a pdf that was converted into a gif or png. Jul 4, 2017 at 18:54
  • Sorry. Wasn't reading it accurate enough. The question wasn't of course not for me :). Still, have a look at en.m.wikipedia.org/wiki/ImageMagick. I use the convert command from the windows command window or in a batch file for that kind of tasks. Jul 4, 2017 at 18:55
  • 1
    @Dr.ManuelKuehner :) The more people to answer the better :) Jul 4, 2017 at 19:13

You must log in to answer this question.

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