# how to make three row with multirow package

I have a code that prints a table with 2 rows. I want to keep format of it and change 2 rows into 3.

\documentclass[conference]{IEEEtran}

\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage{multirow}
\begin{document}

\begin{table}[h]
\caption{Family data set results}
\label{tbl::Fam}
\centering
\begin{tabular}{|l|l|c|c|c!{\vrule width 2pt}l|l|c|c|c|}
%\noalign{\hrule height 2pt}
\hline
\textbf{Column}&\textbf{Algorithm}&\textbf{min}&\textbf{max}&\textbf{std}l&\textbf{Column}&\textbf{Algorithm}&\textbf{min}&\textbf{max}&\textbf{std}\\\hline
\multirow{2}{*}{age}&Original&9&2.8&100&\multirow{2}{*}{employer\_type}&Original&13&2&10\\ \cline{2-5} \cline{7-10}&PrivBayes&2&95&96&&PrivBayes&2&100&100\\\hline
\multirow{2}{*}{education\_level}&Original&7&2&98&\multirow{2}{*}{marital\_status}&Original&10&2&100\\ \cline{2-5} \cline{7-10}&PrivBayes&2&6&96&&PrivBayes&2&6&100\\\hline
\hline %\noalign{\hrule height 2pt}
\end{tabular}
\end{table}

\end{document}


In this picture, I have 2 algorithms {Original, PrivBayes}. I want to change 2 algorithms into 3 algorithms with keeping the format of table.

• Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. Aug 18 '17 at 2:49
– cfr
Aug 18 '17 at 3:05
• Can't find it, though ....
– cfr
Aug 18 '17 at 3:08
• No I did not ask it before. Aug 18 '17 at 3:08
• Your documentclass is not a standard class (at least in texlive)... but I tried with article and it works (I suggest to change documentclass to article for this MWE -I don't think that your specific class has something to do with the question and this way you help anyone who will try to compile-)... Also your question is not clear enough... To add a row you just typing the elements of the row under the last one (after last ///hline)... Do you want to make the last half of columns two new rows? Or what? (Your table already has 5 rows) Aug 18 '17 at 3:15

Your table appears to be considerably wider than the text block is. The easiest remedy would convert the table from a 10-column structure to a more-manageable (and easier on the readers' eyes) 5-column structure.

While you're at it, you may want to give the table a more "open" look, to invite the reader to actually look at and hopefully even absorb the information provided in the table. I suggest you (a) get rid of all vertical rules, (b) use fewer, but well-spaced, horizontal rules, (c) not use any bold fonts and (d) align the numbers in the three numeric columns on their (implicit) decimal markers.

Oh, and I wouldn't use any \multirow directives for the entries in the first column; they're simply not needed.

\documentclass[conference]{IEEEtran}

\usepackage{booktabs,siunitx}
\begin{document}

\begin{table}[h]
\caption{Family dataset results}
\label{tbl::Fam}
\centering
\begin{tabular}{@{} ll *{3}{S[table-format=3.0]} @{}}
\toprule
Column&Algorithm&{min}&{max}&{std.dev.}\\
\midrule
age&Original &9&28&100\\
&PrivBayes&2&95&96\\
&ThirdAlg &10&90&50\\
education\_level&Original&7&28&98\\
&PrivBayes&2&6&96\\
&ThirdAlg &10&90&50\\
employer\_type&Original&13&2&10\\
&PrivBayes&2&100&100\\
&ThirdAlg &10&90&50\\
marital\_status&Original&10&20&100\\
&PrivBayes&2&6&100\\
&ThirdAlg &10&90&50\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

• Thank you, it is very useful suggestion for me. I will apply it. Aug 18 '17 at 5:35
• +1 But I think the OP has to delete "with keeping the format of table". Anyway (practical) aesthetics is always useful and as TeX users have to take it into account! Aug 18 '17 at 7:09
• Also if OP have still a reason to include class1 and class2 rows from this question: tex.stackexchange.com/questions/386977/… he can just put them as first row with \multicolumn{c}{5}{class1 or 2} and may be separate two classes with a single \hline Aug 18 '17 at 7:14

Here is how that can be done:

\documentclass{article}

\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage{multirow}
\begin{document}

\begin{table}[h]
\caption{Family data set results}
\label{tbl::Fam}
\centering
\begin{tabular}{|l|l|c|c|c!{\vrule width 2pt}l|l|c|c|c|}
%\noalign{\hrule height 2pt}
\hline
\textbf{Column}&\textbf{Algorithm}&\textbf{min}&\textbf{max}&\textbf{std}l&\textbf{Column}&\textbf{Algorithm}&\textbf{min}&\textbf{max}&\textbf{std}\\\hline
\multirow{3}{*}{age}&Original&9&2.8&100&\multirow{3}{*}{employer\_type}&Original&13&2&10\\ \cline{2-5} \cline{7-10}
&PrivBayes&2&95&96&&PrivBayes&2&100&100\\\cline{2-5} \cline{7-10}
&ThirdAlg&100&100&100&&ThirdAlg&100&100&100\\\hline
\multirow{3}{*}{education\_level}&Original&7&2&98&\multirow{3}{*}{marital\_status}&Original&10&2&100\\ \cline{2-5} \cline{7-10}
&PrivBayes&2&6&96&&PrivBayes&2&6&100\\\cline{2-5} \cline{7-10}
&ThirdAlg&100&100&100&&ThirdAlg&100&100&100\\\hline
%\hline %\noalign{\hrule height 2pt}
\end{tabular}
\end{table}

\end{document}


Change 100s to your values... Also if you realy need the last \hline remove the % from the row before \end{tabular}

Result:

In landscape or something that table width will be ok, the centering of caption will be ok too.

Edit: Changed second part multirows too because I forgot them before and because of that the right multirow cells was not centered.

• +1. The "look" of the table would increase if all 8 \cline directives were omitted (or, at least, commented out).
– Mico
Aug 18 '17 at 5:02
• @Mico "increase"? Sorry but my English are not very good... Do you mean it would be more beautiful? Aug 18 '17 at 5:07
• @koleygr - Oops. I meant "improve", not "increase"! (I shouldn't start dashing off notes before having had a second cup of coffee in the morning!)
– Mico
Aug 18 '17 at 5:19
• @Mico... No problem... I just thought it is some strange (and new) English for me... (Always English are strange for a Greek lol ). On the subject: I did not change anything as the OP wanted excactly the same style. Not even the "l" typo on first std column (it is a kind of style too :P ) Aug 18 '17 at 5:23