5

I cannot get the name to vertically align with the text on the left or the right. Using a table seems better but its still off.

Just to clarify below are my two attempts to vertically align the name with the contact info on both sides.

The first way is using a new command i created

The second uses a table

Sample

\documentclass[letterpaper]{article}
\usepackage[margin=0.75in]{geometry}
\usepackage[colorlinks=true,urlcolor=cyan]{hyperref}
\usepackage{tabularx}

\def\name{John Doe}
\def\email{john.doe@gmail.com}
\def\phone{(123) 456-7890}

\def\address{123 Main St}
\def\city{Toronto}
\def\province{ON}
\def\country{Canada}
\def\postalCode{M5Y\thinspace4Z7}


\newcommand{\rTitle}{
    \noindent
    \centerline{\Huge \textsc \name} \\
    \href{mailto:\email}{\nolinkurl{\email}} \hfill \address \\
    \texttt{\phone} \hfill \city, \province \space \postalCode \\
}

\begin{document}
    \rTitle

\noindent
  \begin{tabularx}{\linewidth}{l >{\centering}X r}
    \href{mailto:\email}{\nolinkurl{\email}} & \Huge \textsc \name & \address \\
    \texttt{\phone} && \city, \province \space \postalCode \\
  \end{tabularx}


\end{document}
  • Welcome to TeX SE! Could you explain what you want it to look like? What exactly should align with what? – cfr Aug 6 '14 at 0:55
  • updated Hope its more clear now – john Aug 6 '14 at 1:32
  • If you are asking why the two examples aren't aligned then try to set \tabcolsep=0pt before the tabularx environment. BTW. The \\ after \centerline and after \postalCode are badly placed and cause the warning about underfull hbox. Remove them. – wipet Aug 6 '14 at 4:30
4

You could use three (vertically centered) side-by-side minipages:

enter image description here

The code:

\documentclass[letterpaper]{article}
\usepackage[margin=0.75in]{geometry}
\usepackage[colorlinks=true,urlcolor=cyan]{hyperref}
\usepackage{tabularx}

\def\name{John Doe}
\def\email{john.doe@gmail.com}
\def\phone{(123) 456-7890}

\def\address{123 Main St}
\def\city{Toronto}
\def\province{ON}
\def\country{Canada}
\def\postalCode{M5Y\thinspace4Z7}


\newcommand{\rTitle}{%
    \par\noindent
    \begin{minipage}{.333\textwidth}
    \href{mailto:\email}{\nolinkurl{\email}}\par
    \texttt{\phone}
    \end{minipage}%
    \begin{minipage}{.333\textwidth}
    \centering\Huge\textsc{\name}
    \end{minipage}%
    \begin{minipage}{.333\textwidth}
     \raggedleft
     \address\par
     \city, \province \space \postalCode
    \end{minipage}\par%
}

\begin{document}

    \rTitle

\end{document}

Beware of spurious blan spaces in your code.

1

This simple aligment can be done by simple tools without tabularx:

\centerline{\href{mailto:\email}{\nolinkurl{\email}} \hfill \address}
\centerline{\rlap{\texttt{\phone}}\hfill 
            \smash{\Huge \textsc \name}\hfill
            \llap{\province \space \postalCode}}
  • \textsc takes an argument, so this should be \textsc{\name}. – barbara beeton Aug 6 '14 at 13:10
  • @barbarabeeton I've copied this part of the code for the original question and it works, because the parameter is only one token \name and the macro \textsc has one undelimited parameter. If the real parameter is one token then it could be in braces or not. On the other hand, you are right that the usage \textsc{\name} is more clear and educational. – wipet Aug 6 '14 at 16:51

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.