0

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.

Example:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Euclid’s algorithm}\label{euclid}
\begin{algorithmic}[1]
\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$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}

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? – Jeffery Shivers Jun 26 '16 at 21:50
  • I've added a MWE. :-) – Thomas Zuberbühler Jun 27 '16 at 10:05

Your Answer

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

Browse other questions tagged or ask your own question.