0

I want to make interactive slides for my presentation. This is my first attempt to use this type of slide. I found this post and following this applied the command Highlight and only. However I am unable to create what I wanted to. I am explaining with my code below:

\documentclass[10pt,aspectratio=1610]{beamer}
\usepackage{natbib}
\usepackage{enumerate}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage{mwe}
\usepackage{etoolbox}
\usepackage{bookmark}
\usepackage{subcaption}
\usepackage{lipsum}
\usepackage{tabularx}
\usepackage{pdflscape}
\usepackage{float}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{blindtext}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{epstopdf}
\usepackage{bigints}
\usepackage{caption}
\usepackage{xcolor}
\usepackage{stackengine}
\usepackage{multirow}
\usepackage{hyperref}
\usepackage{textgreek} 
\usepackage{color, colortbl}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{fancyvrb}
\usepackage{fvextra}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tiny
\setbeamertemplate{footline}[text line]{%
\parbox{\linewidth}{\vspace*{-8pt}some text\hfill\insertauthor\hfill\insertpagenumber}}
\setbeamertemplate{navigation symbols}{}

\setbeamercolor{framesubtitle}{fg=white!40!black} \usetheme{Madrid} \usecolortheme{seagull}

\makeatletter \setbeamertemplate{footline}{ \leavevmode% \hbox{% \begin{beamercolorbox}[wd=.5\paperwidth,ht=3.2ex,dp=1.6ex,right]{author in head/foot}% \usebeamerfont{author in head/foot} \insertshortauthor \hspace{1mm} \expandafter\ifblank\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)} \end{beamercolorbox}% \begin{beamercolorbox}[wd=.5\paperwidth,ht=3.2ex,dp=1.6ex,left]{date in head/foot}%
\hspace{1mm} \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} \end{beamercolorbox}}% \vskip0pt% } \makeatother \setbeamerfont{institute}{size=\fontsize{10pt}{10pt}} \setbeamerfont{title}{size=\fontsize{16pt}{16pt}} \setbeamerfont{author}{size=\fontsize{14pt}{14pt}} \usepackage{graphicx} \usetheme{Madrid} \setbeamertemplate{caption}[numbered]

\begin{document} \begingroup \setbeamertemplate{footline}{} \begin{frame} \titlepage \end{frame} \endgroup

\makeatletter \patchcmd{\beamer@subsubsectionintoc} {\vfill} {\vskip\itemsep{5ex}} {} {} \makeatother

\hypersetup{ bookmarksnumbered=true } \setcounter{tocdepth}{5}

\makeatletter \patchcmd{\beamer@subsubsection} {\Hy@writebookmark{\the\c@subsubsection}{#2}}% {\Hy@writebookmark{\the\c@subsubsection}{\numberline{\thesection.\thesubsection.\thesubsubsection}#2}}% {} \makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% I just copy pasted some codes. I actually do not get what they mean.%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{tmp} \newcommand<>\Highlight[1]{% \stepcounter{tmp}% \only#2{\begin{tikzpicture}[remember picture,overlay] \fill[gray!60!black,opacity=1] ([xshift=-.2em,yshift=2ex]pic cs:start-\thetmp) rectangle
([xshift=.2em,yshift=-1ex]pic cs:end-\thetmp); \end{tikzpicture}}% \tikzmark{start-\thetmp}#1\hfill\tikzmark{end-\thetmp}% }

\begin{frame}{frametiTle}{\begin{Large}framesubtiTle\end{Large}} \begin{large}\textbf{A BIG LINE}\end{large}

\begin{flalign} &; \hspace{5mm} \Highlight<+>{h1=(\textcolor{blue}{1,,2},,\textcolor{red}{3,,4})},&& \nonumber\ \hspace{3mm} \text{1 some line some line some line some line some line\vspace{-5mm}}&\nonumber ; \genfrac{}{}{0pt}{}{\nearrow}{\searrow}\ &;\hspace{5mm} h2=(1,,2,,3,,4),&&\nonumber \end{flalign}

\hspace*{2mm} 2 another line another line another line another line another line another line another line another line.\vspace{3mm}\

\only<1> {3 third line:third line:third line:third line:third line: \begin{alignat}{1} (a+b)^2 &=(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2\textcolor{green}{(a+b)^2(a+b)^2(a+b)^2}\nonumber \ (a+b)^2 &=(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2\textcolor{green}{(a+b)^2(a+b)^2(a+b)^2}\nonumber \end{alignat} $=(a+b)^2(a+b)^2(a+b)^2$.\vspace{.2cm}\% last line last linelast linelast line $\textcolor{green}{(a+b)^2(a+b)^2(a+b)^2}$ \vspace{.2cm}\ $\textcolor{red}{(a+b)^2(a+b)^2(a+b)^2}$}

\end{frame} \end{document}

This gives

 the output

At first, I want to hide the line in dark gray and the last passage (from 3 third line:third line to (a+b)2). Then I want to show them by making an opaque image of the rest of the parts. How to do this in beamer? Hope I've stated my problem clearly. Any help is truly appreciated.

Ly T
  • 11

1 Answers1

1
  • if you want something only visible on certain slides within your frame, you can use \visible<>{...}. Compared to \only<>{...} this has the advantage that the content will still occupy space and this avoid problems with text jumping between slides.

  • if you want something to be semitransparent on certain overlays, you can use \uncover<>{...} (combined with e.g. \setbeamercovered{transparent})

  • you should really clean up your preamble and document. There are lots of packages which are either not compatible or unnecessary with beamer. Also don't load the same packages multiple times.

    Rule of thumb: only use the code you need for this specific project, this way you avoid much of the unindented side effects.


\documentclass[10pt,aspectratio=1610]{beamer}
\usepackage{natbib}
%\usepackage{enumerate}
%\usepackage{amsmath}
%\usepackage{amssymb}
%\usepackage[utf8]{inputenc}
%\usepackage{mwe}
%\usepackage{etoolbox}
%\usepackage{bookmark}
\usepackage{subcaption}
\usepackage{lipsum}
\usepackage{tabularx}
\usepackage{pdflscape}
%\usepackage{float}
%\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{blindtext}
%\usepackage{amsfonts}
%\usepackage{amssymb}
\usepackage{epstopdf}
\usepackage{bigints}
\usepackage{caption}
%\usepackage{xcolor}
\usepackage{stackengine}
\usepackage{multirow}
%\usepackage{hyperref}
\usepackage{textgreek} 
%\usepackage{color, colortbl}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{fancyvrb}
\usepackage{fvextra}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tiny
\setbeamertemplate{footline}[text line]{%
\parbox{\linewidth}{\vspace*{-8pt}some text\hfill\insertauthor\hfill\insertpagenumber}}
\setbeamertemplate{navigation symbols}{}

\setbeamercolor{framesubtitle}{fg=white!40!black} \usetheme{Madrid} \usecolortheme{seagull}

\makeatletter \setbeamertemplate{footline}{ \leavevmode% \hbox{% \begin{beamercolorbox}[wd=.5\paperwidth,ht=3.2ex,dp=1.6ex,right]{author in head/foot}% \usebeamerfont{author in head/foot} \insertshortauthor \hspace{1mm} \expandafter\ifblank\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)} \end{beamercolorbox}% \begin{beamercolorbox}[wd=.5\paperwidth,ht=3.2ex,dp=1.6ex,left]{date in head/foot}%
\hspace{1mm} \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} \end{beamercolorbox}}% \vskip0pt% } \makeatother \setbeamerfont{institute}{size=\fontsize{10pt}{10pt}} \setbeamerfont{title}{size=\fontsize{16pt}{16pt}} \setbeamerfont{author}{size=\fontsize{14pt}{14pt}} %\usepackage{graphicx} \usetheme{Madrid} \setbeamertemplate{caption}[numbered] \setbeamerfont{framesubtitle}{size=\Large} \setbeamercovered{transparent}

\begin{document}

\makeatletter \patchcmd{\beamer@subsubsectionintoc} {\vfill} {\vskip\itemsep{5ex}} {} {} \makeatother

\hypersetup{ bookmarksnumbered=true } \setcounter{tocdepth}{5}

\makeatletter \patchcmd{\beamer@subsubsection} {\Hy@writebookmark{\the\c@subsubsection}{#2}}% {\Hy@writebookmark{\the\c@subsubsection}{\numberline{\thesection.\thesubsection.\thesubsubsection}#2}}% {} \makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% I just copy pasted some codes. I actually do not get what they mean.%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{tmp} \newcommand<>\Highlight[1]{% \stepcounter{tmp}% \only#2{\begin{tikzpicture}[remember picture,overlay] \fill[gray!60!black,opacity=1] ([xshift=-.2em,yshift=2ex]pic cs:start-\thetmp) rectangle
([xshift=.2em,yshift=-1ex]pic cs:end-\thetmp); \end{tikzpicture}}% \tikzmark{start-\thetmp}#1\hfill\tikzmark{end-\thetmp}% }

\begin{frame} \frametitle{frametiTle} \framesubtitle{framesubtiTle}

{\large \textbf{A BIG LINE}}

\begin{flalign} &; \hspace{5mm} \visible<2->{\Highlight<2>{h1=(\textcolor{blue}{1,,2},,\textcolor{red}{3,,4})},}&& \nonumber\ \hspace{3mm} \text{\uncover<1>{1 some line some line some line some line some line\vspace{-5mm}}}&\nonumber ; \uncover<1>{\genfrac{}{}{0pt}{}{\nearrow}{\searrow}}\ &;\hspace{5mm} \uncover<1>{h2=(1,,2,,3,,4),}&&\nonumber \end{flalign}

\hspace*{2mm} \uncover<1>{2 another line another line another line another line another line another line another line another line.\vspace{3mm}}\

\visible<2-> {3 third line:third line:third line:third line:third line: \begin{alignat}{1} (a+b)^2 &=(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2\textcolor{green}{(a+b)^2(a+b)^2(a+b)^2}\nonumber \ (a+b)^2 &=(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2(a+b)^2\textcolor{green}{(a+b)^2(a+b)^2(a+b)^2}\nonumber \end{alignat} $=(a+b)^2(a+b)^2(a+b)^2$.\vspace{.2cm}\% last line last linelast linelast line $\textcolor{green}{(a+b)^2(a+b)^2(a+b)^2}$ \vspace{.2cm}\ $\textcolor{red}{(a+b)^2(a+b)^2(a+b)^2}$}

\end{frame} \end{document}

enter image description here