如何在多行表中插入方括号?

如何在多行表中插入方括号?

我尝试在多行表格中插入方括号。如图所示,从第四行第二列到第七行第三列,我想在每个单元格的右侧插入方括号和“/times2”。

这是我的开始代码,

\begin{table}
\centering
\scalebox{0.7}{
\begin{tabular}{c|c|c|c}
\hline
Type & VoVNet-39 & VoVNet-29 & Output\\ \hline
Stem & \begin{tabular}[c]{@{}c@{}}3x3 conv, 64,  stride=2\\ 3x3 conv, 64,  stride=1\\ 3x3 conv, 128, stride=1\end{tabular} & \begin{tabular}[c]{@{}c@{}}3x3 conv, 32, stride=2\\ 3x3 conv, 32, stride=1\\ 3x3 conv, 64, stride=1\end{tabular} & \begin{tabular}[c]{@{}c@{}}112\\ 112\\ 112\end{tabular} \\ \hline
Pooling  & 3x3 max pool, stride=2 & 3x3 max pool, stride=2  & 56x56  \\ \hline
\begin{tabular}[c]{@{}c@{}}DRF block\\ stage 2\end{tabular} & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 128{]}x5  \\ concat \& {[}1x1 conv, 256{]}\end{tabular}   & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 64{]}x5\\ concat \& {[}1x1 conv, 64{]}\end{tabular} & 56x56 \\ \hline
\begin{tabular}[c]{@{}c@{}}DRF block\\ stage 3\end{tabular} & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 160{]}x5\\ concat \& {[}1x1 conv, 512{]}\end{tabular}  & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 80{]}x5\\ concat \& {[}1x1 conv, 128{]}\end{tabular} & 28x28  \\ \hline
\begin{tabular}[c]{@{}c@{}}DRF block\\ stage 4\end{tabular} & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 192{]}x5\\ concat \& {[}1x1 conv, 786{]}\end{tabular}  & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 192{]}x5\\ concat \& {[}1x1 conv, 786{]}\end{tabular} & 14x14  \\ \hline
\begin{tabular}[c]{@{}c@{}}DRF block\\ stage 5\end{tabular} & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 192{]}x5\\ concat \& {[}1x1 conv, 786{]}\end{tabular}  & \begin{tabular}[c]{@{}c@{}}{[}3x3 conv, 192{]}x5\\ concat \& {[}1x1 conv, 786{]}\end{tabular} & 7x7  \\ \hline
\end{tabular}
}
\vspace{-0.35cm}
\end{table}

答案1

我建议删除那些对表格的理解没有任何帮助的垂直规则(它们实际上妨碍了阅读)。

对于拆分单元格,最好定义一个特定命令,该命令可以与另一个命令一起补充以将它们括起来。

而不是x我用的\texttimes

不要缩放您的表格;这里\small对于标准文本宽度来说已经足够了article:尝试您自己的设置。

\documentclass{article}
\usepackage{textcomp,array,booktabs}

\newcommand{\splitcell}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}
\newcommand{\bsplitcell}[1]{$\left[\splitcell{#1}\right]$}

\begin{document}

\begin{table}
\centering

\small
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lccc@{}}
\toprule
Type & VoVNet-39 & VoVNet-29 & Output\\
\midrule
Stem &
  \splitcell{3\texttimes3 conv, 64,  stride=2\\ 3\texttimes3 conv, 64,  stride=1\\
             3\texttimes3 conv, 128, stride=1} &
  \splitcell{3\texttimes3 conv, 32, stride=2\\ 3\texttimes3 conv, 32, stride=1\\
             3\texttimes3 conv, 64, stride=1} &
  \splitcell{112\\ 112\\ 112} \\
\midrule
Pooling  & 3\texttimes3 maxpool, stride=2 & 3\texttimes3 maxpool, stride=2  & 56\texttimes56  \\
\midrule
\splitcell{DRF block\\ stage 2} &
  \bsplitcell{3\texttimes3 conv, 128\texttimes5  \\ concat \& 1\texttimes1 conv, 256}\texttimes2 &
  \bsplitcell{3\texttimes3 conv, 64\texttimes5 \\ concat \& 1\texttimes1 conv, 64}\texttimes2 &
  56\texttimes56 \\
\midrule
\splitcell{DRF block\\ stage 3} &
  \bsplitcell{3\texttimes3 conv, 160\texttimes5 \\ concat \& 1\texttimes1 conv, 512}\texttimes2 &
  \bsplitcell{3\texttimes3 conv, 80\texttimes5 \\ concat \& 1\texttimes1 conv, 128}\texttimes2 &
  28\texttimes28 \\
\midrule
\splitcell{DRF block\\ stage 4} &
  \bsplitcell{3\texttimes3 conv, 192\texttimes5 \\ concat \& 1\texttimes1 conv, 786}\texttimes2 &
  \bsplitcell{3\texttimes3 conv, 192\texttimes5\\ concat \& 1\texttimes1 conv, 786}\texttimes2 &
  14\texttimes14 \\
\midrule
\splitcell{DRF block\\ stage 5} &
  \bsplitcell{3\texttimes3 conv, 192\texttimes5\\ concat \& 1\texttimes1 conv, 786}\texttimes2 &
  \bsplitcell{3\texttimes3 conv, 192\texttimes5\\ concat \& 1\texttimes1 conv, 786}\texttimes2 &
  7\texttimes7 \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

在此处输入图片描述

答案2

使用makecell包:

%\bgroup
%\def\arraystretch{1.2}
\begin{tabular}{c|c|c|c}
    \hline
    Type & VoVNet-39 & VoVNet-29 & Output \\
    \hline
    Stem &
    \makecell{
        3x3 conv, 64,  stride=2\\
        3x3 conv, 64,  stride=1\\ 
        3x3 conv, 128, stride=1
    }
    & 
    \makecell{
        3x3 conv, 32,  stride=2\\
        3x3 conv, 32,  stride=1\\ 
        3x3 conv, 64, stride=1
    }
    &
    \makecell{112\\112\\112}\\
    \hline
    Pooling & 3x3 max pool, stride=2 & 3x3 max pool, stride=2 & 56x56 \\
    \hline
    \makecell{
        DRF block\\
        stage 1
    } 
    &
    $\Big[$
    \makecell{
        [3x3 conv, 128]x5\\
        concat \& [1x1 conv, 256]
    }
    $\Big]\times2$
    &
    $\Big[$
    \makecell{
        [3x3 conv, 64]x5\\
        concat \& [1x1 conv, 64]
    }
    $\Big]\times2$
    & 56x56\\
    \hline
\end{tabular}
%\egroup

在此处输入图片描述

我建议表格应该更简单一些,或者你应该给我们提供一个最小工作示例(MWE)。这样的话,上面的代码就会简单得多。

希望它能帮助你!

相关内容