插入算法伪代码Pseudo-code §
使用algorithm2e §
if条件判断 §
\If、\uIf为单if判断(这两个有什么区别?),和\uElseIf、\Else配合使用形成多种不同条件跳转,\eIf为if...else...组合
使用algorithm,algpseudocode §
注释对齐 §
\usepackage{algorithm,algpseudocode}
\usepackage{xparse}
\makeatletter
\NewDocumentCommand{\LeftComment}{s m}{%
\Statex \IfBooleanF{#1}{\hspace*{\ALG@thistlm}}\(\triangleright\) #2}
\makeatother
\begin{document}
\begin{algorithm}
\caption{Algorithm to check quality of methods}
\begin{algorithmic}
\For{\textbf{each} msd $\in$ msdList} \Comment {inline comment}
\Statex \Comment {right aligned, single line}
\LeftComment {left aligned with indent}
\LeftComment*{left-most aligned}
\For{\textbf{each} msd $\in$ msdList} \Comment {inline comment}
\Statex \Comment {right alinged, single line}
\LeftComment {left aligned with indent}
\LeftComment*{left-most aligned}
\EndFor
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}