我在 Beamer 中创建了一个图表,但现在当我翻转幻灯片时(添加“调查中的主要结果”项目符号时),文本会“跳跃”。我希望文本保持稳定。有人能帮我吗?谢谢!
这是我的代码:
\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<5>[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<6>[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<7>[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<1-> [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}
答案1
我真的建议你牢记我在评论中所写的内容:不要使用 C&P,而是利用\visible
和(在适当的情况下)\only
命令。
如果您将所有内容放在一起而不使用 C&P,您将更容易获得一致的(非跳跃的)布局。
我继续将您的示例缩小到必要的部分,并为您提供了无跳跃(参数化)版本的跳跃幻灯片。我希望这能让您了解我为避免任何跳跃所做的事情。由于我认为列表没有必要放在里面tikzpicture
,所以我把它移出了那里。
\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<2->{
\node (A) at ({\horizontalSep}, {\verticalSep + 0.5*\nodeHeight}) {test};
}
\visible<3->{
\node (B) at ({2*\horizontalSep + \nodeWidth}, {\verticalSep + 0.5*\nodeHeight}) {test2};
}
\visible<4->{
\node (C) at ({3*\horizontalSep + 2*\nodeWidth}, {\verticalSep + 0.5*\nodeHeight}) {test3};
}
\visible<5->{
% Add an extra sep for this one
\node (D) at ({(4 + 1)*\horizontalSep + 3*\nodeWidth}, {\verticalSep + 0.5*\nodeHeight}) {test4};
}
\visible<6->{
\path (C.south east) ++(\horizontalSep, {-2*\verticalSep}) node[draw=none,inner sep=0pt,minimum height=0pt,text width=3cm,below] (E) {Endline Choices};
}
\draw<3->[->, blue] (A) -- (B);
\draw<4->[->, blue] (B) -- (C);
\draw<5->[->, blue] (C) -- (D);
\draw<6->[->, blue] (E.north) -- ++(0, {2*\verticalSep + 0.5*\nodeHeight});
\end{tikzpicture}
\end{center}
\begin{itemize}
\item<5-> 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<6-> 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}
答案2
正如已经说过的你的问题的答案,你在得到答案后就删除了:
您可以使用overlay-beamer-styles
库。此库还允许您指定应在哪些覆盖层上填充节点:
\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}