I have some text in a table and I want to add a forced line break. I want to insert a forced line break without having to specify the column width, i.e. something like the following:
\begin{tabular}{|c|c|c|}
\hline
Foo bar & Foo <forced line break here> bar & Foo bar \\
\hline
\end{tabular}
I know that \\
inserts a line break in most cases, but here it starts a new table row instead.
A similar question was asked before: How to break a line in a table
Best Answer
Strangely, no answer (unless I've misread them) mentions a package that is dedicated to this precise question:
makecell
, which allows for common formatting of certain cells, thanks to its\thead
and\makecell
commands, and for line breaks inside these cells. The horizontal and vertical alignments can chosen independently from those of the table they're included in. The default iscc
, but you can change it globally in the preamble withwhere v is one of
t,c,b
and h one ofl,c,r
. Alternatively, for a single cell, you can use the\makecell
or\thead
commands with the optional argument[vh]
.So here is a demo: