I drew a ruler using the MWE below then I realized that It draws each medium (5 mm step) vertical line over the small ones (1 mm step) and each large (numbered) vertical bar over both medium and small ones. So, my question is: how to use conditionals to prevent overlapping?
\documentclass[tikz, border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[{x=(1mm,0)},{y=(0,1mm)}]
\tiny
\draw
(0,0)
rectangle(150,-15)
;
\foreach \x in {5, 6, ..., 145}{
\draw (\x, 0)--(\x, -2);
}
\foreach \y in {5, 10, ..., 145}{
\draw (\y, 0)--(\y, -4);
}
\foreach \z in {5, 15, ..., 145}{
\pgfmathsetmacro{\d}{(\z - 5)/10}
\draw (\z, 0)--(\z, -6) node[below]{\pgfmathprintnumber[fixed,precision=0]{\d}};
}
\end{tikzpicture}
\end{document}
0, 10, ..., 140
and the other for5, 15, ..., 135
. The smallest tick might be solved by two nested loops:\foreach \x in {0, ..., 13} \foreach \xx in {1, 2, 3, 4, 6, 7, 8, 9}
and then use10*\x + \xx
as the x value.