答案1
一个简单的方法是使用enumitem
包来制作嵌套列表。在新行开始列表的技巧改编自这个答案。如果每个项目都包含一些文本,则不需要这样做,但如果步骤直接嵌入为列表的项目,则必须这样做。如果步骤永远不会像这样嵌入,则before={\apptocmd{\item}{\mbox{}}{}{}}
不需要代码。
\documentclass{article}
\usepackage{enumitem}
\usepackage{etoolbox}
\newlist{algolist}{enumerate}{3}
\setlist*[algolist]{leftmargin=*,before={\apptocmd{\item}{\mbox{}}{}{}}}
\setlist*[algolist,1]{label={\itshape Step \arabic*:}}
\setlist*[algolist,2]{label={\itshape Step \arabic{algolisti}.\arabic*:}}
\setlist*[algolist,3]{label={\itshape Step \arabic{algolisti}.\arabic{algolistii}.\arabic*:}}
\begin{document}
\begin{algolist}
\item This is the first step of the algorithm. It can have many lines in it and they will wrap as you would expect.
\item This is the second step of the algorithm.
\begin{algolist}
\item This is the first substep of the second step of the algorithm.
\item This is the second substep of the second step of the algorithm.
\begin{algolist}
\item This is the first substep of the second substep of the algorithm.
\item This is the second substep of the second substep of the algorithm.
\end{algolist}
\end{algolist}
\end{algolist}
\end{document}