我试图将 a 附加minipage
到 atabularx
或 atabular
中,在 a 内table
,小型页面的宽度与 相同tabular(x)
。
我做了一个 MWE 来尝试一些东西,但这带来了一个新的问题,尽管与主题无关:在下面的 MWE 中,为什么 的值\linewidth
取决于它前面(左边)是否有任何东西?请注意 内部的值是如何变化的,tabular
只需在 之前添加文本或将其设置在 中bf
,而不是在 内部multicolumn
和 外部tabular
。这与水平模式或组开始的时间有关吗?我添加了\textwidth
和\columnwidth
仅供我参考。
BTT: 我怎样才能让宽度minipage
自动地与 a 的宽度相同tabular(x)
?当然,我可以手动为 a 赋予minipage
与 a 相同的宽度tabularx
,但是我如何保存 a 的宽度tabular
并在 之后\end{tabular}
但在 之前使用它\end{table}
?在那个地方,\hsize
自然具有与 的宽度完全不同的值tabular
,因此我下面的方法是无稽之谈。由于我完全不知道该怎么做,所以我将 MWE 留在这里。它显示了我想要放置 的位置minipage
(在 的位置\note{…}
)。
\documentclass[DIV=15]{scrartcl}
\usepackage{booktabs}
\newcommand{\note}[1]{%
\begin{minipage}{\hsize}%
\rule{1pt}{1.5ex} minipage of width \texttt{hsize}, inside table, but outside tabular\hfill\rule{1pt}{1.5ex}%
\end{minipage}%
}
\recalctypearea
\begin{document}
\begin{table}[h]
\centering%
\caption{\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize}
\begin{tabular}{@{}p{110mm}lllll@{}}
\toprule
There is a house a house a house a house a house a house a house a house a house a house a house a house a house & B & C & D & E & F\\
\midrule
Below: linewidth, columnwidth, hsize & B & C & D & E & F\\
\the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: a linewidth, columnwidth, hsize & B & C & D & E & F\\
a \the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: \textbf{linewidth,} columnwidth, hsize & B & C & D & E & F\\
\textbf{\the\linewidth,} \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: textwidth, \textbf{linewidth,} columnwidth, hsize & B & C & D & E & F\\
\the\textwidth, \textbf{\the\linewidth,} \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: textwidth, linewidth, columnwidth, hsize & B & C & D & E & F\\
\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
\multicolumn{6}{c}{multicol. all columns: \the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize}\\
\midrule
\multicolumn{6}{c}{multicol. all columns: --\the\textwidth--, --\the\linewidth--, --\the\columnwidth--, --\the\hsize--}\\
\bottomrule
\end{tabular}
\medskip%
Outside tabular, inside table: \the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize
\medskip%
Outside tabular, inside table: a \the\textwidth, b \the\linewidth, c \the\columnwidth, d \the\hsize
\medskip%
\note{a}
\end{table}
\end{document}
原始 MWE(大量代码):
\documentclass[pagesize, DIV=15, parskip = half-]{scrartcl}
\usepackage{booktabs}
\usepackage{tabularx}
\newcommand{\note}[1]{%
\begin{minipage}{\hsize}%
\textbf{#1}\quad\rule{1pt}{1ex}\hfill\rule{1pt}{1ex}%
\end{minipage}%
}
\newcommand{\notesonice}[2]{%
\begin{minipage}{#1}%
\textbf{#2}\quad\rule{1pt}{1ex}\hfill\rule{1pt}{1ex}%
\end{minipage}%
}
\recalctypearea
\begin{document}
textwidth, linewidth, columnwidth, hsize:\\
\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize
--textwidth--, --linewidth--, --columnwidth--, --hsize--:\\
--\the\textwidth--, --\the\linewidth--, --\the\columnwidth--, --\the\hsize--
\begin{table}[h]
\centering%
\caption{\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize}
\begin{tabular}{@{}|l|l|l|@{}}
\hline
\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize &&\\
\hline
A & B & C\\
\hline
\end{tabular}
\end{table}
\begin{table}[h]
\centering%
\caption{\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize, but without lines}
\begin{tabular}{@{}lll@{}}
\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize &&\\
A & B & C
\end{tabular}
\end{table}
\begin{table}[h]
\centering%
\caption{\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize}
\begin{tabularx}{0.95\linewidth}{@{}Xlllll@{}}
\toprule
There is a house a house a house a house a house a house a house a house a house a house a house a house a house & B & C & D & E & F\\
\midrule
Below: linewidth, columnwidth, hsize & B & C & D & E & F\\
\the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: a linewidth, columnwidth, hsize & B & C & D & E & F\\
a \the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: \textbf{linewidth,} columnwidth, hsize & B & C & D & E & F\\
\textbf{\the\linewidth,} \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: textwidth, \textbf{linewidth,} columnwidth, hsize & B & C & D & E & F\\
\the\textwidth, \textbf{\the\linewidth,} \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: textwidth, linewidth, columnwidth, hsize & B & C & D & E & F\\
\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
\multicolumn{6}{c}{multicolumn all six columns: \the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize}\\
\midrule
\multicolumn{6}{c}{multicolumn all six columns: --\the\textwidth--, --\the\linewidth--, --\the\columnwidth--, --\the\hsize--}\\
\bottomrule
\end{tabularx}
Outside tabular, inside table: \the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize
Outside tabular, inside table: a \the\textwidth, b \the\linewidth, c \the\columnwidth, d \the\hsize
\note{a}
\notesonice{0.95\linewidth}{b}
\end{table}
478.00635\,pt:\\
\rule{478.00635pt}{1pt}
355.4792\,pt:\\
\hspace*{0.025\linewidth}\rule{355.4792pt}{1pt}
\end{document}
答案1
我相信您正在寻找threeparttable
。无论如何,您可以measuredtabular
为该作业定义一个环境:
\documentclass[DIV=15]{scrartcl}
\usepackage{booktabs}
\newlength{\tabularwidth}
\newsavebox{\measuredtabularbox}
\newenvironment{measuredtabular}
{\begin{lrbox}{\measuredtabularbox}\begin{tabular}}
{\end{tabular}\end{lrbox}%
\global\tabularwidth=\wd\measuredtabularbox
\usebox{\measuredtabularbox}%
}
\recalctypearea
\begin{document}
\begin{table}[htp]
\centering
\caption{\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize}
\begin{measuredtabular}{@{}p{110mm}lllll@{}}
\toprule
There is a house a house a house a house a house a house a house a
house a house a house a house a house a house & B & C & D & E & F\\
\midrule
Below: linewidth, columnwidth, hsize & B & C & D & E & F\\
\the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: a linewidth, columnwidth, hsize & B & C & D & E & F\\
a \the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: \textbf{linewidth,} columnwidth, hsize & B & C & D & E & F\\
\textbf{\the\linewidth,} \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: textwidth, \textbf{linewidth,} columnwidth, hsize & B & C & D & E & F\\
\the\textwidth, \textbf{\the\linewidth,} \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
Below: textwidth, linewidth, columnwidth, hsize & B & C & D & E & F\\
\the\textwidth, \the\linewidth, \the\columnwidth, \the\hsize & B & C & D & E & F\\
\midrule
\multicolumn{6}{c}{multicol. all columns: \the\textwidth, \the\linewidth,
\the\columnwidth, \the\hsize}\\
\midrule
\multicolumn{6}{c}{multicol. all columns: --\the\textwidth--, --\the\linewidth--,
--\the\columnwidth--, --\the\hsize--}\\
\bottomrule
\end{measuredtabular}
\medskip
\begin{minipage}{\tabularwidth}
There is a house a house a house a house a house a house a house
a house a house a house a house a house a house
a house a house a house a house a house a house
a house a house a house a house a house a house
a house a house a house a house a house a house
a house a house a house a house a house a house
\end{minipage}
\end{table}
\end{document}
您不需要此类东西,tabular*
也不tabularx
需要明确设置宽度,这样您就知道了。