0
\begin{table}
\label{my-label}
\begin{tabular}{ll}
Name       & Local address \\
Affliation & Phone number  \\
Address    & Email        
\end{tabular}
\end{table}

I have a simple table here that I want to use for the header of my CV. However, the output looks like this:

enter image description here

How exactly can I left-align the first first column and right-align the second, similar to what you would typically see as the header of a CV?

enter image description here

3
  • I am not sure I got your guestion but the comand \begin{tabular}{lr} right-aligns second column
    – koleygr
    Sep 10, 2017 at 2:38
  • I added an image that shows what I'm going for (i.e. the Hair and Eyes are aligned with the left margin and the Height and Weight with the right)
    – Adrian
    Sep 10, 2017 at 2:50
  • I have added an answer... but I think if you use tabularx there are easier solutions... I also think if you like my semi-automate answer I can automate it more.
    – koleygr
    Sep 10, 2017 at 3:04

1 Answer 1

1

You could use an empty p{} column in the middle like this:

    \documentclass{article}

    \begin{document}
       \begin{table}
    \label{my-label}
    \begin{tabular}{lp{7cm}l}
    Name       & &Local address \\
    Affliation & &Phone number  \\
    Address    & &Email        
    \end{tabular}
    \end{table}
    \end{document}

or like this:

\documentclass{article}

\begin{document}
   \begin{table}
\label{my-label}
\begin{tabular}{lp{7cm}r}
Name       & &Local address \\
Affliation & &Phone number  \\
Address    & &Email        
\end{tabular}
\end{table}
\end{document}

If you want a semi-automatic calculation of the fill between you can use this:

\documentclass{article}

\begin{document}
   \begin{table}
\label{my-label}
\newsavebox{\sboxl}
\savebox{\sboxl}{Local address}
\newsavebox{\sboxr}
\savebox{\sboxr}{Affiliation}
\xdef\myfill{\dimexpr\linewidth-\wd\sboxl-\wd\sboxr-4\columnsep\relax}

\begin{tabular}{lp{\myfill}r}
Name       & &Local address \\
Affliation & &Phone number  \\
Address    & &Email        
\end{tabular}
\end{table}
\end{document}

I have used the lines with the maximum length and 4 \columnseps to calculate the length for more columns or different values you have to edit.

With tabularx package:

\documentclass{article}
\usepackage{tabularx}

\begin{document}
   \begin{table}
\label{my-label}
\begin{tabularx}{\linewidth}{lXr}
Name       & &Local address \\
Affliation & &Phone number  \\
Address    & &Email        
\end{tabularx}
\end{table}
\end{document}

Not the answer you're looking for? Browse other questions tagged .