![如何避免表格溢出(重叠)到另一侧?](https://linux22.com/image/415292/%E5%A6%82%E4%BD%95%E9%81%BF%E5%85%8D%E8%A1%A8%E6%A0%BC%E6%BA%A2%E5%87%BA%EF%BC%88%E9%87%8D%E5%8F%A0%EF%BC%89%E5%88%B0%E5%8F%A6%E4%B8%80%E4%BE%A7%EF%BC%9F.png)
如何让下面的内容变成两行而不是一行?
我想做到
Selecting Panel
(2 行)而不是Selecting Panel
(1 行)
原因是这是一个两列的页面,并且表格溢出了另一侧。
我知道有一种方法\thead
,但我无法弄清楚并且我不想改变格式\begin{tabular}{lll}
。
梅威瑟:
\documentclass{article}
\usepackage{amsmath,epsfig,times}
\usepackage{makecell, multirow, tabularx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{seqsplit, caption}
\usepackage{tabulary,siunitx}
\begin{document}
\begin{table}[htp!]
\centering
\begin{tabular}{lll}
\toprule
\multirow{2.4}{*}{\textbf{Selecting Panel}} & \multicolumn{2}{c}{\textbf{Total Item}}\\
\cmidrule{2-3}
& {\textbf{Item 1}} & {\textbf{Item 2}} \\
\midrule
Stick & Stick Stick Stick & Stick Stick Stick Stick \\
Stick & Stick Stick Stick & Stick Stick Stick Stick \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
我不会使用\thead
该功能来重置其默认值。您需要的是一个“粉碎”的标题,TeX 会将其视为不占用任何垂直空间。
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\newcommand{\smashedhead}[2][]{%
\smash{#1\begin{tabular}[t]{@{}c@{}}#2\end{tabular}}%
}
\begin{document}
\begin{table}[htp!]
\centering
\begin{tabular}{lll}
\toprule
\smashedhead[\bfseries]{Selecting\\Panel} & \multicolumn{2}{c}{\textbf{Features}}\\
\cmidrule{2-3}
& {\textbf{Item 1}} & {\textbf{Item 2}} \\
\midrule
Stick & Stick Stick & Stick Stick \\
\bottomrule
\end{tabular}
\end{table}
\end{document}