TeX - LaTeX Asked on March 23, 2021
The following presentation depicts an empty circle emerging on frame 2. The color of the circle then proceeds to toggle between blue and red.
This presentation was produced with the following code.
documentclass{beamer}
usepackage{tikz}
usetikzlibrary{overlay-beamer-styles}
begin{document}
begin{frame}{Frame thepage}
[
begin{tikzpicture}
draw[
, ultra thick
, visible on=<{2,3,5}>
, fill=blue
, fill on=<{3,5}>
] circle (2cm);
draw[
, ultra thick
, visible on=<{4, 6}>
, fill=red
, fill on=<{4, 6}>
] circle (2cm);
end{tikzpicture}
]
end{frame}
end{document}
Here, the blue circles are defined separately from the red circles. I’m curious if it’s possible to simplify this code by combining everything into one draw
command. I’ve tried doing
draw[
, ultra thick
, visible on=<{2-}>
, fill=blue
, fill on=<{3,5}>
, fill=red
, fill on=<{4, 6}>
] circle (2cm);
but this ignores all the blue circles:
Is there anything else I can do?
Yes, this is possible with the alt
key (which derives from beamer
's alt
command).
documentclass{beamer}
usepackage{tikz}
usetikzlibrary{overlay-beamer-styles}
begin{document}
begin{frame}{Frame thepage}
[
begin{tikzpicture}
draw[
, ultra thick
, visible on=<{2-6}>
,alt=<{3,5}>{fill=blue}{fill=red,fill on=<{4, 6}>}
] circle[radius=2cm];
end{tikzpicture}
]
end{frame}
end{document}
Answered by user228539 on March 23, 2021
One way is use preaction
and postaction
options:
documentclass{beamer}
usepackage{tikz}
usetikzlibrary{overlay-beamer-styles}
begin{document}
begin{frame}{Frame thepage}
[
begin{tikzpicture}[ultra thick]
draw[preaction={fill=blue, visible on=<{3,5}>},
visible on=<2->,
postaction={fill=red, visible on=<{4,6}>}
] circle (2cm);
end{tikzpicture}
]
end{frame}
end{document}
Answered by Zarko on March 23, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP