Basic loop in latex with variable counter. I want to insert x amount of spaces...
\newcommand{\insertspace}[1]{
\newcount\foo
\foo={#1}
\loop
~
\advance \foo -1
\ifnum \foo>0
\repeat
}
This call gives me an error: Missing number, treated as zero.
I assume this is from the foo counter not recognizing the parameter. (The drawbox is defined in the MWE)
\drawbox{black!100}{5.2cm}{\insertspace{7} Hi im box}
Result:
The insertspace loop works if the counter is static. It also displays my parameter when I reference it somewhere else. Is this something to do with data types?
MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\newcommand{\insertspace}[1]{
\newcount\foo
\foo={#1}
\loop
~~ hi
\advance \foo -1
\ifnum \foo>0
\repeat
}
\newcommand{\drawbox}[3]{ % 1->color ---- 2 -> width of box ----- 3-> text
\begin{tikzpicture}
\node[draw, fill={#1},rectangle,text width={#2}, text = white] {\color{white}\fontsize{6pt}{6pt}\selectfont #3};
\end{tikzpicture}
}
\drawbox{black!100}{5.2cm}{\insertspace{7} Hi im box}
\end{document}