# Arithmetic in tikz coordinates (parentheses)

I want to use parentheses in coordinate calculation in tikz. There should be a simple way, but I couldn't find it. For example,

\def\x{10};
\draw (0,0) -- (1+1/\x,0);


this works fine. But,

\def\x{10};
\draw (0,0) -- (1+1/{\x+1},0);


this doesn't work. Other parentheses didn't work either. What is the expression for parentheses?

## 1 Answer

If your expression contains parentheses or commas, you may use {} around the whole expression:

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}
\def\x{10};
\draw (0,0) -- (1+1/\x,0);
\draw (0,0) -- ({1+1/(\x+1)},0);
\end{tikzpicture}
\end{document}

• Why "you may" ? After experimenting with some Tikz calculation, I'd rather say "you must". – kebs Dec 27 '17 at 15:09
• @kebs Another solution: you may use \pgfmathsetmacro\mytemp{1+1/(\x+1)}; \draw (0,0) -- (\mytemp,0);. Or use a let operation... – Paul Gaborit Dec 28 '17 at 3:08