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 searched a bit, but I could not find a reliable way to wrap text in tables with columns spanning more than one row. Any ideas on how to fit this table in the page?:

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
    \begin{tabular}{cccc}
    \toprule
    & & \multicolumn{2}{c}{Logic of rule adoption} \\
    \cmidrule{3-4}
       & & Logic of consequences & Logic of appropriateness \\
    \midrule
    \multirow{2}{*}{Principal actor in rule adoption process} & EU-driven & External incentives model & Social learning model \\
      & CEE-driven & Lesson-drawing model & Lesson-drawing model \\
    \bottomrule
    \end{tabular}
 \end{document}
share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

In answer to your question about wrapping text contained within a \multirow, you can put the contents <stuff> in a paragraph box \parbox{<len>}{<stuff>} where you specify the width <len>:

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{multirow}% http://ctan.org/pkg/multirow

\begin{document}
  \begin{tabular}{cccc}
    \toprule
    & & \multicolumn{2}{c}{Logic of rule adoption} \\
    \cmidrule{3-4}
    & & Logic of     & Logic of \\
    & & consequences & appropriateness \\
    \midrule
    \multirow{2}{*}{\parbox{4cm}{Principal actor in rule adoption process}} & EU-driven & External incentives model & Social learning model \\
    & CEE-driven & Lesson-drawing model & Lesson-drawing model \\
    \bottomrule
  \end{tabular}
\end{document}

However, this is still very wide in terms of your document specifications (12pt,a4paper). So, here's perhaps a better table layout and some margin adjustments (using geometry):

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage[margin=3cm]{geometry}% http://ctan.org/pkg/geometry

\begin{document}
\noindent\begin{tabular}{ccc}
    \toprule
    & \multicolumn{2}{c}{Logic of rule adoption} \\
    \cmidrule{2-3}
    \parbox{0.3\linewidth}{\centering Principal actor in rule adoption process} & 
    \parbox{0.3\linewidth}{\centering Logic of consequences} & 
    \parbox{0.3\linewidth}{\centering Logic of appropriateness} \\
    \midrule
    EU-driven & External incentives model & Social learning model \\
    CEE-driven & Lesson-drawing model & Lesson-drawing model \\
    \bottomrule
  \end{tabular}
\end{document}

Note the \noindent to avoid a paragraph indent, otherwise it will push the table over to the right, over the text (right) margin.

share|improve this answer
    
Thanks Werner! However if you add \multirow{2}{*} before parbox{0.3\linewidth}{\centering Principal actor in rule adoption process} in order to merge the cells, you got overlapping text. What should I modify? –  looreenzoo Nov 24 '11 at 17:04
    
@looreenzoo: Use \multirow{-2}{*}{...} instead to make the overlap span vertically upward rather than downward. –  Werner Nov 24 '11 at 17:08
    
Great, thanks again! –  looreenzoo Nov 24 '11 at 17:09
    
@looreenzoo: If this solved your problem/question, Please consider upvoting and/or marking it as ‘Accepted’ by clicking on the tickmark below their vote count. This shows that the answer helped you most, and it assigns reputation points to the author of the answer (and to you!). –  Werner Nov 24 '11 at 17:12
    
I tried to upvote, but I do not have enough reputation. Now I see the "Accepted" mark... –  looreenzoo Nov 24 '11 at 17:19
show 2 more comments

Firstly, there are some errors in your original attempt's code (too many columns, multirow definition in wrong place). So our starting point code should be as below:

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
\begin{tabular}{ccc}
\toprule
\multirow{2}{*}{Principal actor in rule adoption process}
& \multicolumn{2}{c}{Logic of rule adoption} \\
\cmidrule{2-3}
& Logic of consequences & Logic of appropriateness \\
\midrule

EU-driven & External incentives model & Social learning model \\
CEE-driven & Lesson-drawing model & Lesson-drawing model \\

\bottomrule
\end{tabular}
\end{document}

What seems like it should work is to convert the columns into paragraph (wrapped) ones; you can use the array package and special p definitions to make them centered. (I'm assuming you need them to stay centered.) I also added a \noindent in so that table doesn't get a paragraph indent before it (common practice).

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{multirow}
\usepackage{array}

\begin{document}
\noindent
\begin{tabular}%
{>{\centering\arraybackslash}p{0.3\textwidth}%
>{\centering\arraybackslash}p{0.3\textwidth}%
>{\centering\arraybackslash}p{0.3\textwidth}}
\toprule
\multirow{2}{*}{Principal actor in rule adoption process}
& \multicolumn{2}{c}{Logic of rule adoption} \\
\cmidrule{2-3}
& Logic of consequences 
& Logic of appropriateness \\
\midrule
EU-driven & External incentives model & Social learning model \\
CEE-driven & Lesson-drawing model & Lesson-drawing model \\
\bottomrule

\end{tabular}
\end{document}

However, this doesn't work because multirow doesn't 'honour' the paragraph column definition and so the text is not wrapped. (The multirow documentation doesn't mention this 'feature', and it surprises me that this isn't mentioned in any other answers to this and similar questions since, to me, this is very unintuitive.)

So we need to wrap the multirow in a parbox to 'reapply the column formatting manually':

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{multirow}
\usepackage{array}

\begin{document}
\noindent
\begin{tabular}%
{>{\centering\arraybackslash}p{0.3\textwidth}%
>{\centering\arraybackslash}p{0.3\textwidth}%
>{\centering\arraybackslash}p{0.3\textwidth}}
\toprule
\multirow{2}{*}{\parbox{0.3\textwidth}{\centering Principal actor in rule adoption process}}
& \multicolumn{2}{c}{Logic of rule adoption} \\
\cmidrule{2-3}
& Logic of consequences 
& Logic of appropriateness \\
\midrule
EU-driven & External incentives model & Social learning model \\
CEE-driven & Lesson-drawing model & Lesson-drawing model \\
\bottomrule

\end{tabular}
\end{document}

You could revert back to {ccc} column definitions and have a parbox of a fixed width <= any other row contents for that column, but that's a bit clunky. Better to leave them like this and have the benefit of wrapped, centered text everywhere.

EDIT: Actually, it also works if you just set the multirow width manually:

\multirow{2}{0.3\textwidth}{\centering Principal actor in rule adoption process}}

This is perhaps a cleaner solution, but it's a bit mysterious why specifying the width manually (cf. *) causes it to start wrapping, but not to get the centering until added manually. (I assume because a specified width implicitly applies paragraph-style wrapping.) At least using a parbox makes it explicit.

EDIT 2: To be more generic, this works if you use \linewidth instead of \textwidth everywhere, with a multirow width of \linewidth (not 0.3\linewidth). \linewidth appears to give you the contextual width which, in a table cell, is the column width. However, no descriptions of \linewidth I've seen (including comprehensive answers on this site: Difference between \textwidth, \linewidth and \hsize) mention this tabular context (they all talk about lists, minipages and parboxes), so I was very surprised that this works like this. Maybe it's because parboxes are being used under the covers(?), or perhaps \linewidth is more general than people realise?

share|improve this answer
1  
Although Werner's answer is correct (and accepted), it does add some extraneous bits in, and I think it is important to state that the more 'obvious' solution (using p columns) doesn't work for subtle reasons. Plus his final code actually misses out the \multirow bit, and the elucidation in the comments is not ideal: it's more normal to reposition the multirow, rather than leave it and use a negative row count. Anyway, hope people find this useful. –  monsieurRigsby Oct 19 '12 at 10:35
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.