# Is print in TikZ's math, useless?

In the manual of TikZ 3.0.0, the section about the math library, we can read (p. 635):

Unlike the print keyword, the brace notation can be used in functions so that tikz path commands can be safely executed inside a tikzpicture.

And then there's this example:

\documentclass[tikz,border=7]{standalone}
\usetikzlibrary{math}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw [help lines] grid (3,2);
\tikzmath{
coordinate \c;
for \x in {0,10,...,360}{
\c = (1.5cm, 1cm) + (\x:1cm and 0.5cm);
{ \fill (\c) circle [radius=1pt]; };
};
}
\end{tikzpicture}
\end{document}


If I replace

{ \fill (\c) circle [radius=1pt]; };


by

print { \fill (\c) circle [radius=1pt]; };


I obtain exactly the same result:

This is probably because there is no function use. If we check with print inside a function that is inside a tikzpicture, we can see the difference.

\documentclass[tikz,border=7]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}
\draw [help lines] grid (5,2);
\tikzmath{
function drawpoint(\s,\t){
{ \fill[red] (\s pt,\t pt) circle [radius=1pt] node[above]{(\s,\t)}; };
print { \fill[blue] (\s pt,\t pt) circle [radius=1pt] node[below]{(\s,\t)}; };
};
coordinate \c; \c = (2cm, 1cm);
drawpoint(\c);
}
\end{tikzpicture}
\end{document}


So my question is: Why do we need print ? Is there some example where we must put it?

• There is no difference between { ... } and print { ... }. Quoting the TikZ manual "[print] is intended as convenience keyword…" – Henri Menke Dec 28 '14 at 14:21
• @HenriMenke you can see in the example that there is a difference, and you can read the citation that I put from the manual. – Kpym Dec 28 '14 at 14:28
• I notice that removing some spaces, as in ...print{\fill... changes the output. – Steven B. Segletes Dec 28 '14 at 14:54
• @StevenB.Segletes interesting. After your comment I checked by putting some text before \fill : the print displays it (I don't know how, it is not a node), and the { } ignores it. The same for print {some text}; and {some text}; inside the function. Both are the same outside the tikzpicture (reproducing the text) and between the function and the tikzpicture both produce error. – Kpym Dec 28 '14 at 16:08
• The difference is that "useless" print command does not execute \nullfont inside a tikzpicture prior to executing its argument (or perform any checks to see if it necessary) making it marginally quicker. Code inside functions is executed by the math parser which installs the prevailing font so that lengths such as 1ex and 2em can be evaluation. Thus, print should not be used inside functions unless extreme care is taken with spaces as they will be printed. The alternative { }; syntax can be used instead. – Mark Wibrow Dec 28 '14 at 18:23

The different between the print {some code or text}; and the {some code or text}; syntax is that the print keyword does not execute \nullfont inside a tikzpicture prior to executing its argument (or perform any checks to see if it necessary) making it marginally quicker.
Code inside functions is executed by the math parser which installs the prevailing font so that lengths such as 1ex and 2em can be evaluated. Thus, print should not be used inside functions unless extreme care is taken with spaces as they will be printed. The alternative { }; syntax can be used instead.
Additionally print is a kind of "syntactic sugar" to make code more readable.
• Thanks to transforming your comment in an answer! In conclusion if I understand well : we should use { }; when we "print" inside tikzpicture (for example {\draw circle(1);};) and we should use print { }; to "print" outside of tikzpicture, for example inside node's text. So print is really useful ;) – Kpym Jan 13 '15 at 10:19