将一张桌子放在乳胶中,标题放在细胞上方

问题描述 投票:0回答:1

我有一张桌子可以放在边缘。我还希望将EPS和PPS添加到单元格的中间,并将这两个加入。我不确定为什么添加标题也不起作用。这是代码:

  \begin{tabular}{ |p{3cm}||p{3cm}|p{3cm}|p{3cm}|p{3cm}|  }
   \multicolumn{5}{c}{} \\
 \hline
&EPS:Pre &EPS:Post &PPS:Pre & PPS:Post \\
\hline
 Species tested:&13 &15& 43& 43\\
 Compounds tested:& 745 & 745& 310& 361 \\
Unique tests:& 193& 193& 406& 407\\
  Total experiments:&17,811 &17,929& 107,470& 130,926\\ 
   \hline
   \end{tabular}
   \label{tab}

谢谢。

latex centering
1个回答
2
投票

那里有几个问题。

  1. 你的桌子太大了,有边距和柱间距。我做了一个宏来精细调整列宽。
  2. 要重新定义列(例如,使标题居中),可以使用`\ multicolumn {1} {c} {header}
  3. \ label指定在编号环境中使用的数字。它与table环境有关,而与tabular无关。标签出现在caption内。此外,表格在表格环境中居中。
\documentclass{article}

\begin{document}
\newcommand{\colwidth}{0.17\textwidth}
\newcommand{\centercolumn}[1]{\multicolumn{1}{c|}{#1}}
\begin{table}
  \centering
  \begin{tabular}{ |p{3cm}||p{\colwidth}|p{\colwidth}|p{\colwidth}|p{\colwidth}|  }
    % \multicolumn{5}{c}{} \\ useless, I think
    \hline
    &\centercolumn{EPS:Pre} &\centercolumn{EPS:Post} &\centercolumn{PPS:Pre} & \centercolumn{PPS:Post} \\
    \hline
    Species tested:&13 &15& 43& 43\\
    Compounds tested:& 745 & 745& 310& 361 \\
    Unique tests:& 193& 193& 406& 407\\
    Total experiments:&17,811 &17,929& 107,470& 130,926\\ 
    \hline
  \end{tabular}
  \caption{My table}
  \label{tab:1}
\end{table}
\end{document}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.