
を使用してアルゴリズムを記述しようとしています。アルゴリズムのさまざまな段階でコメントalgorithm2e
を使用する必要があります\tcc
。コードにコメントを追加すると\tcc
、出力で各\tcc
コメントが行番号付きで表示されます。サンプル コードは以下のとおりです。出力も添付します。
コメントから行番号を削除する方法を教えていただけませんか\tcc
。画像では、\tcc
行番号を付けたくない 2 行を強調表示しています。代わりに、出力にステップ 1 ではなくステップ 2 として表示される「初期化」から始まる行番号を付けたいです。
\begin{algorithm}[H]
\caption{How to write algorithms}
\tcc{Start of Example 1}
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\tcc{End of Example 1}
\end{algorithm}
答え1
に基づく前回の質問あなたは以下を使用していますalgorithm2e
オプション:
\usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
commentsnumbered
コメント行に番号を付けたくない場合は、オプションを削除してください...
\documentclass{article}
\usepackage[linesnumbered,lined,boxed]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\caption{How to write algorithms}
\tcc{Start of Example 1}
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\tcc{End of Example 1}
\end{algorithm}
\end{document}