TransWikia.com

How to adjust position of a node relative to others in beamer?

TeX - LaTeX Asked on January 3, 2021

I want to adjust the two boxes labelled ‘1’ to be in the same horizontal line, right from the first slide (just as it is in the last one)

documentclass{beamer} 
mode<presentation>{usetheme{Madrid}}

usepackage{tikz} 
usetikzlibrary{shapes,positioning,decorations.pathmorphing} 
usetikzlibrary{shapes.geometric, arrows} 
usetikzlibrary{arrows.meta,backgrounds,fit,matrix} 
usepackage[utf8]{inputenc}

tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, thick,draw=blue!50, fill=blue!10] 
tikzstyle{box} = [minimum width=3cm, minimum height=1cm, rounded corners,rectangle, fill=blue!50] 
tikzstyle{arrow}= [thick,->,>=stealth]

begin{document} %For boxes in background 
pgfdeclarelayer{background layer} 
pgfsetlayers{background layer,main}

begin{frame}[t]%{Cloud}{} 
begin{tikzpicture}[ every edge/.style = {draw, thick, -Stealth}] %
path (-1,-1)rectangle(1,1); 
node (box11) [box] {1};


tikzstyle{box} = [minimum width=3cm, minimum height=2.5cm, rounded corners,rectangle, fill=blue!30] 
node<+(1)-> (box12) [box, right of=box11,xshift=6cm] {1};

tikzstyle{box} = [minimum width=1cm, minimum height=1cm, rounded corners,rectangle, fill=blue!50] 
draw<.(1)-> [arrow] (box11.east) -- (box12.west);

begin{pgfonlayer}{background layer} 
node<.(1)-> [cloud, draw, align=left, cloud puffs=20,cloud puff arc=110, aspect=2, inner sep=0mm,fit= (box12) (box12)]{3}; 
end{pgfonlayer}

node<+(1)-> (box13) [box, right of=box12,yshift=-0.7cm] {2}; 
end{tikzpicture}

end{frame}

end{document}

One Answer

This is because the bounding box of the 3 slides are not identical. To find a sufficiently large box, just draw a rectangle that encompasses the 3.

path[use as bounding box] (-1.5,2.2)rectangle(10.7,-2.2); 
%draw (-1.5,2.2)rectangle(10.7,-2.2);  %<- bounding box

documentclass{beamer} 
mode<presentation>{usetheme{Madrid}}

usepackage{tikz} 
usetikzlibrary{shapes,positioning,decorations.pathmorphing} usetikzlibrary{shapes.geometric, arrows} usetikzlibrary{arrows.meta,backgrounds,fit,matrix} 
usepackage[utf8]{inputenc}

tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, thick,draw=blue!50, fill=blue!10] 
tikzstyle{box} = [minimum width=3cm, minimum height=1cm, rounded corners,rectangle, fill=blue!50] 
tikzstyle{arrow}= [thick,->,>=stealth]

begin{document} %For boxes in background 
pgfdeclarelayer{background layer} 
pgfsetlayers{background layer,main}

begin{frame}[t]%{Cloud}{} 
begin{tikzpicture}[ every edge/.style = {draw, thick, -Stealth}] %
path[use as bounding box] (-1.5,2.2)rectangle(10.7,-2.2); 
%path (-1.5,2.2)rectangle(10.7,-2.2); 
node (box11) [box] {1};


tikzstyle{box} = [minimum width=3cm, minimum height=2.5cm, rounded corners,rectangle, fill=blue!30] 
node<+(1)-> (box12) [box, right of=box11,xshift=6cm] {1};

tikzstyle{box} = [minimum width=1cm, minimum height=1cm, rounded corners,rectangle, fill=blue!50] 
draw<.(1)-> [arrow] (box11.east) -- (box12.west);

begin{pgfonlayer}{background layer} 
node<.(1)-> [cloud, draw, align=left, cloud puffs=20,cloud puff arc=110, aspect=2, inner sep=0mm,fit= (box12) (box12)]{3}; 
end{pgfonlayer}

node<+(1)-> (box13) [box, right of=box12,yshift=-0.7cm] {2}; end{tikzpicture}

end{frame}

end{document}

Correct answer by AndréC on January 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP