显示两列(一列文本,一列内联 tikZ 数学),一次显示一个项目

显示两列(一列文本,一列内联 tikZ 数学),一次显示一个项目

在演示文稿中,我试图按顺序展示四个想法。我将框架分成两列:左列显示文本,右列显示数学。我想一次显示一个项目,同时在两列中显示。我尝试了以下方法,但结果却是内联数学(以前是内联的)不再与文本在同一行。有人可以帮忙吗?提前致谢!

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, 
                backgrounds,
                calc,
                decorations.pathmorphing,
                patterns, positioning, 
                quotes,
                shapes,
                tikzmark
                }
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
%\usepackage{fourier,erewhon}
%\usepackage{amssymb, amsbsy}
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
%\usepackage[x11names, table]{xcolor}
\usepackage{caption}


\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
% modifications of 
% \tikzset{
%     invisible/.style={opacity=0,text opacity=0},
%     visible on/.style={alt=#1{}{invisible}},
% }
% from overlay-beamer-styles

\tikzset{sort of visible/.style={opacity=0.3,text opacity=0.3},
fully visible on/.style={alt=#1{}{sort of visible}},}
\begin{document}

\section{Problem Setup, History, \& Our Result: A Snapshot}


\begin{frame}{Step 2: (Approximate) Feasibility Condition as Potential}
\tikzset{optimization problem/.style = {%
            rounded corners, 
            draw = myblue,
            thick,
            fill= myyellow,
            inner ysep=5pt,
            inner xsep=5pt,
            align = center}}

\begin{minipage}[t]{0.30\linewidth}
        \begin{itemize}
            \item<1-> Goal
            \item<2-> Instead, track
            \item<3-> Invariant 
            \item<4-> Termination at 
        \end{itemize}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{0.66\linewidth}%
        \begin{itemize}
            \item<1-> \raisebox{1 ex}{\begin{tikzpicture}[baseline,thick]
\draw
node [baseline, style=optimization problem, fully visible on = <1>] {$ \lambda_{\textup{max}}(N) \leq (1+\epsilon) \lambda_{\textup{min}}(M).$};
\end{tikzpicture}} 
            \item<2-> \raisebox{.5 ex}{\begin{tikzpicture}[baseline,thick]
\draw
node [baseline, style=optimization problem] {$ (1-\epsilon) \log f \exp(N)  + \log f \exp(-M).$};
\end{tikzpicture}}
            \item<3-> \raisebox{.5 ex}{\begin{tikzpicture}[baseline,thick]
\draw
node [baseline, style=optimization problem] {$g \leq \log n$};
\end{tikzpicture}}
            \item<4-> \raisebox{.5 ex}{\begin{tikzpicture}[baseline,thick]
\draw
node [baseline, style=optimization problem] {$\lambda_{\textup{min}}(M)\geq \frac{\log n}{\epsilon}$};
\end{tikzpicture}} 
        \end{itemize}
    \end{minipage}  

\end{frame}
\end{document}

答案1

这里的建议是使用投影机的内置列,并以一种相当残酷但有效的方式同步它们。

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, 
                backgrounds,
                calc,
                decorations.pathmorphing,
                patterns, positioning, 
                quotes,
                shapes,
                tikzmark
                }
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}


\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
% modifications of 
% \tikzset{
%     invisible/.style={opacity=0,text opacity=0},
%     visible on/.style={alt=#1{}{invisible}},
% }
% from overlay-beamer-styles

\tikzset{sort of visible/.style={opacity=0.3,text opacity=0.3},
fully visible on/.style={alt=#1{}{sort of visible}},}

\newcommand<>{\SyncCols}[3][0.3\linewidth]{\begin{columns}
\begin{column}{#1}
\begin{itemize}
 \item \vphantom{#3}#2
\end{itemize}
\end{column}
\begin{column}{\dimexpr\linewidth-#1-0.02\linewidth}
\begin{itemize}
 \item \vphantom{#2}#3
\end{itemize}
\end{column}
\end{columns}}

\begin{document}

\section{Problem Setup, History, \& Our Result: A Snapshot}


\begin{frame}{Step 2: (Approximate) Feasibility Condition as Potential}
\tikzset{optimization problem/.style = {%
            rounded corners, 
            draw = myblue,
            thick,
            fill= myyellow,
            inner ysep=5pt,
            inner xsep=5pt,
            align = center}}

\uncover<1->{\SyncCols{Goal}{\begin{tikzpicture}[baseline={(X.base)}]
\node[style=optimization problem, fully visible on = <1>](X){%
$ \lambda_{\textup{max}}(N) \leq (1+\epsilon) \lambda_{\textup{min}}(M)$.};
\end{tikzpicture}}}
%
\uncover<2->{\SyncCols{Instead, track}{\begin{tikzpicture}[baseline={(X.base)}]
\node[style=optimization problem, fully visible on = <2>](X){%
$(1-\varepsilon) \log f \exp(N)  + \log f \exp(-M)$.};
\end{tikzpicture}}}
%
\uncover<3->{\SyncCols{Invariant}{\begin{tikzpicture}[baseline={(X.base)}]
\node[style=optimization problem, fully visible on = <3>](X){%
$g \leq \log n$.};
\end{tikzpicture}}}
%
\uncover<4->{\SyncCols{Termination at}{\begin{tikzpicture}[baseline={(X.base)}]
\node[style=optimization problem, fully visible on = <4>](X){%
$\lambda_{\textup{min}}(M)\geq \frac{\log n}{\varepsilon}$.};
\end{tikzpicture}}}
\end{frame}
\end{document}

在此处输入图片描述

但是,我可以想象,在这里执行此操作的更好方法是使用 的栅格tcolorbox,并使用 来制作框tcolorbox。或者,您可以像上面一样使用节点,但将它们放在 的矩阵中,tikz左列由文本填充。

事实上,利用矩阵,人们可以用计数做一些有趣的小事\pgfmatrixcurrentrow

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}

\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
\begin{document}

\section{Problem Setup, History, \& Our Result: A Snapshot}


\begin{frame}[fragile]
\frametitle{Step 2: (Approximate) Feasibility Condition as Potential}
\centering
\begin{tikzpicture}[optimization problem/.style = {%
            rounded corners, 
            draw = myblue,
            thick,
            fill= myyellow,
            inner ysep=5pt,
            inner xsep=5pt,
            align = center},
            pics/trian/.style={code={\fill[blue!80!black] 
            (0,0) -- (150:1ex) -- (210:1ex) --cycle;}}]

\matrix[matrix of nodes,row sep=1em,column sep=1em,
    nodes={anchor=west,
    visible on=<\the\pgfmatrixcurrentrow->,},
    column 2/.style={nodes={optimization problem,
    alt=<\pgfmatrixcurrentrow>{}{opacity=0.3,text opacity=0.3},
    alt=<-\the\numexpr\pgfmatrixcurrentrow-1>{opacity=0,text opacity=0}{},
    }}](M){
Goal & $ \lambda_{\textup{max}}(N) \leq (1+\varepsilon)
\lambda_{\textup{min}}(M)$\\
Instead, track & $(1-\varepsilon) \log f \exp(N)  + \log f \exp(-M)$\\
Invariant & $g \leq \log n$\\
Termination at & 
$\lambda_{\textup{min}}(M)\geq \frac{\log n}{\varepsilon}$\\
};          

\end{tikzpicture}
\end{frame}
\end{document}

在此处输入图片描述

如您所见,根本不需要输入覆盖规范。一切都是自动完成的。

当然,如果需要的话,也可以自动添加三角形。

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}

\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
\begin{document}

\section{Problem Setup, History, \& Our Result: A Snapshot}


\begin{frame}[fragile]
\frametitle{Step 2: (Approximate) Feasibility Condition as Potential}
\centering
\begin{tikzpicture}[optimization problem/.style = {%
            rounded corners, 
            draw = myblue,
            thick,
            fill= myyellow,
            inner ysep=5pt,
            inner xsep=5pt,
            align = center},
            pics/trian/.style={code={\fill[blue!80!black] 
            (0,0) -- (150:1ex) -- (210:1ex) --cycle;}}]

\matrix[matrix of nodes,row sep=1em,nodes in empty cells,
    nodes={anchor=west,
    visible on=<\the\pgfmatrixcurrentrow->},
    every odd column/.style={execute at begin node={\textcolor{blue!80!black}{$\blacktriangleright$}}},
    column 2/.style={column sep=1em},
    column 4/.style={nodes={optimization problem,
    alt=<\pgfmatrixcurrentrow>{}{opacity=0.3,text opacity=0.3},
    alt=<-\the\numexpr\pgfmatrixcurrentrow-1>{opacity=0,text opacity=0}{},
    }}](M){
&Goal & &$ \lambda_{\textup{max}}(N) \leq (1+\varepsilon)
\lambda_{\textup{min}}(M)$\\
&Instead, track & &$(1-\varepsilon) \log f \exp(N)  + \log f \exp(-M)$\\
&Invariant & &$g \leq \log n$\\
&Termination at & &
$\lambda_{\textup{min}}(M)\geq \frac{\log n}{\varepsilon}$\\
};          
\end{tikzpicture}
\end{frame}
\end{document}

在此处输入图片描述

答案2

问题似乎是 有点minipage太窄了,所以tikzpicture被推到了下一行。把它弄0.67\textwidth宽一点,看起来会更好。

为了在线上获得更好的垂直对齐,请删除所有\raiseboxes,为节点命名,如a,然后在选项baseline=(a.base)中进行设置tikzpicture

在此处输入图片描述

两个列表中的项目未垂直对齐,因为行高不同,您想让它们对齐吗?

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, 
                backgrounds,
                calc,
                decorations.pathmorphing,
                patterns, positioning, 
                quotes,
                shapes,
                tikzmark
                }
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
%\usepackage{fourier,erewhon}
%\usepackage{amssymb, amsbsy}
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
%\usepackage[x11names, table]{xcolor}
\usepackage{caption}


\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
% modifications of 
% \tikzset{
%     invisible/.style={opacity=0,text opacity=0},
%     visible on/.style={alt=#1{}{invisible}},
% }
% from overlay-beamer-styles

\tikzset{sort of visible/.style={opacity=0.3,text opacity=0.3},
fully visible on/.style={alt=#1{}{sort of visible}},}
\begin{document}

\section{Problem Setup, History, \& Our Result: A Snapshot}


\begin{frame}{Step 2: (Approximate) Feasibility Condition as Potential}
\tikzset{optimization problem/.style = {%
            rounded corners, 
            draw = myblue,
            thick,
            fill= myyellow,
            inner ysep=5pt,
            inner xsep=5pt,
            align = center}}

\begin{minipage}[t]{0.30\linewidth}
        \begin{itemize}
            \item<1-> Goal
            \item<2-> Instead, track
            \item<3-> Invariant 
            \item<4-> Termination at 
        \end{itemize}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{0.67\linewidth}%
        \begin{itemize}
            \item<1-> \begin{tikzpicture}[baseline=(a.base),thick]
\node [style=optimization problem, fully visible on = <1>] (a) {$ \lambda_{\textup{max}}(N) \leq (1+\epsilon) \lambda_{\textup{min}}(M).$};
\end{tikzpicture}
            \item<2-> \begin{tikzpicture}[baseline=(a.base),thick]
\node [style=optimization problem] (a) {$ (1-\epsilon) \log f \exp(N)  + \log f \exp(-M).$};
\end{tikzpicture}
            \item<3-> \begin{tikzpicture}[baseline=(a.base),thick]
\node [style=optimization problem] (a) {$g \leq \log n$};
\end{tikzpicture}
            \item<4-> \begin{tikzpicture}[baseline=(a.base),thick]
\node [style=optimization problem] (a) {$\lambda_{\textup{min}}(M)\geq \frac{\log n}{\epsilon}$};
\end{tikzpicture}
        \end{itemize}
    \end{minipage}  
\end{frame}

\end{document}

相关内容