latex - 表中未满 \hbox (badness 10000)
问题描述
我有下一张桌子,但它显示了标题的警告。
\begin{table}[!hbt]
\centering
\caption{Learning Types}
\begin{tabular}{| p{0.14\textwidth} | p{0.42\textwidth} | p{0.34\textwidth} |}
\hline Supervised Learning & The data you feed to the algorithm is labeled.
It is often used for classification and regression & \Centerstack{\\k-Nearest Neighbors\\Linear Regression\\
Logistic Regression\\Support Vector Machines (SVMs)\\
Decision Trees and Random Forests\\Neural networks\\} \tabularnewline
\hline Unsupervised Learning & hh & hh \tabularnewline
\hline Semi-supervised Learning & hh & hh \tabularnewline
\hline Reinforcement Learning & hh & hh \tabularnewline \hline
\end{tabular}
\end{table}
我搜索过,有人说是因为 \\(现在是 \tabularnewline),但我不知道如何使警告消失。
解决方案
列p{<len>}
规范试图证明任何多行内容的合理性,将其拉伸,使其与列边界左对齐和右对齐(最后一行除外)。在您的情况下,无法伸展Supervised
以完全适合0.14\textwidth
in ,从而导致“未满\hbox
”警告。
由于该列非常窄,因此最好使用\makecell
(来自makecell
package)强制一些对齐/间距。下面我也使用了booktabs
andtabularx
来提高视觉吸引力。
\documentclass{article}
\usepackage{booktabs,makecell,tabularx}
\begin{document}
\begin{table}
\centering
\caption{Learning Types}
\begin{tabularx}{\linewidth}{ l X l }
\toprule
\thead{Type} & \thead{Description} & \thead{Example(s)} \\
\midrule
\makecell[lt]{Supervised \\ Learning} &
The data you feed to the algorithm is labeled.
It is often used for classification and regression &
\makecell[lt]{%
$k$-Nearest Neighbors \\
Linear Regression \\
Logistic Regression \\
Support Vector Machines (SVMs) \\
Decision Trees and Random Forests \\
Neural networks%
} \\
\addlinespace[10pt]
\makecell[lt]{Unsupervised \\ Learning} & Description & Example(s) \\
\addlinespace[10pt]
\makecell[lt]{Semi-supervised \\ Learning} & Description & Example(s) \\
\addlinespace[10pt]
\makecell[lt]{Reinforcement \\ Learning} & Description & Example(s) \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
推荐阅读
- php - Woocommerce 感谢页面 ajax 在桌面上工作但不是在移动设备上工作
- jenkins - 如何使用 groovy 更改计划作业的构建显示名称
- c++ - 重新定义符号的算术是如何工作的?
- docker - 尝试构建 Centos8 rootfs 和 docker 映像似乎挂在所需的用户交互上,无法访问
- python-3.x - 如何在python图像操作中消除类型转换中的值错误
- javascript - 某些提交的 Google Analytics 事件跟踪失败
- python - while 循环中的 for 循环 - For 循环不会遍历所有项目
- json.net - 如何从 json.net 中的 JProperty 获取 json 属性的值?
- javascript - 如何从组件调用 API 数据
- regex - 如何将模式转化为多个字段名称