我正在制作一个好看的浮动枚举。还需要做的是在第一个枚举项上方添加 booktabs 的 toprule,在最后一个枚举项下方添加 booktab 的 bottomrule。我为什么要这样做?因为这可以让读者更清楚地知道这不是文内枚举。我的请求的草图:
问题:toprule 和 bottomrule 似乎是为表格设计的
问题1:如何优雅地完成我的案例?最终结果优雅,代码优雅。
我认为最终结果的优雅主要涉及
(1)第一项和顶部规则之间的垂直间距是多少?最后一项和底部规则之间也一样。为了保持一致性,也许这个间距应该与表格的间距相同,也许应该更大一些,因为枚举项之间的垂直间距大于表格行之间的垂直间距。我愿意在这里提出设计想法。
(2)toprule 和其上方的常规文本之间的垂直间距是多少?bottomrule 和其下方的标题之间也一样。我的直觉告诉我这不是问题,垂直间距应该与表格相同。不过,我并不熟悉 toprule 和 bottomrule 的复杂性。
问题2加分项:
我使用 booktab 的 toprule 和 bottomrule 撰写论文,但我希望提交的期刊使用 revtex。Revtex 也有自己的等效版本:
\def\toprule{\hline\hline}%
\def\botrule{\hline\hline}%
如果您的解决方案需要对 revtex 的 toprule 和 botrule 进行调整,您能否向我演示如何操作?
我目前最好的 MWE 是:
\documentclass{article}
\usepackage{booktabs}
%For my floating enumerate
\usepackage{trivfloat}
\trivfloat{enum}
\usepackage{enumitem}
\usepackage{calc}
%Allocate several lengths to be used later on
\newlength{\lengtha}
\newlength{\lengthb}
\newlength{\lengthc}
\begin{document}
Some test sentences are written here. Some test sentences are written here. Some test sentences are written here.
%My centered floating enumerate
\setlength{\lengtha}{\widthof{2.} + \labelsep + \widthof{A description of the second step is written here}}
\setlength{\lengthb}{\textwidth-\lengtha}
\setlength{\lengthc}{\lengthb/2}
\begin{enum}[!h]
\begin{enumerate}[leftmargin=*, label={}, labelwidth=0mm, labelindent=\lengthc]
\item 1.\hspace{\labelsep}First step in a procedure\\
A description of the first step is written here
\item 2.\hspace{\labelsep}Second step in a procedure\\
A description of the second step is written here
\item 3.\hspace{\labelsep}Third step in a procedure\\
A description of the third step is written here
\end{enumerate}
\caption{My floating enum}
\end{enum}
Some test sentences are written here. Some test sentences are written here. Some test sentences are written here.
\end{document}
答案1
toprule
我没有选择拟合和bottomrule
枚举, 而是选择了表格并更改了其垂直间距以反映枚举。我得到了四个结果:
1) 常规表格带有toprule
和bottomrule
。与 进行比较。
2) 带有枚举itemsep
项间距的表格。
看起来有点太拥挤,项与规则之间的间距应该更大3)设置
为 的浮动枚举(通常设置为 0.4ex)设置为 0.65/0.4* (通常设置为 0.65ex) 这样看起来不错4)设置 为 的浮动枚举(在枚举中是第一个/最后一个项与周围文本之间的间距(在正常情况下))也设置为 不好,看起来更像是两个部分之间的分隔规则,而不是属于枚举。
aboverulesep
itemsep
aboverulesep
itemsep
aboverulesep
topsep
topsep
belowrulesep
topsep
toprule
Revtex 的aboverulesep
and没有and ,因此我在两种情况下都插入了一个空格。请参阅以下代码中的最后一个注释版本:belowrulesep
toprule
botrule
itemsep
\documentclass{article}
\usepackage{booktabs}
%For my floating enumerate
\usepackage{trivfloat}
\trivfloat{enum}
\usepackage{enumitem}
\usepackage{calc}
%Allocate several lengths to be used later on
\newlength{\lengtha}
\newlength{\lengthb}
\newlength{\lengthc}
%Fit results on one page
\usepackage[top=2cm, bottom=2cm]{geometry}
\begin{document}
\noindent
Regular table.
Some test sentences are written here. Some test sentences are written here.
\begin{table}[!h]
\centering
\begin{tabular}{@{}l@{}}
\toprule
some item is written here\\
some item is written here\\
some item is written here\\
some item is written here\\
\bottomrule
\end{tabular}
\caption{Some caption here.}
\end{table}
Some test sentences are written here. Some test sentences are written here.
Some test sentences are written here. Some test sentences are written here.
\\
\\
Table with enumerate spacing between items.
Some test sentences are written here. Some test sentences are written here.
\begin{table}[!h]
\centering
\begin{tabular}{@{}l@{}}
\toprule
some item is written here\\[\itemsep]
some item is written here\\[\itemsep]
some item is written here\\[\itemsep]
some item is written here\\
\bottomrule
\end{tabular}
\caption{Some caption here.}
\end{table}
Some test sentences are written here. Some test sentences are written here.
Some test sentences are written here. Some test sentences are written here.
Some test sentences are written here. Some test sentences are written here.
\\
\\
Enum with enumerate spacing between items and relative itemsep spacing.
\begin{enum}[!h]
\centering
\setlength{\lengtha}{\belowrulesep / \aboverulesep * \itemsep}
\setlength{\belowrulesep}{\lengtha}
\setlength{\aboverulesep}{\itemsep}
\begin{tabular}{@{}l@{}}
\toprule
some item is written here\\[\itemsep]
some item is written here\\[\itemsep]
some item is written here\\[\itemsep]
some item is written here\\
\bottomrule
\end{tabular}
\caption{Some caption here.}
\end{enum}
Some test sentences are written here. Some test sentences are written here.
Some test sentences are written here. Some test sentences are written here.
\\
\\
Enum with enumerate spacing between items and absolute topsep spacing.
Some test sentences are written here. Some test sentences are written here.
\begin{enum}[!h]
\centering
\setlength{\aboverulesep}{\topsep}
\setlength{\belowrulesep}{\topsep}
\begin{tabular}{@{}l@{}}
\toprule
some item is written here\\[\itemsep]
some item is written here\\[\itemsep]
some item is written here\\[\itemsep]
some item is written here\\
\bottomrule
\end{tabular}
\caption{Some caption here.}
\end{enum}
Some test sentences are written here. Some test sentences are written here.
Some test sentences are written here. Some test sentences are written here.
Some test sentences are written here. Some test sentences are written here.
%\\
%\\
%Revtex solution:
% \begin{enum}[!h]
% \centering
% \begin{tabular}{@{}l@{}}
% \toprule
% \noalign{\vskip \itemsep}
% some item is written here\\[\itemsep]
% some item is written here\\[\itemsep]
% some item is written here\\[\itemsep]
% some item is written here\\[\itemsep]
% \botrule
% \end{tabular}
% \caption{Some caption here.}
% \end{enum}
\end{document}