2

Good morning everybody,

I tried to build up a multi level enumeration within a table. The items shall be something like an row identifier in the 1 column (see attached example).

Writing Items in the table and continue enumeration in the next row worked with resume. But I was not able to create sublevels.

Additionally I was not able to bring the items in a "smaller row height". The margin over the items is Ok in the example, but below I was not able to reduce the space.

Can anyone help?

Regards, Christian

Example Table

\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}
  • How deep do you want your sublevels ? If you are limited to 1 sublevels, a crude solution would be to define 2 counters and increment them as you need to. – alex_reader Jan 12 at 8:47
  • hi alex, I need at least 2 sublevels – ChrisP Jan 12 at 8:55
4

I would define a specific environment:

\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}

You can add \subsubitem in a similar fashion if you need more levels.

enter image description here

A non caged table:

\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}

enter image description here

  • Hello egreg, thanks, that is perfect! Regards, Christian – ChrisP Jan 13 at 21:17
3

enter image description here


\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}

Here is slightly more automated version that results in the same output as shown above:

\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}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.