1

I am creating a table using booktabs, but I also need multirow in specific places, in combination with long paragraphs of text. If I use multirow normally, there is no way to break the text:

\usepackage{float}
\usepackage{booktabs}
\usepackage{multirow}

\begin{table}[H]
\small
\begin{tabular}{@{}p{1cm}p{5cm}p{6.5cm}p{2cm}@{}}
  \toprule
  \textbf{Ch.\#} &  \textbf{Project title} & \textbf{Milestones} & \textbf{Expected date} \\ \midrule
  3 & \multirow{4}{*}{This project will be an \newline extension of Ch. \#2. The code will be parallelized...}\\  
    & & Milestone 1 & 2019 \\ 
    & & Milestone 2 & 2019 \\ 
    & & Milestone 3 & 2019 \\ \midrule
  4 & Title of project 4 & &\\
  \bottomrule
\end{tabular}
\end{table}

enter image description here

And if I remove the brackets around the long text, it keeps to the cell size but it looks wrongly formatted and the multirows in the next column just move down:

\usepackage{float}
\usepackage{booktabs}
\usepackage{multirow}

\begin{table}[H]
\small
\begin{tabular}{@{}p{1cm}p{5cm}p{6.5cm}p{2cm}@{}}
  \toprule
  \textbf{Ch.\#} &  \textbf{Project title} & \textbf{Milestones} & \textbf{Expected date} \\ \midrule
  3 &  \multirow{4}{*} This project will be an \newline extension of Ch. \#2. The code will be parallelized...\\  
    & & Milestone 1 & 2019 \\ 
    & & Milestone 2 & 2019 \\ 
    & & Milestone 3 & 2019 \\ \midrule
  4 & Title of project 4 & &\\
  \bottomrule
\end{tabular}
\end{table}

enter image description here

What would be a proper way to combine these two packages for this specific case?

1 Answer 1

5

Multirow works perfectly with booktabs. You simply forgot that using the parameter {*} to specify the multirow width makes it have a single line. In a column with predefined width, use {=] instead.

I took the liberty to modify your preamble to improve the layout of the table, in particular with the makecell package.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{float}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ragged2e}
\usepackage{makecell}
\renewcommand{\theadfont}{\small\bfseries}

\begin{document}

\begin{table}[H]
\small\centering
\begin{tabular}{@{}lp{5cm}p{5cm}p{2cm}@{}}
  \toprule
  \thead{Ch.\#} & \thead{Project title} & \thead{Milestones} & \thead{Expected\\ date} \\ \midrule
  3 & \multirow{4}{=}{\RaggedRight This project will be an extension of Ch. \#2. The code will be parallelized...}\\
    & & Milestone 1 & 2019 \\
    & & Milestone 2 & 2019 \\
    & & Milestone 3 & 2019 \\ \midrule
  4 & Title of project 4 & &\\
  \bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

2
  • I didn't know about having to use =. Thanks! Apr 8, 2019 at 23:05
  • 1
    Read the documentations! ;o) (this parameter is relatively recent – as well as non-integer number of rows)
    – Bernard
    Apr 8, 2019 at 23:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .