I have been trying to use \multirow
to merge the cells for x ,y1 and y2 but I can't make it through.I tried to make table using an online table generator online table generator and tried to modify it for my needs but there is something wrong here. Could you help me fix the error?
\documentclass[14pt, a4paper, twoside]{report} % 'twoside' when printing
%\setcounter{secnumdepth}{3}
\usepackage[utf8]{inputenc} % UTF-8 input
\usepackage[english]{babel} % Set language to english
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{geometry}
\usepackage{array}
\newcolumntype{?}{!{\vrule width 1pt}} %Thick vertical line
\newcolumntype{H}{>{\setbox0=\hbox\bgroup}c<{\egroup}@{}}
\newcolumntype{Z}{>{\setbox0=\hbox\bgroup}c<{\egroup}@{\hspace*{-\tabcolsep}}}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{subcaption}
\usepackage{tabularx}
\usepackage{floatrow, makecell}%
\makeatother
% Center the table horizontally
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
% Center the table vertically
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
% Center the table horizontally and vertically
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{float}
\begin{document}
\begin{table}[H]\footnotesize\setlength{\tabcolsep}{5pt}\textbf{}
\centering
\caption{Total Effect}
\bgroup
\def\arraystretch{1.5}% 1 is the default, change whatever you need
\begin{tabular}{ ? p{0.4em} | p{2em}? p{3.2cm} | p{4.1cm}| p{4.2cm} | p{3.7cm}| }
\toprule
& Si \newline index&Max & Mean &Median &Eqm \\
\Xhline{4\arrayrulewidth}
\multirow{3}{*}{$x$} &$s_{T}$&
$\left[x_{0}\right],\,\newline
\left[\left(\text{ all others}\right)\right]$ &
$\left[b\,\,\delta_{2},\,\delta_{1},\,\omega_{2},\,\omega_{1},\,\psi,\,x_{0}\right],\,\newline \left[\phi,\,\left(a,\,{y_{1}}_{0},\,{y_{2}}_{0}\right)\right]$ &
$\left[b,\,\delta_{2},\,\delta_{1},\,\omega_{2},\,\omega_{1},\,\psi,\,\phi\right],\,\newline \left[{y_{1}}_{0},\,a,\,x_{0},\,{y_{2}}_{0}\right]$ &
$\left[b,\,\delta_{2},\,\delta_{1},\,\omega_{1},\,\omega_{2},\,\psi,\,\phi\right],\,\newline \left[x_{0},\,\left({a,\,y_{1}}_{0},\,{y_{2}}_{0}\right)\right]$ \\
\hline
&$\mu^{\star}$ &
$\left[x_{0}\right],\,\newline
\left[\left(\text{ all others}\right)\right] $ &
$\left[b,\,x_{0},\,\delta_{1},\,\omega_{1},\,\delta_{2},\,\omega_{2}\right],\,\newline
\left[\psi,\,\phi,\,{y_{2}}_{0},\,{y_{1}}_{0},\,a\right]$ &
$\left[b,\,x_{0},\,\omega_{1},\,\delta_{1},\,\delta_{2}\omega_{2}\right],\,\newline
\left[\psi,\,\phi,\,a,\,{y_{2}}_{0},\,{y_{1}}_{0}\right]$ &
$\left[b,\,x_{0},\,\delta_{1},\,\omega_{1},\,\delta_{2}\omega_{2}\right],\,\newline
\left[\psi,\,\phi,\,a,\,{y_{2}}_{0},\,{y_{1}}_{0}\right]$ \\
\hline
&$\delta$ &
$\left[x_{0}\right],\,\newline
\left[\left(\text{ all others}\right)\right]$&
$\left[b,\,\delta_{2},\,x_{0},\,\omega_{2},\,\delta_{1},\,\omega_{1}\right],\,\newline\left[\psi,\,a,\,\left({\phi,\,y_{2}}_{0},\,{y_{1}}_{0}\right)\right]$&
$\left[b,\,\delta_{2},\,\omega_{2},\,\delta_{1},\,\omega_{1},\,\psi\right],\,\newline\left[a,\,{y_{2}}_{0},\,x_{0},\,\phi,\,{y_{1}}_{0}\right]$&
$\left[b,\,\delta_{2},\,\omega_{2},\,\delta_{1},\,\omega_{1},\,\psi\right],\,\newline\left[a,\,x_{0},\,{y_{2}}_{0},\,\phi,\,{y_{1}}_{0}\right]$ \\
\Xhline{4\arrayrulewidth}
\multirow{3}{*}{$y_{1}$} &$s_{T}$&
$\left[{y_{1}}_{0}\right],\,\newline\left[\left(\text{ all others}\right)\right]$&
$\left[b,\,\delta_{2},\,\delta_{1},\,\psi,\,\omega_{1},\,\omega_{2}\right],\,\newline\left[\phi,\,{y_{1}}_{0},\,x_{0},\,{y_{2}}_{0},\,a\right]$&
$\left[b,\,\delta_{2},\,\delta_{1},\,\psi,\,\omega_{1},\,\omega_{2},\,\phi\right],\,\newline\left[x_{0},\,{y_{2}}_{0},\,\left(a,\,{y_{1}}_{0}\right)\right]$&
$\left[\omega_{1},\,b,\,\delta_{2},\,\delta_{1},\phi,\,\psi,\,\omega_{2}\right],\,\newline\left[x_{0},\,{y_{2}}_{0},\,a,\,{y_{1}}_{0}\right]$ \\
\hline
&$\mu^{\star}$&
$\left[{y_{1}}_{0}\right],\,\newline\left[\left(\text{ all others}\right)\right] $ &
$\left[b,\,x_{0},\,\phi,\,\omega_{1},\,\delta_{1},\,{y_{1}}_{0}\right],\,\newline
\left[\delta_{2},\,\psi,\,\omega_{2},\,{y_{2}}_{0},\,a\right]$ &
$\left[b,\,x_{0},\,\delta_{2},\,\omega_{1},\,\omega_{2},\,\phi,\,\psi,\,\delta_{1}\right],\,\newline\left[{y_{2}}_{0},\,{y_{1}}_{0},\,a\right]$ &
$\left[b,\,\delta_{2},\,\omega_{1},\,x_{0},\,\delta_{1},\,\omega_{2},\,\psi,\,\phi\right],\,\newline\left[a,\,{y_{1}}_{0},\,{y_{2}}_{0}\right]$ \\
\hline
&$\delta$ &
$\left[{y_{2}}_{0}\right],\,\newline\left[\left(\text{ all others}\right)\right]$&
$\left[{y_{1}}_{0},\,b,\,\psi,\,\delta_{2},\,\omega_{2},\,\phi\right],\,\newline\left[x_{0},\,{y_{2}}_{0},\,a,\,\omega_{1},\,\delta_{1}\right]$ &
$\left[\omega_{2},\,b,\,\delta_{1},\,\delta_{2},\,\psi,\,\phi,\,\right],\,\newline\left[\left(a,\,\omega_{1},\,x_{0},\,{y_{1}}_{0},\,{y_{2}}_{0}\right)\right]$ &
$\left[\left(a,\,\phi,\, \omega_{1},\,x_{0},\,{y_{1}}_{0},\,{y_{2}}_{0},\ \omega_{2}\right)\right],\,\newline\left[b,\,\delta_{2},\,\psi,\,\delta_{1}\right]$ \\
\Xhline{4\arrayrulewidth}
\multirow{3}{*}{$y_{2}$} &$s_{T}$ &
$\left[\omega_{2},\,b,{y_{2}}_{0},\,x_{0},\,\omega_{1},\,\phi,\,\psi\right],\,\newline
\left[\delta_{2},\,{y_{1}}_{0},\,\left(a,\,\delta_{1}\right)\right]$ & $\left[b,\,\delta_{2},\,\delta_{1},\,\phi,\,\omega_{2},\,\psi,\,\omega_{1}\right],\,\newline
\left[x_{0},\,{y_{2}}_{0},\,\left(a,\,{y_{1}}_{0}\right)\right]$ &
$\left[b,\,\delta_{2},\,\delta_{1},\,\omega_{2},\,\phi,\,\psi,\,\omega_{1}\right],\,\newline
\left[x_{0},\,{y_{1}}_{0},\,{y_{2}}_{0},\,a\right]$ &
$\left[\phi,\, \delta_{2},\,\psi,\,b,\,\omega_{1},\,\delta_{1},\,\omega_{2}\right],\,\newline \left[x_{0},\,\left(a,\,{y_{1}}_{0},\,{y_{2}}_{0}\right)\right]$ \\
\hline
&$\mu^{\star}$ &
$\left[\omega_{2},\,b,\,\psi,\,\omega_{1},\,\phi,\,x_{0} \right],\,\newline
\left[\delta_{2},\,{y_{2}}_{0},\,{y_{1}}_{0},\,\delta_{1},\,a\right]$ &
$\left[b,\,\omega_{2},\,\delta_{2},\,\phi,\,x_{0},\,\omega_{1},\,\psi\right],\,\newline
\left[\delta_{1},\,{y_{2}}_{0},\,{y_{1}}_{0},\,a\right]$ &
$\left[b,\,\delta_{2},\,\omega_{2},\,x_{0},\,\phi,\,\psi,\,\omega_{1},\,\delta_{1}\right],\,\newline
\left[{y_{2}}_{0},\,a,\,{y_{1}}_{0}\ \right]$ &
$\left[\delta_{2},\,\omega_{2},\,\delta_{1},\,b,a,\,x_{0},\,\omega_{1}\right],\,\newline
\left[{{y_{1}}_{0},\,\psi,\,\phi,\,y_{2}}_{0}\right]$ \\
\hline
&$\delta$&
$\left[{y_{2}}_{0},\,b,\,\omega_{2},\,\omega_{1},\,\phi,\,\psi\right],\,\newline\left[\delta_{2},\,\delta_{1},\,x_{0},\,{y_{1}}_{0},\,a\right]$ &
$\left[{y_{2}}_{0},\,b,\,\delta_{1},\,\omega_{1},\,\psi,\,{y_{1}}_{0},\,a,\,\omega_{1},\,\phi\right],\,\newline\left[\delta_{2},\,x_{0},\,a\right]$ &
$\left[b,\,\delta_{1},\,\omega_{1},\,\psi,\,{y_{1}}_{0},\,a,\,{y_{2}}_{0},\,\phi,\, x_{0}\right],\,\newline\left[\delta_{2}\right]$ &
$\left[b,\,\delta_{2},\,\omega_{2},\,\omega_{1},\,\psi,\,\phi\right],\,\newline\left[\delta_{1},\,{y_{1}}_{0},\, x_{0},\,{y_{2}}_{0},\,a\right]$ \\
\bottomrule
\end{tabular}
\egroup
tablegenerator.com
is a real piece of work. It's probably pointless to try to improve it measurably. (Well, deleting all 87 instances of\left
and all 87 instances of\right
would constitute a good first step. Replacing all 301 [!!] instances of,\,
with,
would constitute a good second step...) To achieve your immediate formatting objective, though, all you need to do is (a) change all 3 instances of\multirow{3}
to\multirow{5}
and (b) replace all 6 instances of\hline
with\cline{2-6}
. – Mico Jul 2 '20 at 15:36\multirow
is the number of vertical cells . Why you suggest removing all\left,\right
and all\,
because I need some space between the parameters inside[]
. I did as your last two recommendations and it works now. Put it as answer to accept it. – F.O Jul 2 '20 at 15:56\,
(thinspace) directives: they're not needed because TeX automatically inserts a bit of whitespace after commas in math mode. – Mico Jul 2 '20 at 17:28