이런 종류의 의사 코드는 라텍스로 어떻게 작성됩니까?

이런 종류의 의사 코드는 라텍스로 어떻게 작성됩니까?

Latex의 일반적인 알고리즘 라이브러리의 지침을 사용하여 형식이 지정되지 않은 것 같습니다.여기에 이미지 설명을 입력하세요

단순히 형식화된 텍스트인 것 같은데 확실하지 않습니다.

답변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}

코드 출력

관련 정보