Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My goal in trying to learn tkz-euclide is so that I can be able to get an arbitrary point from a circle and define the other elements of my figure from that. So far, from what I can understand from the examples given in the manual (I don't know any French), I came up with the following code.

\documentclass[tikz]{standalone}

\usepackage{tkz-euclide}
\usetkzobj{all} 

\begin{document}
\begin{tikzpicture}
    \tkzDefPoint(0,0){O} % Defines a point
    \tkzGetRandPointOn[circle=center O radius 1.5cm]{A} % Gets random point of the circle with center at O and radius 1.5cm
    \tkzDrawCircle(O,A) % Draws the circle
    \tkzDefPointBy[rotation=center O angle 100](A) % Defines a point...
        \tkzGetPoint{C} % named C
    \tkzDefPointBy[rotation=center O angle 78](A) % Defines a point...
        \tkzGetPoint{B} % named B
    \tkzDrawPoints(O,A,B,C) % Draws dots
    \tkzDrawSegments(C,B B,A A,O O,C) % Draws the segments
    \tkzLabelPoints(O,A,B,C)    % Labels the points
    %\node [below] at (O) {$O$};
    %\node [above] at (A) {$A$};
    %\node [left] at (B) {$B$};
    %\node [left] at (C) {$C$};
\end{tikzpicture}
\end{document}

This is nice. But the random positioning of the points screws up the positioning of the labels. (Try compiling several times to see.) I have tried setting up the nodes through the usual \node commands but I still end up with the same problem.How can I control the behavior of the labels so that they would not overlap with other elements of the figure?

Edit

I read this mod comment on my list of questions: Have you considered accepting an answer or starting a bounty for this question? Indeed, I have considered accepting an answer since the solution now looks trivial with tikz but I would still like to see a tkz-euclide-based solution, too. So I thought I would prolong accepting an answer for a short while. So how about starting a bounty instead? Well, why not?

share|improve this question
    
It may be worth comparing the answer below with mine. –  Please don't touch Sep 12 '12 at 3:20
    
Yeah. I saw that. I left a comment in that question too. Not the package that I am asking for but very well done in so short a code. –  hpesoj626 Sep 12 '12 at 3:25
    
It is not the link you gave a comment to. –  Please don't touch Sep 12 '12 at 3:26
    
I'm lost. Which link? –  hpesoj626 Sep 12 '12 at 3:29
    
The link in my first comment. –  Please don't touch Sep 12 '12 at 3:31
show 1 more comment

1 Answer

up vote 9 down vote accepted
+50

You could compute a point radially outside of the circle at each point to place the node:

enter image description here enter image description here enter image description here enter image description here

The label for the origin is placed at a point opposite of the (B) node. A slightly better solution would be to compute the angle midway between (OA) and (OC) and place the origin label at a 180 degree offset from that.

Code:

\documentclass[tikz,border=2pt]{standalone}

\usepackage{tkz-euclide}
\usetkzobj{all} 

\begin{document}
\begin{tikzpicture}
    \tkzDefPoint(2,1){O} % Defines the point at which the origin is located
    \tkzGetRandPointOn[circle=center O radius 1.5cm]{A} % Gets random point of the circle with center at O and radius 1.5cm
    \tkzDrawCircle(O,A) % Draws the circle
    \tkzDefPointBy[rotation=center O angle 100](A) % Defines a point...
    \tkzGetPoint{C} % named C
    \tkzDefPointBy[rotation=center O angle 78](A) % Defines a point...
    \tkzGetPoint{B} % named B
    \tkzDrawPoints(O,A,B,C) % Draws dots
    \tkzDrawSegments(C,B B,A A,O O,C) % Draws the segments

    % compute vectors of each point form the origin
    \coordinate (OA) at ($(A)-(O)$);
    \coordinate (OB) at ($(B)-(O)$);
    \coordinate (OC) at ($(C)-(O)$);

    \node [red] at ($(O)+1.15*(OA)$)  {A};
    \node [red] at ($(O)+1.15*(OB)$)  {B};
    \node [red] at ($(O)+1.15*(OC)$)  {C};
    \node [red] at ($(B)-1.15*(OB)$)  {O};
\end{tikzpicture}
\end{document}
share|improve this answer
    
Put each label outside the circle but on the corresponding bisector will be more beautiful (in my opinion). –  Please don't touch Sep 11 '12 at 17:51
1  
@GarbageCollector: Not sure I understand. To me, the correct place to put the label is along the radial line from the origin, which is what is done here. –  Peter Grill Sep 11 '12 at 18:01
    
OK. For this special case (as opposed to arbitrary polygon), putting the labels radially outward makes sense! –  Please don't touch Sep 11 '12 at 18:08
    
There is still the old trouble with that center. I tried moving it to another point with nonzero coordinates but the result was a mess. –  hpesoj626 Sep 12 '12 at 1:58
    
@hpesoj626: Have corrected for an arbitrary origin. –  Peter Grill Sep 12 '12 at 5:06
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.