文字和线条为何如此接近?

文字和线条为何如此接近?
\begin{table}[htbp]
\centering
\caption{}\label{TABfeatures}
\begin{tabular}
{|c|c|c|}
\hline
layername& 18layer& xx\\
\hline
ss & \multicolumn{2}{c|}{xx}\\
\hline
\multirow{3}{*}{fdsfs} &  $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $ & sf \\
\cline{2-3}
& $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $& fsd\\
\hline
xx & fds & fsd\\
\hline
\end{tabular}
\end{table}

在此处输入图片描述

答案1

以下是表格的 4 个不同版本:

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{caption} 

% Only used in first example:
\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{0.5\tabcolsep}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}

% Only used in second example:
\usepackage{makecell}
\setcellgapes{0.5\tabcolsep}

% Only used in third example:
\usepackage{booktabs}

% Only used in last example:
\usepackage{nicematrix}
\NiceMatrixOptions{cell-space-limits = 0.5\tabcolsep}

\begin{document}

\begin{table}[htbp]
\centering
\caption{with cellspace}\label{TABfeatures}
\begin{tabular}{|0c|0c|0c|}
\hline
layername& 18layer& xx\\
\hline
ss & \multicolumn{2}{c|}{xx}\\
\hline
\multirow{3.5}{*}{fdsfs} &  $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $ & sf \\
\cline{2-3}
& $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $& fsd\\
\hline
xx & fds & fsd\\
\hline
\end{tabular}
\end{table}


\begin{table}[htbp]
\centering
\makegapedcells
\caption{with makecell}\label{TABfeatures}
\begin{tabular}{|c|c|c|}
\hline
layername& 18layer& xx\\
\hline
ss & \multicolumn{2}{c|}{xx}\\
\hline
\multirow{3.5}{*}{fdsfs} &  $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $ & sf \\
\cline{2-3}
& $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $& fsd\\
\hline
xx & fds & fsd\\
\hline
\end{tabular}
\end{table}

\begin{table}[htbp]
\centering
\caption{with booktabs}\label{TABfeatures}
\begin{tabular}{ccc}
\toprule
layername& 18layer& xx\\
\midrule
ss & \multicolumn{2}{c}{xx}\\
\addlinespace
\multirow{3.5}{*}{fdsfs} &  $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $ & sf \\
\addlinespace
& $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $& fsd\\
\addlinespace
xx & fds & fsd\\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[htbp]
\centering
\caption{with nicematrix}\label{TABfeatures}
\begin{NiceTabular}{ccc}[hvlines]
layername& 18layer& xx\\
ss & \Block{1-2}{xx}\\
\Block{2-1}{fdsfs} &  $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $ & sf \\
& $\left[\begin{array}{l}3 \times 3,64 \\ 3 \times 3,64\end{array}\right] \times 3 $& fsd\\
xx & fds & fsd\\
\end{NiceTabular}
\end{table}

\end{document}

答案2

在这里,我定义了一个\mystrut命令,它将产生问题的矩阵的行数作为参数;它生成一个具有同样多的行数加上一行减 1ex 的幻影矩阵。

我还添加了一个带有“无笼”表的不同解决方案。

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{multirow} % first solution
\usepackage{booktabs} % second solution

\sisetup{output-decimal-marker={,}}

% you may need \usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\mystrut}{m}
 {
  \vphantom
   {
    \begin{matrix} \prg_replicate:nn { #1 + 1 } { \\ }[-1ex] \end{matrix}
   }
 }
\ExplSyntaxOff

\begin{document}

\begin{tabular}{|c|c|c|}
\hline
layername & 18layer & xx\\
\hline
ss & \multicolumn{2}{c|}{xx}\\
\hline
\multirow{4}{*}{fdsfs}
  & $\mystrut{2} \begin{bmatrix} 3 \times \num{3,64} \\ 3 \times \num{3,64} \end{bmatrix} \times 3$
  & sf \\
\cline{2-3}
  & $\mystrut{2} \begin{bmatrix} 3 \times \num{3,64} \\ 3 \times \num{3,64} \end{bmatrix} \times 3$
  & fsd\\
\hline
xx & fds & fsd\\
\hline
\end{tabular}

\bigskip

\begin{tabular}{@{}ccc@{}}
\toprule
layername & 18layer & xx \\
\cmidrule(r){1-1} \cmidrule(l){2-3}
ss & \multicolumn{2}{c}{xx}\\
\midrule
fdsfs
  & $ \begin{bmatrix} 3 \times \num{3,64} \\ 3 \times \num{3,64} \end{bmatrix} \times 3$
  & sf \\
\addlinespace
  & $ \begin{bmatrix} 3 \times \num{3,64} \\ 3 \times \num{3,64} \end{bmatrix} \times 3$
  & fsd\\
\midrule
xx & fds & fsd\\
\bottomrule
\end{tabular}

\end{document}

在第二个表中,不需要\multirow,因为很明显指fsdf的是整个块。

在此处输入图片描述

相关内容