1

I'd like to generate an image from my e-mail address and import it in a document on the fly, that is, something like

\begin{importaspng}
[email protected]
\end{importaspng}

that would then typeset the mail address with the same properties as the surrounding text (typeface etc.) but as a png or svg file. Is it possible?

11
  • If you do want your readers sending you a mail, why do you want them to type your mail address by hand? And if you don't want mails from your readers, why do you add your mail address at all? At the end your document is not a web page where spammers will farm your mail address... Commented Mar 28, 2018 at 10:29
  • 1
    @TimothyTruckle I'm worried about crawlers getting my address. Do you say it's not a problem with pdfs? Commented Mar 28, 2018 at 10:37
  • I'd say it's not worth the efford. There is a much higer risk that the spammerst get your address direcly from the addressbook of one of your contacts. Or why do you think facebook and Whatsapp are for free? Commented Mar 28, 2018 at 10:49
  • Sounds like the beginning of an interesting discussion :-) Slightly off-topic, though. Well, I'm leaving the question open (I'm curious about whether it's possible and how) but I'll probably just add my full address to the document then. Commented Mar 28, 2018 at 11:09
  • 1
    "I'm curious about whether it's possible and how" The best way I see is to make an SVG from you Mail addrss and uses that. At least you will be able to scale it to the sourrounding font size. Maybe someone knows of a TeX2PNG converter but even then it would be an extra step outside the document and thus not exaclty fitting your requirement to keep the same font as the rest. Commented Mar 28, 2018 at 11:17

1 Answer 1

1

Arch Stanton, you can solve your problem in three steps:

  1. Copy this LaTeX script (below, my vb_email.tex) to generate an appropriate postscript file with dvips command.

    \documentclass[oneside]{letter}
    \usepackage[T1]{fontenc}
    \usepackage[latin1]{inputenc}
    \usepackage[frenchb,english]{babel}
    \usepackage[dvips]{geometry}
    \usepackage{calc}
    \pagestyle{empty}
    \setbox0=\hbox{[email protected]}
    \geometry{papersize={\the\wd0, \the\ht0 + \the\dp0}, noheadfoot, top=0ex, bottom=-1ex, left=0cm, right=0cm, voffset=0cm, hoffset=0cm}%
    \begin{document}
    \noindent{\raisebox{0.5em}{[email protected]}}
    % Install and use Imagemagick to convert images from one format to another:
    % convert -density 400 -colorspace RGB c:\latex_documents\vb_email.ps -resize 800 -interlace none email.png
    \end{document}
    
  2. Dowload and use imagemagick software to convert your .ps file to .png file.

    convert -density 400 -colorspace RGB c:\latex_documents\vb_email.ps -resize 800 -interlace none email.png
    

image generated by LaTeX and converted to png format with Imagemagick

  1. Insert your .png in your LaTeX with some adaptations to align it appropriately.

    \documentclass[oneside]{letter}
    \usepackage[T1]{fontenc}
    \usepackage[latin1]{inputenc}
    \usepackage[french,english]{babel}
    \usepackage{graphicx} % or \usepackage{tikz}
    
    \setbox0=\hbox{[email protected]}
    
    \begin{document}
    \hbox{\raisebox{1ex}{My email address is }{\raisebox{0.65ex}{{\includegraphics[width=\the\wd0]{email.png}}}} \raisebox{1ex}{other text on the same line}\raisebox{0ex}{}} \vspace{-2.6ex} other text on the next line\\
    Third line%
    \end{document}
    

\raisebox allow you to adjust the position of the base line for \hbox.

Finally, your pdf file allow you to edit your text but not your email address.

2
  • Dammit, this is a bit more complicated than I had hoped for! Commented Mar 30, 2018 at 11:22
  • 1
    By the way, unless there are some advantages in your approach that I haven't noticed, I think \documentclass[border=1,png={density=600}]{standalone} \begin{document} \texttt{[email protected]} \end{document} is a much quicker alternative to the first two steps. What I was looking for, though, is something that adapts to changes in the style of the document (typeface and the like) without having to recompile external files. Commented Mar 30, 2018 at 12:22

You must log in to answer this question.

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