Graphics, Figures & TablesNew Line Formatting in Table Headers

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sw3quant
Posts: 76
Joined: Tue Nov 02, 2010 11:40 pm

New Line Formatting in Table Headers

Post by sw3quant »

For a table (such as my MWE below), the header names are all shown on the same line.

Code: Select all

\begin{longtable}{ccc}
\toprule
header name 1 & header name 2 & header name 3\\
\toprule
\endhead
\bottomrule
\endfoot
\\
\\
val1
val2
val3
\\
\end{longtable}
when I try and use "\\" to induce a new line between each it doesnt work.

Code: Select all

\begin{longtable}{ccc}
\toprule
header \\name \\1 & header\\ name\\ 2 & header \\name\\ 3\\
\toprule
\endhead
\bottomrule
\endfoot
\\
\\
val1
val2
val3
\\
\end{longtable}
what I would like is header name N, all under one another. The problem is my real work has long headers and they all dont fit on the page.

many thanks
Last edited by Stefan Kottwitz on Tue Jun 14, 2011 7:54 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

New Line Formatting in Table Headers

Post by Stefan Kottwitz »

Hi,

for line breaking in cells use paragraph cells, such as with p{3cm} instead of c columns.

You could also use \multicolumn for single cells in c columns, such as

Code: Select all

\multicolumn{1}{p{3cm}}{header\\text}
Stefan
LaTeX.org admin
Post Reply