我想在幻灯片中放置一个文字块,并在其右侧放置一个图形,这样在幻灯片中图形将位于左侧,解释文字块将位于右侧。我使用的是 Beamer。
我尝试了发布的示例同一张幻灯片上的 Beamer 文本和图像但它不起作用。
如何才能做到这一点?
答案1
我构建了一个示例,其中以思维导图为图形,以三个块为解释文字(只是为了同时使用block
、alertblock
和exampleblock
)。
用于创建思维导图的代码取自如何为思维导图概念着色?,所以也许你不感兴趣,但我认为这可以有助于向你展示如何动态地呈现图形,而不仅仅是块。
以下是代码(已注释,因此您可以跳过对思维导图有用的部分):
\documentclass{beamer}
\usepackage{lmodern}
%%% Theme definitions
\usetheme{Singapore}
\usecolortheme{rose} % to have colored blocks
\setbeamertemplate{blocks}[rounded][shadow=true]
\usepackage{tikz}
\usetikzlibrary{mindmap}
% ---- from now starts code useful to draw the mindmap
%%% Overlay definitions
% based on Daniel's code
% https://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer/55849#55849
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
}
}
%%% Shadings definitions
% based on
% https://tex.stackexchange.com/questions/58249/how-to-add-shade-to-mindmap-concept/62097#62097
\makeatletter
\pgfdeclareradialshading[tikz@ball]{myball}{\pgfqpoint{5bp}{10bp}}{%
color(0bp)=(tikz@ball!30!white);
color(9bp)=(tikz@ball!75!white);
color(18bp)=(tikz@ball!90!black);
color(25bp)=(tikz@ball!70!black);
color(50bp)=(black)}
% to make possible use "myball color=..."
\tikzoption{myball color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball}\tikz@addmode{\tikz@mode@shadetrue}}
\pgfdeclareradialshading[tikz@ball]{myball-left}{\pgfqpoint{5bp}{-9bp}}{%
color(0bp)=(tikz@ball!30!white);
color(15bp)=(tikz@ball!75!white);
color(25bp)=(tikz@ball!90!black);
color(40bp)=(tikz@ball!70!black);
color(70bp)=(black)}
\tikzoption{myball-left color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball-left}\tikz@addmode{\tikz@mode@shadetrue}}
\pgfdeclareradialshading[tikz@ball]{myball-right}{\pgfqpoint{-5bp}{-9bp}}{%
color(0bp)=(tikz@ball!30!white);
color(15bp)=(tikz@ball!75!white);
color(25bp)=(tikz@ball!90!black);
color(40bp)=(tikz@ball!70!black);
color(70bp)=(black)}
\tikzoption{myball-right color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball-right}\tikz@addmode{\tikz@mode@shadetrue}}
\makeatother
\tikzset{level 1 concept/.append style={font=\sf, sibling angle=90,level distance = 25mm}}
\tikzset{level 2 concept/.append style={font=\sf, sibling angle=45,level distance = 16mm}}
\tikzset{level 3 concept/.append style={font=\sf, sibling angle=45,level distance = 17mm}}
\tikzset{every node/.append style={scale=0.45}}
% ---- end of code useful to draw the mindmap
\begin{document}
\begin{frame}{Title}
\begin{columns}
% Figure
\begin{column}{0.49\textwidth}
\begin{tikzpicture}[mindmap, concept color=blue, font=\sf\bf, text=white,scale=0.7]
\node[circle,shading=myball,visible on=<1->]{Root Concept}[clockwise from=315]
child [concept color=orange,visible on=<2->] {node[circle, myball-left color=orange] (c1){Child 1}
child[visible on=<3->] {node [circle, myball-left color=orange](c11){Child 1-1}}
child[visible on=<3->] {node [circle,myball-left color=orange](c12){Child 1-2}}
child[visible on=<3->] {node [circle,myball-left color=orange](c13){Child 1-3}}
}
child [concept color=violet,visible on=<4->]{node [circle,myball-right color=violet](c2){Child 2}
child[visible on=<5->] {node [circle,myball-right color=violet](c21){Child 2-1}}
child[visible on=<5->] {node [circle,myball-right color=violet](c22){Child 2-2}}
child[visible on=<5->] {node [circle,myball-right color=violet](c22){Child 1-3}}
};
\end{tikzpicture}
\end{column}
% Explanation Blocks
\begin{column}{0.49\textwidth}
\begin{block}<1>{Root concept explanation}
This ... consist of... because....\\
and is peculiar of...
\end{block}
\begin{exampleblock}<2,3>{Child concept}
This ... consist of... because....\\
and is peculiar of...
\end{exampleblock}
\begin{alertblock}<4,5>{Another child concept}
This ... consist of... because....\\
and is peculiar of...
\end{alertblock}
\end{column}
\end{columns}
\end{frame}
\end{document}
结果是:
为了与图像保持一致,在展示给定概念时会显示与该概念相关的块;在图片中,为了决定何时应该呈现新概念,它使用visible on=<value>
。同样的价值因此,应用于块:\begin{block}<value>...
。如果value
不包括-
,则该块将仅在给定的时刻呈现value
。这个想法来自思维导图 tikzpicture 在 beamer 中 (逐步显示)。
让我们稍微改变一下前面的例子来展示这个事实(改变的只是块部分,其余代码仍然相同):
% Blocks
\begin{column}{0.49\textwidth}
\begin{block}<1->{Root concept explanation}
This ... consist of... because....\\
and is peculiar of...
\end{block}
\begin{exampleblock}<2,3->{Child concept}
This ... consist of... because....\\
and is peculiar of...
\end{exampleblock}
\begin{alertblock}<4,5->{Another child concept}
This ... consist of... because....\\
and is peculiar of...
\end{alertblock}
\end{column}
现在的结果是:
需要注意的重要一点是-
所有覆盖规范。
由于评论中提到dynblocks
包,我提供了一个利用它的解决方案。注意:编译需要 0.2a 版本。
代码:
\documentclass{beamer}
\usepackage{lmodern}
\usepackage[shadow,roundedcorners,customcolors]{dynblocks}
%%% Theme definitions
\usetheme{Singapore}
\usecolortheme{rose} % to have colored blocks
\setbeamertemplate{blocks}[rounded][shadow=true]
\usepackage{tikz}
\usetikzlibrary{mindmap}
% ---- from now starts code useful to draw the mindmap
%%% Overlay definitions
% based on Daniel's code
% https://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer/55849#55849
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
}
}
%%% Shadings definitions
% based on
% https://tex.stackexchange.com/questions/58249/how-to-add-shade-to-mindmap-concept/62097#62097
\makeatletter
\pgfdeclareradialshading[tikz@ball]{myball}{\pgfqpoint{5bp}{10bp}}{%
color(0bp)=(tikz@ball!30!white);
color(9bp)=(tikz@ball!75!white);
color(18bp)=(tikz@ball!90!black);
color(25bp)=(tikz@ball!70!black);
color(50bp)=(black)}
% to make possible use "myball color=..."
\tikzoption{myball color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball}\tikz@addmode{\tikz@mode@shadetrue}}
\pgfdeclareradialshading[tikz@ball]{myball-left}{\pgfqpoint{5bp}{-9bp}}{%
color(0bp)=(tikz@ball!30!white);
color(15bp)=(tikz@ball!75!white);
color(25bp)=(tikz@ball!90!black);
color(40bp)=(tikz@ball!70!black);
color(70bp)=(black)}
\tikzoption{myball-left color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball-left}\tikz@addmode{\tikz@mode@shadetrue}}
\pgfdeclareradialshading[tikz@ball]{myball-right}{\pgfqpoint{-5bp}{-9bp}}{%
color(0bp)=(tikz@ball!30!white);
color(15bp)=(tikz@ball!75!white);
color(25bp)=(tikz@ball!90!black);
color(40bp)=(tikz@ball!70!black);
color(70bp)=(black)}
\tikzoption{myball-right color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball-right}\tikz@addmode{\tikz@mode@shadetrue}}
\makeatother
\tikzset{level 1 concept/.append style={font=\sf, sibling angle=90,level distance = 25mm}}
\tikzset{level 2 concept/.append style={font=\sf, sibling angle=45,level distance = 16mm}}
\tikzset{level 3 concept/.append style={font=\sf, sibling angle=45,level distance = 17mm}}
\tikzset{mynode/.style={scale=0.45}}
% ---- end of code useful to draw the mindmap
\begin{document}
\begin{frame}{Title}
\begin{columns}[T]
% Figure
\begin{column}{0.49\textwidth}
\begin{tikzpicture}[mindmap, concept color=blue, font=\sf\bf, text=white,scale=0.7]
\node[mynode,circle,shading=myball,visible on=<1->]{Root Concept}[clockwise from=315]
child [concept color=orange,visible on=<2->] {node[mynode,circle, myball-left color=orange] (c1){Child 1}
child[visible on=<3->] {node [mynode,circle, myball-left color=orange](c11){Child 1-1}}
child[visible on=<3->] {node [mynode,circle,myball-left color=orange](c12){Child 1-2}}
child[visible on=<3->] {node [mynode,circle,myball-left color=orange](c13){Child 1-3}}
}
child [concept color=violet,visible on=<4->]{node [mynode,circle,myball-right color=violet](c2){Child 2}
child[visible on=<5->] {node [mynode,circle,myball-right color=violet](c21){Child 2-1}}
child[visible on=<5->] {node [mynode,circle,myball-right color=violet](c22){Child 2-2}}
child[visible on=<5->] {node [mynode,circle,myball-right color=violet](c22){Child 1-3}}
};
\end{tikzpicture}
\end{column}
% Blocks
\begin{column}{0.49\textwidth}
\begin{dynblock}
\opaqueblock<1>{
This ... consist of... because....\\
and is peculiar of...
}
\invblock<2->
\end{dynblock}
\\[2ex]
\begin{dynblock}
\setblockcolor{orange!20}
\setbordercolor{orange}
\opaqueblock<{2,3}>{
This ... consist of... because....\\
and is peculiar of...
}
\invblock<4->
\end{dynblock}
\\[2ex]
\begin{dynblock}
\setblockcolor{violet!20}
\setbordercolor{violet}
\opaqueblock<{4,5}>{
This ... consist of... because....\\
and is peculiar of...
}
\end{dynblock}
\end{column}
\end{columns}
\end{frame}
\end{document}
结果: