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.

I'm trying to make a rotated table using the sidewaystable package, and I cannot get the text to wrap. It compiles, but it I haven't been able to wrap the text within the columns or define the width of the columns.

The code is rather messy but here is an extract:

\begin{sidewaystable}[htbp]  
  \centering  
  \caption{bla bla bla}  
   \begin{threeparttable}[b]  
    \begin{tabular}{rrr}  
    \toprule  
          Awesome intro\\  
    \midrule  
    \multicolumn{1}{l}{bla bla} & \multicolumn{1}{l}{more bla} & \multicolumn{1}{l}{final bla} \\  
\bottomrule  
    \end{tabular}%  
    \begin{tablenotes}\footnotesize  
        \item Source: bla bla  
         \end{tablenotes}  
    \end{threeparttable}  
  \label{tab:xx}%  
\end{sidewaystable}%  

Edit:

  • It is also going on a seperate page in the appendix, if that makes a difference..
  • I am using the threeparttable to be add "footnotes" to the tables.
share|improve this question
2  
Instead of \begin{tabular}{rrr} try \begin{tabular}{p{5cm}p{8cm}p{4cm}} or whatever width you need. –  Gonzalo Medina Jun 5 '13 at 23:15
    
Tried that but there is no difference. I've tried with different sizes too –  Anders Jun 5 '13 at 23:59
1  
Get rid of all those \multicolumn{1}{l}{text} which are overriding the p{<length>} column type: \begin{tabular}{p{3cm}p{3cm}p{3cm}} \toprule a \ \midrule bla bla & more bla & final bla \\ \bottomrule \end{tabular} –  Gonzalo Medina Jun 6 '13 at 0:29
    
Welcome to the site, Anders. Could you extend your "snippet" into a compilable .tex file, starting with \documentclass and ending with \end{document}? It is easier to reproduce the issue you're having if I can just paste your code into my editor and hit "compile" :-). –  John Wickerson Jun 6 '13 at 4:57
    
Thank you Gonzalo! Removing all the \multicolumns worked! I know that they are superfluous in some cases, but I am using an excel to latex table exporter which does it by default. Which is proving to be less of a time saver than I thought! Without using multicolumns, how will i be able to merge two columns? –  Anders Jun 6 '13 at 12:28
add comment

1 Answer

Use p{...} type columns and avoid the \multicolumn{1}{l}{...} which override the initial column type; you can still use \multicolumn with a p{...} column type to merge several columns. A little example:

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\usepackage{rotating}
\usepackage{threeparttable}

\begin{document}

\begin{sidewaystable}[htbp]  
  \centering  
  \caption{bla bla bla}  
   \begin{threeparttable}[b]  
    \begin{tabular}{p{4cm}p{4cm}p{4cm}}  
    \toprule  
          Awesome intro\\  
    \midrule  
    Some test text spanning several lines & Some test text spanning several lines  & Some test text spanning several lines  \\ 
   \multicolumn{2}{>{\centering}p{8cm}}{Some test text spanning several lines in a multicolumn for two columns} & Some test text spanning several lines \\
\bottomrule  
    \end{tabular}%  
    \begin{tablenotes}\footnotesize  
        \item Source: bla bla  
         \end{tablenotes}  
    \end{threeparttable}  
  \label{tab:xx}
\end{sidewaystable}

\end{document}

enter image description here

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.