Having an algorithm written with the package algorithmicx, I'd like to rewrite two (single) lines in a later section of my document.

However, if possible, I'd prefer not to write the complete algorithm again but only these lines. Therefore I would like to omit the first 10 lines and the lines between the changed lines.


\caption{Euclid’s algorithm}\label{euclid}
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\State \textbf{return} $b$\Comment{The gcd is b}

Source of example:

If not possible, is there a way to highlight these lines within a \begin{algorithmicx} block?

  • You can definitely highlight specific lines. Could you expand your code to a MWE? Jun 26, 2016 at 21:50
  • I've added a MWE. :-)
    – Thomas
    Jun 27, 2016 at 10:05


You must log in to answer this question.

Browse other questions tagged .