# Insert new line in table

I am trying to put part of a header of a table on a new line.

This is my code:

\documentclass[a4paper,11pt]{article}
\begin{document}
\title{}
\author{My name}
\date{\today}
\maketitle

\section{}

\begin{table}[!htbp] \centering
\caption{This is a table}
\label{}
\begin{tabular}{@{\extracolsep{5pt}} lll}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
\hline \\[-1.8ex]
value & $1.330$ & $1.080$ \\
value & $0.440$ & $0.360$ \\
value & $0.730$ & $$-0.380 \\ \normalsize \end{tabular} \end{table} \end{document}  This is output: The output table I want should look like: Note how in my desired output, only the word "header" of "Quite a long header" is on a new line. How can I achieve this table? - If you pay attention to Mico's answer, his way is more robust. You may want to consider reading it. – azetina Jan 10 '14 at 21:52 ## 4 Answers We adjust the column type to p{<length>} so that we can introduce paragraphs and call the array package to use the option >{\raggedright}. Here is the change in the code: \begin{tabular}{@{\extracolsep{5pt}} l>{\raggedright}p{8em}l}  Here is a MWE: \documentclass[a4paper,11pt]{article} \usepackage{array} \begin{document} \title{} \author{My name} \date{\today} \maketitle \section{} \begin{table}[!htbp] \centering \caption{This is a table} \label{} \begin{tabular}{@{\extracolsep{5pt}} l>{\raggedright}p{8em}l} \\[-1.8ex]\hline \hline \\[-1.8ex] \textbf{Rownames} & \textbf{Quite a long header} & \textbf{Short header} \\ \hline \\[-1.8ex] value & 1.330 & 1.080 \\ value & 0.440 & 0.360 \\ value & 0.730 & -0.380 \\ \normalsize \end{tabular} \end{table} \end{document}  - If you replace $$-$0.380$ with $-0.380$, LaTeX will use the typographically correct "minus" symbol instead of the "hyphen-dash" symbol. –  Mico Jan 10 '14 at 21:41
@Mico Sorry I was just addressing the issue of the table headers. –  azetina Jan 10 '14 at 21:47

You may want to do the following:

• Use a tabularx environment instead of a tabular environment, and use the X column type for the headers of columns 2 and 3. In the example below I've chosen the X column type for the first row as well, but depending on the "real" contents of that column you may prefer to set its type to l. I came up with a total width of 9cm for the tabularx environment; depending on the size and other characteristics of the font you use, you may need to change that width a bit.

\bottomrule
\normalsize
\end{tabular}
\end{table}

\end{document}


-