Complex Count in \foreach for number line
There are many ways for numerical calculations. The following example uses e-TeX's \numexpr
:
\the\numexpr 135 + 5 * \x \relax
Full example:
\documentclass[letterpaper,12pt]{book}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=1pt,line cap=round,x=.5cm,y=.5cm]
\clip (0,-0.8) rectangle (10,1);
% Inequality Line
\draw [<->,thick] (0,0) -- (10,0);
% Tick Marks
\foreach \x in {1,2,...,9}
\draw (\x,-2pt) -- (\x,2pt) node [anchor=north,below=3pt]
{$\scriptstyle \the\numexpr135+5*\x\relax$};
% Displayed Solution
\end{tikzpicture}
\end{document}
There are many ways for numerical calculations inside \foreach
loop. Here are two possibilities, one use count
, the other evaluate
:
\documentclass[preview, border=7mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=1pt,line cap=round,x=.5cm,y=.5cm]
% axes
\draw [<->,thick] (0,0) -- (10,0);
% tick marks and numbers below
\foreach[count=\x] \l in {140,145,...,180}
\draw (\x,2pt) -- (\x,-2pt) node[blue, below,scale=.5]{$\l$};
% numbers above
\foreach[evaluate={\l=int(5*\x+135)}] \x in {1,...,9}
\node[above,scale=.5,red] at (\x,2pt) {$\l$};
\end{tikzpicture}
\end{document}