7

So basically what I am trying to achieve is something like the following...

Mobile      :  +12 111 111 111      Email     :  [email protected]
Phone       :  +12 111 111          Website   :  http://www.something.com
Nationality :  Somenationality      Birthdate :  xx/xx/xxxx

keeping the blocks of text together for every line. I don't really know how to tackle that problem. The trick is to keep the : together in a row, keep the same spacing between Mobile Information and the Email title for example and keep that space for the three lines. What would be the right solution to get this nicely together...

so far I solved it like this but it doesn't really work that great

  \begin{center}
    {\LARGE \textbf{My Name}}\\
    \textnormal{xx, rue du XX \ \ X-XXXX XXXXXX} \\[3mm]
    \par\noindent\parbox{1.3cm}{Mobile}\parbox{0.2cm}{:} \parbox{3.5cm}{+122 111 111 111} \hspace{0.01cm} \parbox{1.3cm}{Email}   \parbox{0.2cm}{:} \parbox{3.5cm}{[email protected]}\\
    \par\noindent\parbox{1.3cm}{Phone} \parbox{0.2cm}{:} \parbox{3.5cm}{+122 111 111}     \hspace{0.01cm} \parbox{1.3cm}{Website} \parbox{0.2cm}{:} \parbox{3.5cm}{http://www.something.com}\\
    \par\noindent\parbox{1.3cm}{Nat.}  \parbox{0.2cm}{:} \parbox{3.5cm}{Somenationality}    \hspace{0.01cm} \parbox{1.3cm}{Birthdate}\parbox{0.2cm}{:} \parbox{3.5cm}{xx.xx.xxxx}\\
  \end{center}
3
  • 3
    Have you considered just using a table? Commented Nov 12, 2011 at 18:05
  • Yes kinda, I tried multicols but couldn't really get it to work like i wanted to do you have any examples maybe? Thanks
    – latz
    Commented Nov 12, 2011 at 18:07
  • 1
    For formatting purposes, perhaps you might be interested in using the url package for typesetting websites or emails.
    – Werner
    Commented Nov 12, 2011 at 19:33

2 Answers 2

11

I would recommend using a tabular environment as below. The @{} removes the inter column spacing.

enter image description here

\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}
1
  • 3
    Or you could use @{:} instead of a whole column for the :. It might also be worth mentioning the tabularx environment. I would post the answer, but it would be too similar. It's probably worth putting in a detailed explanation as this is a beginner's problem
    – cmhughes
    Commented Nov 12, 2011 at 18:14
9

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}

enter image description here

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.
0

You must log in to answer this question.

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