1

I have been trying to format a table with multirow but something seems to be going wrong and I can't quite pinpoint what is it. Any help is much appreciated!

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pdflscape}
\usepackage{graphicx}
\usepackage{indentfirst}
\usepackage{geometry}
\usepackage{dcolumn}
\usepackage{wrapfig}
\usepackage{booktabs}
\usepackage{placeins}
\usepackage{float}
\usepackage{siunitx}
\usepackage{setspace}
\linespread{2.0}
\usepackage{tikz}
\usepackage{multirow}

\begin{document}
\begin{tabular}{|c|c|c|c|c|}
\hline
                             & \textbf{Models} & \textbf{DV}                 & \textbf{IV}               & \textbf{Controls}                                                                                                      \\ \hline
\multirow{2}{*}{\textbf{H1}} & Model 1         & Male Secondary enrollment   & \multirow{2}{*}{Conflict} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}GDP pc\\ Education Investment\\ Year Effects\\ Region Effects\end{tabular}} \\ \cline{2-3}
                             & Model 2         & Female Secondary enrollment &                           &                                                                                                                        \\ \hline
\textbf{H2}                  & Model 3         & Gender Educational Gap      & Conflict                  & \begin{tabular}[c]{@{}c@{}}GDP pc\\ Education Investment\\ Year Effects\\ Region Effects\end{tabular}                  \\ \hline
\textbf{H3}                  & Model 4         & Gender Educational Gap      & Intensity*                & \begin{tabular}[c]{@{}c@{}}GDP pc\\ Education Investment\\ Year Effects\\ Region Effects\end{tabular}                  \\ \hline
\end{tabular}
\end{document}

The output I get is the following: enter image description here

2 Answers 2

1

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{setspace}
\linespread{2.0}
\usepackage{multirow}

\begin{document}
\begin{tabular}{|c|c|c|c|c|}
\hline
                             & \textbf{Models} & \textbf{DV}                 & \textbf{IV}               & \textbf{Controls}                                                                                                      \\ \hline
\multirow{4}{*}{\textbf{H1}} & \multirow{2}{*}{Model 1}     & \multirow{2}{*}{Male Secondary enrollment}   & \multirow{4}{*}{Conflict} & \multirow{4}{*}{\begin{tabular}[c]{@{}c@{}}GDP pc\\ Education Investment\\ Year Effects\\ Region Effects\end{tabular}} \\ 
& & & &\\ \cline{2-3}
                             & \multirow{2}{*}{Model 2}     & \multirow{2}{*}{Female Secondary enrollment} &                           &                                                                                                                       \\ 
                             & & & & \\\hline
\textbf{H2}                  & Model 3          & Gender Educational Gap      & Conflict                  & \begin{tabular}[c]{@{}c@{}}GDP pc\\ Education Investment\\ Year Effects\\ Region Effects\end{tabular}                  \\ \hline
\textbf{H3}                  & Model 4          & Gender Educational Gap      & Intensity*                & \begin{tabular}[c]{@{}c@{}}GDP pc\\ Education Investment\\ Year Effects\\ Region Effects\end{tabular}                  \\ \hline
\end{tabular}
\end{document}
1
  • Perfect solution! Thank you
    – pfragon
    Commented Jan 14, 2021 at 18:00
2

By using makecell package and define Strut for adding vertical space in rows where needed. Also instead of \linespread{2.0} is used \doublespacing which hasn't effect in table:

\documentclass{article}
\usepackage{geometry}
\usepackage{dcolumn}
\usepackage{booktabs,
            makecell,
            multirow}
\usepackage{setspace}
\doublespacing <---

\begin{document}
\lipsum[11]
    \begin{table}[ht]
    \def\Strut{\rule[-2ex]{0pt}{5.4ex}}
    \setcellgapes{3pt}
    \setcellgapes{3pt}
    \makegapedcells
\begin{tabular}{|c|c|c|c|c|}
\hline
     & \textbf{Models} & \textbf{DV}                 
        & \textbf{IV}               
            & \textbf{Controls}     
     \\ \hline
\multirow{3.6}{*}{\textbf{H1}}
    & Model 1   \Strut     
        & Male Secondary enrollment   
            & \multirow{3.6}{*}{Conflict} 
                & \multirow{3.6}{*}[1ex]{\makecell[l]{
                    GDP pc\\ 
                    Education Investment\\ 
                    Year Effects\\ 
                    Region Effects}} 
    \\  \cline{2-3}
    & Model 2   \Strut
        & Female Secondary enrollment
            &   &   
    \\ \hline
\textbf{H2}                  
    & Model 3 
        & Gender Educational Gap 
            & Conflict 
                &   \makecell[l]{
                    GDP pc\\
                    Education Investment\\
                    Year Effects\\
                    Region Effects}                   
    \\ \hline
\textbf{H3}
    & Model 4         
        & Gender Educational Gap      
            & Intensity*                
                &   \makecell[l]{
                    GDP pc\\
                    Education Investment\\
                    Year Effects\\
                    Region Effects}
    \\ \hline
\end{tabular}
    \end{table}
\end{document}

enter image description here

You must log in to answer this question.

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