0

I want to get this kind of figures in LaTeX: enter image description here

enter image description here

enter image description here

I am pretty sure these were not written manually in tikz, since it would take too much time. How can I draw hard geometry in tikz without needing to spend half an hour on each figure? I tried geogebra but the figures produced are horrible. Even by changing the software’s settings you still get ugly tikz figures and the nodes labels are placed incorrectly. Please help me, maybe with something like a WYSIWYG program for tikz, because it is not the best option to manually write the tikz code for 200 figures..

  • 5
    This is a part of tkz-euclide duty. – user108724 Apr 13 at 9:55
  • In the first figure, I don't understand how the point W is defined, geometrically. Is the line AW the bissectrix of angle LAC, per chance? – Bernard Apr 13 at 10:03
  • I think it is the bissectrix, yes. But I didn't ask for somebody to reproduce me these figures. They are only as a refrence of what I wish I would be able to draw as latex figures. I might try tkz-euclide, but it seems hard to learn. – furfur Apr 13 at 10:06
  • I just want to provide an example of what can be done in a comparatively easy way with pstricks, as its language is LaTeX-like (it is justan interface between LaTeX and the postscript language). – Bernard Apr 13 at 10:50
  • 1
    I think you should accept Schrödinger's cat answer as better one, not mine! – user197952 Apr 13 at 12:17
3

I would recommend drawing these using tkz-euclide which finally has a fantastic manual written in English. Again, the code below is just an example, but I it only took me 10 minutes to write it. Now you wont have that speed when you are starting out, but the package is very simple to use. I challenge you to find a better output, that can be done faster, with a lower learning curve ;-)

enter image description here

Code

\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all} % Remove if you use TexLive2020

\begin{document}

\begin{tikzpicture}
    % Every aspect of the figure can be altered through these definitions
    \def\radius{3} \def\X{0.35} \def\labelSpacing{1.1}
    \def\A{110} \def\B{315} \def\C{70} \def\D{215}

    % Restricts the canvas
    \tkzInit[xmin=-3.25,xmax=3.25,ymin=-3.25,ymax=3.25]\tkzClip

    \tkzDefPoints{0/0/O, \radius/0/R} % defines the first two points

    % The remainder of the points are defined through rotation
    \tkzDefPointBy[rotation=center O angle \A](R)\tkzGetPoint{A}
    \tkzDefPointBy[rotation=center O angle \B](R)\tkzGetPoint{B}
    \tkzDefPointBy[rotation=center O angle \C](R)\tkzGetPoint{C}
    \tkzDefPointBy[rotation=center O angle \D](R)\tkzGetPoint{D}

    % Get the point M as the intersection between the lines AB and CD
    \tkzInterLL(A,B)(C,D)   \tkzGetPoint{M}

    % Calculate the length AD, and define the point X
    % as X = 0 at A and X = 1 at D
    \tkzCalcLength[cm](A,D) \tkzGetLength{dAD}
    \pgfmathparse{\X*\dAD} 
    % Intersect between circle with center A and radius \X * AD
    \tkzInterLC[R](A,D)(A,\pgfmathresult cm) \tkzGetPoints{X'}{X}

    % Finds the intersection for PQ in a similar fashion, same with Y
    \tkzInterLC(X,M)(O,R)                    \tkzGetPoints{P}{Q}
    \tkzInterLL(X,M)(C,B)                    \tkzGetPoint{Y}

    \tkzDrawPoints[fill=black,size=7pt](A,B,C,D,X,Y,P,Q,M)

    \tkzMarkAngle[size=1cm, arc=lll](C,D,A)
    \tkzMarkAngle[size=1cm, arc=lll](C,B,A)

    \tkzMarkAngle[size=0.5cm, arc=ll](X,M,D)
    \tkzMarkAngle[size=0.5cm, arc=ll](Y,M,C)

    \tkzMarkAngle[size=0.4cm, arc=l](A,M,X)
    \tkzMarkAngle[size=0.4cm, arc=l](B,M,Y)

    \tkzDrawSegments(A,B B,C C,D D,A P,Q)
    \tkzDrawCircle(O,R)

    % This just defines the labels radially, looks slightly better
    \node at ($(O)+\labelSpacing*(A)$)  {$A$};
    \node at ($(O)+\labelSpacing*(B)$)  {$B$};
    \node at ($(O)+\labelSpacing*(C)$)  {$C$};
    \node at ($(O)+\labelSpacing*(D)$)  {$D$};
    \node at ($(O)+\labelSpacing*(P)$)  {$P$};
    \node at ($(O)+\labelSpacing*(Q)$)  {$Q$};

    \tkzLabelPoints[above=0.2cm](M)
    \tkzLabelPoints[above left](X)
    \tkzLabelPoints[above right](Y)
\end{tikzpicture}
\end{document}
| improve this answer | |
  • 2
    I guess you need to add \end{document} so that others can upvote you. Please note also that \usetkzobj{all} is no longer used in newer TeX installations and will cause an error when kept in the code. That is, there were quite some changes in tkz-euclide. – user194703 Apr 13 at 19:21
  • @Schrödinger'scat currently running on TexLive2019 sadly, but I will add a comment about it =) – N3buchadnezzar Apr 13 at 20:36
  • 1
    I am afraid it isn't that simple. The output looks quite different when compiled on TeXLive2020. (While I think that tkz-euclide is a really great and amazing tool, I would also refrain from advertising it so strongly. This figure can be produced in half the lines of codes very quickly just using the calc, intersections and angles libraries in well below 10 minutes, and the output is stable over many years. Of course, these times are sort of meaningless, they just reflect how familiar one is with the syntax.) – user194703 Apr 13 at 20:41
  • 1
    Yes, I have been thinking about learning more about basic TikZ,especially about the hidden powers of TikZ. As you said, I am more familiar with tkz-euclide. However, from a beginner perspective I think it can be hard enough just writing a plain document without figures. Thus, tkz-euclide can be a good starting point. Also it was made with geometric figures in mind =) – N3buchadnezzar Apr 13 at 21:23
  • 2
    Absolutely. Each of them has their justification. asymptote is a really great tool, but you need to run asy, tkz-euclide is specialized and if you are sure that you are mainly concerned with 2d Euclidean geometry most likely the way to go, and "plain" TikZ does unlike asymptote not have a 3d engine but is incredibly powerful once you have "learned" pgf keys. While I have thousands of PSTricks figures on my hard drive I am not using it any more because IMHO it cannot compete with the other tools. – user194703 Apr 13 at 21:30
7

You can compute the angles through calc and intersections.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles,through,calc,intersections}
\tikzset{circle through 3 points/.style n args={3}{% https://tex.stackexchange.com/a/461180
insert path={let    \p1=($(#1)!0.5!(#2)$),
                    \p2=($(#1)!0.5!(#3)$),
                    \p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
                    \p4=($(#1)!0.5!(#3)!1!90:(#3)$),
                    \p5=(intersection of \p1--\p3 and \p2--\p4)
                    in },
at={(\p5)},
circle through= {(#1)}
}}

\begin{document}
\begin{tikzpicture}[angle radius=0.3cm,line cap=round,line join=round,
    dot/.style={circle,fill,inner sep=1.5pt}]
\draw (0,0) coordinate[label=above:$A$] (A) --
    (-1.5,-4)  coordinate[label=below:$B$] (B) --
     (5,-4.5) coordinate[label=below:$C$] (C) --cycle
     (A) -- ($(C)!(A)!(B)$) coordinate[label=below:$W$] (L)
     pic [draw] {right angle = C--L--A}
     (B) -- ($(A)!(B)!(C)$) coordinate[label=above:$M$] (M)
     pic [draw] {right angle = C--M--B}
     (C) -- ($(B)!(C)!(A)$) coordinate[label=left:$N$] (N)
     pic [draw] {right angle = C--N--A}
     (intersection of A--L and B--M) 
        coordinate[label=below left:$H$](H)
     let \p1=($(C)-(A)$),\p2=($(L)-(A)$), \n1={atan2(\y2,\x2)+atan2(\y1,\x1)}
     in ($(A)+(\n1/2:5)$) coordinate (aux) 
     (A) --
      (intersection of A--aux and B--C) coordinate[label=below left:$W$] (W) ;
    \begin{scope}  
     \clip (-2,-5.5)     rectangle (8,2);
     \path[nodes=draw] 
         node[circle through 3 points={B}{L}{N}] (BLN){}
         node[circle through 3 points={B}{C}{M}] (BCM){}
         node[circle through 3 points={C}{B}{M},label=above right:$\omega_3$] (CBM){}
         node[circle through 3 points={C}{M}{W},label=above:$\omega_2$] (CMW){}
         node[circle through 3 points={B}{N}{W},label=above:$\omega_1$] (BNW){};
     \foreach \X in {BLN,BCM,CBM,CMW,BNW}
     {\path[name path global=\X] let \p1=(\X.center),\p2=(\X.east) in 
         (\p1) circle[radius=\x2-\x1];}
     \path  [name intersections={of=CMW and BNW,by={Z,aux}}] 
      (Z) coordinate[dot,label=below:$Z$] (Z);
     \path[overlay,draw,dashed,name path=HZ] let \p1=($(Z)-(H)$),\n1={atan2(\y1,\x1)} in
      ($(Z)+(\n1:10)$) --  ($(Z)-(\n1:10)$);
     \path  [name intersections={of=HZ and BNW,by={aux,X}}] 
      (X) coordinate[dot,label=below:$X$] (X);
     \path  [name intersections={of=HZ and CMW,by={Y,aux}}] 
      (Y) coordinate[dot,label=below:$Y$] (Y);
    \end{scope} 
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
4

Really just for fun. This code took less than 10 minutes to write and uses tools and a syntax that can be used everywhere, also in 3d drawings, in pgfplots and so on. I personally find the syntax also very intuitive to learn, and I am a big fan of pgf keys and the calc syntax.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles,calc,intersections}
\begin{document}
\begin{tikzpicture}[declare function={R=3;},
    dot/.style={circle,fill,inner sep=1.5pt},
    tarc/.style={draw,double distance=2pt,angle radius=10mm,
    pic actions/.append code=\tikzset{postaction={draw}}},
    sarc/.style={draw,angle radius=4mm},
    darc/.style={draw,double,angle radius=5mm},
    ]
 \begin{scope}[nodes={dot}]
  \draw[name path=circ,semithick]   (0,0) coordinate (O) circle[radius=R];  
  \path (110:R) node[label=above:$A$] (A){}
        (-50:R) node[label=below:$B$] (B){}     
    (70:R) node[label=above:$C$] (C){}
    (220:R) node[label=below:$D$] (D){}
   (intersection of A--B and C--D) node[label=above:$M$] (M){}
   (A) -- (D) node[pos=0.3,label=above left:$X$](X){};
  \path[overlay,name path=line] let \p1=($(M)-(X)$),\n1={atan2(\y1,\x1)} in
   ($(M)+(\n1:10)$) --  ($(M)+(\n1+180:10)$);
  \path[name intersections={of=circ and line,by={P,Q}},nodes={dot}]
   (P) node[label=above:$P$]{} (Q) node[label=above:$Q$]{};
  \draw[fill=none] (A) -- (D) -- (C) -- (B) -- (A) (P) -- (Q) 
  (intersection of P--Q and C--B) node[dot,label=above right:$Y$] (Y){};
 \end{scope}        
 \path   pic[tarc]{angle={C--D--A}}
         pic[tarc]{angle={C--B--A}}
         pic[darc]{angle={Q--M--D}}
         pic[darc]{angle={P--M--C}}
         pic[sarc]{angle={B--M--P}}
         pic[sarc]{angle={A--M--Q}}  ;
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
2

The pst-eucl module of pstricks has tools to make geometric constructions, with a latex-like syntax. I propose this code for the first figure:

\documentclass[border=6pt]{standalone}
\usepackage{pst-eucl}

\begin{document}

  \begin{pspicture*}(-2,-0.8)(10,6.5)
    \psset{PointSymbol=none, PointNameSep=1.25em}
    \pstTriangle[PosAngle={90,-120,-40}](3,6){A}(0,0){B}(8,0){C}
    % orthocenter and altitudes
    \pstTriangleHC[PosAngle ={-115,-80,80}]{A}{B}{C}{H}[L][M]
    \pstInterLL[PosAngle=120]{A}{B}{C}{H}{N}
    \pstLineAB{A}{L}\pstLineAB{B}{M}\pstLineAB{C}{N}
    \psset{linewidth=0.5pt, RightAngleSize=0.15}
    \pstRightAngle{A}{L}{C}\pstRightAngle{B}{M}{C}\pstRightAngle{B}{N}{C}
    %%bissectrix
    \pstBissectBAC[PointName=none, nodesepB=-0.4]{L}{A}{C}{I}
    \pstInterLL[PointName=none]{B}{C}{A}{I}{W}
    %% Circles & their centres
    \pstCircleABC[PointName=none]{M}{W}{C}{O2}
    \pstInterLC[PosAngleA=-120,PosAngleB=-70]{A}{W}{O2}{C}{Z}{W}
    \pstCircleAB{B}{H} % circle with diameter BH
    \pstCircleAB{B}{C}% circle with diameter BC
    \pstCircleABC[PointName=none]{B}{W}{N}{O1} %% circle through B, W, N
    %dashed line
    \psset{PointNameSep=0.8em}
    \pstInterLC[PointNameB=, PosAngleA=120]{H}{Z}{O1}{W}{X}{Z}
    \pstInterLC[PointNameB=, PosAngleA=90]{Z}{H}{O2}{W}{Y}{Z}
    \pstLineAB[linestyle=dashed, dash=3pt 2pt, nodesepA=-0.3cm, nodesepB=-0.6cm]{X}{Y}
  \end{pspicture*}

\end{document}

enter image description here

| improve this answer | |
  • Shouldn't the intersection of the two circles near Z be precisely on the dashed line? – user194703 Apr 13 at 20:08
  • @Schrödinger'scat: You're right. I'll investigate and try to find a fix. I guess it's due to some rounding error. – Bernard Apr 13 at 20:18

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.