Center line based on only part of text
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 protected]}\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.
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 protected]}{http://www.webaddress.html}
\end{document}
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 protected]}
{http://www.webaddress.html}
\end{document}
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 protected]}
{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 protected]}
{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.
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 protected]}%
{http://www.webaddress.html}%
\end{document}