5

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

This is what I am currently obtaining:

Problem of alignment

My only inelegant solution so far is:

\emailfrom{ % Email address [email protected] \\ [email protected] \\ [email protected] } 

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.

2
  • Are you using the newlfm class? Commented Sep 30, 2014 at 2:55
  • yes, I am using it. Commented Oct 1, 2014 at 23:29

3 Answers 3

0

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

\emailfrom{% Email address \begin{tabular}[t]{l} [email protected] \\ [email protected] \\ [email protected] \end{tabular} } 

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

\href{mailto:your name}{first.email} 
3
  • How can I include mailto to the links? I've tried but gives me an error. Thank you. Commented Sep 30, 2014 at 3:20
  • @OneEyeQuestion -- The package hyperref is required for the \href macro. Commented Sep 30, 2014 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. Commented Oct 1, 2014 at 23:34
1

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{[email protected], [email protected], [email protected]} 
3
  • 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{[email protected] \\ [email protected] \\ [email protected]} that needs no fancy trick with spaces? Commented Oct 1, 2014 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. Commented Oct 2, 2014 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. Commented Oct 2, 2014 at 9:46
0

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} \emailfrom{% Email address [email protected], [email protected], [email protected]} \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.)

2
  • 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. Commented Sep 30, 2014 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....) Commented Sep 30, 2014 at 3:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.