summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex39
1 files changed, 19 insertions, 20 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex
index d090ccae996..4e112adb9d7 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex
@@ -50,7 +50,7 @@ following command:
that \emph{every statement should end with a semi-colon}. This is likely to
be the most common reason why the |\tikzmath| command fails.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
% Adapted from http://www.cs.northwestern.edu/academics/courses/110/html/fib_rec.html
function fibonacci(\n) {
@@ -82,7 +82,7 @@ In addition to this command the following key is provided:
\begin{key}{/tikz/evaluate={\meta{statements}}}
This key simply executes |\tikzmath{|\meta{statements}|}|.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikz[x=0.25cm,y=0.25cm,
evaluate={
int \i, \j;
@@ -96,13 +96,12 @@ In addition to this command the following key is provided:
\foreach \i in {0,...,10}
\foreach \j in {0,...,10}
\fill [red!\a{\i,\j}!yellow] (\i,\j) rectangle ++(1, 1);
-
\end{codeexample}
%
\end{key}
The following sections describe the miniature language that this library
-provides and can be used in the |\tikzmath| command and the |evaluate| key.
+provides and can be used in the |\tikzmath| command and the |evaluate| key.
The language consists only of simple keywords and expressions but the
mini-parser allows you to format code in a reasonably versatile way (much like
the |tikz| parser) except that \emph{all the keywords must be followed by at
@@ -116,7 +115,7 @@ In the simplest case, you will want to evaluate an expression and assign it to
a macro, or a \TeX\ count or dimension register. In this case, use of the
|math| library is straightforward:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\newcount\mycount
\newdimen\mydimen
\tikzmath{
@@ -132,7 +131,7 @@ In addition, \TeX-macros (\emph{not} \TeX\ registers) can be suffixed with an
index, similar to indices in mathematical notation, for example, $x_1$, $x_2$,
$x_3$:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
\x1 = 3+4; \x2 = 30+40; \x3 = 300+400;
}
@@ -142,7 +141,7 @@ $x_3$:
The index does not have to be a number. By using braces |{}|, more
sophisticated indices can be created:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
\c{air} = 340; \c{water} = 1435; \c{steel} = 6100;
}
@@ -167,7 +166,7 @@ the following keyword:
Any spaces preceding \meta{expression} are removed, but any trailing spaces
(before the semi-colon) are included.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
let \x = (5*4)+1;
let \c1 = blue;
@@ -196,7 +195,7 @@ keywords shown below. It is important to remember that by telling the |math|
library you want it to do a particular assignment for a variable, it will also
do the same assignment when the variable is indexed.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
integer \x;
\x1 = 3+4; \x2 = 30+40; \x3 = 300+400;
@@ -214,7 +213,7 @@ do the same assignment when the variable is indexed.
\emph{not} \TeX\ registers. In addition the variables should \emph{not} be
indexed.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
integer \x, \y, \z;
\x = 4*5+6;
@@ -249,7 +248,7 @@ following keyword.
|(my node.east)| to be parsed and assigned to \meta{variable} in the form
$x,y$, which can then be used in a |tikzpicture|:
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
coordinate \c;
\c = (45:10pt);
@@ -261,7 +260,7 @@ following keyword.
performed; the coordinate expression does not have to be surrounded by
|($|\ldots|$)|.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
coordinate \c, \d;
\c = (-1,2)+(1,-1);
@@ -277,7 +276,7 @@ following keyword.
the name of \meta{variable} suffixed with |y| (i.e., |\cy|) and is assigned
the $y$ coordinate of |\c|.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
coordinate \c;
\c1 = (30:20pt);
@@ -307,7 +306,7 @@ following keyword.
comma, it \emph{must} be surrounded by braces, for example,
|{mod(5, 2)}|.
%
-\begin{codeexample}[]
+\begin{codeexample}[pre={\pgfmathsetseed{1}},preamble={\usetikzlibrary{math}}]
\tikzmath{
int \x, \v;
\v=1;
@@ -321,7 +320,7 @@ following keyword.
\item Because each item is evaluated, you cannot use \tikzname\
coordinates in \meta{list}.
\item Only single variable assignment is supported.
- \item The ``dots notation'' (e.\,g., |1,2,...,9|) can be used in
+ \item The ``dots notation'' (e.g., |1,2,...,9|) can be used in
\meta{list}, but is not as sophisticated as the \pgfname\
|\foreach| command. In particular, contextual replacement is not
possible.
@@ -330,7 +329,7 @@ following keyword.
|for| statement. This includes the values assigned to the
\meta{variable}.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\tikzmath{
int \x, \y;
\y = 0;
@@ -362,7 +361,7 @@ of an expression. In this case the following keyword can be used:
\meta{if-zero-statements} are executed if the expression in
\meta{condition} evaluates to zero.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\begin{tikzpicture}
\tikzmath{
int \x;
@@ -405,7 +404,7 @@ You can add functions by using the following keywords:
Although \meta{definition} can take any statements accepted by |\tikzmath|,
it is not advisable try to define functions inside other functions.
%
-\begin{codeexample}[]
+\begin{codeexample}[pre={\pgfmathsetseed{1}},preamble={\usetikzlibrary{math}}]
\tikzmath{
function product(\x,\y) {
return \x*\y;
@@ -438,7 +437,7 @@ options. Firstly, the following keyword can be used:
in real programming languages). The \meta{code} is executed inside a \TeX\
group.
%
-\begin{codeexample}[]
+\begin{codeexample}[pre={\pgfmathsetseed{1}},preamble={\usetikzlibrary{math}}]
\tikzmath{
int \x, \y, \z;
\x = random(2, 5);
@@ -458,7 +457,7 @@ is executed inside a \TeX\ group. Unlike the |print| keyword, the brace
notation can be used in functions so that |tikz| path commands can be safely
executed inside a |tikzpicture|.
%
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usetikzlibrary{math}}]
\begin{tikzpicture}
\draw [help lines] grid (3,2);
\tikzmath{