
答案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}