TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a multirow inside a tabularx, but because the multirow doesn't wrap, I am putting the multirow's text inside a parbox environment:

\begin{tabularx}{\textwidth}{@{}XX@{}} \toprule
blah & \multirow{2}{*}{\parbox{\columnwidth}{blah}} \\
blah & \\
\end{tabularx}

What should I put as the parbox's width so that it responds to the column width that tabularx chooses?

share|improve this question
up vote 6 down vote accepted

\linewidth, since that will be the width of the column as adjusted by tabularx's X-column. Here's an example:

enter image description here

\documentclass{article}
\usepackage{tabularx,multirow,booktabs}% http://ctan.org/pkg/{tabularx,multirow,booktabs}
\begin{document}
\noindent\begin{tabularx}{\textwidth}{@{}XX@{}} \toprule
blah & \multirow{2}{*}{\setlength{\fboxsep}{-\fboxrule}\fbox{\parbox{\linewidth}{blah}}} \\
blah & \\
\end{tabularx}
\end{document}

Contrary to belief, \columnwidth does not span the width of a table column.

share|improve this answer

\multirow would linewrap if you passed a length rather than *

enter image description here

\documentclass{article}
\usepackage{tabularx,multirow,booktabs}% http://ctan.org/pkg/{tabularx,multirow,booktabs}
\begin{document}
\def\blah{blah blah blah blah blah blah blah blah blah blah blah blah}

\noindent\begin{tabularx}{\textwidth}{@{}XX@{}} \toprule
\blah & \multirow{2}{\linewidth}{\blah \blah} \\
\blah & \\
\end{tabularx}
\end{document}
share|improve this answer
    
Thanks! It's always nice to have optimized code. – Neil G Dec 17 '12 at 17:44
    
Thanks @David for your suggestion on explicit passing of the length – Amir Feb 21 at 14:24

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.