2

I'm working with IEEEtran and algorithm2e package. I have a pseudocode with numbered lines. I want to mark some of my line numbers (not the lines themselves) with an asterisk mark. How can I do that? Here is a minimal example:

\documentclass[conference]{IEEEtran}
\usepackage[ruled,linesnumbered]{algorithm2e}

% *** MATH PACKAGES ***
\usepackage{amsmath}
\usepackage{amssymb}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
\begin{document}

\begin{algorithm}
\nlset{1}
$\pi=1$\;
$\Phi=2$\;
\end{algorithm}

\end{document
Werner
  • 603,163
Elnaz
  • 1,427

1 Answers1

0

Do not auto-enumerate the lines. Instead, set those that require a number using \nl and those that require something else with \nlset{<stuff>}:

enter image description here

\documentclass[conference]{IEEEtran}

\usepackage[ruled]{algorithm2e}

\begin{document}

\begin{algorithm}
  \nl $\pi=1$\;
  \nlset{*} $\Phi = 2$\;
  \nl $\pi = 3$\;
\end{algorithm}

\end{document}

Another option might be to add an asterisk to the existing line number:

enter image description here

\documentclass[conference]{IEEEtran}

\usepackage[ruled]{algorithm2e}

\makeatletter
\newcommand{\nlast}{\refstepcounter{AlgoLine}\nlset{\theAlgoLine\rlap{*}}}
\makeatother

\begin{document}

\begin{algorithm}
  \nl $\pi=1$\;
  \nlast $\Phi = 2$\;
  \nl $\pi = 3$\;
\end{algorithm}

\end{document}
Werner
  • 603,163