跨表枚举列表

跨表枚举列表

我想要一个表格内的枚举列表,但每个单元格中的项目数量不同,如下所示:在此处输入图片描述

这种方法是可行的,但当然不是列举

\begin{tabular}{| p{.45\textwidth} | p{.45\textwidth} |}
\hline
Column 1 Heading & Column 2 Heading \\
\hline
1. Item 1 & 2. Lorem ipsum dolor sit amet, consectetur adipisicing elit.. \\
                   & 3. More and more lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod. \\
\hline
4. Perhaps this text could go on for a while too & 5. Item 5 \\
\hline
\end{tabular}

答案1

您可以使用包resume*中的选项enumitem来获得连续的编号,即使在不同的enumerate环境中也是如此:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\begin{tabular}{| p{.45\textwidth} | p{.45\textwidth} |}
\hline
Column 1 Heading & Column 2 Heading \\
\hline
\begin{enumerate}[series=table,nosep,leftmargin=*,after=\vspace{-\baselineskip},before=\vspace{-0.5\baselineskip}] \item Item 1\end{enumerate} &
\begin{enumerate}[resume*=table] \item Lorem ipsum dolor sit amet, consectetur adipisicing elit.. 
                  \item More and more lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod. \end{enumerate}\\
\hline
\begin{enumerate}[resume*=table] \item Perhaps this text could go on for a while too \end{enumerate} & 
\begin{enumerate}[resume*=table] \item Item 5 \end{enumerate}\\
\hline
\end{tabular}
\end{document}

以下 MWE 包含一些有关一般表格布局的改进。使用该tabularx包,您可以均匀分布表格列,以便整个表格的宽度与文本宽度完全相同。删除垂直线并用包\hline中的适当规则替换命令booktabs可以使表格看起来更加开放:

\documentclass{article}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}
\begin{tabularx}{\textwidth}{XX}
\toprule
Column 1 Heading & Column 2 Heading \\
\midrule
\begin{enumerate}[series=table,nosep,leftmargin=*,after=\vspace{-\baselineskip},before=\vspace{-0.5\baselineskip}] \item Item 1\end{enumerate} &
\begin{enumerate}[resume*=table] \item Lorem ipsum dolor sit amet, consectetur adipisicing elit.. 
                  \item More and more lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod. \end{enumerate}\\
\begin{enumerate}[resume*=table] \item Perhaps this text could go on for a while too \end{enumerate} & 
\begin{enumerate}[resume*=table] \item Item 5 \end{enumerate}\\
\bottomrule
\end{tabularx}

\end{document}

在此处输入图片描述

如果您想在整个文档中更频繁地使用这种样式的表格,您可能还想全局定义一个已包含所有布局参数的新环境。这可以借助 和 来\newlist完成\setlist

\documentclass{article}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{booktabs}

\newlist{tabenumi}{enumerate}{1}
\setlist[tabenumi]{label={\arabic*.},nosep,leftmargin=*,after=\vspace{-\baselineskip},before=\vspace{-0.5\baselineskip}}

\begin{document}
\begin{tabularx}{\textwidth}{XX}
\toprule
Column 1 Heading & Column 2 Heading \\
\midrule
\begin{tabenumi}[series=table] \item Item 1\end{tabenumi} &
\begin{tabenumi}[resume*=table] \item Lorem ipsum dolor sit amet, consectetur adipisicing elit.. 
                  \item More and more lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod. \end{tabenumi}\\
\begin{tabenumi}[resume*=table] \item Perhaps this text could go on for a while too \end{tabenumi} & 
\begin{tabenumi}[resume*=table] \item Item 5 \end{tabenumi}\\
\bottomrule
\end{tabularx}

\end{document}

相关内容