修复列宽

修复列宽

各位 Stack Exchanger 朋友,大家好,

我正在尝试创建一个表格,但所有列都混乱了,列中的文本溢出到相邻列,数字分散在多行中。

有人知道我可以使用什么代码来实现自动化吗?

如果您在 Distributed: 和一系列 \cite 命令之间插入一个空格,则 LaTeX 会插入一个换行符。下面屏幕截图中出现的 ? 标记是因为我无法解析 \cite 指令。如果需要,请在一些 \cite 命令之间插入另一个空格,以便允许另一个换行符。

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Spillover Effect onto Other Industries}\label{other industries}
\begin{tabularx}{\textwidth}{p{2cm}p{1.5cm}p{1.5cm}p{1.5cm}}
\hline\hline & \multicolumn{1}{c}{Baseline} & \multicolumn{2}{c}{Economic Slack} \\ \cmidrule{2-2} \cmidrule(lr){3-4}
 \multicolumn{1}{c}{Industries}                   &\multicolumn{1}{c}{Public Ed Construction (\$ millions)} &\multicolumn{1}{c}{Public Ed Construction (\$ millions)} &\multicolumn{1}{c}{Economic Slack Interaction}\\  
 \multirow{2}{*}{Agriculture, Forestry and Fishing}& 0.00539 & -0.0130 & 0.0231**\\ &(0.68)& (-1.04)& (2.41) \\ \multirow{2}{*}{Mining}& -0.0109* & -0.0292 & 0.0226\\ &(-2.36)&(-1.85)&(1.53) \\ \multirow{2}{*}{Manufacturing}& 0.0205 & 0.00547 & 0.0183\\&(1.43)&(0.30)& (1.71)\\ \multirow{2}{*}{Electricity, Gas, Water and Waste Services}& -0.00458* & -0.0137*** & 0.0115*\\&(-2.05)&(-4.38)& (2.07)\\ Wholesale Trade& -0.0125 & -0.0194 &  0.00875\\&(-1.52)&(-1.15)& (0.54)\\ \multirow{2}{*}{Retail Trade}& -0.0117 & -0.0170 & 0.00511 \\&(-1.00)& (-0.76)&(0.32) \\ \multirow{2}{*}{Accommodation and Food Services}& 0.00404 & 0.00193 & 0.00290\\&(1.28)&(0.17)& (0.23)\\ \multirow{2}{*}{Transport, Postal and Warehousing}& -0.00342 & 0.00612 & -0.0120\\&(-0.43)&(0.71)& (-1.45)\\ \multirow{2}{*}{Information Media and Telecommunications}& 0.00766 & 0.0126 & -0.00645\\&(1.82)&(1.88)& (-1.03)\\ \multirow{2}{*}{Financial and Insurance Services}& 0.00355 & 0.0160 & -0.0159\\&(1.20)&(1.41)& (-1.32)\\ \multirow{2}{*}{Rental, Hiring and Real Estate Services}& 0.00426 & 0.00165 &  0.00296 \\&(0.71)&(0.22) (0.53)\\ \multirow{2}{*}{Professional, Scientific and Technical Services}& -0.0009 & 0.0399** & -0.0517**\\&(-0.15)&(2.95)& (-2.52)\\ \multirow{2}{*}{Administrative and Support Services}& 0.00519* & -0.00109 & -0.0137\\&(1.92)&(-0.13)& (0.91)\\ \multirow{2}{*}{Public Administration and Safety}& -0.0110 & -0.000109 & -0.0200\\&(-1.50)&(-0.01)& (-1.55)\\ \multirow{2}{*}{Education and Training}& 0.00674 & 0.0227 &\\&(0.57)&(1.17)& -0.0311* \\ \multirow{2}{*}{Health Care and Social Assistance}& 0.00483 & 0.0298 & -0.0311*\\&(0.35)&(1.42)& (-1.25)\\ \multirow{2}{*}{Arts and Recreation Services}& 0.00415 & 0.00948* & -0.00687\\&(1.11)&(2.06)& (-1.37)\\ \multirow{2}{*}{Other Services}& -0.0129 & -0.0141 & 0.00166\\&(-1.76)&(-0.74)& (0.10)
\end{tabularx}
\end{table}
\end{document}

答案1

这是表格的一部分。其余代码可进行相应调整:

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{C}{>{\Centering}X}
\begin{document}

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Spillover Effect onto Other Industries}\label{other industries}
\begin{tabularx}{\textwidth}{p{4cm}CCC}
\toprule & \multicolumn{1}{c}{Baseline} & \multicolumn{2}{c}{Economic Slack} \\ \cmidrule{2-2} \cmidrule(lr){3-4}
 Industries                   &Public Ed Construction (\$ millions) & Public Ed Construction (\$ millions) &Economic Slack Interaction\\ 
 \midrule 
 \multirow{2}{=}{Agriculture, Forestry and Fishing}& 0.00539 & -0.0130 & 0.0231**\\ &(0.68)& (-1.04)& (2.41) \\ \addlinespace
Mining& -0.0109* & -0.0292 & 0.0226\\ &(-2.36)&(-1.85)&(1.53) \\ \addlinespace
Manufacturing& 0.0205 & 0.00547 & 0.0183\\&(1.43)&(0.30)& (1.71)\\ \addlinespace
\multirow{2}{=}{Electricity, Gas, Water and Waste Services}& -0.00458* & -0.0137*** & 0.0115*\\&(-2.05)&(-4.38)& (2.07)\\ \addlinespace
\end{tabularx}
\end{table}
\end{document}

与原版相比的变化:

  • 删除了\multicolumn表头中的命令,因为它们阻止了自动换行
  • 替换 \multirow{2}{*}\multirow{2}{=},因为后者也对多行使用声明的宽度(在本例中为 4 厘米)。
  • 添加了一些\addlinespace命令以提高可读性
  • 使用C基于数据列的类型列的新的居中类型tabularxX
  • ...

相关内容