I want to partition a line segment into 5 segments of equal length and put tick marks at the new partition points. I want the tick marks to appear in black. Next I want to partition each new segment into 5 segments of equal length and want to color only the new tick marks in blue.
To achieve this task, I used TikZ and following is the code.
\documentclass[11pt]{amsart}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,10)-- (15,10);
\foreach \x in {0,...,5}
\draw (3*\x,10)--(3*\x,9.8);
\foreach \x in {1,...,4,6,...,9,11,...,14,16,...,19,21,...,24}
\draw[draw=blue] (3*\x/5,10)--(3*\x/5,9.8);
\end{tikzpicture}
\end{document}
However, the outcome is not the desired outcome.
So I read the manual and it suggests that I should include at least two starting numbers. I edited the code accordingly, and obtained the desired outcome. The new code is given below.
\documentclass[11pt]{amsart}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,10)-- (15,10);
\foreach \x in {0,...,5}
\draw (3*\x,10)--(3*\x,9.8);
\foreach \x in {1,...,4, 6,7,...,9, 11,12,...,14,16,17,...,19, 21,22,...,24}
\draw[draw=blue] (3*\x/5,10)--(3*\x/5,9.8);
\end{tikzpicture}
\end{document}
Here is my puzzle. If you give the starting number and the ending number to a counter that knows the increment is by 1(by default) then you do not have to give two starting numbers.
This seems to be the case, as the following works.
\foreach \x in {0,...,5}
\draw (3*\x,10)--(3*\x,9.8);
But, the counter seems to loose this capability the second time around as I have to give two numbers to remind the counter that the increment is by 1. (This is my hypothesis.)
What is the reason behind this?
Best Answer
By trial and error, it seems like whenever TikZ has an ambiguous step increment size, it simply assumes the
previous integercurrent 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 size6-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 size8.7-1=7.7
. You can test it for yourself usingIt also applies to letters such that
results with
a,b,c,f,k,p,u,z