4

I am new to latex and I want the following format but simple things like \hfill does not help here.

Name:XX                                                          Email: [email protected]
Work:YY                                                          Phone: +1 666222

In particular I want starting of phone and email to be aligned, as well as Name and Work to be aligned.

Any help appriciated.

2 Answers 2

5
\begin{tabular}[t]{@{}ll@{}}
Name& zz\\
Work& zzz
\end{tabular}%
\hfill
\begin{tabular}[t]{@{}rr@{}}
email& z\\
phone& zzz
\end{tabular}

You need to align each side in a box (eg tabular) then push them apart with \hfill

3
  • Could you please explain this : @{}ll@{} Commented Nov 9, 2014 at 22:01
  • @AmanDeepGautam ll is two left aligned columns @{} removes the cell padding (\tabcolsep) that would normally be around the table Commented Nov 9, 2014 at 22:03
  • @AmanDeepGautam You may want ll in the right hand table as well rather than rr depending on the style you want. Commented Nov 9, 2014 at 22:04
1

For this specific case, David Carlisle's answer works great. But, in general if you want table to span the entire \linewidth, I find using the X column from tabularx to be very useful:

enter image description here

Notes:

  • The showframe package was used just to show the page margins. It is not needed in your actual use case. was just to show the page margins.

  • Here I have used the X column to be the blank column between the two groups of text. Hence the double && separating the two groups.

  • The @{} at the left and right of the table remove the inter column padding that would normally be applied.

Code:

\documentclass{article}
\usepackage{tabularx}
\usepackage{showframe}

\begin{document}
\noindent
\begin{tabularx}{\linewidth}{@{}l l X l l@{}}
    Name: & XX   && Email: & [email protected]\\
    Work: & YYY  && Phone: & +1 666222\\
\end{tabularx}%
\end{document}

You must log in to answer this question.

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