# subtotal in table formatting

I have a table similar to multirow table formatting part of which i can create using \makecel as suggested in accepted answer, but there is subtotal kind of row and then in last 2 rows last 2 columns need to be merged. i had done it like this but without horizontal and vertical lines and need to make it look like this image, can someone guide me to format it like this (sorry for blacking out values, its my thesis results table):

Here is partial code till no subtotal row is added and columns are not merged:

\begin{document}
\begin{table}[htb]
\resizebox{\columnwidth}{!}{%
\centering\small\sffamily%
\setlength\aboverulesep{1ex}
\setlength\belowrulesep{1ex}
\renewcommand{\cellalign}{lc}
\setlength\arrayrulewidth{0.5pt}
\begin{tabular}{ >{\rule[-0.35cm]{0pt}{0cm}}m{1cm}|m{1cm}|m{2cm}}
\toprule[2pt]
Xxxxxx & Xxxxx & xxxxx xxxx xxxx x \\
\midrule[0.5pt]
Xxxxx & \makecell{Xxxxxx xxxxx \\ Xxxxxxxxxxxx \\ Xxxxxxxx \\ Xxxxxxxxxxxxxxxxx \\ Xxxxxxxxxxxxxxxxxx \\ Xxxxxxxxxxxxxxx } & \makecell{xxxxxx \\ xxxxxx \\ xxxxx \\ xxxxx \\ xxxxx \\ xxxxx} \\%
Xxxxxxxxxxxxxxxx & xxxxxx & \\
Xxxxxxxxxxxxxxxxx & xxxxxx & \\
\bottomrule[2pt]%
\end{tabular}%
}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.}
\label{tab:res}
\end{table}%
\end{document}

• Can you please replace your blacked out table with a real compilable example. That is, a minimal example of code starting with \documentclass and ending with \end{document}. In that way it is much easier to get started on your problem, and it is much more likely you will get answers. – StefanH Feb 13 '17 at 15:04
• @StefanH i edited my question to add partial code. – Miaon Feb 13 '17 at 15:25

If I understand it right you are looking for \multicolumn (and \cline).

\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs,array,makecell}
\begin{document}
\begin{table}[htb]
\resizebox{\columnwidth}{!}{%
\centering\small\sffamily%
\setlength\aboverulesep{1ex}
\setlength\belowrulesep{1ex}
\renewcommand{\cellalign}{lc}
\setlength\arrayrulewidth{0.5pt}
\begin{tabular}{ >{\rule[-0.35cm]{0pt}{0cm}}m{3cm}|m{3cm}|m{3cm}}
\toprule[2pt]
Xxxxxx & Xxxxx & xxxxx xxxx xxxx x \\
\midrule[0.5pt]
Xxxxx & \makecell{Xxxxxx xxxxx \\ Xxxxxxxxxxxx \\ Xxxxxxxx \\ Yyyyxxxxxxxxxxxxx \\ Xxxxxxxxxxxxxxxxxx \\ Xxxxxxxxxxxxxxx } & \makecell{xxxxxx \\ xxxxxx \\ xxxxx \\ xxxxx \\ xxxxx \\ xxxxx} \\\cline{2-3}
& \multicolumn{2}{c}{Zzzzzzz}\\\midrule %new row
Xxxxxxxxxxxxxxxx & \multicolumn{2}{c}{xxxxxx} \\
Xxxxxxxxxxxxxxxxx & \multicolumn{2}{c}{xxxxxx} \\
\bottomrule[2pt]%
\end{tabular}%
}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.}
\label{tab:res}
\end{table}%
\end{document}


With use of multirow and tabularx, removing vertical lines (which are to my opinion ugly and degrade professional look of table), and without resizing of table width the table become:

\documentclass{article}
\usepackage{booktabs, makecell, multirow, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcommand\mc[1]{\multicolumn{2}{c}{#1}}

% if you like to see page layout, remove before next two lines
%\usepackage{showframe}  %
%\renewcommand*\ShowFrameColor{\color{red}}

\begin{document}
\begin{table}[htb]
\renewcommand\tabularxcolumn[1]{m{#1}}
\centering
\sffamily%
\setlength\aboverulesep{1ex}
\setlength\belowrulesep{1ex}
\renewcommand{\cellalign}{lc}
\begin{tabularx}{\linewidth}{ L L L}
\toprule[2pt]
Xxxxxx  & Xxxxx                 & xxxxx xxxx xxxx x \\
\midrule[0.5pt]
\multirow{7}{=}{Xxxxx}
&   Xxxxxx xxxxx        &   yyyyyy          \\
&   Xxxxxxxxxxxx        &   yyyyyy          \\
&   Xxxxxxxx            &   yyyyyy          \\
&   Yyyyxxxxxxxxxxxxx   &   yyyyyy          \\
&   Xxxxxxxxxxxxxxxxxx  &   yyyyyy          \\
&   Xxxxxxxxxxxxxxx     &   yyyyyy          \\
\cmidrule{2-3}
&   \mc{Zzzzzzz}\\
\midrule
Xxxxxxxxxxxxxxxx        &   \mc{xxxxxx} \\
Xxxxxxxxxxxxxxxxx   &   \mc{xxxxxx} \\
\bottomrule[2pt]%
\end{tabularx}%
\end{table}%
\end{document}