Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vertical alignment in cell table Latex

I created this table in Latex:
Table
As you can see the text (MNIST, CIFAR10,…) in the column Dataset is not vertical aligned. How can I put that strings in the middle of the cell?
This is my code:

\begin{table}[!hbt]
\caption{Multi-row table}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
    \hline
    Category & Epochs per round & Dataset & FedAvg & FedCurv \\
    \hline
    \multirow{9}{2.5cm}{\centering Uniform Distribution} &  1 & MNIST & accuracy & accuracy \\ 
    & 10 &  & accuracy & accuracy \\ 
    & 30 &  & accuracy & accuracy \\ \cline{2-5}
    & 1 & CIFAR10  & accuracy & accuracy\\
    & 10 &  & accuracy & accuracy\\ 
    & 30 &  & accuracy & accuracy \\\cline{2-5}
    & 1 & TinyImageNet & accuracy & accuracy \\
    & 10 &  & accuracy & accuracy \\
    & 30 &  & accuracy & accuracy \\
    \hline
    \multirow{9}{2.5cm}{\centering Quantity Skew} &  1 & MNIST & accuracy & accuracy \\ 
    & 10 &  & accuracy & accuracy \\ 
    & 30 &  & accuracy & accuracy \\ \cline{2-5}
    & 1 & CIFAR10 & accuracy & accuracy\\
    & 10 & & accuracy & accuracy\\ 
    & 30 &  & accuracy & accuracy \\ \cline{2-5}
    & 1 & TinyImageNet & accuracy & accuracy \\
    & 10 & & accuracy & accuracy\\
    & 30 &  & accuracy & accuracy \\
    \hline
    \multirow{9}{2.5cm}{\centering Quantity Labels Skew} &  1 & MNIST & accuracy & accuracy \\ 
    
...

    \multirow{9}{2.5cm}{\centering Covariate Shift} & 1 & MNIST & accuracy & accuracy \\ 
    & 10 & & accuracy & accuracy \\ 
    & 30 &  & accuracy & accuracy \\ \cline{2-5}
    & 1 & CIFAR10 & accuracy & accuracy\\
    & 10 &   & accuracy & accuracy\\ 
    & 30 &  & accuracy & accuracy \\ \cline{2-5}
    & 1 & TinyImageNet  & accuracy & accuracy \\
    & 10 &  & accuracy & accuracy\\
    & 30 &  & accuracy & accuracy \\
    \hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I suggest to use the tabularray package instead of a traditional tabular.

Unrelated to the problem, but don’t use the center environment inside a float, this will add additional vertical spacing. You can use \centering instead.

\documentclass{article}

\usepackage{tabularray}

\begin{document}


\begin{table}[!hbt]
\caption{Multi-row table}
%\begin{center}
\centering
\begin{tblr}{|c|c|c|c|c|}
    \hline
    Category & Epochs per round & Dataset & FedAvg & FedCurv \\
    \hline
    \SetCell[r=9]{} Uniform Distribution &  1 & \SetCell[r=3]{} MNIST & accuracy & accuracy \\ 
    & 10 &  & accuracy & accuracy \\ 
    & 30 &  & accuracy & accuracy \\ \cline{2-5}
    & 1 & \SetCell[r=3]{}CIFAR10  & accuracy & accuracy\\
    & 10 &  & accuracy & accuracy\\ 
    & 30 &  & accuracy & accuracy \\\cline{2-5}
    & 1 & \SetCell[r=3]{}TinyImageNet & accuracy & accuracy \\
    & 10 &  & accuracy & accuracy \\
    & 30 &  & accuracy & accuracy \\
    \hline
\end{tblr}
%\end{center}
\label{tab:multicol}
\end{table}

\end{document}

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading