TeX - LaTeX Asked by Yossi Gil on May 27, 2021
I would like to set up a presentation in which different parts of the same tikz picture appear, depending on the value of one, perhaps more, integer variables. I tried at first using a fixed picture, with changing the visibility of the different path elements of it, depending on the slide number, but this did not scale. There are about 150 slides in a single frame.
Then, I tried an alternative in which the entire picture is defined as a macro, which is invoked once per slide, with different portions showing based on global conditions. However, I failed in including conditionals within the keys.
Here is a not so minimal and certainly not working example demonstrating my failures. Any help would be appreciated:
documentclass{beamer} usepackage{tikz} usetikzlibrary{chains} tikzset{% invisible/.style={opacity=0}, } newcounter{count} newcommandmyPicture{ begin{tikzpicture} begin{scope}[start chain = going right] node[draw, circle, on chain] { ifnum value{count} > 1 {Count is greater than s} fi}; node[draw, circle, on chain,opacity=0] {B}; node[draw, circle, on chain, ifnum value{count} > 1relax invisiblefi] {C}; node[draw, circle, on chain] {D}; end{scope} end{tikzpicture} } begin{document} begin{frame} setcounter{count}{2} ifnum value{count} > 1 {Count is greater than 1} fi ifnum value{count} > 2 {Count is greater than s} fi only{ setcounter{count}{2} myPicture } only{ setcounter{count}{1} myPicture } only{ setcounter{count}{2} myPicture } end{frame} end{document}
Here is a minimal example giving an idea of the expected result, but of course, without achieving it:
documentclass{beamer} usepackage{tikz} usetikzlibrary{chains} newcounter{count} newcommandmyPicture{ begin{tikzpicture} begin{scope}[start chain = going below] node[draw, rectangle, on chain] {display only when counter is between 1 and 3}; node[draw, rectangle, on chain] {display only when counter is negative}; % node[draw, rectangle, on chain] {display only if counter is between 100 and 200}; node[draw, circle, on chain] {only when counter is in the range 3 to 20}; end{scope} end{tikzpicture} } begin{document} begin{frame} only{setcounter{count}{-3}myPicture} only{setcounter{count}{105}myPicture} only{setcounter{count}{39}myPicture} only{setcounter{count}{2}myPicture} end{frame} end{document}
I am definitely unfamiliar with both beamer
and tikz
(do not quite get what the only
are supposed to do) but perhaps this could go in the direction you want:
documentclass{beamer}
usepackage{tikz}
usetikzlibrary{chains}
newcounter{count}
% helper macro:
longdefGobToSemiColon #1;{}
newcommandmyPicture{
begin{tikzpicture}
begin{scope}[start chain = going below]
ifnumvalue{count}<1 expandafterGobToSemiColonfi
ifnumvalue{count}>3 expandafterGobToSemiColonfi
node[draw, rectangle, on chain] {display only when counter is between
1 and 3};
ifnumvalue{count}>-1 expandafterGobToSemiColonfi
node[draw, rectangle, on chain] {display only when counter is
negative};
ifnumvalue{count}<100 expandafterGobToSemiColonfi
ifnumvalue{count}>200 expandafterGobToSemiColonfi
node[draw, rectangle, on chain] {display only if counter is between
100 and 200};
ifnumvalue{count}<3 expandafterGobToSemiColonfi
ifnumvalue{count}>20 expandafterGobToSemiColonfi
node[draw, circle, on chain] {only when counter is in the range 3 to 20};
end{scope}
end{tikzpicture}
}
begin{document}
begin{frame}
only{setcounter{count}{-3}myPicture}
only{setcounter{count}{105}myPicture}
only{setcounter{count}{39}myPicture}
only{setcounter{count}{2}myPicture}
only{setcounter{count}{5}myPicture}
end{frame}
end{document}
Correct answer by user4686 on May 27, 2021
I tried to modify your minimal example by introducing a changing tikzpicture
depending on the value of an integer.
To make the drawing stable on all the slides, I included a clip
action.
I couldn't quite figure out what your problem was and I imagine that the lapse of time between your question and my answer is not helping. Let me know if you are still looking for something else.
documentclass{beamer}
usepackage{xcolor}
usepackage{tikz}
usetikzlibrary{chains}
newcounter{count}
newcommand{myPicture}[1]{%
begin{tikzpicture}
clip (-5, -3.3) rectangle (5, 3.3);
begin{scope}[start chain = going below]
ifnum#1<4
node[draw, rectangle, on chain, fill=yellow]
{display only when counter is between 1 and 3};
node[on chain, red!50!black, fill=blue!50!black!10,
inner sep=2ex, rounded corners, scale=1.25, rotate={(#1-1)*10}]
{counter=#1};
else
ifnum#1<6
node[draw, rectangle, on chain, rounded corners]
{display only when counter is 4 or 5};
else
ifnum#1=6
node[draw, rectangle, on chain]
{display only when counter is 6 or 7};
else
ifnum#1=7
node[draw, rectangle, on chain,
label={[fill=orange]-35:not so identical}]
{display only when counter is 6 or 7};
else
node[draw, very thick, blue, circle, on chain]
{only when counter is 8, or ldots};
fifififi
end{scope}
end{tikzpicture}
}
begin{document}
begin{frame}{Introduction}
Some information on the first frame and an example with multiple slides based on a TikZ picture on the second one.
end{frame}
begin{frame}{A changing image on this frame}
The inspiring test: (on slide thepage -- total counting)
bigskip
only<1> {myPicture{1}}
only<2> {myPicture{2}}
only<3> {myPicture{3}}
only<4-5> {myPicture{4}}
only<6> {myPicture{6}}
only<7> {myPicture{7}}
only<8> {myPicture{8}}
end{frame}
end{document}
Answered by Daniel N on May 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP