如何在表格单元格内插入编号列表?
我想展示两种不同程序的比较以及它们如何改变一组序列。
答案1
您可以使用p{}
类型列或者仅插入 parbox。
选项1:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{p{.45\textwidth}p{.45\textwidth}}
\toprule Head & Head\\\midrule
\begin{enumerate}
\item Test
\item Second
\end{enumerate} & \begin{enumerate}
\item Test
\item Second
\item Third
\end{enumerate}\\\bottomrule
\end{tabular}
\end{document}
选项 2:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ll}
\toprule Head & Head\\\midrule
\parbox{.45\textwidth}{\begin{enumerate}
\item Test
\item Second
\end{enumerate}} & \parbox{.45\textwidth}{\begin{enumerate}
\item Test
\item Second
\item Third
\end{enumerate}}\\\bottomrule
\end{tabular}
\end{document}
答案2
以下是一些改进,包括tabularx
和:enumitem
makecell
\documentclass{article}
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{tabularx, makecell}%
\renewcommand\theadfont{\normalsize\bfseries}
\usepackage{etoolbox} %
\AtBeginEnvironment{tabularx}{\setlist[enumerate, 1]{wide, leftmargin=*, itemsep=0pt, before=\vspace{-\dimexpr\baselineskip +2 \partopsep}, after=\vspace{-\baselineskip}}}
\begin{document}
\begin{tabularx}{\linewidth}{XX}
\toprule %
\thead{Head} & \thead{Head}\\%
\cmidrule[\lightrulewidth](lr){1-2}
\begin{enumerate}
\item Test
\item Second
\end{enumerate} & \begin{enumerate}%
\item Test
\item Second
\item Third
\end{enumerate}\\%
\bottomrule
\end{tabularx}
\end{document}