
을 사용하여 알고리즘을 작성하려고 합니다 algorithm2e
. \tcc
알고리즘의 여러 단계에서 주석을 사용해야 합니다 . 코드에 주석을 추가하면 \tcc
출력에 각 \tcc
주석이 줄 번호로 표시됩니다. 예제 코드는 아래와 같으며 출력도 여기에 첨부되어 있습니다.
\tcc
누구든지 댓글 에서 줄 번호를 제거하는 방법을 제안해 주실 수 있나요 ? 이미지에서 \tcc
나는 줄 번호를 원하지 않는 두 줄을 강조 표시했습니다. 오히려 "초기화"에서 줄 번호가 시작되기를 원합니다. 즉, 출력의 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}