Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm working off of a resume template I found. This is what it looks like

header

I want to center the bottom line of text differently. Right now, it is centered based on the whole line of text, but I would like the email address to line up centered under the name and address.

Here's an example that generates the document.

\documentclass[11pt,letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\pagestyle{empty}
\raggedright


\newcommand{\lineunder}{\vspace*{-8pt} \\ \hspace*{-18pt} \hrulefill \\}
\newcommand{\contact}[3]{
\vspace*{-8pt}
\begin{center}
{\LARGE \scshape {#1}}\\
    #2 \lineunder 
    #3
\end{center}
\vspace*{-8pt}
}

\begin{document}

\contact{First M. Last}
{ Address, City, State Zip}
{(123) 456-7890 \qquad {email@mail.edu}
\qquad http://www.webaddress.html
}
\end{document}
share|improve this question
    
Is it one purpose that the \lineunder rule hangs into the left margin but not into the right one? –  Qrrbrbirlbel Oct 3 '12 at 0:51
    
@Qrrbrbirlbel probably not. I'm working starting from someone else's template. I didn't even notice. Actually, looking now I don't see a difference in the resulting pdf between the left and right margin. –  Joe Oct 3 '12 at 1:09
    
Put \usepackage[showframe,pass]{geometry} in your preamble and you can see it for yourself. \hspace*{-18pt} puts the line 18pt into the left margin. Repeat it after \hrulefill to get the same effect on the right side. –  Qrrbrbirlbel Oct 3 '12 at 1:17
    
@Qrrbrbirlbel I see it now. In the full template, it is actually intended because \lineunder is also used as part of section headers that hang into the margin. I just didn't realize it because I thought it was working the other way, i.e. the rest of the text was indented. –  Joe Oct 3 '12 at 1:33
add comment

3 Answers

up vote 5 down vote accepted

You can use boxes. A variant using \parboxes in which each one having a width equal to one third of \textwidth:

\documentclass[11pt,letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\pagestyle{empty}
\raggedright


\newcommand{\lineunder}{\vspace*{-8pt}\par\hspace*{-18pt}\hrulefill\par}
\newcommand{\contact}[3]{%
\vspace*{-8pt}
\begin{center}
{\LARGE\scshape #1}\\
    #2 \lineunder 
    #3
\end{center}
\vspace*{-8pt}
}

\begin{document}

\contact{First M. Last}{Address, City, State Zip}
{\parbox[t]{.3333\textwidth}{(123) 456-7890\hfill}%
\parbox[t]{.3333\textwidth}{\hfil\texttt{email@mail.edu}\hfil}%
\parbox[t]{.3333\textwidth}{\hfill\url{http://www.webaddress.html}}%
}
\end{document}

It is not clear to me if the hanging indent of the rule is meant to be the way it is now.

enter image description here

Now a variant using a \makebox and \llap, \rlap centering the email and keeping the \qquad separation:

\documentclass[11pt,letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}

\pagestyle{empty}
\raggedright


\newcommand{\lineunder}{\vspace*{-8pt}\par\hspace*{-18pt}\hrulefill\par}
\newcommand{\contact}[5]{%
\vspace*{-8pt}
\begin{center}
{\LARGE\scshape #1}\\
    #2 \lineunder 
\makebox[\textwidth][c]{%
\llap{#3\qquad}\texttt{#4}\rlap{\qquad\url{#5}}}
\end{center}
\vspace*{-8pt}
}

\begin{document}

\contact{First M. Last}{Address, City, State Zip}{(123) 456-7890}{email@mail.edu}{http://www.webaddress.html}
\end{document}

enter image description here

share|improve this answer
    
This works great on the example text I gave. Unfortunately, my actual web address is a little longer, and doesn't quite fit in .333\textwidth –  Joe Oct 3 '12 at 0:54
    
I swapped the web address into the center parbox, and adjusted the widths of the center and right to .444 and .222 respectively, and that seems to work. –  Joe Oct 3 '12 at 0:57
    
@Joe of course, you can adjust the widths according to your needs; too hard to guess from you example that the widths needed to be different. –  Gonzalo Medina Oct 3 '12 at 1:00
    
what do you mean by hanging indent? –  Joe Oct 3 '12 at 1:10
    
I didn't realize at first that the adjustment of the widths was going to be trivial, which is why there are two comments. –  Joe Oct 3 '12 at 1:11
show 2 more comments

A variant that centers the email address under the postal address and keeps \qquad as separation to the phone number and the home page.

\documentclass[11pt,letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\pagestyle{empty}
\raggedright

\newcommand{\lineunder}{\vspace*{-8pt} \\ \hspace*{-18pt} \hrulefill \\}
\newcommand{\contact}[5]{
\vspace*{-8pt}
\begin{center}
{\LARGE \scshape {#1}}\\
    #2 \lineunder
  \sbox0{#4}%
  \centerline{%
    \hbox to .5\dimexpr\hsize-\wd0{\hfill#3\qquad}%
    \usebox0 %
    \hbox to .5\dimexpr\hsize-\wd0{\qquad#5\hfill}%
  }%
\end{center}
\vspace*{-8pt}
}

\begin{document}

\contact{First M. Last}
  {Address, City, State Zip}
  {(123) 456-7890}
  {email@mail.edu}
  {http://www.webaddress.html}
\end{document}

Result

Rewritten as "pure LaTeX":

\documentclass[11pt,letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\pagestyle{empty}
\raggedright

\newlength{\emailwidth}
\newlength{\partialwidth}

\newcommand{\lineunder}{\vspace*{-8pt} \\ \hspace*{-18pt} \hrulefill \\}
\newcommand{\contact}[5]{
\vspace*{-8pt}
\begin{center}
{\LARGE \scshape {#1}}\\
    #2 \lineunder
  \settowidth{\emailwidth}{#4}%
  \setlength{\partialwidth}{\linewidth}%
  \addtolength{\partialwidth}{-\emailwidth}%
  \setlength{\partialwidth}{.5\partialwidth}%
  \parbox{\linewidth}{%
    \mbox{%
      \parbox{\partialwidth}{\hspace{\fill}\mbox{#3\qquad}}%
      #4%
      \parbox{\partialwidth}{\mbox{\qquad#5}}%
    }%
  }%
\end{center}
\vspace*{-8pt}
}

\begin{document}

\contact{First M. Last}
  {Address, City, State Zip}
  {(123) 456-7890}
  {email@mail.edu}
  {http://www.webaddress.html}
\end{document}

The next variant is probably much easier to understand:

\documentclass[11pt,letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\pagestyle{empty}
\raggedright

\newcommand{\lineunder}{\vspace*{-8pt} \\ \hspace*{-18pt} \hrulefill \\}
\newcommand{\contact}[5]{
\vspace*{-8pt}
\begin{center}
{\LARGE \scshape {#1}}\\
    #2 \lineunder
   \makebox[0pt][r]{#3\qquad}#4\makebox[0pt][l]{\qquad#5}%
\end{center}
\vspace*{-8pt}
}

\begin{document}

\contact{First M. Last}
  {Address, City, State Zip}
  {(123) 456-7890}
  {email@mail.edu}
  {http://www.webaddress.html}
\end{document}

However, the disadvantage of this solution is, that TeX does not warn, if the phone number or the home page is too long to properly fit in the line. Therefore the first solutions are a little more complicate, because they additionally define the space that is allowed for the phone number and the home page.

share|improve this answer
    
I don't fully follow why the modified code works. In particular \sbox and pretty much everything in \centerline{...} –  Joe Oct 3 '12 at 1:03
add comment

Here is an alternative, where the command \contact takes 5 arguments

\documentclass[11pt,letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\usepackage{calc}
\pagestyle{empty}
\raggedright


\newcommand{\lineunder}{\vspace*{-8pt}\par\hspace*{-18pt}\hrulefill\par}
\newcommand{\contact}[5]{%
\vspace*{-8pt}
\begin{center}
{\LARGE\scshape #1}\\
    #2 \lineunder 
    \newlength{\emailaddress}  
    \settowidth{\emailaddress}{\texttt{#4}}%
    \makebox[.5\textwidth-.5\emailaddress][r]{#3\qquad}%
    \makebox[\emailaddress][c]{\texttt{#4}}%
    \makebox[.5\textwidth-.5\emailaddress][l]{\qquad \url{#5}}%    
\end{center}
\vspace*{-8pt}
}

\begin{document}

\contact{First M. Last}
  {Address, City, State Zip}
  {(123) 456-7890}
  {email@mail.edu}%
  {http://www.webaddress.html}%

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.