单元格 table Latex 中的垂直对齐

Vertical alignment in cell table Latex

我在 Latex 中创建了这个 table: 如您所见,Dataset 列中的文本(MNIST、CIFAR10、...)未垂直对齐。我怎样才能把那些字符串放在单元格的中间? 这是我的代码:

\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}

我建议使用 tabularray 包而不是传统的表格。

与问题无关,但不要在浮动中使用 center 环境,这会增加额外的垂直间距。您可以改用 \centering

\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}