我创建了下面的表格。但是,有一些格式问题我无法修复。
\documentclass[9pt,twocolumn]{article}
\usepackage{tabularx}
\usepackage[format=plain, indention=1cm]{caption}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
Here some text.
%.......................................Table..................................
\begin{table*}[!htb]
\captionsetup{size=footnotesize}
\caption{Heading}
\label{tab:Test1}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}p{2cm}p{5cm}p{5cm}p{5cm}}
\hline \toprule
Col 1 & \multicolumn{2}{c}{Col 2} & Col 3\\
\hline \midrule
\multirow{4}{*}{\parbox{1.5cm}{This is row 1}}
& \multicolumn{2}{c}{Subheading 1}
& \multirow{4}{*}{\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text \\ with a line break \\ and a second one}}\\
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content}
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content} & \\
& \multicolumn{2}{c}{\parbox[t][][t]{10cm}{\centering This is a very very very very very long centered Subheading 2 over two lines}} & \\
& \multicolumn{2}{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\
\hline
\multirow{3}{*}{\parbox[t][][c]{1.5cm}{This is row 2}}
& \multicolumn{2}{c}{\parbox[t][][c]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}}
& \multirow{6}{*}{\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} \\
& \multicolumn{2}{c}{\parbox[t][][t]{2cm}{\centering Subheading 3}} & \\
& \multicolumn{2}{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\
\cline{1-3}
\multirow{3}{*}{\parbox[t][][c]{1.5cm}{This is row 3}}
& \multicolumn{2}{c}{\parbox[t][][c]{9.5cm}{fleet, older generation, preceding generation, previous generation}} & \\
& \multicolumn{2}{c}{\parbox[t][][t]{2cm}{\centering Subheading 4}} & \\
& \multicolumn{2}{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\
\bottomrule
\hline
\end{tabular*}
\end{table*}
%................
\end{document}
答案1
对于复杂的表格,这multirow
不是正确的解决方案。它超出了它的能力,因为它实际上是按行计算的,而不是按多行表格行计算的。
该包tabularray
更适合这些类型的表。这里有一个解决方案。它可能需要一些微调。例如,一些\parbox
es 可能被删除。
我把大多数\multirow
参数放在括号中,尽管它们并不需要这样。
\documentclass[twocolumn]{article}
\usepackage[format=plain, indention=1cm]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
Here some text.
%.......................................Table..................................
\begin{table*}[!htb]
\captionsetup{size=footnotesize}
\caption{Heading}
\label{tab:Test1}
\begin{tblr}{colspec={p{1.5cm} l l p{4.5cm}},colsep=2pt,width=\textwidth}
\toprule
Col 1 & \SetCell[c=2]{c}{Col 2} & & Col 3\\
\midrule
\SetCell[r=4]{l}This is row 1 & \SetCell[c=2]{c}Subheading 1 & &
\SetCell[r=4]{l}\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text \\ with a line break \\ and a second one} \\
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content}
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content} & \\
& \SetCell[c=2]{c}{\parbox[t][][t]{10cm}{\centering This is a very very very very very long centered Subheading 2 over two lines}} & & \\
& \SetCell[c=2]{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\
\hline
\SetCell[r=3]{l}This is row 2
& \SetCell[c=2]{c}{\parbox[t][][c]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}}
&
& \SetCell[r=6]{l}{\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} \\
& \SetCell[c=2]{c}{\parbox[t][][t]{2cm}{\centering Subheading 3}} & & \\
& \SetCell[c=2]{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & & \\
\cline{1-3}
\SetCell[r=3]{l}This is row 3
& \SetCell[c=2]{c}{\parbox[t][][c]{9.5cm}{fleet, older generation, preceding generation, previous generation}} & & \\
& \SetCell[c=2]{c}{\parbox[t][][t]{2cm}{\centering Subheading 4}} & \\
& \SetCell[c=2]{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & & \\
\bottomrule
\end{tblr}
\end{table*}
%................
\end{document}
答案2
- 如果您愿意使用
tabularray
包,那么您的表格并不难写。 - 您的表格示例非常庞大,无法简单化。要将其插入文档,您可以采取以下方法:
- 表格写成跨两页的长表格。在这种情况下,
tblr
应该使用longtblr
表格环境。但是,现在表格不必封装在table
浮动中,您需要更改 - 通过使用
geometry
包来增加文本区域的大小。 - 使用较小的字体大小,例如,
footnotesize
也减少\baselineskip
。
- 表格写成跨两页的长表格。在这种情况下,
- 如果实际的桌子不是那么大,则不需要上述测量。
长表解决方案:
\documentclass[twocolumn]{article}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
%\usepackage[format=plain, indention=1cm]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth}
\begin{document}
\onecolumn
\begin{longtblr}[
caption = {Heading},
label = {tab:Test1}
]{%
colspec={@{} Q[l, 3em] X[j] X[j] X[j] @{}},
row{1} = {font=\bfseries, c},
hspan = minimal,
}
\toprule
Col 1 & \SetCell[c=2]{c} Col 2
& & Col 3 \\
\midrule
& \SetCell[c=2]{c} Subheading 1
& & \\
\midrule[dashed]
\SetCell[r=2]{h} This is row 1
& content, content, content, content, content, content, content, content, content, content, content
& content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
& \SetCell[r=2]{l} {This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
with a line break \\
and a second one} \\
& & & \\
& content, content, content, content, content, content, content, content, content, content, content
& content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
& \\
\midrule
\pagebreak % <--- insert manualy
& \SetCell[c=2]{c} This is a very very very very very long centered Subheading 2 over two lines
& & \\
\midrule[dashed]
\SetCell[r=2]{h} This is row 2
& \SetCell[c=2]{j} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
& & \SetCell[r=3]{l} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
& \SetCell[c=2]{c} Subheading 3
& & \\
& \SetCell[c=2]{j} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
& & \\
\midrule
\SetCell[r=2]{h} This is row 3
& \SetCell[c=2]{c} fleet, older generation, preceding generation, previous generation
& & \\
& \SetCell[c=2]{c} Subheading 4
& & \\
& \SetCell[c=2]{c} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
& & \\
\bottomrule
\end{longtblr}
\end{document}
(红线显示页面布局)。
在以下 MWE 中,将考虑上述选项中的最后一个。表格以table*
浮点形式插入:
\documentclass[twocolumn]{article}
\usepackage[format=plain, indention=1cm]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth}
\begin{document}
\begin{table*}[!htb]
\caption{Heading}
\label{tab:Test1}
\begin{tblr}{colspec={@{} Q[l, 3em] X[j] X[j] X[j] @{}},
row{1} = {font=\bfseries, c},
hspan = minimal,
rows = {font=\footnotesize\linespread{0.84}\selectfont}
}
\toprule
Col 1 & \SetCell[c=2]{c} Col 2
& & Col 3 \\
\midrule
& \SetCell[c=2]{c} Subheading 1
& & \\
\SetCell[r=2]{h} This is row 1
& content, content, content, content, content, content, content, content, content, content, content
& content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
& \SetCell[r=2]{l} {This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
with a line break\\
and a second one} \\
& & & \\
& content, content, content, content, content, content, content, content, content, content, content
& content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
& \\
\midrule
& \SetCell[c=2]{c} This is a very very very very very long centered Subheading 2 over two lines
& & \\
\SetCell[r=2]{h} This is row 2
& \SetCell[c=2]{j} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
& & \SetCell[r=3]{l} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
& \SetCell[c=2]{c} Subheading 3
& & \\
& \SetCell[c=2]{j} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
& & \\
\midrule
\SetCell[r=2]{h} This is row 3
& \SetCell[c=2]{c} fleet, older generation, preceding generation, previous generation
& & \\
& \SetCell[c=2]{c} Subheading 4
& & \\
& \SetCell[c=2]{c} This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
& & \\
\bottomrule
\end{tblr}
\end{table*}
\end{document}