# Automatic line-breaks in tables?

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

• "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.

• l cells don't break use p{3in} (or better use a list) – David Carlisle Oct 11 '13 at 23:53
• Although this calls for a description list, you can use the tabularx package and use \begin{tabularx}{\linewidth}{lX}. – Qrrbrbirlbel Oct 12 '13 at 0:03
• @Qrrbrbirlbel: Can you write your comment as an answer, so that I can accept it. \tabularx is what I'm using now. – John Garreth Oct 12 '13 at 0:49

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

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}


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}

• 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 0:22
• @John, that warning in latex usually is negligible, and it wouldn't affect the reading style actually. – selwyndd21 Oct 12 '13 at 1: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