我想要创建如下结果:
一开始我尝试使用 来实现tabbing
,但在 里面却不行enumerate
。所以我发现它可以与表格一起使用。
我怎样才能做到这一点?
- - - 编辑 - - -
这是我的序言和包裹:
\documentclass[11pt, a4paper, notitlepage]{report}
\usepackage{polski}
\usepackage[cp1250]{inputenc}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage[final]{pdfpages}
\usepackage[T1]{fontenc}
----- 编辑 2 ------
感谢@A.Ellett 对我的问题的出色回答。此外,我想为这些列添加标题,如图所示:
答案1
那么像下面这样怎么样:
\documentclass{article}
\newcounter{tablerowcounter}
\newcommand{\mytablerow}{\stepcounter{tablerowcounter}\theenumi.\arabic{tablerowcounter}}
\begin{document}
\begin{enumerate}
\item Object \par
\begin{tabular}{clll}
\mytablerow & Name & abcd & bcdf\\
\mytablerow & ABC & xyz & zyx \\
\end{tabular}
\item File \par
\begin{tabular}{clll}\setcounter{tablerowcounter}{0}%%'
\mytablerow & Name & aaa & bb \\
\mytablerow & ABC & ccc & ddd \\
\end{tabular}
\end{enumerate}
\end{document}
这是一种更加自动化且稍微更灵活的方法,它并没有硬连线到环境的第一级enumerate
。
\documentclass{article}
\newcounter{tablerowcounter}
\makeatletter
\def\myenumilevel{enum\romannumeral\the\@enumdepth}
\makeatother
\newcommand{\mytablerow}{%%'
\stepcounter{tablerowcounter}%%'
\arabic{\myenumilevel}.\arabic{tablerowcounter}.}
\newenvironment{mytablelist}[1]
{\par\setcounter{tablerowcounter}{0}%'
\begin{tabular}{#1}}
{\end{tabular}}
\begin{document}
\begin{enumerate}
\item Object
\begin{mytablelist}{clll}
\mytablerow & Name & abcd & bcdf\\
\mytablerow & ABC & xyz & zyx \\
\end{mytablelist}
\item File
\begin{mytablelist}{clll}
\mytablerow & Name & aaa & bb \\
\mytablerow & ABC & ccc & ddd \\
\end{mytablelist}
\end{enumerate}
\end{document}
关于标题
对于您的标题,我采取了一种截然不同的方法。我放弃了环境enumerate
,选择将所有内容都作为表格的一部分。如果表格必须跨越多页,那么这将成为一个问题。但也许您可以加载包longtable
来允许您执行此操作。但目前我还没有看到一种干净的方法来维护之前的答案并添加标题,如上所示。
这是新的 MWE:
\documentclass{article}
%% Two counters to keep track of categories and
%% subcategories
\newcounter{mycategorycounter}
\newcounter{subcategorycounter}
\newcommand{\mytablerow}{%%'
& \stepcounter{subcategorycounter}%%'
\arabic{mycategorycounter}.\arabic{subcategorycounter}.}
\newcommand{\tableColumnTitles}[3]{%%'
&\multicolumn{2}{l}{#1} \\}
%% create the category names; rules are here to add open space
%% above and below entry. I use `\rlap` to alow the category
%% name to apparently span multiply columns
\newcommand{\currentCategory}[1]
{\rule{0pt}{3ex}%%'
\rule[-1ex]{0pt}{1pt}%%'
\stepcounter{mycategorycounter}%'
\arabic{mycategorycounter}. & \rlap{#1} \\
}
\begin{document}
\begin{tabular}{rl*{3}{p{1.5in}}}
\tableColumnTitles{ABCD}{CLASS}{CATEGORY}
\currentCategory{Object}
\mytablerow & Name & abcd & bcdf \\
\mytablerow & ABC & xyz & zyx \\
\currentCategory{File}
\mytablerow & Name & aaa & bb \\
\mytablerow & ABC & ccc & ddd \\
\end{tabular}
\end{document}