创建包含大量文本的表格时 \hbox 未满

创建包含大量文本的表格时 \hbox 未满

我对 LaTeX 以及如何在此环境中创建表格完全陌生。目前,我正在尝试使用 tabularx 创建一个在每个单元格中包含大量文本的表格。输出看起来不太糟糕,Underfull \hbox (badness 10000) in paragraph在与各个单元格相关的日志中创建了很多错误。

有没有什么办法可以修改它?

我正在尝试制作下表:

\documentclass[12pt,a4paper]{article}
\usepackage[onehalfspacing]{setspace}
\usepackage{booktabs,tabularx}

\begin{document}
\begin{table}
\centering
\caption{Diagnostic tests overview}
\setlength{\tabcolsep}{10pt}
\begin{tabularx}{\textwidth}{X p{2.8cm} p{2.8cm} p{2.8cm}}
\toprule
Test & Diagnose & $H_0$ & $H_1$ \\
\midrule
F-test & Joint significance & $\beta_0=\beta_1=\ldots=\beta_i=0$ & Some or all $\beta_i\neq0$ \\[0.7cm]
Jarque-Bera & Normality & No skewness or excess kurtosis & Non-normality \\[0.7cm]
White & Hetero\-skedasticity & Homo\-skesdasticity & Hetero\-skedasticity \\[0.7cm]
White Cross-Products (X) & Hetero\-skedasticity & Homo\-skesdasticity & Hetero\-skedasticity \\[0.7cm]
Breusch-Godfrey & Autocorrelation & No autocorrelation & Autocorrelation \\[0.7cm]
Ramsey\-RESET 1 & Misspecification & Correct specification & Misspecification \\[0.7cm]
Ramsey\-RESET 2 & Misspecification & Correct specification & Misspecification \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

答案1

底部的方框是因为 LaTeX 试图在包含很少文本的窄列中对齐文本。使用

\begin{tabularx}{\textwidth}{
>{\raggedright\arraybackslash}X 
*{3}{>{\raggedright\arraybackslash}p{2.8cm}}
}

将文本设置为参差不齐,未满警告会消失,但会收到一些过满警告

Overfull \hbox (2.05496pt too wide) in paragraph at lines 25--25
[]|\OT1/cmr/m/n/12 Misspecification|

因为该单词比列宽。如果您使用

\begin{tabularx}{\textwidth}{
>{\raggedright\arraybackslash}X 
*{3}{>{\raggedright\arraybackslash}p{2.9cm}}
}

LaTeX 非常安静。

相关内容