如何在表格中换行文字(LaTeX)?

如何在表格中换行文字(LaTeX)?

我一直试图将该表格包含在我的 LaTeX 文档中,但无法使其工作。

代码

\begin{table}[]
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Anode Voltage (kV)} & \multicolumn{3}{c|}{Peak Intensity of Cu K (Counts)} & \multirow{2}{*}{Average Peak Intensity (Counts)} & \multirow{2}{*}{Standard Deviation} \\ \cline{2-4}
 & Reading 1 & Reading 2 & Reading 3 &  &  \\ \hline
12 & 1195603 & 1217383 & 1243457 & 1218814 & ± 23959 \\ \hline
14 & 2843477 & 2902688 & 2956431 & 2900865 & ± 56499 \\ \hline
16 & 5323053 & 5638567 & 5476203 & 5479274 & ± 157779 \\ \hline
18 & 7825059 & 8089811 & 7906875 & 7940581 & ± 135556 \\ \hline
20 & 14743612 & 14799927 & 15101689 & 14881742 & ± 192549 \\ \hline
\end{tabular}
\end{table}

输出

表格输出

我甚至尝试使用 Tabulary,但后来又遇到了另一个问题。

代码

\begin{table}[]
\begin{tabulary}{\textwidth}{|C|C|C|C|C|C|}
\hline
\multirow{2}{*}{Anode Voltage (kV)} & \multicolumn{3}{c|}{Peak Intensity of Cu K (Counts)} & \multirow{2}{*}{Average Peak Intensity (Counts)} & \multirow{2}{*}{Standard Deviation} \\ \cline{2-4}
 & Reading 1 & Reading 2 & Reading 3 &  &  \\ \hline
12 & 1195603 & 1217383 & 1243457 & 1218814 & ± 23959 \\ \hline
14 & 2843477 & 2902688 & 2956431 & 2900865 & ± 56499 \\ \hline
16 & 5323053 & 5638567 & 5476203 & 5479274 & ± 157779 \\ \hline
18 & 7825059 & 8089811 & 7906875 & 7940581 & ± 135556 \\ \hline
20 & 14743612 & 14799927 & 15101689 & 14881742 & ± 192549 \\ \hline
\end{tabulary}
\end{table}

输出

表格输出

任何帮助都将不胜感激。提前致谢!

编辑

下面给出了一个似乎可行的解决方案。但是,这会过度减小表格的总宽度。

代码

\begin{table}[]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Anode Voltage (kV)} &
  \multicolumn{3}{c|}{Peak Intensity of Cu K (Counts)} &
  \multirow{2}{*}{Average Peak Intensity (Counts)} &
  \multirow{2}{*}{Standard Deviation} \\ \cline{2-4}
   & Reading 1 & Reading 2 & Reading 3 &          &          \\ \hline
12 & 1195603   & 1217383   & 1243457   & 1218814  & ± 23959  \\ \hline
14 & 2843477   & 2902688   & 2956431   & 2900865  & ± 56499  \\ \hline
16 & 5323053   & 5638567   & 5476203   & 5479274  & ± 157779 \\ \hline
18 & 7825059   & 8089811   & 7906875   & 7940581  & ± 135556 \\ \hline
20 & 14743612  & 14799927  & 15101689  & 14881742 & ± 192549 \\ \hline
\end{tabular}%
}
\end{table}

答案1

也许这样——

在此处输入图片描述

\begin{table}[]\setcellgapes{3pt}
    \makegapedcells
    \begin{tabular}{>{\centering\arraybackslash}p{0.5in}p{1in}p{1in}p{1in}>{\centering\arraybackslash}p{1in}>{\centering\arraybackslash}p{1in}}
        \hline
        {Anode Voltage (kV)} & 
        \multicolumn{3}{c}{Peak Intensity of Cu K (Counts)} & 
        {Average Peak Intensity (Counts)} & 
        {Standard Deviation} \\ 
        \cline{2-4}
        & Reading 1 & Reading 2 & Reading 3 &  &  \\ \hline
        12 & 1195603 & 1217383 & 1243457 & 1218814 & ± 23959 \\ \hline
        14 & 2843477 & 2902688 & 2956431 & 2900865 & ± 56499 \\ \hline
        16 & 5323053 & 5638567 & 5476203 & 5479274 & ± 157779 \\ \hline
        18 & 7825059 & 8089811 & 7906875 & 7940581 & ± 135556 \\ \hline
        20 & 14743612 & 14799927 & 15101689 & 14881742 & ± 192549 \\ \hline
    \end{tabular}
\end{table}

相关内容