-1

I created a diagram in beamer, but right now the text "jumps" when I flip the slide (When adding the "Primary outcomes in survey" bullet point). I'd like the text to stay stable. Could someone help me please? Thank you!

This is my code:

\documentclass[aspectratio=169]{beamer} 
\mode<presentation>
{
  \usetheme{default}
  \usecolortheme{default}
  \usefonttheme{default}
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel} \usepackage[utf8x]{inputenc} \usepackage{bbold} %indicator function \usepackage{centernot} \usepackage[absolute,overlay]{textpos} \AtBeginSection[] { \begin{frame} \frametitle{Outline} \tableofcontents[currentsection] \end{frame} }

\setbeamercovered{dynamic} %% Maybe get rid of, shows when going to uncover

\usepackage[thicklines]{cancel} \usepackage{pgfpages} \usepackage{amsmath} \usepackage{graphicx} \usepackage{adjustbox} \usepackage{amssymb} \usepackage{xcolor} \usepackage{amsfonts} \usepackage{appendixnumberbeamer} \usepackage{bbm} \usepackage{tabu} \usepackage{anyfontsize} \usepackage{multirow} \usepackage{graphics} \usepackage{hyperref} \usepackage{comment} \definecolor{light-gray}{gray}{0.8} \definecolor{invisible}{gray}{1} \definecolor{blue(pigment)}{rgb}{0.2, 0.2, 0.6} \definecolor{ceruleanblue}{rgb}{0.16, 0.32, 0.75} \definecolor{indigo(dye)}{rgb}{0.0, 0.25, 0.42} \definecolor{kellygreen}{rgb}{0.3, 0.73, 0.09} \definecolor{Blue}{HTML}{005073} \definecolor{test}{RGB}{0,136,196}%{106,168,79}%{48,159,169}%{48,149,193}%{3,168,158}%%{69,160,199}%{37,132,214}

\usetheme{metropolis} \setbeamercolor{frametitle}{bg=Blue}%ceruleanblue} \setbeamercolor{background canvas}{bg=white} \setbeamercolor{alerted text}{fg=test}

%%%% TIKZ STUFF \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{fit,shapes.geometric} \usetikzlibrary{arrows.meta}

\usetikzlibrary{matrix,shapes,arrows,fit} \newcolumntype{.}{D{.}{.}{-1}} \usepackage{booktabs,dcolumn} \usepackage{tabularx}

% Overlays

\newcounter{jumping} \resetcounteronoverlays{jumping}

\makeatletter \tikzset{ stop jumping/.style={ execute at end picture={% \stepcounter{jumping}% \immediate\write\pgfutil@auxout{% \noexpand\jump@setbb{\the\value{jumping}}{\noexpand\pgfpoint{\the\pgf@picminx}{\the\pgf@picminy}}{\noexpand\pgfpoint{\the\pgf@picmaxx}{\the\pgf@picmaxy}} }, \csname jump@\the\value{jumping}@maxbb\endcsname \path (\the\pgf@x,\the\pgf@y); \csname jump@\the\value{jumping}@minbb\endcsname \path (\the\pgf@x,\the\pgf@y); }, } } \def\jump@setbb#1#2#3{% @ifundefined{jump@#1@maxbb}{% \expandafter\gdef\csname jump@#1@maxbb\endcsname{#3}% }{% \csname jump@#1@maxbb\endcsname \pgf@xa=\pgf@x \pgf@ya=\pgf@y #3 \pgfmathsetlength\pgf@x{max(\pgf@x,\pgf@xa)}% \pgfmathsetlength\pgf@y{max(\pgf@y,\pgf@ya)}% \expandafter\xdef\csname jump@#1@maxbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% } @ifundefined{jump@#1@minbb}{% \expandafter\gdef\csname jump@#1@minbb\endcsname{#2}% }{% \csname jump@#1@minbb\endcsname \pgf@xa=\pgf@x \pgf@ya=\pgf@y #2 \pgfmathsetlength\pgf@x{min(\pgf@x,\pgf@xa)}% \pgfmathsetlength\pgf@y{min(\pgf@y,\pgf@ya)}% \expandafter\xdef\csname jump@#1@minbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% } } \makeatother

%%%%%% END TIKZ STUFF % Continue MD stuff \newenvironment{itemize1}{\begin{itemize}\setlength{\itemsep}{10pt}\setlength{\parskip}{10pt}}{\end{itemize}} \newenvironment{itemize2}{\begin{itemize}\setlength{\itemsep}{5pt}\setlength{\parskip}{5pt}}{\end{itemize}} \newenvironment{enumerate1}{\begin{enumerate}\setlength{\itemsep}{10pt}\setlength{\parskip}{10pt}}{\end{enumerate}} \newenvironment{enumerate2}{\begin{enumerate}\setlength{\itemsep}{5pt}\setlength{\parskip}{5pt}}{\end{enumerate}} \newcommand{\comment}[1]{}

% Wider slide \newcommand\Wider[2][3em]{% \makebox[\linewidth][c]{% \begin{minipage}{\dimexpr\textwidth+#1\relax} \raggedright#2 \end{minipage}% }% }

\setbeamertemplate{footline}{% \raisebox{5pt}{\makebox[\paperwidth]{\hfill\makebox[10pt]{\scriptsize\insertframenumber}}}}

\begin{document}

\tikzset{   
    every picture/.style={remember picture,baseline},
    every node/.style={anchor=base,align=center,outer sep=-1pt},
    every path/.style={thick},
}

\newcommand\marktopleft[1]{%
    \tikz[overlay,remember picture] 
    \node (marker-#1-a) at (.1em,.3em) {};%
}

\newcommand\tikzmark[2]{%

\tikz[remember picture,overlay] \node[inner sep=1pt,outer sep=2.5pt] (#1){#2};% }

\newcommand\markbottomright[1]{%
    \tikz[overlay,remember picture] 
    \node (marker-#1-b) at (.1em,.3em) {};%
    \tikz[overlay,remember picture,inner sep=3pt]
    \node[draw=red,rounded corners,fit=(marker-#1-a.north west) (marker-#1-b.south east)] {};%
}   
\usetikzlibrary {positioning}   


\begin{frame}[label=data_collection]{Overview of data collection} \begin{tikzpicture}[stop jumping]

% Main \node<2->[draw, text width=4.15em, minimum height=4em, text centered, rounded corners] (ArgumentA) at (1,0) { \footnotesize Baseline beliefs}; \node<2>[draw, text width=4.15em, minimum height=4em, text centered, rounded corners,fill=black!20] (ArgumentA) at (1,0) { \footnotesize Baseline beliefs}; \node<3->[draw, text width=4.5em, minimum height=4em, text centered, rounded corners] (ArgumentB) at (3.25,0) {\footnotesize Information treatment}; \node<3>[draw, text width=4.5em, minimum height=4em, text centered, rounded corners,fill=black!20] (ArgumentB) at (3.25,0) {{\visible<1->{\footnotesize Information treatment}}}; \node<4->[draw, text width=4.15em, minimum height=4em, text centered, rounded corners] (ArgumentC) at (5.5,0) {{\visible<1->{\footnotesize Endline Beliefs}}}; \node<4>[draw, text width=4.15em, minimum height=4em, text centered, rounded corners,fill=black!20] (ArgumentC) at (5.5,0) {{\visible<1->{\footnotesize Endline Beliefs}}}; \node<5->[draw, text width=4.5em, minimum height=4em, text centered, rounded corners] (ArgumentD) at (8.3,-0.25) {{\visible<1->{\footnotesize Outcomes}}}; \node<5>[draw, text width=4.5em, minimum height=4em, text centered, rounded corners,fill=black!20] (ArgumentD) at (8.3,-0.25) {{\visible<1->{\footnotesize Outcomes}}}; \node<6->[] (ArgumentE) at (6.8, -2) {{\visible<1->{\footnotesize Endline Choices}}}; \node<6->[] (ArgumentF) at (6.8, -0.3) {};

   %% Measure outcomes
        \node&lt;5&gt;[draw, text width=\textwidth, minimum height=4em, text centered, rounded corners, draw=invisible] (ExplA) at (4,-1.25) {
    %For all treatment and subset of control (to avoid priming), ask: 

            \begin{itemize}
                \bigskip
                \bigskip
                \item Primary outcomes in Resource Center
                    \begin{itemize}
                        \item \alert{Job training}: complete intake form for employment training services 
                        \item \alert{Math skills}: sign up for online math and computer tutoring 
                        %\item Sign up for email about savings account (secondary outcome)
                    \end{itemize}
            \smallskip
            \item[]
                \begin{itemize}
                    \item[]
                    \item[]
                \end{itemize}                \end{itemize}
    };

\node&lt;6&gt;[draw, text width=\textwidth, minimum height=4em, anchor=west, draw=invisible] (ExplA) at (-3,-3.2) {

      \begin{itemize}
           \bigskip
           \bigskip
           \bigskip
            \item Primary outcomes in Resource Center
                \begin{itemize}
                    \item \alert{Job training}: complete intake form for employment training services 
                    \item \alert{Math skills}: sign up for online math and computer tutoring 
                \end{itemize}
            \smallskip
            \item Primary outcomes in survey
                \begin{itemize}
                    \item \alert{Tutoring}: decide between \$50 cash and \$300 tutoring if win
                    \item \alert{Career book}: \$40 cash or (\$35 + Career Prep for Teens book, worth \$12)
                \end{itemize}
        \end{itemize}


        };

\node&lt;7&gt;[draw, text width=\textwidth, minimum height=4em, anchor=west, draw=invisible] (ExplA) at (-3,-3.2) {

      \begin{itemize}
           \bigskip
           \bigskip
           \bigskip
            \item Secondary outcomes
                \begin{itemize}
                    \item Savings: sign up for email about ABLE savings account (Resource Center)
                    \item Employment and college plans (survey)
                \end{itemize}
            \smallskip
            \item Medium- and long-run outcomes
                \begin{itemize}
                    \item Education (e.g., attendance), use of job training services, employment outcomes
                \end{itemize}
        \end{itemize}


        };


\draw<3->[->,draw=test] (ArgumentA) to (ArgumentB); \draw<4->[->,draw=test] (ArgumentB) to (ArgumentC); \draw<5->[->,draw=test] (ArgumentC) to (ArgumentD); \draw<6->[->, draw=test] (ArgumentE) to (ArgumentF);

\draw&lt;1-&gt; [rounded corners, draw=black!50, dashed,thick](-.25,-1.25) rectangle (7,1);

\draw<1-> (3.25,1.25) node {\footnotesize \emph{Day 1: Web Survey}}; \draw<5-> (8.3,1.25) node {\footnotesize \emph{Day 2 onwards}};

\end{tikzpicture} \end{frame}

\end{document}

Giane
  • 141
  • 5

2 Answers2

5

As already said in the answer to your question, which you deleted as soon as you got an answer:

You can use the overlay-beamer-styles library. This library also allows you to specify on which overlays a node should be filled:

\documentclass[aspectratio=169]{beamer}

\definecolor{Blue}{HTML}{005073}

\usepackage{tikz}

\usetikzlibrary{overlay-beamer-styles}

\usetheme{moloch}% modern fork of the metropolis theme \setbeamercolor{frametitle}{bg=Blue}

\begin{document}

\begin{frame}[label=data_collection] \frametitle{Overview of data collection} \begin{tikzpicture}

% Main \node[visible on={<2->}, fill=black!20, fill on=<2>, draw, text width=4.15em, minimum height=4em, text centered, rounded corners, font=\footnotesize] (ArgumentA) at (1,0) {Baseline beliefs}; \node[visible on={<3->}, fill=black!20, fill on=<3>, draw, text width=4.5em, minimum height=4em, text centered, rounded corners, font=\footnotesize] (ArgumentB) at (3.25,0) {Information treatment};
\end{tikzpicture} \end{frame}

\end{document}

enter image description here

  • Thanks! Sorry for deleting the question , I'm not too familiar using this and I saw that my code had some mistakes and my question was not so clear so I thought that it would be better to re-ask it. – Giane Nov 22 '22 at 20:44
  • @Giane In the future just edit. It is such a waste of time if one writes and answer and then the OP just deletes it with the question :( – samcarter_is_at_topanswers.xyz Nov 22 '22 at 20:46
  • Will do, sorry for the inconvenience! – Giane Nov 22 '22 at 20:49
4

I really recommend you take to heart what I already wrote in my comment: Don't use C&P but instead leverage the \visible and (where appropriate) the \only commands.

If you keep everything together without C&P you'll have a much easier time arriving at a consistent (non-jumping) layout.

I went ahead and shrunk your example to the essential parts and provide you with a jump-free (parametrized) version of your jumpy slide. I hope this gets the idea across of what I did to avoid any jumping. As I did not see any need for the list to be inside the tikzpicture, I moved it out of there.

\documentclass[aspectratio=169]{beamer}

\usetheme{metropolis}

\usepackage[english]{babel} \usepackage[utf8x]{inputenc} \usepackage{tikz}

\begin{document}

\begin{frame}[label=data_collection]{Overview of data collection}
    \def\horizontalSep{0.5cm}
    \def\verticalSep{0.5cm}
    \def\nodeWidth{4.5em}
    \def\nodeHeight{4.5em}
    \def\nodeInnerSep{0.5em}
    \pgfmathsetmacro\nodeTextWidth{\nodeWidth - 2*\nodeInnerSep}

    \tikzset{
        rounded corners,
        every node/.style = {
            right,
            draw,
            minimum height = \nodeHeight,
            text width = \nodeTextWidth,
            text centered,
            outer sep = 0pt,
            inner sep = \nodeInnerSep,
        },
    }

    \begin{center}
        \begin{tikzpicture}
            \draw[gray, dashed] (0,0) rectangle ++({3*\nodeWidth + 4*\horizontalSep}, {\nodeHeight + 2*\verticalSep});

            \visible&lt;2-&gt;{
                \node (A) at ({\horizontalSep}, {\verticalSep + 0.5*\nodeHeight}) {test};
            }
            \visible&lt;3-&gt;{
                \node (B) at ({2*\horizontalSep + \nodeWidth}, {\verticalSep + 0.5*\nodeHeight}) {test2};
            }
            \visible&lt;4-&gt;{
                \node (C) at ({3*\horizontalSep + 2*\nodeWidth}, {\verticalSep + 0.5*\nodeHeight}) {test3};
            }
            \visible&lt;5-&gt;{
                % Add an extra sep for this one
                \node (D) at ({(4 + 1)*\horizontalSep + 3*\nodeWidth}, {\verticalSep + 0.5*\nodeHeight}) {test4};
            }

            \visible&lt;6-&gt;{
                \path (C.south east) ++(\horizontalSep, {-2*\verticalSep}) node[draw=none,inner sep=0pt,minimum height=0pt,text width=3cm,below] (E) {Endline Choices};
            }

            \draw&lt;3-&gt;[-&gt;, blue] (A) -- (B);
            \draw&lt;4-&gt;[-&gt;, blue] (B) -- (C);
            \draw&lt;5-&gt;[-&gt;, blue] (C) -- (D);
            \draw&lt;6-&gt;[-&gt;, blue] (E.north) -- ++(0, {2*\verticalSep + 0.5*\nodeHeight});
        \end{tikzpicture}
    \end{center}

    \begin{itemize}
        \item&lt;5-&gt; Primary outcomes in Resource Center
            \begin{itemize}
                \item Job training: complete intake form for employment training services
                \item Math skills: sign up for online math and computer tutoring
            \end{itemize}
        \item&lt;6-&gt; Primary outcomes in survey
            \begin{itemize}
                \item Tutoring: decide between \$50 cash and \$300 tutoring if win
                \item Career book: \$40 cash or (\$35 + Career Prep for Teens book, worth \$12)
            \end{itemize}
    \end{itemize}
\end{frame}

\end{document}

Raven
  • 3,023