在轴环境中暂停

在轴环境中暂停

我希望在 beamer 演示文稿中按顺序显示带有 axis 环境的 tikz 图片。但是,当我在 axis 环境中使用命令 \pause 时,演示文稿只会显示一张空白幻灯片,并在下一张幻灯片中显示整个图表,而我想要的是在第一张幻灯片中显示图表的某些部分,在第二张幻灯片中显示其他部分。

任何帮助都将不胜感激。以下是 MWE:

\documentclass[usenames,dvipsnames,aspectratio=169]{beamer} % --> loads xcolor and hyperref

%----------------------------------------------------------------------------------------------
% PACKAGES
%----------------------------------------------------------------------------------------------

% Loaded by default in beamer (and many others...)
%\usepackage{
%   amsthm
%   color
%   enumerate
%   fourier
%   hyperref
%   xcolor
%}

\usepackage{
    fourier,            % For typesetting
    newtxtext,      % To set the fonts to Times New Roman
    import,         % to import files
    caption,            % To include captions in tables and figures
    subcaption,     % To include subcaptions in tables and figures
    graphicx,       % A more advanced package for images and figures
    float,          % Improves floating objects: figures and tables
    nicematrix,         % To make nice tables
    multicol,       % For multicolum slides
    ragged2e,       % New commands and environments for ragged tex
    mathtools,      % Loads and enhances the features of amsmath
    amssymb,            % to cross a term in an equation
    cancel,         % to cross a term in an equation
    marvosym            % Adds Marting Vogel's symbols: euro, comunicaiton,...
}                   
    
%TO BE REMOVED
    %\let\marvosymLightning\Lightning   
    %This sequence of packages controls the mathematical tools of latex
            %\usepackage[makeroom]{cancel}  % to cross a term in an equation


%----------------------------------------------------------------------------------------------
% CONTROL SEQUENCES
%----------------------------------------------------------------------------------------------

% Others
\definecolor{Red}{RGB}{176,23,31}           % To define new colors
\setlength{\columnsep}{5pt}                 % (multicol) Controls the separation of column
\setlength{\parskip}{\baselineskip} 
\hypersetup{                                    % To control the colors of the hyperref package
    colorlinks=true,
    linkcolor=DarkOrchid,
    filecolor=magenta,      
    urlcolor=Purple,
}
% Allign caption and remove 'Figure'
\captionsetup{
    font                = large,
    skip                = 10pt,
    justification   = raggedright,
    %singlelinecheck    = false,
    labelformat     = empty,
    labelsep            = none
}
%\setbeamertemplate{caption}{\raggedright\insertcaption\par}

% Alligning (ragged2e)
\apptocmd{\frame}{}{\justifying}{}
    \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm} % For justifying the whole document
    \usepackage[none]{hyphenat} % <--- to remove hyphens
    \sloppy %to justify when there is no hyphenation


%----------------------------------------------------------------------------------------------
% GRAPH CONTROL
%----------------------------------------------------------------------------------------------

\usepackage{pgfplots} %--> it loads tikz, already loaded?
    \usetikzlibrary{    
        fit, 
        calc,
        matrix,
        positioning,
        arrows.meta,
        intersections,
        through,
        backgrounds,
        patterns,
        shapes,
        decorations.pathreplacing,
        arrows.meta
    }
    \usepgfplotslibrary{fillbetween}
    \pgfplotsset{compat = newest}
    \pgfplotsset{overwrite option/.style args={#1 with #2}{#1=#2,#1/.code=}}
    \pgfplotsset{
        vasymptote/.style={before end axis/.append code={\draw[dashed,<->,-{Latex}] ({rel axis cs:0,0} -| {axis cs:#1,0}) -- ({rel axis cs:0,1} -| {axis cs:#1,0}); }},
        myaxis/.style={axis line style={<->, {Latex}-{Latex}}}
    }   % This fancy shit sets the arrows to both parts of the axis in the axis environment of pgfplot




%----------------------------------------------------------------------------------------------
% STRUCTURE OF THE BEAMER
%----------------------------------------------------------------------------------------------

\usefonttheme{professionalfonts}
\usefonttheme{serif}

\setbeamercolor{title}{fg=Red}

\setbeamercolor{normal text}{fg=darkgray}   % Set the font color globally
\setbeamerfont{normal text}{size=\small}

\setbeamercolor{frametitle}{fg=Red}
\setbeamerfont{frametitle}{shape=\itshape, size=\huge}
\setbeamertemplate{frametitle}[default][left]
    \addtobeamertemplate{frametitle}{\vskip 5pt \hskip 10pt }{\vskip 10pt} % to control the height

\setbeamercolor{structure}{fg=Red}

\setbeamercolor*{enumerate item}{fg=black}
\setbeamercolor*{enumerate subitem}{fg=black}
\setbeamercolor*{enumerate subsubitem}{fg=black}


\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{section in toc}[sections numbered] % to number sections in the table of contents
\setbeamertemplate{itemize items}[ball]
\setbeamertemplate{subitems}[triangle]
% \useoutertheme{miniframes}
\setlength{\leftmargini}{20.00pt}


%----------------------------------------------------------------------------------------------
% METADATA OF PRESENTATION
%----------------------------------------------------------------------------------------------

\title{1. Labour Supply}
\author{Rub\'{e}n P\'{e}rez Sanz}
\institute{University of Bristol, School of Economics}
\date{\footnotesize{\today}}


\makeatother
\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
    \insertframenumber{} / \inserttotalframenumber\hspace*{1ex}
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatletter

\newcommand\Smallfont{\fontsize{7.5}{12}\selectfont}
\newcommand\Normalfont{\fontsize{9}{12}\selectfont}


%----------------------------------------------------------------------------------------------
% TABLE OF CONTENTS
%----------------------------------------------------------------------------------------------

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Table of Contents}
    \tableofcontents[currentsection]
  \end{frame}
}


%----------------------------------------------------------------------------------------------
% START OF THE PRESENTATION
%----------------------------------------------------------------------------------------------

\begin{document}
 
    \frame{\titlepage}
    
    \begin{frame}
        \frametitle{Table of Contents}
        \tableofcontents
    \end{frame}

    
\begin{frame}{Substitution and income effects}
    
    \begin{figure}[ht]
        \centering
        %------------------------------------------------------------------------------
% SUBSTITUTION AND INCOME EFFECTS
%------------------------------------------------------------------------------

\begin{tikzpicture}[scale = 1]
    \begin{axis}[
        width=6cm,
        xscale = 1, yscale = 1,
        axis lines = middle,
        % myaxis,
        % grid,
        % grid style={densely dashed},
        xmin = -20, xmax = 130, ymin = -25, ymax = 200,
        every axis/.append style={font=\tiny},
        xlabel = {$L$}, xlabel style={at=(current axis.right of origin), anchor=west},
        ylabel = $C$, ylabel style={at=(current axis.above origin), anchor=east},
        xtick = \empty,
        xticklabels = \empty,
        ytick = \empty,
        yticklabels = \empty,
        samples=100,
        domain=-2:10,
        % axis equal,
        % no markers
        ]
        
        % Functions
        
        \addplot[domain=0:110,       Mahogany, name path = ic0]{(90*60^(1/3))/(x^(1/3))};
        \addplot[domain=0:112,       black   , name path = bc0]{120-1/2*x} ;
        
        \addplot[domain=0:110,       Mahogany, name path = ic0]{(132*44^(1/3))/(x^(1/3))};
        \addplot[domain=0:112,       black   , name path = bc0]{176-x} ;
        
        \addplot[domain=10:50,       Mahogany, name path = ic0, draw opacity = .5]{(90*30^(1/3))/(x^(1/3))} ;
        \addplot[domain=0:112,       black   , name path = bc0, draw opacity = .5]{120-x} node[right, xshift = -4] at (112,8) {\fontsize{4}{4} \selectfont $R_c$};
        
            \addplot[domain=0:112,       black   , name path = bc0, draw opacity = .5]{120*2^(1/4)-x} ;
        \pause
        
        % Points
        \draw[black, thick, fill] (axis cs: 60,90) circle [ radius = .5] node[above] at (60,90) {\fontsize{5}{5} \selectfont $E_0$};
        \draw[black, thick, fill] (axis cs: 44,132) circle [ radius = .5] node[above] at (44,132) {\fontsize{5}{5} \selectfont $E_1$};
        \draw[black, thick, fill] (axis cs: 30,90) circle [ radius = .5] node[above,yshift = -2] at (30,90) {\fontsize{4}{4} \selectfont $E'$};
        \draw[black, thick, fill] (axis cs: 35.676,107.0286) circle [ radius = .5] node[above] at (35.676,107.0286) {\fontsize{4}{4} \selectfont $E''$};
        
        % Arrows
        \draw[-latex, ultra thin] (120,27)--(120,0) node[above, yshift=-5, xshift=-1] at (120,32) {\fontsize{4}{4} \selectfont $R$};
        \draw[-latex, ultra thin] (120,37)--(120,64);
        
        \draw[-latex, ultra thin] (51,-20)--(0,-20) node[above, yshift=-5, xshift=-1] at (56,-20) {\fontsize{4}{4} \selectfont $T$};
        \draw[-latex, ultra thin] (61,-20)--(112,-20);
        
        \draw[-latex, ultra thin] (-10,55)--(-10,0) node[above, yshift=-7, xshift=-1] at (-10,65) {\fontsize{4}{4} \selectfont $V$};
        \draw[-latex, ultra thin] (-10,65)--(-10,120);
        
        
        % Solid lines
        \draw[black, ultra thin] (117,64)--(123,64);
        
        \draw[black, ultra thin] (0,-17)--(0,-23);
        \draw[black, ultra thin] (112,-17)--(112,-23);
        
        \draw[black, ultra thin] (-13,0)--(-7,0);
        \draw[black, ultra thin] (-13,120)--(-7,120);
        
        % Dashed lines
        \draw[dashed,gray, ultra thin] (112,0)--(112,200);
        
        \draw[dashed,gray, ultra thin] (60,0)--(60,90) node[below] at (60,0) {\fontsize{4}{4} \selectfont $L^*$};
        \draw[dashed,gray, ultra thin] (0,90)--(60,90) node[left, xshift = 2] at (0,90) {\fontsize{4}{4} \selectfont $C^*=C'$};
        
        \draw[dashed,gray, ultra thin] (44,0)--(44,132) node[below] at (44,0) {\fontsize{4}{4} \selectfont $L_1$};                                  \draw[dashed,gray, ultra thin] (0,132)--(44,132) node[left, xshift = 2] at (0,132) {\fontsize{4}{4} \selectfont $C_1$};
        
        \draw[dashed,gray, ultra thin] (30,0)--(30,90) node[below] at (30,0) {\fontsize{4}{4} \selectfont $L'$};                                    \draw[dashed,gray, ultra thin] (0,90)--(30,90);
        
        \draw[dashed,gray, ultra thin] (35.676,0)--(35.676,107.0286) node[below] at (35.676,0) {\fontsize{4}{4} \selectfont $L''$};                                 \draw[dashed,gray, ultra thin] (0,107.0286)--(35.676,107.0286) node[left, xshift = 2] at (0,107.0286) {\fontsize{4}{4} \selectfont $C''$};
                        
        \draw[dashed,gray, ultra thin] (90,64)--(112,64) node[above,xshift = 5] at (90,60) {\fontsize{4}{4} \selectfont $w$};
        
    \end{axis}
\end{tikzpicture}
    \end{figure}
    
\end{frame}
    

\end{document}

答案1

TikZ 宏(如\draw)可感知叠加层。这意味着您可以使用例如\draw<2->来指定元素应显示在哪些叠加层上:

\documentclass[usenames,dvipsnames,aspectratio=169]{beamer} % --> loads xcolor and hyperref

%----------------------------------------------------------------------------------------------
% PACKAGES
%----------------------------------------------------------------------------------------------

% Loaded by default in beamer (and many others...)
%\usepackage{
%   amsthm
%   color
%   enumerate
%   fourier
%   hyperref
%   xcolor
%}

\usepackage{
    fourier,            % For typesetting
    newtxtext,      % To set the fonts to Times New Roman
    import,         % to import files
    caption,            % To include captions in tables and figures
    subcaption,     % To include subcaptions in tables and figures
%    graphicx,       % A more advanced package for images and figures
    float,          % Improves floating objects: figures and tables
    nicematrix,         % To make nice tables
    multicol,       % For multicolum slides
    ragged2e,       % New commands and environments for ragged tex
    mathtools,      % Loads and enhances the features of amsmath
%    amssymb,            % to cross a term in an equation
    cancel,         % to cross a term in an equation
    marvosym            % Adds Marting Vogel's symbols: euro, comunicaiton,...
}                   
    
%TO BE REMOVED
    %\let\marvosymLightning\Lightning   
    %This sequence of packages controls the mathematical tools of latex
            %\usepackage[makeroom]{cancel}  % to cross a term in an equation


%----------------------------------------------------------------------------------------------
% CONTROL SEQUENCES
%----------------------------------------------------------------------------------------------

% Others
\definecolor{Red}{RGB}{176,23,31}           % To define new colors
\setlength{\columnsep}{5pt}                 % (multicol) Controls the separation of column
\setlength{\parskip}{\baselineskip} 
\hypersetup{                                    % To control the colors of the hyperref package
    colorlinks=true,
    linkcolor=DarkOrchid,
    filecolor=magenta,      
    urlcolor=Purple,
}
% Allign caption and remove 'Figure'
\captionsetup{
    font                = large,
    skip                = 10pt,
    justification   = raggedright,
    %singlelinecheck    = false,
    labelformat     = empty,
    labelsep            = none
}
%\setbeamertemplate{caption}{\raggedright\insertcaption\par}

% Alligning (ragged2e)
\apptocmd{\frame}{}{\justifying}{}
    \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm} % For justifying the whole document
    \usepackage[none]{hyphenat} % <--- to remove hyphens
    \sloppy %to justify when there is no hyphenation


%----------------------------------------------------------------------------------------------
% GRAPH CONTROL
%----------------------------------------------------------------------------------------------

\usepackage{pgfplots} %--> it loads tikz, already loaded?
    \usetikzlibrary{    
        fit, 
        calc,
        matrix,
        positioning,
        arrows.meta,
        intersections,
        through,
        backgrounds,
        patterns,
        shapes,
        decorations.pathreplacing,
        arrows.meta
    }
    \usepgfplotslibrary{fillbetween}
    \pgfplotsset{compat = newest}
    \pgfplotsset{overwrite option/.style args={#1 with #2}{#1=#2,#1/.code=}}
    \pgfplotsset{
        vasymptote/.style={before end axis/.append code={\draw[dashed,<->,-{Latex}] ({rel axis cs:0,0} -| {axis cs:#1,0}) -- ({rel axis cs:0,1} -| {axis cs:#1,0}); }},
        myaxis/.style={axis line style={<->, {Latex}-{Latex}}}
    }   % This fancy shit sets the arrows to both parts of the axis in the axis environment of pgfplot




%----------------------------------------------------------------------------------------------
% STRUCTURE OF THE BEAMER
%----------------------------------------------------------------------------------------------

\usefonttheme{professionalfonts}
\usefonttheme{serif}

\setbeamercolor{title}{fg=Red}

\setbeamercolor{normal text}{fg=darkgray}   % Set the font color globally
\setbeamerfont{normal text}{size=\small}

\setbeamercolor{frametitle}{fg=Red}
\setbeamerfont{frametitle}{shape=\itshape, size=\huge}
\setbeamertemplate{frametitle}[default][left]
    \addtobeamertemplate{frametitle}{\vskip 5pt \hskip 10pt }{\vskip 10pt} % to control the height

\setbeamercolor{structure}{fg=Red}

\setbeamercolor*{enumerate item}{fg=black}
\setbeamercolor*{enumerate subitem}{fg=black}
\setbeamercolor*{enumerate subsubitem}{fg=black}


\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{section in toc}[sections numbered] % to number sections in the table of contents
\setbeamertemplate{itemize items}[ball]
\setbeamertemplate{subitems}[triangle]
% \useoutertheme{miniframes}
\setlength{\leftmargini}{20.00pt}


%----------------------------------------------------------------------------------------------
% METADATA OF PRESENTATION
%----------------------------------------------------------------------------------------------

\title{1. Labour Supply}
\author{Rub\'{e}n P\'{e}rez Sanz}
\institute{University of Bristol, School of Economics}
\date{\footnotesize{\today}}


\makeatother
\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
    \insertframenumber{} / \inserttotalframenumber\hspace*{1ex}
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatletter

\newcommand\Smallfont{\fontsize{7.5}{12}\selectfont}
\newcommand\Normalfont{\fontsize{9}{12}\selectfont}


%----------------------------------------------------------------------------------------------
% TABLE OF CONTENTS
%----------------------------------------------------------------------------------------------

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Table of Contents}
    \tableofcontents[currentsection]
  \end{frame}
}


%----------------------------------------------------------------------------------------------
% START OF THE PRESENTATION
%----------------------------------------------------------------------------------------------

\begin{document}

    
\begin{frame}{Substitution and income effects}
    
    \begin{figure}[ht]
        \centering
        %------------------------------------------------------------------------------
% SUBSTITUTION AND INCOME EFFECTS
%------------------------------------------------------------------------------

\usetikzlibrary{overlay-beamer-styles}

\begin{tikzpicture}[scale = 1]
    \begin{axis}[
        width=6cm,
        xscale = 1, yscale = 1,
        axis lines = middle,
        % myaxis,
        % grid,
        % grid style={densely dashed},
        xmin = -20, xmax = 130, ymin = -25, ymax = 200,
        every axis/.append style={font=\tiny},
        xlabel = {$L$}, xlabel style={at=(current axis.right of origin), anchor=west},
        ylabel = $C$, ylabel style={at=(current axis.above origin), anchor=east},
        xtick = \empty,
        xticklabels = \empty,
        ytick = \empty,
        yticklabels = \empty,
        samples=100,
        domain=-2:10,
        % axis equal,
        % no markers
        ]
        
        % Functions
        
        \addplot[domain=0:110,       Mahogany, name path = ic0]{(90*60^(1/3))/(x^(1/3))};
        \addplot[domain=0:112,       black   , name path = bc0]{120-1/2*x} ;
        
        \addplot[domain=0:110,       Mahogany, name path = ic0]{(132*44^(1/3))/(x^(1/3))};
        \addplot[domain=0:112,       black   , name path = bc0]{176-x} ;
        
        \addplot[domain=10:50,       Mahogany, name path = ic0, draw opacity = .5]{(90*30^(1/3))/(x^(1/3))} ;
        \addplot[domain=0:112,       black   , name path = bc0, draw opacity = .5]{120-x} node[right, xshift = -4] at (112,8) {\fontsize{4}{4} \selectfont $R_c$};
        
            \addplot[domain=0:112,       black   , name path = bc0, draw opacity = .5]{120*2^(1/4)-x} ;
%        \pause
        
        % Points
        \draw<2->[black, thick, fill] (axis cs: 60,90) circle [ radius = .5] node[above] at (60,90) {\fontsize{5}{5} \selectfont $E_0$};
        \draw<2->[black, thick, fill] (axis cs: 44,132) circle [ radius = .5] node[above] at (44,132) {\fontsize{5}{5} \selectfont $E_1$};
        \draw<2->[black, thick, fill] (axis cs: 30,90) circle [ radius = .5] node[above,yshift = -2] at (30,90) {\fontsize{4}{4} \selectfont $E'$};
        \draw<2->[black, thick, fill] (axis cs: 35.676,107.0286) circle [ radius = .5] node[above] at (35.676,107.0286) {\fontsize{4}{4} \selectfont $E''$};
        
        % Arrows
        \draw<2->[-latex, ultra thin] (120,27)--(120,0) node[above, yshift=-5, xshift=-1] at (120,32) {\fontsize{4}{4} \selectfont $R$};
        \draw<2->[-latex, ultra thin] (120,37)--(120,64);
        
        \draw<2->[-latex, ultra thin] (51,-20)--(0,-20) node[above, yshift=-5, xshift=-1] at (56,-20) {\fontsize{4}{4} \selectfont $T$};
        \draw<2->[-latex, ultra thin] (61,-20)--(112,-20);
        
        \draw<2->[-latex, ultra thin] (-10,55)--(-10,0) node[above, yshift=-7, xshift=-1] at (-10,65) {\fontsize{4}{4} \selectfont $V$};
        \draw<2->[-latex, ultra thin] (-10,65)--(-10,120);
        
        
        % Solid lines
        \draw<2->[black, ultra thin] (117,64)--(123,64);
        
        \draw<2->[black, ultra thin] (0,-17)--(0,-23);
        \draw<2->[black, ultra thin] (112,-17)--(112,-23);
        
        \draw<2->[black, ultra thin] (-13,0)--(-7,0);
        \draw<2->[black, ultra thin] (-13,120)--(-7,120);
        
        % Dashed lines
        \draw<2->[dashed,gray, ultra thin] (112,0)--(112,200);
        
        \draw<2->[dashed,gray, ultra thin] (60,0)--(60,90) node[below] at (60,0) {\fontsize{4}{4} \selectfont $L^*$};
        \draw<2->[dashed,gray, ultra thin] (0,90)--(60,90) node[left, xshift = 2] at (0,90) {\fontsize{4}{4} \selectfont $C^*=C'$};
        
        \draw<2->[dashed,gray, ultra thin] (44,0)--(44,132) node[below] at (44,0) {\fontsize{4}{4} \selectfont $L_1$};                                  \draw<2->[dashed,gray, ultra thin] (0,132)--(44,132) node[left, xshift = 2] at (0,132) {\fontsize{4}{4} \selectfont $C_1$};
        
        \draw<2->[dashed,gray, ultra thin] (30,0)--(30,90) node[below] at (30,0) {\fontsize{4}{4} \selectfont $L'$};                                    \draw<2->[dashed,gray, ultra thin] (0,90)--(30,90);
        
        \draw<2->[dashed,gray, ultra thin] (35.676,0)--(35.676,107.0286) node[below] at (35.676,0) {\fontsize{4}{4} \selectfont $L''$};                                 
        \draw<2->[dashed,gray, ultra thin] (0,107.0286)--(35.676,107.0286) node[left, xshift = 2] at (0,107.0286) {\fontsize{4}{4} \selectfont $C''$};
                        
        \draw<2->[dashed,gray, ultra thin] (90,64)--(112,64) node[above,xshift = 5] at (90,60) {\fontsize{4}{4} \selectfont $w$};
        
    \end{axis}
\end{tikzpicture}
    \end{figure}
    
\end{frame}
    

\end{document}

在此处输入图片描述

相关内容