2

In Tikz, I'm trying to do something like this:

\foreach \x in {0,...,4}
\draw[fill=black] (\x ,\x *\x ) circle [radius=.2] node[below right] {$(\x,\x*\x)$};

The problem is that the node doesn't recognize that I want the second coordinate to be the square of the first; it just writes (0,0*0), (1,1*1), etc.

Is there a clean, simple way to tell Tikz that I want parts of the node to be expressions of \x?

1
  • @marmot He's referring to the node text, not the coordinate. Jan 16 '18 at 0:49
6

For example with evaluate:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach [evaluate={\y=int(\x*\x)}] \x in {0,...,4}
  \draw[fill=black] (\x ,\x *\x ) circle [radius=.2] node[below right] {$(\x,\y)$};
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.