1

I'm using tkz-euclide to draw some diagrams.

    \begin{tikzpicture}
        \tkzDefPoints{0/0/O,4/0/P}
        \tkzDrawCircle(O,P)
        \tkzDefPointBy[rotation= center O angle -60](P)
        \tkzGetPoint{A}
        \tkzDefPointBy[rotation= center O angle -120](P)
        \tkzGetPoint{B}
        \tkzDrawSegments(O,A O,B)
        \tkzLabelPoints[below right](A){$A$}
        \tkzLabelPoints[below left](B){$B$}
        \tkzDrawSector[R with nodes,fill=gray!20](O,4)(B,A)
        \tkzLabelSegment(O,A){\SI{5}{\centi\m}}
        \tkzLabelArc[below](O,B,A){$7$}
      \end{tikzpicture}

My issue is labelling at the centre. The code appears to be overwriting, and I'm not sure what I've done to make it do this! The issue is overwriting at the centre of the circle

The 7 was a remnant of an earlier question. I left the label as I was trying to get the other labelling correct!

3
  • Your question is not entirely clear to me. When I compile your code (after adding the documentclass, packages, begin/end document) I get i.stack.imgur.com/cq2cx.png. In the center it has labels A and B. What exactly is the problem with this output? What would you like to see differently? Maybe you can add a screenshot to your question that you modify in an image editor to show the current output and a sketch of the required output.
    – Marijn
    May 18, 2022 at 7:59
  • Just out of interest, what is the label "7" supposed to represent? With a radius of 5cm and an angle of arc of 60° the length of arc AB would be π / 3 * 5cm which is not obviously 7 of anything ??
    – Thruston
    Mar 16, 2023 at 9:38
  • I was adapting from another question, and often concentrate on the figure, fixing the labels up later. This is a remnant of this.
    – bbujeya
    May 28, 2023 at 3:28

2 Answers 2

2

I know the question was about tkz-euclide, but just for comparison, here is the code just using tikz, which may be preferable for some users.

enter image description here

\documentclass{article}

\usepackage{tikz}
\usepackage{siunitx}
 
\begin{document}
    
\begin{tikzpicture}
  \draw coordinate(O) circle[radius=4cm];
  \draw[fill=gray!20] (-60:4)node[below right]{$A$}--node[right]{\SI{5}{\centi\m}} (O) 
    --(-120:4)node[below left]{$B$} arc (-120:-60:4)node[midway, below]{7};
\end{tikzpicture}
      
\end{document}
2

You have made a mistake:

you need \tkzLabelPoint[below right](A){$A$} instead of \tkzLabelPoints[below right](A){$A$}. When you use \tkzLabelPoints you can't put {$A$} because this macro allows you to place several labels and the labels are placed automatically. It's preferable to use \tkzDrawSector[fill=gray!20](O,B)(A) to avoid using numerical values

\documentclass{article}

\usepackage{tkz-euclide}
\usepackage{siunitx}
 
\begin{document}
    
\begin{tikzpicture}
    \tkzDefPoints{0/0/O,4/0/P}
    \tkzDrawCircle(O,P)
    \tkzDefPointBy[rotation= center O angle -60](P)
    \tkzGetPoint{A}
    \tkzDefPointBy[rotation= center O angle -120](P)
    \tkzGetPoint{B}
    \tkzDrawSegments(O,A O,B)
    \tkzLabelPoint[below right](A){$A$}
    \tkzLabelPoint[below left](B){$B$}
    \tkzDrawSector[fill=gray!20](O,B)(A)
    \tkzLabelSegment(O,A){\SI{5}{\centi\m}}
    \tkzLabelArc[below](O,B,A){$7$}
\end{tikzpicture}
      
\end{document}

update : The triangle being equilateral

\documentclass{article}
\usepackage{tkz-euclide}
\usepackage{siunitx}
 
\begin{document}
\begin{tikzpicture}
    \tkzDefPoints{0/0/B,5/0/A}
    \tkzDefTriangle[equilateral](B,A) \tkzGetPoint{O}
    \tkzDrawCircle(O,A)
    \tkzDrawPolygon(A,B,O)
    \tkzFillSector[fill=gray!20](O,B)(A)
    \tkzLabelPoint[below right](A){$A$}
    \tkzLabelPoint[below left](B){$B$}
    \tkzLabelPoint[above](O){$O$}
    \tkzLabelSegment[right](O,A){\SI{5}{\centi\m}}
    \tkzLabelArc[below](O,B,A){$7$}
\end{tikzpicture}     
\end{document}

With tkz-elements: soon possible with lua and almost object programming.

Not particularly interesting here because the figure is very simple but the advantage is that once the calculations are done you can use either TikZ, or tkz-euclide, or another package.

\documentclass{article}
\usepackage{tkz-euclide,tkz-elements}
\usepackage{siunitx}
 
\begin{document}
   \begin{elements}
   z.B = point: new (0,0)
   z.A = point: new (5,0)
   L   = line:  new (z.B,z.A)
   z.O = L:tr_equilateral ()
   \end{elements}
   
\begin{tikzpicture}
   \tkzGetNodes

    \tkzDrawCircle(O,A)
    \tkzDrawPolygon(A,B,O)
    \tkzFillSector[fill=gray!20](O,B)(A)
    \tkzLabelPoint[below right](A){$A$}
    \tkzLabelPoint[below left](B){$B$}
    \tkzLabelPoint[above](O){$O$}
    \tkzLabelSegment[right](O,A){\SI{5}{\centi\m}}
    \tkzLabelArc[below](O,B,A){$7$}
\end{tikzpicture}     
\end{document}

enter image description here

8
  • 1
    In my opinion, '\tkzLabelPoints' (with 's', plural) is almost useless, confusing, hence, it should be removed
    – Black Mild
    May 18, 2022 at 17:14
  • 1
    @BlackMild Sorry but I don't agree. All macros in the package have their variant with s with the principle that the same process is applied to a set of points. This allows to minimize the number of lines of code. The variant without s allows mainly to differentiate the label and the name of the node. May 18, 2022 at 19:43
  • @Alain Matthes I couldn't find tkz-elements on CTAN.
    – pascal974
    Mar 15, 2023 at 13:21
  • @pascal974 With tkz-elements: soon !! I will first put it on my site link tonight or tomorrow so that others can test it, but I have to finish a small documentation. Perhaps some users will want to participate in the development. Mar 15, 2023 at 14:02
  • @Alain Matthes Sorry, I did not see soon... thank you for all this work
    – pascal974
    Mar 15, 2023 at 14:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .