用于数学证明的嵌套枚举列表

用于数学证明的嵌套枚举列表

对于编号数学证明,我希望能够生成类似这样的输出,其中(我)枚举列表中的每个项目(在本例中为项目 1)都可以被枚举子项目的嵌套子列表替换,并且(二)我可以通过它替换的项目的标签来引用整个嵌套子列表:

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.

请注意,没有单独的项目 1,但是,使用 \label{} 和 \ref{},我需要能够将由行 1.1 - 1.2 组成的块称为“块 1”。

请注意,我需要一个适用于多层嵌套的解决方案,其中嵌套块可以与任何级别的项目混合。例如

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

编辑:使用@Alan Munn 的答案中的想法更新解决方案这个帖子

这个想法是在每个块之前有一个虚拟项,它被标记并且可以在 LaTeX 源中引用,但它不会出现在输出中。直观地说,就像这样:

%% 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.

这是一个完整的工作示例。

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

输出结果如下:

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

像这样吗?

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

代码输出

相关内容