4

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

Name:XX                                                          Email: abc@example.com
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.

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

  • Could you please explain this : @{}ll@{} – Aman Deep Gautam Nov 9 '14 at 22:01
  • @AmanDeepGautam ll is two left aligned columns @{} removes the cell padding (\tabcolsep) that would normally be around the table – David Carlisle Nov 9 '14 at 22:03
  • @AmanDeepGautam You may want ll in the right hand table as well rather than rr depending on the style you want. – David Carlisle Nov 9 '14 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: & abc@example.com\\
    Work: & YYY  && Phone: & +1 666222\\
\end{tabularx}%
\end{document}

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.