I'm trying to make a tikz drawing using the component lengths as macros so I can easily adjust things and have changes propagate. That works, but when I try to use division to draw lines at even intervals on a macro-defined width, I get problems. I think it is because the fractions are being applied to only the first value in the tableWidth command, as it is just a dumb substitution, rather than combining the values in the command before inserting it into the body.
How can I force latex to evaluate math on a dimension before I apply other operations to it? Are there other packages I should be using to do this? I have googled around and found things relating to dimexpr and others but can't make sense of it or make it work for my context.
\documentclass[letterpaper]{scrartcl}
\usepackage{tikz}
\usepackage{graphicx}
\newcommand{\positionRad}{14mm}
\newcommand{\positionSpacing}{32mm}
\newcommand{\iconSize}{12mm}
\newcommand{\tableHeight}{20mm}
\newcommand{\tablePad}{6mm}
\newcommand{\tablePositionSep}{\positionRad+8mm}
\newcommand{\tableWidth}{4*\positionSpacing + \positionRad}
\graphicspath{{../icons/}}
\begin{document}
\begin{tikzpicture}
\draw (\positionSpacing, \tablePositionSep+\tableHeight) circle (\positionRad) node{\LARGE1};
\draw (2\positionSpacing, \tablePositionSep+\tableHeight) circle (\positionRad) node{\LARGE2};
\draw (3\positionSpacing, \tablePositionSep+\tableHeight) circle (\positionRad) node{\LARGE3};
\draw (4*\positionSpacing, \tablePositionSep+\tableHeight) circle (\positionRad) node{\LARGE4};
\draw (\positionSpacing-\positionRad,\tablePad) rectangle (\tableWidth,\tablePad+\tableHeight);
\draw (1/6\tableWidth,\tablePad) -- (1/6\tableWidth,\tablePad+\tableHeight);
\draw (1/3\tableWidth,\tablePad) -- (1/3\tableWidth,\tablePad+\tableHeight);
\draw (1/2\tableWidth,\tablePad) -- (1/2\tableWidth,\tablePad+\tableHeight);
\draw (5/6\tableWidth,\tablePad) -- (5/6\tableWidth,\tablePad+\tableHeight);
\draw (2/3\tableWidth,\tablePad) -- (2/3\tableWidth,\tablePad+\tableHeight);
\end{tikzpicture}
\end{document}
\newcommand{\tablePositionSep}{\the\dimexpr\positionRad+8mm} \newcommand{\tableWidth}{\the\dimexpr4*\positionSpacing + \positionRad}? I think that you should remove things of the type\includegraphics[width=\iconSize]{inf.png}because others won't have the png file, and add an appropriate\documentclassso that others can run your file – May 05 '21 at 00:45