Is it possible to define points in tkz-euclide outside of the tikzpicture environment?

For example I would like to have something like this exercise in elementary geometry:


Consider the triangle $\Delta$ defined by the points \definePoint{A,2,3}, 
\definePoint{B,10,3} and \definePoint{C,-1,4}. 
Draw the inscribed circle and the circumscribed circle of this triangle.


% The triangle
%A,B,C are defined in the exercise above
\tkzDrawSegments(A,B B,C C,A)

% circumcircle

% incircle
\tkzDrawCircle[R](I,\rIN pt)

\tkzLabelPoints[below left](C)
\tkzLabelPoints[above left](A,I,G)

The point is, that if I modify the coordinates of the Points A,B,C in the question, the points in the solution should be modified too.


I don't know any official way to do this. TikZ seems to remembers the position of nodes between pictures, but I think this is mostly an unintended side-effect of the way nodes a stored, rather than anything officially supported. Anyway, you can write

\tikz \tkzDefPoint(1,2){A};

and the position of A will be know in the next picture (or technically until a new node with name A is defined).

It might be nicer to store the point definitions in a hook and add them at the beginning of the tikzpicture, as done in the following code. That way, one doesn't have to rely on undocumented features and can use the label option of \tkzDefPoint.


% Define a point for use in the next TkZ drawing.
% Takes 2 mandatory and one optional argument:
%  * The optional argument is passed as optional argument to \tkzDefPoint.
%  * The first mandatory argument is the name of the point, e.g. “A”.
%  * The second mandatory argument is the coordinates of the point (without parenthesis).
% The macro also adds $name = (coordinates)$ to the text.
% To actually add the points to a tikzpicture, you need to call \definedPoints
% at the start of the tikzpicture.

% hook to store the points until they are used

% Print anything in the hook and clear in afterwards.

Consider the triangle $\Delta$ defined by the points \definePoint[label=above:$A$]{A}{2,3}, 
\definePoint{B}{8,3} and \definePoint{C}{-1,-1}. 

    % The triangle
    % A,B,C are defined in the exercise above
    \tkzDrawSegments(A,B B,C C,A)
  • Thanks. Is it possible to modify this, that it is possible to reuse the identifier A later in the text for another point, for example one may append this to your example: Consider another triangle $\Delta_2$ defined by the points \definePoint[label=above:$A$]{A}{1,3}, \definePoint{B}{2,3} and \definePoint{C}{-1,-1}. \begin{tikzpicture} % The triangle %A,B,C are defined in the exercise above \tkzDrawSegments(A,B B,C C,A) \end{tikzpicture} – student Apr 21 '11 at 21:20
  • @user: Do you mean that the same definition should be used in a second tikzpicture? – Caramdir Apr 21 '11 at 21:23
  • @Caramdir: If I use the points A,B,C from your example in a second tikzpicture, there is no problem. However, I want to redefine A, B and C after the first tikzpicture. I tried this, but it has no effect. (Just append the code from my last comment and see what happens). – student Apr 21 '11 at 21:28
  • @user You need to add \definedPoints in every tikzpicture where you want to use the defined points. – Caramdir Apr 21 '11 at 21:34

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.