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}
stanton@sadhill.com
\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?

  • 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... – Timothy Truckle Mar 28 '18 at 10:29
  • 1
    @TimothyTruckle I'm worried about crawlers getting my address. Do you say it's not a problem with pdfs? – Arch Stanton Mar 28 '18 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? – Timothy Truckle Mar 28 '18 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. – Arch Stanton Mar 28 '18 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. – Timothy Truckle Mar 28 '18 at 11:17
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{nickname@myprovider.org}
    \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}{nickname@myprovider.org}}
    % 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{nickname@myprovider.org}
    
    \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.

  • Dammit, this is a bit more complicated than I had hoped for! – Arch Stanton Mar 30 '18 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{stanton@sadhill.com} \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. – Arch Stanton Mar 30 '18 at 12:22

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.