
Estoy intentando escribir un algoritmo usando algorithm2e
. Tengo que usar \tcc
comentarios en diferentes fases del algoritmo. Cuando agrego \tcc
un comentario en el código, en el resultado, cada \tcc
comentario aparece numerado en línea. A continuación se muestra un código de ejemplo y el resultado también se adjunta al presente.
¿Alguien puede sugerirme cómo eliminar los números de línea de \tcc
los comentarios? En la imagen, resalté esas 2 \tcc
líneas, donde no quiero ningún número de línea. Más bien quiero que el número de línea comience desde "Inicialización", es decir, que aparezca en el paso 2 en lugar del paso 1 en la salida.
\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}
Respuesta1
Residencia entu pregunta anteriorestás usando lo siguientealgorithm2e
opciones:
\usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
Elimine la commentsnumbered
opción si no desea que las líneas de comentarios estén 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}