单元格表中的垂直对齐 Latex

Cas*_*aJr 5 latex

我在 Latex 中创建了这个表: 桌子 正如您所看到的,数据集列中的文本(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}
Run Code Online (Sandbox Code Playgroud)

sam*_*ter 5

我建议使用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}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述