12

I'm writing a short tabular CV that I have to add to my thesis. I thought a quick way would be to use a table for that purpose:

\begin{tabular}{ll}
2009-present           & very long text 1, very long text 2, very long text 3 , very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10\\
2009  & Masters\\
2006  & Bachelors\\
\end{tabular}

Unfortunately, LaTeX does not break the lines at the spaces. The only solutions I found so far, are

  • "adding additional rows to the table"
  • "use fixed table size + \newline".

Manually adjusting texts is not very efficient.

Is there also a way to automate this (e.g. by define a cell/column as "text-cell/column")?

\begin{tabular}{lp{12cm}}
2009-present           & very long text 1, very long text 2, very long text 3 , very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10\\
2009  & Masters\\
2006  & Bachelors\\
\end{tabular}

Could be a solution, but the right column does not automatically reach the right "border" of the page.

Moriambar
  • 11,466
John Garreth
  • 223
  • 1
  • 2
  • 6

3 Answers3

16

Anyway you shoud specify desired width of column. Noone other can guess which one would be acceptable:)

You may specify width of column using p{} instead of column justification. It has the only argument, the width of the column.

\documentclass{article}

\begin{document}
\begin{tabular}{lp{5cm}}
    2009--present           & very long text 1, very long text 2, very long text 3, very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10\\
    2009  & Masters\\
    2006  & Bachelors\\
\end{tabular}
\end{document}

Or you may use \parbox{}{} in a cell with long text.

\documentclass{article}

\begin{document}
\begin{tabular}{ll}
    2009--present           & \parbox{5cm}{very long text 1, very long text 2, very long text 3, very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10}\\
    2009  & Masters\\
    2006  & Bachelors\\
\end{tabular}
\end{document}
ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
Smylic
  • 834
8

As requested, an answer with tabularx. I also added a solution with listliketab. I still prefer a description list because of the vertical alignment.

Code

\documentclass{article}
\usepackage{tabularx}
\usepackage{listliketab}
\usepackage{lipsum} % only for this example
\begin{document}
\lipsum[2]
\medskip

\noindent
\begin{tabularx}{\linewidth}{@{}>{\bfseries}l@{\hspace{.5em}}X@{}}
    2009--present & very long text 1, very long text 2, very long text 3, very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10 \\
    2009          & Masters                                                                                                                                                                              \\
    2006          & Bachelors
\end{tabularx}

\medskip
\lipsum[2]
\begin{description}
    \item[2009--present] very long text 1, very long text 2, very long text 3, very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10
    \item[2009]          Masters
    \item[2006]          Bachelors
\end{description}

\lipsum[2]
\storestyleof{description}
\begin{listliketab}
  \begin{tabularx}{\linewidth}{@{}>{\bfseries}l @{\hspace{.5em}} XR}
    2009--present & very long text 1, very long text 2, very long text 3, very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10 \\
    2009          & Masters                                                                                                                                                                              \\
    2006          & Bachelors
  \end{tabularx}
\end{listliketab}

\lipsum[2]
\end{document}

Output

enter image description here

Moriambar
  • 11,466
Qrrbrbirlbel
  • 119,821
6

You could use a table, but it's normally better to use a list such as

\begin{description}
\item[2009--present]            very long text 1, very long text 2, very long text 3 , very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10
\item[2009]Masters
\item[2006] Bachelors
\end{description}
David Carlisle
  • 757,742
  • I'd love to use a description-list. Unfortunately I always have problem with lists, since there is not breaking at dashes (e.g. self-destruction). This can easily cause errors like Overfull \hbox ... – John Garreth Oct 12 '13 at 00:22
  • @John, that warning in latex usually is negligible, and it wouldn't affect the reading style actually. – Tawei Oct 12 '13 at 01:30
  • @David: I think warnings should not be ignored. Especially the \hbox warning often means, that the text is wider than allowed. Similar to John, I once also had the problem that a word (although having dashes) was not correctly split. Result: the text was too wide and hardly visible after binding. – Sven Oct 14 '13 at 17:36
  • @JohnGarreth latex does break at explicit hyphens, and the linebreaking behaviour is the same in a list or in a tabularx so that is no reason not to use a list. – David Carlisle Oct 14 '13 at 18:57
  • @Sven I agree, it wasn't my comment you are replying to, even though you @ pinged me:-) – David Carlisle Oct 14 '13 at 18:58