A while ago I had a question about having multi-line strings in a table cell ( in-cell newlines (in tabular environments)?).

I remember seeing it working but I've just tried to use it again and ... \newline did nothing.

A test LaTeX source is below, which, despite the \newline commands, it did not split the cells on multiple lines:

alt text


    \begin{tabular}{@{}l l l l@{}}
           & \textbf{Foo} & {\textbf{Bar}} & \textbf{Baz} \\
            \textbf{Single line} & foo1 foo2 & bar1 bar2 & baz1 baz2 \\
            \textbf{Multiline} & foo1 \newline foo2 & bar1 \newline bar2 & baz1 \newline baz2 \\
    \caption {\small{bla bla}}\label{my-label}
  • Far from minimal example, and nothing to do with booktabs. – Lev Bishop Oct 18 '10 at 3:52
  • I put the packages that I thought might influence it (and thought booktabs was used since it's imported). Sorry about \vspace, I missed it when editing the real table. – wishihadabettername Oct 18 '10 at 4:08
  • 1
    You should have tried which of the packages influence it before posting the question... – Jukka Suomela Oct 18 '10 at 12:21

Use tabular p specifier instead of l.

\begin{tabular}{@{}l p{2cm}p{3cm}p{3cm}@{}}
    & \textbf{Foo} & {\textbf{Bar}} & \textbf{Baz} \\
    \textbf{Single line} & foo1 foo2 & bar1 bar2 & baz1 baz2 \\
    \textbf{Multiline} & foo1 \newline foo2 & bar1 \newline bar2 & baz1 \newline baz2 \\
  • it doesn't work. I had tried it before posting, I got "Missing number, treated as zero" on the line declaring the table header.My tabular declaration was \begin{tabular}{@{}p p p p@{}} – wishihadabettername Oct 18 '10 at 4:09
  • The format is p{length}. Minimal example attached. – Lev Bishop Oct 18 '10 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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