4

I will be using the beamer class for my presentation. I want to present the algorithm line by line in such a way that the line on which I am working should get zoomed or lensed or highlighted. See my working code given below:

\documentclass[hyperref={pdfpagelabels=false}]{beamer}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{caption}

\begin{document}
\begin{minipage}{1\linewidth}
\begin{algorithm}[H]\footnotesize

\SetAlgoLined

\textbf{Line 1} \\~\\

Line 2 \\


\end{algorithm}
\end{minipage}


\end{document}
4

Sorry, I have misinterpreted "zoom". Do you want something like this?

\documentclass[hyperref={pdfpagelabels=false}]{beamer}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{tikzmark,overlay-beamer-styles,fit}


\begin{document}
\begin{frame}[t]
\frametitle{An algorithm}
\begin{algorithm}[H]\footnotesize

\SetAlgoLined

\tikzmarknode{1}{\textbf{Line 1}} \\~\\

\tikzmarknode{2}{Line 2} \\

\end{algorithm}
\begin{tikzpicture}[overlay,remember picture]
\node[visible on=<1>,fit=(1),draw=red]{};
\node[visible on=<2>,fit=(2),draw=red]{};
\end{tikzpicture}

\end{frame}
\end{document}

enter image description here

If you were to use listings instead, you could use the full potential of tikzmark, see e.g. this nice answer.

OLD ANSWER: You can use \framezoom in beamer. Algorithms are no exceptions.

\documentclass[hyperref={pdfpagelabels=false}]{beamer}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{caption}

\begin{document}
\begin{frame}[t]
\frametitle{An algorithm}
\framezoom<2><3>[border=2](-0.6cm,-0.1cm)(2cm,2cm)
\begin{algorithm}[H]\footnotesize

\SetAlgoLined

\textbf{Line 1} \\~\\

Line 2 \\

\end{algorithm}

\end{frame}
\end{document}

enter image description here

  • 1
    Thanks for the answer. I want only zoomed in not the effect. – Isla_Bonita Jan 22 at 6:48
  • @Isla_Bonita Sorry about that. I added something. Is that what you want? – marmot Jan 22 at 15:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.