# Align two lines of text inside a \emailfrom

I am very new to TeX and I am trying to do a simple cover letter using LaTeX. I've downloaded a template for a cover letter and it has a component (don't know how you call these things) named \emailfrom. My code looks like this:

\emailfrom{ % Email address
first.email@email.com \\
second.email@email.com \\
third.email@email.com
}


This is what I am currently obtaining:

My only inelegant solution so far is:

\emailfrom{ % Email address
first.email@email.com \\
~~~~~~~~~~~~~~second.email@email.com \\
~~~~~~~~~~~~~~third.email@email.com
}


I would like to be able to align second and third email to the first one. How can I achieve this?

Sorry for the vagueness but I am clueless about TeX.

Untested in the absence of a MWE. Try some thing like this:

\emailfrom{% Email address
\begin{tabular}[t]{l}
first.email@email.com \\
second.email@email.com \\
third.email@email.com
\end{tabular}
}


To get hyperlinks and mailto: put\usepackage{hyperref} in the preamble, and use

\href{mailto:your name}{first.email}

• How can I include mailto to the links? I've tried but gives me an error. Thank you. – OneEyeQuestion Sep 30 '14 at 3:20
• @OneEyeQuestion -- The package hyperref is required for the \href macro. – jon Sep 30 '14 at 3:23
• Note that you should also actually use a @{}l@{} column specification, as the l alone adds a \tabcolsep space on either end. – Werner Oct 1 '14 at 23:34

Maybe something like this:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{etoolbox,hyperref}

\newcounter{email}
\newcommand{\emailfrom}[1]{%
\begingroup
\parindent 0pt%
\parbox{2cm}{Email:}%
\setcounter{email}{0}%
\renewcommand*{\do}[1]{%
\stepcounter{email}%
\ifnum\value{email}<2\relax%
\emailformat{##1}\par
\else
\hspace{2cm}\emailformat{##1}\par
\fi}%
\docsvlist{#1}
\endgroup}
\newcommand{\emailformat}[1]{\href{mailto:#1}{#1}}

\begin{document}

first.email@email.com, second.email@email.com, third.email@email.com}

\end{document}


It sets a counter called 'email' so that you can make the first item in the list behave differently than those that follow. The command \emailformat is used so you can style the email addresses more easily. The parameters for \parindent and \parindent should be changed to taste. (They could -- if you like -- be incorporated into the definition to \emailfrom so you can change them at the time you issue the command.)

• Thank you for your input. I accepted Harish Kumar answer since it is the simplest and the one I understand even though yours works too (and includes \href{mailto:} which I knew nothing about). Yours is too advanced for me. – OneEyeQuestion Sep 30 '14 at 3:13
• @OneEyeQuestion -- No problem. As long as your question is answered. (Plus, sometimes the best answers aren't necessarily the funnest ones to write....) – jon Sep 30 '14 at 3:23

Here is another "funny" answer which canot be accepted because TeX primitives (used here) are not explained in LaTeX guides, unfortunately.

% in preamble:
\def\emails#1{\vtop\bgroup\emailsA #1,,}
\def\emailsA#1,{\ifx,#1,\egroup\else\hbox{\ignorespaces#1}\expandafter\emailsA\fi}

% in document:
Emails: \emails{first.email@email.com, second.email@email.com, third.email@email.com}

• You should have \leavevmode before \vtop. Why should this be simpler than \newcommand{\emails}[1]{\begin{tabular}[t]{@{}l@{}}#1\end{tabular}} called as \emails{a@b.c \\ d@e.f \\ g@h.i} that needs no fancy trick with spaces? – egreg Oct 1 '14 at 23:42
• @egreg We needn't \leavevmode because \emails is used at the end of the paragraph. If it is used in vertical mode, no problem. Your suggestion with tabular is simpler from one point of view. It expands to \vtop{\halign{...}} (note, without \leavevmode). My answer shows, what should be done at primitive level: \vtop{\hbox{}\hbox{}\hbox{}}. I prefer hboxes if there is only one left aligned column but this isn't probably based on any good arguments. – wipet Oct 2 '14 at 8:09
• Of course \begin{tabular} does \tabular which ends with \@tabular. And this macro starts with, guess what, \leavevmode. I could understand not using it if “Emails:” had been incorporated in it; as the macro is defined, \leavevmode` is definitely needed. – egreg Oct 2 '14 at 9:46