4

I would like to mark (e.g. with a *) a line in a pseudo-code typeset with the algorithmic package. I would like the label to appear on the left margin, instead of the line number. Is that possible?

I would like to have something like this:

  a = 5
  b = 7
* if a < b then
    ...
  end if
1

Use a \marginpar.

\documentclass{article}
\usepackage{algorithmic}
\reversemarginpar % left hand
\begin{document}
\begin{algorithmic}
\STATE foo\marginpar{\hfill*}
\STATE bar
\end{algorithmic}
\end{document}

In two-sided document, you must test if the page number is odd using \ifoddpage from changepage, and choose \reversemarginpar or \normalmarginpar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy