Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm working on a table containing multi-line cells and I wonder if the following concept is supported by LaTeX.

The concept itself is simple: allow a cell to span multiple lines by increasing the line height (similar to how it works in Office suites when you press Ctrl-Enter or Alt-Enter to wrap the current cell). Using \\ doesn't work as it causes LaTeX to go to the next table row.

Thus what would be required is an equivalent of \\ which is scoped to a table cell. Is this implemented already (I suppose not in LaTeX, but perhaps there are packages)?

I realize that the same can be achieved with \multirow, but I don't find that approach very user-friendly.

share|improve this question
add comment

1 Answer

up vote 15 down vote accepted

Sure, just use \newline instead of \\:

\documentclass{article}
\begin{document}
\begin{tabular}{|p{5cm}|p{5cm}|}
\hline
foo & foo \\
\hline
line\newline break & another \newline break \\
\hline
\end{tabular}
\end{document}
share|improve this answer
    
Only works if you use p and specify the size of the (of all?!) column(s) –  Nils Mar 9 '11 at 11:18
1  
Or \linebreak which has the advantage to give the correct alignment when \centering or \raggedleft is used in the column. –  Ulrike Fischer Apr 16 '11 at 14:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.