我正在使用longtable
和enumitem
并希望枚举 longtable 中的项目。我正在为 RFQ 制作一个模板,需要枚举具有节/小节编号的所有点。我有一个 MWE 示例(如下所示)和一个不起作用的示例。我想使用 enumitem 的标签函数来识别项目,同时保持一致的格式(即,如在文档的其余部分中使用的格式),这就是 MWE 不够强大而无法满足要求的原因。我尝试制作一个计数器,然后定义一个标签,但它无法编译。我愿意接受其他解决方案。谢谢大家!
我的想法如下: 自动表格行号
\documentclass{article}
\usepackage{longtable}
\usepackage{enumitem}
\setenumerate[1]{label=\thesection.\arabic*.}
\setenumerate[2]{label*=\arabic*.}
%% Counters
\newcounter{magicrownumbers}
\newcommand\rownumber{\stepcounter{magicrownumbers}\arabic{magicrownumbers}}
\begin{document}
\begin{center}
\renewcommand{\arraystretch}{1.2}
\begin{longtable}{| l | l|}
\hline
\multicolumn{1}{|c|}{\textbf{Description}} & \multicolumn{1}{c|}{\textbf{File Types}} \\
\hline
\endfirsthead
\multicolumn{2}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline
\multicolumn{1}{|c|}{\textbf{Description}} & \multicolumn{1}{c|}{\textbf{File Types}}\\ \hline
\endhead
\hline
\multicolumn{2}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\hline
\endlastfoot
\thesection.\rownumber. Controls One-line & Visio or AutoCAD 2015 \\ %%<-- Works by has issues when text takes two lines
\begin{enumerate}[label = {\thesection.\rownumber.}] \item Mechanical Layout \end{enumerate} & AutoCAD 2015 \\ %%<----Doesn't work
\end{longtable}
\end{center}
\end{document}
答案1
具有自动行计数和专门环境的版本enumerate
。
在我看来,enumerate
那里的环境并不健康。
\documentclass{article}
\usepackage{longtable}
\usepackage{enumitem}
\usepackage{array}
\usepackage{chngcntr}
\newlist{rownumbers}{enumerate}{2}
\setlist[rownumbers,1]{label=\thesection.\arabic*,resume}
\setlist[rownumbers,2]{label*=\arabic*}
% Counter is named rownumbersi !!!!
% Let it restart with the next table!
\counterwithin{rownumbersi}{table}
%% Counters
%\setenumerate[1]{label=\thesection.\arabic*.}
%\setenumerate[2]{label*=\arabic*.}
%\newcounter{magicrownumbers}
%\newcommand\rownumber{\stepcounter{magicrownumbers}\arabic{magicrownumbers}}
\newcommand\rownumber{\stepcounter{rownumbersi}\therownumbersi}
\newcolumntype{N}[1]{>{\raggedleft\rownumber}p{#1}}
\newcolumntype{L}[1]{>{\raggedright}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\renewcommand{\arraystretch}{1.2}
\begin{longtable}{|L{5cm} | L{2in}|}
\hline
\multicolumn{1}{|c|}{\textbf{Description}} & \multicolumn{1}{c|}{\textbf{File Types}} \\
\hline
\endfirsthead
\multicolumn{2}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline
\multicolumn{1}{|c|}{\textbf{Description}} & \multicolumn{1}{c|}{\textbf{File Types}}\\ \hline
\endhead
\hline
\multicolumn{2}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\hline
\endlastfoot
%\thesection.\rownumber. Controls One-line & Visio or AutoCAD 2015 \\ %%<-- Works by has issues when text takes two lines
\begin{rownumbers}
\item Mechanical Layout
\item Foo
\item Some stuff
\end{rownumbers} & AutoCAD 2015 \tabularnewline %%<----Doesn't work
\end{longtable}
\end{document}