By trial and error, it seems like whenever TikZ has an ambiguous step increment size, it simply assumes the previous integer current index minus one, as the step size. In other words, when you enter {1,...4,6,...20}
, it gives you {1,2,3,4,6,11,16}
with step size 6-1=5
and similarly if you enter {1,...4,8.7,...25}
you get {1,2,3,4,8.7, 16.4, 24.09999}
with step size 8.7-1=7.7
. You can test it for yourself using
\begin{tikzpicture}
\foreach \x in {1,...,4,8,...,25}
{\node at (\x / 2,0) {$\x$};}
\end{tikzpicture}
It also applies to letters such that
\begin{tikzpicture}
\foreach \x [count = \xi] in {a,...,c,f,...,z}
{\node at (\xi,0) {$\x$};}
\end{tikzpicture}
results with a,b,c,f,k,p,u,z
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:
\long\def\GobToSemiColon #1;{}
\newcommand\myPicture{
\begin{tikzpicture}
\begin{scope}[start chain = going below]
\ifnum\value{count}<1 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>3 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is between
1 and 3};
\ifnum\value{count}>-1 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is
negative};
\ifnum\value{count}<100 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>200 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only if counter is between
100 and 200};
\ifnum\value{count}<3 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>20 \expandafter\GobToSemiColon\fi
\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}
Best Answer
and an example with placing the value in a node: