我制作了一个 L 形的大表格,我想知道在 Latex 中是否有任何方法可以在 L 的 ege 处书写,而表格中没有任何内容。请参见下图:
因此,当扁平表格中还有剩余空间时,这个想法是为了节省空间以继续常规文档。我知道这通常看起来很糟糕,但如果表格很大(相当高),可能就不是这样了。我希望你明白我的意思。
\documentclass{scrreprt}
\usepackage{booktabs}
\usepackage{amsmath}
\begin{document}
\begin{table}[tbp]
\centering
\caption{This is a huge table. Guess what the magic number is...}
\label{magic numbers}
{\small
\begin{tabular}{lcccccccc}
\toprule
& \multicolumn{1}{c}{This} & \multicolumn{1}{c}{is} &
\multicolumn{1}{c}{is} & \multicolumn{1}{c}{This} \\
\midrule \multicolumn{4}{l}{Magic numbers} \\ \multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42\\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
\end{tabular}
}
\end{table}
\end{document}
答案1
在下面的例子中,我在par
agraph中设置了文本box
。\parbox
对齐/锚定在b
底部,高度为0pt
(以免影响 内的其他行tabular
),并从底部开始b
向上移动。 宽度计算为正好 3 列宽(存储在框 1 中的 3 个条目),加上列之间的-54.42
剩余s:\tabcolsep
\documentclass{scrreprt}% http://ctan.org/pkg/koma-script
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\begin{document}
\begin{table}[tbp]
\centering
\caption{This is a huge table. Guess what the magic number is...}
\label{ovbdiffx3to5}
\setbox1=\hbox{-54.42}
\small\begin{tabular}{*{9}{c}}
\toprule
& This & is & is & This \\
\midrule \multicolumn{4}{l}{Magic numbers} \\
A & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42\\
B & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
C & 54.42 & 54.42 & 54.42 & 54.42& -54.42& -54.42& -54.42 \\
$D$ & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
A & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
B & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
C & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
$D$ & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
A & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
B & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
C & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
$D$ & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
B & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
C & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
$D$ & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
B & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
C & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
$D$ & -54.42 & -54.42 & -54.42 & -54.42 &&&
\multicolumn{1}{r}{\relax\llap{\parbox[b][0pt][b]{\dimexpr3\wd1+3\tabcolsep}{%
Here is some text. It is enough to span multiple lines, filling in from
the bottom upwards.%
}}}
\end{tabular}
\end{table}
\end{document}
如果您的内容tabular
包含数字,请使用数学模式来设置数字(如$-54.42$
),因为它将提供一元运算符的适当间距-
。
答案2
这是一种不同的方法,它使用 Werner 的方法来计算适当的宽度。(至少我认为是这样,尽管我对 TeX 的尺寸不太了解,所以不能确定。)
\documentclass{scrreprt}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{multirow}
\begin{document}
\begin{table}[tbp]
\centering
\caption{This is a huge table. Guess what the magic number is...}
\label{ovbdiffx3to5}
\setbox1=\hbox{-54.42}
\newlength{\mycols}
\setlength{\mycols}{\dimexpr3\wd1+3\tabcolsep}
{\small
\begin{tabular}{lcccccccc}
\toprule
& \multicolumn{1}{c}{This} & \multicolumn{1}{c}{is} &
\multicolumn{1}{c}{is} & \multicolumn{1}{c}{This} \\
\midrule \multicolumn{4}{l}{Magic numbers} \\ \multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42\\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 & %
\multicolumn{3}{p{\mycols}}{\multirow{8}{\mycols}{Here is some text. It is enough to span multiple lines, filling in from the centre upwards and downwards.}}\\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
\multicolumn{1}{l}{B} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
\multicolumn{1}{l}{C} & 54.42 & 54.42 & 54.42 & 54.42 &&& \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
\end{tabular}
}
\end{table}
\end{document}
我认为,如果文本也利用表格右侧的空间,这样看起来就不会那么奇怪了,部分表格。但是,如果不放弃 booktabs,我无法让它工作。我还想知道在前一行之后使用 \cmidrule{6-8},但这会引入额外的垂直间距,因此会弄乱表格的其余部分。