I have some pseudocode where I want to reveal an algorithm little-by-little. Currently I highlight the code that is revealed by coloring it red and this looks good onscreen. However, on print, this coloring is difficult to see so I additionally want to highlight the lines that are revealed by wrapping them inside a box. I want this to also include the line numbers. How can I do this?
I've provided a picture of what I want to achieve below, and added the MWE at the bottom (btw, is there a simple way of copying and pasting code snippets onto this page? I had to manually adjust the indentation of the code in order for it to be recognized as such, which was very annoying).
\documentclass{article}\usepackage{xcolor}\usepackage{adjustbox}\usepackage[noend]{algpseudocode}\begin{document}\scriptsize\setlength{\tabcolsep}{2pt}\renewcommand{\arraystretch}{2}\begin{adjustbox}{tabular={ll},center} \begin{adjustbox}{minipage=[t]{.62\linewidth},fbox} \begin{algorithmic}[1] \Statex \If{code} \State code \color{lightgray!20} \ElsIf{code} \State code \Else \State code \EndIf \end{algorithmic} \end{adjustbox} & \begin{adjustbox}{minipage=[t][]{.62\linewidth},fbox} \begin{algorithmic}[1] \Statex \If{code} \State code \color{red} \ElsIf{code} \State code \color{lightgray!20} \Else \State code \EndIf \end{algorithmic} \end{adjustbox} \\ \begin{adjustbox}{minipage=[t][]{.62\linewidth},fbox} \begin{algorithmic}[1] \Statex \If{code} \State code \ElsIf{code} \State code \color{red} \Else \State code \EndIf \end{algorithmic} \end{adjustbox}\end{adjustbox}\end{document}