2

I am encountering issues with a TikZ figure after copying the code from an excellent answer here:

  \documentclass[11pt,a4paper]{article}
    \usepackage{blindtext}
    \usepackage{tkz-euclide}
    \usetkzobj{all}
    \usepackage{color}
   \begin{document}
   \begin{center}
  \begin{tikzpicture}
  \tkzDefPoint(0,0){M}
 \tkzDefPoint(1.5,0){A}
\tkzLabelPoints[below](A)
\tkzDefPoint(12,0){N}
\tkzDefPoint(10.5,0){B}
\tkzLabelPoints[below](B)
\tkzDrawSegment(M,N)
\tkzDefPoint(9.0,7){L}
\tkzDefPoint(7,5.1){C}
\tkzLabelPoints[above](C)
\tkzDrawSegment(A,L)
  \tkzDefLine[bisector](B,A,C)\tkzGetPoint{a}
  \tkzDrawSegment(A,a)
  \tkzDefPointWith[linear,K=0.6](A,a) \tkzGetPoint{D}
  \tkzDefPointBy[projection=onto A--C](D)
  \tkzGetPoint{h}
  \tkzDrawSegment(D,h)
  \tkzMarkRightAngle[fill=lightgray](A,h,D)
  %
  \tkzDefPointBy[projection=onto A--B](D)
  \tkzGetPoint{g}
  \tkzDrawSegment(D,g)
  \tkzMarkRightAngle[fill=lightgray](A,g,D)
  \end{tikzpicture}
  \end{center}
  \end{document}

My first problem arises when trying to compile the code. I need to comment \usetkzobj{all}. Otherwise, I get an error message. I attempted to update the tkz-euclide package using MikTeX Package Manager, but the issue persists. If helpful, this is a screenshot of MikTeX:

enter image description here

When the document is compiled (with the afforementioned command commented) I get the following picture.

enter image description here

I cannot understand why the labels were displaced. I did not change a single iota from the original code.

For comparison, this is the image from the linked answer. https://i.sstatic.net/VUFYR.png

Additionally, I would like to know how to add lines indicating congruence, as shown below:

enter image description here

Thank you very much for any feedback.

1
  • The new version of tkz-euclide loads all elements, so the command \usetkzobj{all} is obsolete. I have no compilation errors with PdfLaTeX on this file. Which compilation engine do you use? The nodes are incorrectly placed in the linked file, the image does not match the code. What you see corresponds to the written code.
    – AndréC
    Commented Apr 15 at 11:09

2 Answers 2

4
  1. I used AndréC's code with a few modifications. I removed what was unnecessary. In your code, I removed \usepackage{tikz} because tkz-euclide loads it itself.

In André's code, I've changed the line \tkzDefPointWith[linear,K=0.6](A,a) \tkzGetPoint{D}. It's still valid, but \tkzDefPointWith[linear normed,K=8](A,a) \tkzGetPoint{D} is preferable, as this way we know the exact length of AD.

Finally, it's a good idea to define and determine the points first, then, as a last step, trace, label and mark them.

For label positions, a .cfg configuration file is available. Depending on the user, it may be different, resulting in different positions. The best solution is to redefine your own styles.

 \documentclass[11pt,a4paper]{article}
 \usepackage{tkz-euclide}
 \begin{document}

  \begin{tikzpicture}
 % definition
  \tkzDefPoint(0,0){M}
  \tkzDefPoint(12,0){N}
  \tkzDefPoint(1.5,0){A}
  \tkzDefPoint(9,7){L}
  % calculate
  \tkzDefLine[bisector](N,A,L)             \tkzGetPoint{a}
  \tkzDefPointWith[linear normed,K=8](A,a) \tkzGetPoint{D}
  \tkzDefPointBy[projection=onto A--L](D)  \tkzGetPoint{C}
  \tkzDefPointBy[projection=onto A--N](D)  \tkzGetPoint{B}
  % drawing
  \tkzDrawSegments(D,B D,C A,a A,L M,N)
  % labeling
  \tkzLabelPoints[below](A,B)
  \tkzLabelPoints[above](C)
  % marking
  \tkzMarkRightAngles[fill=lightgray](A,C,D A,B,D)
  \tkzMarkSegments[mark=||](C,D D,B)
  \tkzMarkAngles[mark=|,size=2](B,A,D)
  \tkzMarkAngle[mark=|,size=2.1](D,A,C)
  \end{tikzpicture}

  \end{document}

enter image description here

  1. Here's a version with tkz-elements and tkz-euclide. Compiling is done with lualatex.

The definition part changes only in syntax. We define the triangle T.ANL. This avoids creating the straight lines L.AN and L.AL, which will be defined by T.ANL.ab and T.ANL.ca (ab, bc and ca are the three sides of the triangle).

bisector defines the bisector from A. bisector (2) defines the bisector from B etc.

z.a is the second point of the line L.Aa . L.Aa.pa designates the first and L.Aa.pb the second point.

z.D = L.Aa: report (6)` places point D 6cm from A.

\documentclass[11pt,a4paper]{article}
 \usepackage{tkz-euclide,tkz-elements}
 \begin{document}

\begin{tkzelements}
    -- definition
 z.M = point : new (0,0)
 z.N = z.M   : east (12)
 z.A = point : new (1.5,0)
 z.L = point : new (9,7)
 T.ANL = triangle : new (z.A,z.N,z.L)
   -- calculate
 L.Aa = T.ANL : bisector ()
 z.a  = L.Aa.pb
 z.D  = L.Aa :  report (6)
 z.B  = T.ANL.ab : projection (z.D)
 z.C  = T.ANL.ca : projection (z.D)
\end{tkzelements}

  \begin{tikzpicture}
\tkzGetNodes
 % drawing
 \tkzDrawSegments(B,D D,C A,a A,L M,N)
% labeling
 \tkzLabelPoints[below](A,B)
 \tkzLabelPoints[above](C)
% marking
 \tkzMarkRightAngles[fill=lightgray](A,C,D A,B,D)
 \tkzMarkSegments[mark=||](C,D D,B)
 \tkzMarkAngles[mark=|,size=2](B,A,D)
 \tkzMarkAngle[mark=|,size=2.1](D,A,C)
\end{tikzpicture}

\end{document}
3

I've lightened the code of unnecessary commands. The code unnecessarily defines points B, D, h and g. I've removed h and g and replaced them with B and D. I've put a slight discrepancy on the radius of the angles as it seems clearer to read that the angles are equal with the coding when their radius differs. But you can change this.

 \documentclass[11pt,a4paper]{article}
 \usepackage{blindtext}
 \usepackage{tkz-euclide}
 \usepackage{color}
 \begin{document}
   \begin{center}
  \begin{tikzpicture}
  \tkzDefPoint(0,0){M}
 \tkzDefPoint(1.5,0){A}
\tkzLabelPoints[below](A)
\tkzDefPoint(12,0){N}

\tkzDrawSegment(M,N)
\tkzDefPoint(9.0,7){L}

\tkzDrawSegment(A,L)
  \tkzDefLine[bisector](N,A,L)\tkzGetPoint{a}
  \tkzDrawSegment(A,a)
  \tkzDefPointWith[linear,K=0.6](A,a) \tkzGetPoint{D}
  \tkzDefPointBy[projection=onto A--L](D)

  \tkzGetPoint{C}
  \tkzLabelPoints[above](C)

  \tkzMarkRightAngle[fill=lightgray](A,C,D)

  \tkzDefPointBy[projection=onto A--N](D)
  \tkzGetPoint{B}
  \tkzLabelPoints[below](B)
  \tkzDrawSegments(D,B D,C)
    \tkzMarkSegments[mark=||](C,D D,B)
    \tkzMarkAngle[mark=|,size=2](B,A,D)
    \tkzMarkAngle[mark=|,size=2.1](D,A,C)
  \tkzMarkRightAngle[fill=lightgray](A,B,D)
  \end{tikzpicture}
  \end{center}
  \end{document}

enter image description here

You must log in to answer this question.

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