生成表格时有问题?

生成表格时有问题?

我正在使用数组包,在生成下表时遇到问题:

\begin{table}
\renewcommand{\arraystretch}{1.5}
\centering 
\caption{Design values of thermal properties of typical building materials}
\label{t:material_prop}
\begin{tabular}{l@{\hskip 1.5cm} >{\centering}p{1.5cm} >{\centering}p{1.5cm} >{\centering}p{1.5cm}}
\toprule[3pt] \toprule
\textbf{Material} & \textbf{Thermal conductivity (W/m.K)} & \textbf{Density (kg/m\textsuperscript{3})} & \textbf{Specific heat (kJ/kg.K)} \\ \midrule
Acoustic tile & 0.061 & 481 & 0.84 \\
Clay tile & 0.571 & 1121 & 0.84 \\
Common brick & 0.727 & 1922 & 0.84 \\
Dense insulation & 0.043 & 91 & 0.84 \\
Face brick & 1.333 & 2002 & 0.92 \\
Felt and membrane & 0.19 & 1121 & 1.67 \\
Finish & 0.415 & 1249 & 1.09 \\
heavy-weight concrete & 1.731 & 2243 & 0.84 \\
heavy-weight concrete block & 0.813 & 977 & 0.84 \\
Light insulation & 0.043 & 32 & 0.84 \\
light-weight concrete & 0.173 & 641 & 0.84 \\
light-weight concrete block & 0.381 & 609 & 0.84 \\
Plaster or gypsum & 0.727 & 1602 & 0.84 \\
Slag & 0.19 & 1121 & 1.67 \\
Steel siding & 44.998 & 7689 & 0.42 \\
Stone & 1.436 & 881 & 1.67 \\
Stucco & 0.692 & 1858 & 0.84 \\
Wood & 0.121 & 593 & 2.51 \\
\bottomrule \bottomrule[3pt]
\end{tabular}
\end{table}

答案1

使用S希尼奇为您提供更加整洁的表格,表格编号正确对齐。

\centering命令改变了行尾的行为\\。您需要使用来恢复它arraybackslash。我刚刚定义了一个新的 columntype P,因此代码更简洁。

但我仍然认为使用siunitx会产生更令人赏心悦目的结果。

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{P}{>{\centering\arraybackslash}p{1.5cm}}
\usepackage{siunitx}

\begin{document}

 \begin{tabular}{l@{\hskip 1.5cm} PPP }
  \toprule
  {Material} & {Thermal conductivity } & {Density} & {Specific heat} \\
  \midrule
  Acoustic tile & 0.061 & 481 & 0.84 \\
  Clay tile & 0.571 & 1121 & 0.84 \\
  \bottomrule
 \end{tabular}

\begin{table}
 \centering 
 \caption{Design values of thermal properties of typical building materials}
 \label{t:material_prop}
 \begin{tabular}{lSSS}
 \toprule
 {Material} & {Thermal conductivity } & {Density} & {Specific heat} \\
   &  \si{\watt\per\meter\per\kelvin} & \si{\kilo\gram\per\cubic\meter} &
      \si{\kilo\joule\per\kilo\gram\kelvin}\\
 \midrule
 Acoustic tile & 0.061 & 481 & 0.84 \\
 Clay tile & 0.571 & 1121 & 0.84 \\
 Common brick & 0.727 & 1922 & 0.84 \\
 Dense insulation & 0.043 & 91 & 0.84 \\
 Face brick & 1.333 & 2002 & 0.92 \\
 Felt and membrane & 0.19 & 1121 & 1.67 \\
 Finish & 0.415 & 1249 & 1.09 \\
 heavy-weight concrete & 1.731 & 2243 & 0.84 \\
 heavy-weight concrete block & 0.813 & 977 & 0.84 \\
 Light insulation & 0.043 & 32 & 0.84 \\
 light-weight concrete & 0.173 & 641 & 0.84 \\
 light-weight concrete block & 0.381 & 609 & 0.84 \\
 Plaster or gypsum & 0.727 & 1602 & 0.84 \\
 Slag & 0.19 & 1121 & 1.67 \\
 Steel siding & 44.998 & 7689 & 0.42 \\
 Stone & 1.436 & 881 & 1.67 \\
 Stucco & 0.692 & 1858 & 0.84 \\
 Wood & 0.121 & 593 & 2.51 \\
 \bottomrule 
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

相关内容