昨天用户 mbertLamport 证明风格,enumitem,增强嵌套级别 为 Lamport 风格的证明提供了很好的增强,增强了枚举深度。他的解决方案是:
\documentclass{article}
\usepackage{enumitem}
\makeatletter
\newenvironment{lamport}{%
\renewlist{enumerate}{enumerate}{9}
\setlist[enumerate]{
label=$\langle$\the\@enumdepth$\rangle$\arabic*.,
ref=$\langle$\the\@enumdepth$\rangle$\arabic*,
nosep
}
}{}
\makeatother
\begin{document}
\begin{lamport}
\begin{enumerate}
\item \label{item:nest2:1}
The theorem follows from Lemma 1\\
\textsc{Proof of Lemma 1:}
\begin{enumerate}
\item \label{item:nest2:2}
Lemma 1 follows from Lemma 2\\
\textsc{Proof of Lemma 2:}
\begin{enumerate}
\item \label{item:nest2:4}
Lemma 2 follows from Lemma 3\\
\textsc{Proof of Lemma 3:}
\begin{enumerate}
\item \label{item:nest2:5}
Lemma 3 follows from Lemma 4\\
\textsc{Proof of Lemma 4:}
\begin{enumerate}
\item \label{item:nest2:6}
Lemma 4 follows from Lemma 5\\
\textsc{Proof of Lemma 5:}
\begin{enumerate}
\item \label{item:nest2:7}
Lemma 5 follows from Lemma 6\\
\textsc{Proof of Lemma 6:}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{lamport}
然而大卫卡莱尔提供了解决方案 lampor pf2.sty 并隐藏/显示嵌套枚举环境的部分 用于隐藏和显示旧代码的枚举级别
\def\labelenumi{\theenumi}
\usepackage[shortlabels]{enumitem}
\makeatletter
\newenvironment{lamport}{%
\setenumerate{
label=$\langle$\the\@enumdepth$\rangle$\arabic*.,
ref=$\langle$\the\@enumdepth$\rangle$\arabic*,
nosep,
topsep=0pt,
itemsep=1pt,
partopsep=1ex,
parsep=2ex
}
}{}
\makeatother
他的解决方案是
\newcount\pflevel
\newcommand\pfshowlevel[1]{\pflevel=#1\relax}
\let\zzenumerate\enumerate
\makeatletter
\def\enumerate{%
\ifnum\pflevel=\@enumdepth
\setbox0\vbox\bgroup\begingroup\aftergroup\egroup\aftergroup\endgroup
\fi
\zzenumerate}
但是现在枚举深度增强了,这个方法就行不通了。有谁知道如何显示/隐藏新代码的级别吗?谢谢
乌韦·布劳尔