I am trying to make a table which has in total 4 rows (1 tittle + 3 data). In one column, which contains the same information for all 3 rows, I decided to use \multirow.
In this multicolumn I would like to write information and split it in 7 rows (i.e. more than the total rows of the table), using \makecell.
My code is
\documentclass[12pt,a4paper]{book}
%~~~~~~~~~~~~~~~ Fonts ~~~~~~~~~~~~~~~~~~~~
\usepackage{kpfonts}
%~~~~~~~~~~~~~~~ Tables ~~~~~~~~~~~~~~~~~~~~~
\usepackage{makecell,booktabs}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{multirow}
%~~~~~~~~~~~~~~ Commands
\newcommand{\pu}{$^{240}Pu$ }
\begin{document}
\begin{table}
\centering
% table caption is above the table
\caption{This will be filled later!\label{tab:filters}}
% Give a unique label
% For LaTeX tables use
\begin{tabular}{ccccccc}
\toprule
\hline
\rowcolor{Gray}[6pt][40pt]
\makecell{Sample} & \makecell{Reference\\Number} & \makecell{Activity\\(MBq)} & \makecell{Mass\\(mg)} & \multicolumn{2}{c}{\makecell{Areal density\\(mg/cm$^2$) ($\times 10^{-4}$ atoms/b)}} & \makecell{Atomic\\abundances\\(mol/mol)}\\
\hline
{} & {TP2010-011-01} & {6.016(23)} & {0.7163(28)} & {0.1017(4)} & {2.55(1)} &
\multirow{3}{*}{ \makecell{$^{238}Pu$ : $7.33(29) \cdot 10^{-4}$\\
$^{239}Pu$ : $1.44(18) \cdot 10^{-4}$\\
$^{240}Pu$ : $0.998915(18) \cdot 10^{-4}$\\
$^{241}Pu$ : $4.1(31) \cdot 10^{-6}$\\
$^{242}Pu$ : $2.027(41) \cdot 10^{-4}$\\
$^{244}Pu$ : $4.6(88) \cdot 10^{-7}$}}\\
{\pu} & {TP2010-011-03} & {6.793(26)} & {0.809(3)} & {0.1148(5)} & {2.88(1)} & {}\\
{} & {TP2010-011-04} & {6.410(25)} & {0.763(3)} & {0.1083(5)} & {2.72(1)} & {}\\
\bottomrule
\hline
\end{tabular}
\end{table}
\end{document}
and my ugly output is
So here there are many issues.
- The last column overlaps with the other rows and the automatic spacing makes the data in the multirows to fall out of the table boarders.
- The table is much wider than the page. This was fixed by using
\resizebox, though not the best option for tables... - The
\rowcolorcommand combined with\makecellresults in white spaces when the maximum width of the column is smaller that the width of the colored row : This was solved by using[6pt][40pt]in the\rowcolorcommand! - The table is ugly...
Any idea on how to solve these issues?
EDIT I tried to remove \multirow and use only \makecell but still the outcome is a bit strange.
The new version of the code is
\documentclass[12pt,a4paper]{book}
%~~~~~~~~~~~~~~~ Fonts ~~~~~~~~~~~~~~~~~~~~
\usepackage{kpfonts}
%~~~~~~~~~~~~~~~ Tables ~~~~~~~~~~~~~~~~~~~~~
\usepackage{makecell,booktabs}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{multirow}
%~~~~~~~~~~~~~~ Commands
\newcommand{\pu}{$^{240}Pu$ }
\begin{document}
\begin{table}
\centering
% table caption is above the table
\caption{This will be filled later!\label{tab:filters}}
% Give a unique label
% For LaTeX tables use
\begin{tabular}{ccccccc}
\toprule
\hline
\rowcolor{Gray}[6pt][40pt]
\makecell{Sample} & \makecell{Reference\\Number} & \makecell{Activity\\(MBq)} & \makecell{Mass\\(mg)} & \multicolumn{2}{c}{\makecell{Areal density\\(mg/cm$^2$) ($\times 10^{-4}$ atoms/b)}} & \makecell{Atomic\\abundances\\(mol/mol)}\\
\hline
{\pu} & \makecell{TP2010-011-01\\TP2010-011-03\\TP2010-011-04} & \makecell{6.016(23)\\6.793(26)\\6.410(25)} & \makecell{0.7163(28)\\0.809(3)\\0.763(3)} & \makecell{0.1017(4)\\0.1148(5)\\0.1083(5)} & \makecell{2.55(1)\\2.88(1)\\2.72(1)} &
\makecell{$^{238}Pu$ : $7.33(29) \cdot 10^{-4}$\\
$^{239}Pu$ : $1.44(18) \cdot 10^{-4}$\\
$^{240}Pu$ : $0.998915(18) \cdot 10^{-4}$\\
$^{241}Pu$ : $4.1(31) \cdot 10^{-6}$\\
$^{242}Pu$ : $2.027(41) \cdot 10^{-4}$\\
$^{244}Pu$ : $4.6(88) \cdot 10^{-7}$}\\
\bottomrule
\hline
\end{tabular}
\end{table}
\end{document}



makecellcommand was already discussed here: How to color column heads determined width makecell and here: colortbl's \cellcolor not filling whole cell in combination with \makecell. Regarding the width of the table: As you can most likely not reduce the width by splitting contents over multiple lines, you might either consider redesigning the table (transposing...) or rotate the whole table e.g. withsidewaystablefromrotating. – leandriis Jun 25 '18 at 15:43makecellalso for the contents of the other columns in order to avoid the usage ofmultirowcompletely? – leandriis Jun 25 '18 at 15:48\rowcolor. I also tried to remove\multicolsbut still...it's not pretty. As far as the width is concerned, this is only one third of the table, so I can't rotate it... – Thanos Jun 25 '18 at 16:10\makecell: This is not what I meant with my comment. I would suggest, that you use a single row instead of three and use\makecellin every column (e.g:\makecell{TP2010-011-01 \\ TP2010-011-03 \\ TP2010-011-04}) Without any placement options, the contents of all columns will be vertically centered with this approach. – leandriis Jun 25 '18 at 16:17\hrulebelow the colored row. This can for example be done as described here: How to add vertical space struts after hline? – leandriis Jun 25 '18 at 16:20ltype column for the last column in order to align all:. Could you please also explain the desired alignment in the 'areal density' column(s)? Currently I am not able to understand which value has which meaning, as they share a heading. – leandriis Jun 25 '18 at 17:07resizeboxand doesn't look that bad! As far as the areal density is concerned, I have different units for the same quantity. – Thanos Jun 26 '18 at 06:02\smallfont. – Zarko Jun 26 '18 at 07:13resizeboxas it will lead to inconsistent font sizes. – leandriis Jun 26 '18 at 07:18