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?
{ ... }
andprint { ... }
. Quoting the TikZ manual "[print] is intended as convenience keyword…" – Henri Menke Dec 28 '14 at 14:21...print{\fill...
changes the output. – Steven B. Segletes Dec 28 '14 at 14:54\fill
: theprint
displays it (I don't know how, it is not a node), and the{ }
ignores it. The same forprint {some text};
and{some text};
inside the function. Both are the same outside thetikzpicture
(reproducing the text) and between the function and thetikzpicture
both produce error. – Kpym Dec 28 '14 at 16:08print
command does not execute\nullfont
inside atikzpicture
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 as1ex
and2em
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