
Estou tentando escrever um algoritmo usando algorithm2e
. Tenho que usar \tcc
comentários em diferentes fases do algoritmo. Quando adiciono \tcc
comentários no código, na saída, cada \tcc
comentário aparece numerado em linhas. Um exemplo de código é o seguinte e a saída também está anexada a este documento.
Alguém pode me sugerir como remover números de linha dos \tcc
comentários. Na imagem destaquei aquelas 2 \tcc
linhas, onde não quero nenhum número de linha. Em vez disso, quero que o número da linha comece em "Inicialização", que aparece na etapa 2 em vez da etapa 1 na saída.
\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}
Responder1
Baseado emsua pergunta anteriorvocê está usando o seguintealgorithm2e
opções:
\usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
Remova a commentsnumbered
opção se não quiser que as linhas de comentários sejam numeradas...
\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}