- A macro is defined by a name and a command. A macro can have local variables and parameters called : %1, %2, .... Declaring parameters is not necessary.
- So that the macro text will not be recorded in one line in the file *.teg, it
has to be formated using line feeds [with the Enter key]
^{3}therefore increasing the lisibility. Added to that, it is also possible to add comments. Two methods for the comments: between braces : {this is a comment}, or a comment line beginning with //. - Exemple(s): here is the command defining a macro called racine that is
giving the n-th roots of a complex number:
{usage: racine(n,z), gives the n-th root list of z}

if (Ent(%1)=%1) And %1>0

then $a:= abs(%2)^(1/%1),

for $k from 0 to %1-1 do a*exp(i*(Arg(%2)+$k*2*pi)/%1) od

fi- It is tested if the first parameter (represents n) is a positive integer, then we store in a local variable the n-th root of the modulus of z (second parameter) then we give the solutions list (else the macro returns Nil).
- The execution of [$a:=3, racine(a,i)] gives: [0.866025+0.5*i, -0.866025+0.5*i, -i].

- TeXgraph doesn’t test the number of arguments, the implicit value of the missing arguments is Nil. If there are too many arguments, surplus are ignored.