表中有多级枚举列表

表中有多级枚举列表

大家早上好,

我尝试在表格中建立多级枚举。项目应类似于第一列中的行标识符(参见所附示例)。

在表格中写入项目并在下一行继续枚举,这可以继续使用。但我无法创建子级别。

此外,我无法将项目放在“较小的行高”中。示例中项目上方的边距没问题,但下面我无法减少空间。

有人可以帮忙吗?

问候,克里斯蒂安

示例表

\documentclass{scrreprt}

\usepackage{enumitem}

\begin{document}

        \begin{tabular}{|p{.1\textwidth}|l|l|l|}

        \hline

        Identifier & Content 1 & Content 2 \\

        \hline

        \hline

        \begin{enumerate}[series=tableLevel1,nosep,leftmargin=*,after=\vspace{-0.2\baselineskip},before=\vspace{-0.2\baselineskip}] \item \end{enumerate} & bla & \\

        \hline

        \begin{enumerate}[resume*=tableLevel1] \item \end{enumerate} & blub & \\

        \hline

        \begin{enumerate}[resume*=tableLevel1] \item \end{enumerate} & blabla & \\

        \hline

        \begin{enumerate}[resume*=tableLevel1] \item \end{enumerate} & blablub & \\

        \hline

        \begin{enumerate}[resume*=tableLevel1] \item \end{enumerate} & foo & \\

        \hline

        \begin{enumerate}[resume*=tableLevel1] \item \end{enumerate} & foobla & \\

        \hline

    \end{tabular}


\end{document}

答案1

我将定义一个特定的环境:

\documentclass{article}

\newcounter{myenumi}
\newcounter{myenumii}[myenumi]
\renewcommand{\themyenumi}{\arabic{myenumi}}
\renewcommand{\themyenumii}{\themyenumi.\arabic{myenumii}}

\newenvironment{enumtabular}[1]
 {%
  \setcounter{myenumi}{0}%
  \setcounter{myenumii}{0}%
  \renewcommand{\item}{\refstepcounter{myenumi}\themyenumi.}%
  \renewcommand{\subitem}{\refstepcounter{myenumii}\quad\themyenumii.}%
  \begin{tabular}{#1}
 }
 {\end{tabular}}

\begin{document}

\begin{enumtabular}{|l|l|l|}
\hline
Identifier & Contents 1 & Contents 2 \\
\hline
\item & blabla & blabla \\
\hline
\item & blu & blublu \\
\hline
\subitem\label{test} & blabla & blabla \\
\hline
\subitem & blub & blub \\
\hline
\item & xyz & zyx \\
\hline
\end{enumtabular}

\bigskip

Reference: \ref{test}

\end{document}

如果您需要更多级别,可以\subsubitem采用类似的方式添加。

在此处输入图片描述

非笼状表:

\documentclass{article}
\usepackage{booktabs}

\newcounter{myenumi}
\newcounter{myenumii}[myenumi]
\renewcommand{\themyenumi}{\arabic{myenumi}}
\renewcommand{\themyenumii}{\themyenumi.\arabic{myenumii}}

\newenvironment{enumtabular}[1]
 {%
  \setcounter{myenumi}{0}%
  \setcounter{myenumii}{0}%
  \renewcommand{\item}{\refstepcounter{myenumi}\themyenumi.}%
  \renewcommand{\subitem}{\refstepcounter{myenumii}\quad\themyenumii.}%
  \begin{tabular}{#1}
 }
 {\end{tabular}}

\begin{document}

\begin{enumtabular}{lll}
\toprule
Identifier & Contents 1 & Contents 2 \\
\midrule
\item & blabla & blabla \\
\midrule
\item & blu & blublu \\
\subitem\label{test} & blabla & blabla \\
\subitem & blub & blub \\
\midrule
\item & xyz & zyx \\
\bottomrule
\end{enumtabular}

\bigskip

Reference: \ref{test}

\end{document}

在此处输入图片描述

答案2

在此处输入图片描述


\documentclass{scrreprt}

\usepackage{enumitem}
\newlist{tabenum}{enumerate}{3}

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


\begin{document}

        \begin{tabular}{|p{.175\textwidth}|l|l|l|}

        \hline

        Identifier & Content 1 & Content 2 \\

        \hline

        \hline

        \begin{tabenum}[series=tableLevel1]\item\quad\end{tabenum} & bla & \\

        \hline

        \begin{tabenum}[resume*=tableLevel1] \item\quad \end{tabenum} & blub & \\

        \hline

        \begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum} \item\quad \end{tabenum}\end{tabenum} & blabla & \\

        \hline

        \begin{tabenum}[resume*=tableLevel1] \item\quad \end{tabenum} & blablub & \\

        \hline

        \begin{tabenum}[resume*=tableLevel1] \item\quad \end{tabenum} & foo & \\

        \hline


        \begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[series=tableLevel2] \item\quad \end{tabenum}\end{tabenum} & blabla & \\

        \hline


        \begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[resume*=tableLevel2] \item\quad \end{tabenum}\end{tabenum} & blabla & \\

        \hline

        \begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[resume*=tableLevel2]\item[]\begin{tabenum}[series=tableLevel3] \item\quad \end{tabenum}\end{tabenum}\end{tabenum} & blabla & \\

        \hline

        \begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[resume*=tableLevel2]\item[]\begin{tabenum}[resume*=tableLevel3] \item\quad \end{tabenum}\end{tabenum}\end{tabenum} & blabla & \\

        \hline

        \begin{tabenum}[resume*=tableLevel1] \item\quad \end{tabenum} & foobla & \\

        \hline
        \begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[series=tableLevel2] \item\quad \end{tabenum}\end{tabenum} & blabla & \\

        \hline


        \begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[resume*=tableLevel2] \item\quad \end{tabenum}\end{tabenum} & blabla & \\

        \hline

    \end{tabular}


\end{document}

以下是稍微自动化一些的版本,其输出结果与上面所示相同:

\documentclass{scrreprt}

\usepackage{enumitem}
\newlist{tabenum}{enumerate}{3}

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

\newcommand{\tabenumfirst}[1]{\begin{tabenum}[#1=tableLevel1]\item\quad\end{tabenum}}
\newcommand{\tabenumsecond}[1]{\begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[#1=tableLevel2] \item\quad \end{tabenum}\end{tabenum}}
\newcommand{\tabenumthird}[1]{\begin{tabenum}[resume*=tableLevel1]\item[]\begin{tabenum}[resume*=tableLevel2]\item[]\begin{tabenum}[#1=tableLevel3] \item\quad \end{tabenum}\end{tabenum}\end{tabenum}}

\begin{document}

        \begin{tabular}{|p{.175\textwidth}|l|l|l|}

        \hline

        Identifier & Content 1 & Content 2 \\

        \hline

        \hline

        \tabenumfirst{series} & bla & \\

        \hline

        \tabenumfirst{resume*} & blub & \\

        \hline

        \tabenumsecond{series}  & blabla & \\

        \hline

        \tabenumfirst{resume*} & blablub & \\

        \hline

        \tabenumfirst{resume*} & foo & \\

        \hline


        \tabenumsecond{series} & blabla & \\

        \hline

        \tabenumsecond{resume*} & blabla & \\

        \hline

        \tabenumthird{series} & blabla & \\

        \hline

        \tabenumthird{resume*} & blabla & \\

        \hline

        \tabenumfirst{resume*} & foobla & \\

        \hline

        \tabenumsecond{series} & blabla & \\

        \hline

        \tabenumsecond{resume*} & blabla & \\

        \hline

    \end{tabular}


\end{document}

相关内容