10

I would like to place in a slide a block of words and at right of it a figure so that in the slide the figure will be on the left and the block explaining it at right. I'm using Beamer.

I tried the example posted in Beamer text and image on the same slide but it doesn't work.

How can this be done?

1 Answers1

8

I built an example with a mindmap as figure and three blocks as explanation text (just to use both block, alertblock and exampleblock).

The code used to create the mindmap is taken from How to shade mindmap concepts?, so maybe you are not interested in, but I think this could be useful to show you also how to present figures dynamically, not only blocks.

Here is the code (commented such that you can skip the part useful for the mindmap):

\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}

The result is:

enter image description here

To be coherent with the image, blocks related to a given concept are displayed when the concept is shown; in the picture, to decide when a new concept should be presented, it is used visible on=<value>. The same value, therefore, is applied to the block: \begin{block}<value>.... If the value does not comprise a -, that block will presented just in the moments given in value. This idea is taken from Mindmap tikzpicture in beamer (reveal step by step).

Let's change a bit the previous example to show this fact (the change is just for the block part, the rest of the code is still the same):

% 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}

The result now is:

enter image description here

The important thing to notice is the - in all overlay specifications.


Since in the comments has been mentioned the dynblocks package, I provide a solution that makes use of it. Note: to compile the version 0.2a is required.

Code:

\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}

Result:

enter image description here

David Carlisle
  • 757,742
  • Hi Claudio!! I applied your code to my presentation! It works fine and it gave me other suggestions to perform it. But I have a question.Is it ok to use the package dynplot you developed? I find it easy. Thanks a lot! – NewUsr_stat Jul 15 '12 at 14:40
  • Yes of course. The dynblocks package is developed exactly for these situations :). – Claudio Fiandrino Jul 15 '12 at 14:46
  • @Yang: glad you like it :) – Claudio Fiandrino May 27 '14 at 06:20
  • @ClaudioFiandrino I don't know why, but \opaqueblock<{2,3}> doesn't work; another set of braces seems necessary: \opaqueblock<{{2,3}}> – egreg Sep 17 '14 at 21:37
  • @ClaudioFiandrino Alternatively <{2-3}> does the trick as well. – 1010011010 Sep 17 '14 at 22:09
  • @egreg: Indeed, thank you for pointing this out. Honestly I don't see the reason for that. The macro is created with xparse through r<> option. It can be either an issue due to the new release of xparse or because of TikZ 3.0.0. More tests are needed. – Claudio Fiandrino Sep 18 '14 at 05:33
  • @1010011010: Thank you: the alternative you suggested works. However, it may not work in a more general case, for instance if one has to make visible overlays 2,3,6,8. Hence it is better to know the need of double braces anyway ;) – Claudio Fiandrino Sep 18 '14 at 05:35
  • @ClaudioFiandrino I got no error when I redefined \opaqueblock with <{#1}> everywhere in the replacement text, so the braces that got stripped are reinstated. They should make no harm in the other situations, because they're stripped anyway later. – egreg Sep 18 '14 at 08:22
  • @egreg: True! I will fix that and upload to CTAN the new version. Thanks for the hint :) – Claudio Fiandrino Sep 18 '14 at 09:21