I am trying to prepare a slideshow to illustrate the countability of the set of all integers. Here is what I have done so far:
\documentclass[aspectratio=169]{beamer}
\usetheme{CambridgeUS}
\usefonttheme{serif}
\setbeamercolor{background canvas}{bg=black}
\setbeamercolor{normal text}{fg=white}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{frame}{$ \mathbb{Z} $ is countable}
\begin{figure}
\centering
\begin{tikzpicture}[>=stealth, font=\tiny, declare function={a=0.2;b=2;c=6.5;}]
\onslide<+->
{
\foreach \n in {-10,...,-1}
\fill [blue] (\n/2,0) node[white] {$ \n $} circle (a);
\foreach \n in {1,...,10}
\fill [magenta] (\n/2,0) node[white] {\n} circle (a);
\fill [magenta!50!blue] (0,0) node[white] {0} circle (a);
\node [left=-5pt] at (-5.5,0) {\huge$ \dots $};
\node [right=-5pt] at (5.5,0) {\huge$ \dots $};
\node at (0,-0.5) {\normalsize$ \mathbb{Z} $};
\draw [thick, ->] (-1/2+a,-0.5) -- (-6.5,-0.5);
\draw [thick, ->] (1/2-a,-0.5) -- (6.5,-0.5);
\draw [thick, ->] (1/2-a-c-0.5,-b-0.75) -- (21/2-c,-b-0.75);
\node at (-c-0.5,-b-0.75) {\normalsize$ \mathbb{N} $};
\foreach \n in {1,...,21}
{
\draw [densely dotted] ({(\n-1)/2-c},-b) circle (a);
\node at ({(\n-1)/2-c},-b-0.5) {\footnotesize$ \n $};
}
\node [right=-5pt] at (21/2-c,-b-0.5) {\huge$ \dots $};
\node [right=-5pt] at (21/2-c,-b) {\huge$ \dots $};
}
\onslide<+->
{
\fill [magenta!50!blue] (-c,-b) node[white] {0} circle (a);
\fill [black] (0,0) node[white] {0} circle (a);
}
\foreach [evaluate=\n as \tint using {(1+(-1)^\n)*50}] \n in {1,...,20}
{
\onslide<+->
{
\fill [blue!\tint!magenta] (\n/2-c,-b) circle (a);
}
}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
What I exactly want can be seen with the behaviour of the '0' ball in slide 2. I want to replicate this behaviour for the other balls. Precisely, what I want to add more in each slide from the 3rd slide onwards are
- Colour the integer balls in black along the 'Z' line and leave their integer numbering at their centres,
- Number the consecutive balls along the 'N' line with their corresponding integer numbering.
I am unable to achieve this with the single variable \n
. Is there any way to declare variables based on the even or odd nature of \n
? Please help.