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.

how to split the column headings? How do I get newline after some word? When I put \\, it changes the alignment badly.

This is my code:

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\usepackage{booktabs,tabularx}


\begin{document}

\begin{table}[t]
%\setlength{\tabcolsep}{6.2 pt}
\caption{Case studies}
\centering
 \begin{tabularx}{\textwidth}{p{3cm}ccccc}
    \toprule
\centering Nature of unreliability &  Sender SST & Receiver SST & Implementation SST & Retransmission Bound & Decidability\\


\midrule

Noisy (Single fixed error message) & DSST & DSST & DSST & Unbounded & Yes\\
\bottomrule
\end{tabularx}
\label{case-studies}
\end{table}


\end{document} 

This what I got:

I just want to split the column title in two rows. How do I do that?

enter image description here

share|improve this question
add comment

1 Answer

You need a column type that allows for wrapping of its contents, like p{<len>}, m{<len>} (from the array package) or X (from tabularx). Regular c-, l- and r-columns do not break their contents naturally. Since you're using tabularx, the following might be what you're after:

enter image description here

\documentclass{article}
\usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{booktabs,tabularx}% http://ctan.org/pkg/{booktabs,tabularx}

\begin{document}

\begin{table}[t]
  \centering
  \caption{Case studies}\label{case-studies}
  \begin{tabularx}{\textwidth}{p{3cm}*{5}{X}}
    \toprule
    \centering Nature of unreliability &  Sender SST & Receiver SST & Implementation SST & Retransmission Bound & Decidability \\
    \midrule
    Noisy (Single fixed error message) & DSST & DSST & DSST & Unbounded & Yes \\
    \bottomrule
  \end{tabularx}
\end{table}

\end{document}

I've used geometry just to set the tabularx in better light; the margin of the default article wasn't wide enough to showcase the typesetting.

share|improve this answer
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.