![如何平等分配细胞空间?](https://linux22.com/image/249350/%E5%A6%82%E4%BD%95%E5%B9%B3%E7%AD%89%E5%88%86%E9%85%8D%E7%BB%86%E8%83%9E%E7%A9%BA%E9%97%B4%EF%BC%9F.png)
我的论文中的回归表存在问题,因为尽管代码中说明了精确的比例,但 LaTeX 并没有将单元格空间分配均等。
以下是相关代码:
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{palatino,url}
\usepackage{amssymb}
\usepackage{threeparttable}
\usepackage{caption}
\begin{document}
...
\begin{table}[htbp]\footnotesize
\caption{OLS Estimates}
\begin{center}
\begin{threeparttable}[b]
\scalebox{0.8}{%
\begin{tabular}{|p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}|}
\hline
\multicolumn{ 1}{|c|}{Constant} & \multicolumn{ 1}{|c|}{GNI} & \multicolumn{ 1}{|c|}
{CPI} & \multicolumn{ 1}{|c|}{Inflation} & \multicolumn{ 1}{|c|}{Liquidity} &
\multicolumn{ 1}{|c|}{DebtExports} & \multicolumn{ 1}{|c|}{GDPGrowth} \\ \hline
\multicolumn{ 1}{l}{} & \multicolumn{ 1}{l}{} & \multicolumn{ 1}{l}{} & \multicolumn{
1}{l}{} & \multicolumn{ 1}{l}{} & \multicolumn{ 1}{l}{} & \multicolumn{ 1}{l}{}\\\hline
\multicolumn{ 1}{|c|}{14.303\tnote{***}} & \multicolumn{ 1}{|c|}{-1.704\tnote{**}} &
\multicolumn{ 1}{|c|}{-1.28\tnote{**}} & \multicolumn{ 1}{|c|}{0.127\tnote{**}} &
\multicolumn{ 1}{|c|}{-0.042\tnote{***}} & \multicolumn{ 1}{|c|}{0.368\tnote{**}} &
\multicolumn{ 1}{|c|}{0.052} \\
\multicolumn{ 1}{|c|}{(8.91)} & \multicolumn{ 1}{|c|}{(3.01)} & \multicolumn{ 1}{|c|}
{(2.52)} & \multicolumn{ 1}{|c|}{(2.93)} & \multicolumn{ 1}{|c|}{4.47)} & \multicolumn{
1}{|c|}{(2.16)} & \multicolumn{ 1}{|c|}{(1.04)} \\ \hline
\multicolumn{ 3}{l}{Note: Absolute values of t-Statistics are reported in parentheses}
\end{tabular}}
\begin{tablenotes}
\item[\tnote{***}]Significant at the 1 percent level.
\item[\tnote{**}]Significant at the 5 percent level.
\item[\tnote{*}]Significant at the 10 percent level.
\end{tablenotes}
\end{threeparttable}
\end{center}
\label{}
\end{table}
有人知道如何让单元格 3(CPI)重新对齐吗?到目前为止,所有其他包含的表格都运行良好。
答案1
问题出在最后,\multicolumn{3}{...}
应该是\multicolumn{7}{...}
:文本不适合三个单元格,因此多余的部分放在跨越的列的最后一列中。
但是,您的输入非常复杂,我建议一种更简单的方法:
\begin{table}[htbp]\footnotesize
\caption{OLS Estimates}\label{xxx}
\centering
\begin{threeparttable}[b]
\begin{tabular}{|*{7}{>{\centering\arraybackslash}p{\dimexpr(\textwidth-2\tabcolsep)/7\relax}|}}
\hline
Constant & GNI & CPI & Inflation & Liquidity & DebtExports & GDPGrowth \\
\hline
\hline
14.303\tnote{***} & $-$1.704\tnote{**} & $-$1.28\tnote{**} & 0.127\tnote{**} &
$-$0.042\tnote{***} & 0.368\tnote{**} & 0.052 \\
(8.91) & (3.01) & (2.52) & (2.93) & (4.47) & (2.16) & (1.04) \\
\hline
\multicolumn{7}{l}{Note: Absolute values of t-Statistics are reported in parentheses}
\end{tabular}
\begin{tablenotes}
\item[\tnote{***}]Significant at the 1 percent level.
\item[\tnote{**}]Significant at the 5 percent level.
\item[\tnote{*}]Significant at the 10 percent level.
\end{tablenotes}
\end{threeparttable}
\end{table}
每列分配七分之一的可用空间,内容居中。
我还建议加载booktabs
包并避免垂直规则:tabular
将成为
\begin{tabular}{|*{7}{>{\centering\arraybackslash}p{\dimexpr(\textwidth-2\tabcolsep)/7\relax}|}}
\toprule
Constant & GNI & CPI & Inflation & Liquidity & DebtExports & GDPGrowth \\
\midrule
14.303\tnote{***} & $-$1.704\tnote{**} & $-$1.28\tnote{**} & 0.127\tnote{**} &
$-$0.042\tnote{***} & 0.368\tnote{**} & 0.052 \\
(8.91) & (3.01) & (2.52) & (2.93) & (4.47) & (2.16) & (1.04) \\
\bottomrule
\multicolumn{7}{l}{Note: Absolute values of t-Statistics are reported in parentheses}
\end{tabular}
答案2
这是因为您使用命令覆盖了列类型\multicolumn
。所以您不应该在这里使用这些列。看起来您想要让p{3cm}
文本居中;为此,您可以使用包\newcolumntype
中的命令定义一种新的列类型array
。这是您的表格,其格式为每列 1.5 厘米居中(以适合页面)。请注意,表格内容的可读性也提高了多少!
\documentclass[12pt]{article}
\usepackage{threeparttable}
\usepackage{array}
% define a new column type Z
\newcolumntype{Z}{>{\centering\hspace{0pt}\arraybackslash}p{1.5cm}}
% notice that we could have defined a parametrized column type like this:
% \newcolumntype{C}[1]{>{\centering\hspace{0pt}\arraybackslash}p{#1}}
% this would be used as C{1.5cm} inside the column definition of tabular
\begin{document}
\footnotesize
\begin{tabular}{|Z|Z|Z|Z|Z|Z|Z|}
\hline
Constant & GNI & CPI & Inflation & Liquidity & DebtExports & GDPGrowth \\
\hline
& & & & & & \\
\hline
14.303\tnote{***} & -1.704\tnote{**} & -1.28\tnote{**} & 0.127\tnote{**} & -0.042\tnote{***} & 0.368\tnote{**} & 0.052 \\
(8.91) & (3.01) & (2.52) & (2.93) & 4.47) & (2.16) & (1.04) \\
\hline
\multicolumn{7}{l}{Note: Absolute values of t-Statistics are reported in parentheses}
\end{tabular}
\begin{tablenotes}
\item[\tnote{***}]Significant at the 1 percent level.
\item[\tnote{**}]Significant at the 5 percent level.
\item[\tnote{*}]Significant at the 10 percent level.
\end{tablenotes}
\end{document}
答案3
p{3cm} 将设置列的最小宽度。但如果其中一列\multicolumn
大于该宽度,则列将进行调整。
最后一个 \multicolumn 中的注释长度超过 9 厘米,因此它会强制第三列变大。使用
\multicolumn{7}{l}{Note: Absolute values of t-Statistics are reported in parentheses}