Align columns of text
I would recommend using a tabular
environment as below. The @{}
removes the inter column spacing.
\documentclass[border=5pt]{standalone}
\begin{document}
\noindent
\begin{tabular}{l@{}cll@{}cl}
Mobile &:&+12 111 111 111 &Email &:&[email protected]\\
Phone &:&+12 111 111 &Website &:&http://www.something.com\\
Nationality&:&Somenationality &Birthdate&:&xx/xx/xxxx
\end{tabular}
\end{document}
As @cmhughes mentions, there is also a tabularx
environment that will help with column stretching, but that might be overkill for this particular problem.
Alternatively, you could use something similar to what you were doing but use \makebox
instead. Here I define a \LeftBox
for the text on the left, and a separate \RightBox
for text on the right, each of which takes two parameters. You could of course define just one command that takes four parameters, but this should get you started:
\documentclass[border=5pt]{standalone}
\begin{document}
\newcommand{\ColonSep}{\makebox[0.2cm][l]{:}}%
\newcommand{\LeftBox}[2]{\par\noindent\makebox[1.3cm][l]{#1}\ColonSep\makebox[3.5cm][l]{#2}}%
\newcommand{\RightBox}[2]{\hspace{0.5cm}\makebox[1.5cm][l]{#1}\ColonSep\makebox[3.5cm][l]{#2}}%
\begin{center}
{\LARGE \textbf{My Name}}\\
\textnormal{xx, rue du XX \ \ X-XXXX XXXXXX} \\[3mm]
\LeftBox{Mobile}{+122 111 111 111} \RightBox{Email}{[email protected]}\\
\LeftBox{Phone}{+122 111 111} \RightBox{Website}{http://www.something.com}\\
\LeftBox{Nat.}{Somenationality} \RightBox{Birthdate}{xx.xx.xxxx}\\
\end{center}
\end{document}
You can also use a tabbing
environment:
\documentclass{article}
\begin{document}
\begin{tabbing}
\=Nationality\=:\quad\=+12 111 111 111\hspace{4em}\=Birthdate\=:\quad\[email protected] \kill % set the tabbings
\>Mobile \>: \>+12 111 111 111 \> Email \>: \> [email protected] \\
\>Phone \>: \>+12 111 111 \>Website \>: \>http://www.something.com \\
\>Nationality \>: \>Somenationality \>Birthdate \>: \>xx/xx/xxxx
\end{tabbing}
\end{document}
A brief description of the basic commands commands used:
\=
sets a tab stop at the current position.\>
advances to the next tab stop.\kill
sets tab stops without producing text. Works just like\\
except that it throws away the current line instead of producing output for it. The effect of any\=
commands in that line remain in effect.