3

For numbering mathematical proofs, I'd like to be able to generate output something like this, where (i) each item (item 1 in this case) in the enumerated list can be replaced by a nested sublist of enumerated subitems, and (ii) I can refer to the entire nested sublist by the label of the item it replaces:

1.1. This is the first item in the nested list.
1.2. This is the second item in the nested list.
2. This is the last item of the outer list.

Note that Item 1.1 occurs in Block 1.

Note that there is no separate item 1, yet, using \label{} and \ref{}, I need to be able to refer to the block consisting of lines 1.1 - 1.2 as "Block 1".

Note that I need a solution that works with multiple levels of nesting, where nested blocks can be mixed with items in any level. E.g.

1.1. ...
1.2. ...
2. ...
3.1. ... 
3.2.1. ...
3.2.2. ...
3.3. ...
4. ...

EDIT: Updating with solution, using ideas from the answer by @Alan Munn and this post.

The idea is to have a virtual item before each block, which is labeled and can be referred to in the LaTeX source, but that does not appear in the output. Intuitively, something like this:

%% 1. This item exists for referencing, but does not appear in output
1.1. This is the first item in the nested list.
1.2. This is the second item in the nested list.
2. This is the last item of the outer list.

Note that Item 1.1 occurs in Block 1.

Here is a full working example.

\documentclass[12pt]{article}

\usepackage{enumitem}

\newlist{steps}{enumerate}{3}
\setlist[steps]{wide,
  parsep=1pt,
  partopsep=0pt,
  itemindent=0pt,
}
\setlist[steps,1]{
  label=\arabic*.,ref=\arabic*
}
\setlist[steps,2]{
  label=\arabic{stepsi}.\arabic*.,ref=\arabic{stepsi}.\arabic*
}
\setlist[steps,3]{
  label=\arabic{stepsi}.\arabic{stepsii}.\arabic*.,
  ref=\arabic{stepsi}.\arabic{stepsii}.\arabic*
}

\makeatletter
\newcommand{\skipitem}{\refstepcounter{\@enumctr}}
\makeatother

\newenvironment{block}
{\skipitem\item[] \begin{steps}}{\end{steps}}

\begin{document}

\begin{steps}
  \begin{block}\label{blockX}
  \item This is the first item in the first nested list.\label{lineY}
  \item This is the second item in the first nested list. 
  \end{block}
  \item This is the last item in the outer list.
  \begin{block}\label{blockZ}
    \item This is the first item in the second nested list.\label{lineW}
    \item This is the second item in the second nested list. 
    \begin{block}\label{blockA}
    \item This is the first item in the second nested list.\label{lineB}
    \item This is the second item in the second nested list. 
    \end{block}
  \end{block}
\end{steps}

Item~\ref{lineY} occurs in Block~\ref{blockX}. 

Item~\ref{lineW} occurs in Block~\ref{blockZ}. 

\end{document}

This gives the following output:

1.1. This is the first item in the first nested list.
1.2. This is the second item in the first nested list.
2. This is the last item in the outer list.
3.1. This is the first item in the second nested list.
3.2. This is the second item in the second nested list. 
3.3.1. This is the first item in the second nested list. 
3.3.2. This is the second item in the second nested list.

Item 1.1 occurs in Block 1. 
Item 3.1 occurs in Block 3.
1

1 Answer 1

5

Something like this?

\documentclass{article}
\usepackage{enumitem}
\newlist{block}{enumerate}{4}
\setlist[block]{label={},ref=\arabic{blocki}}
\begin{document}
\begin{block}
\item\label{blockone}
\begin{enumerate}[label=\theblocki.\arabic*]
\item One
\item Two
\end{enumerate}
\end{block}
As we can see One and Two are part of block \ref{blockone}.
\end{document}

output of code

1
  • Although this answer doesn't meet all the requirements, I am accepting it because I was able to extend its idea of using an empty label to obtain a solution. I updated the post with the full solution.
    – Neal Young
    Jan 8, 2018 at 2:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .