skip to content

Learn to Use tikz-euclide

2 min read

# tikz
# latex
Not in series

The following content is from tkz-euclide v5 Euclidean Geometry.

tkz-euclide is a set of convenient macros for drawing in a plane (fundamental two-dimensional object) with a Cartesian coordinate system. It handles the most classic situations in Euclidean Geometry. tkz-euclide is built on top of PGF and its associated front-end TikZ and is a (La)TeX-friendly drawing package. The aim is to provide a high-level user interface to build graphics relatively simply. The idea is to allow you to follow step by step a construction that would be done by hand as naturally as possible.

Drawing

tkz-euclide can draw 5 types of objects : point, line or line segment, circle, arc and sector.

Draw a point or some points

By default, point style is defined like this :

\tikzset{point style/.style = {%
    draw = black,
    inner sep = 0pt,
    shape = circle,
    minimum size = 3 pt,
    fill = black
    }
  }
\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}[scale=.5]
\tkzDefPoint(1,3){A}
\tkzDefPoint(4,1){B}
\tkzDefPoint(0,0){O}
\tkzDrawPoint[color=red](A)
\tkzDrawPoint[fill=blue!20,draw=blue](B)
\tkzDrawPoint[shape=cross,size=8pt,color=teal](O)
\end{tikzpicture}
\end{document}
main

or to be short:

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{1/3/A,4/1/B,0/0/C}
\tkzDrawPoints[size=3,color=red,fill=red!50](A,B,C)
\end{tikzpicture}
\end{document}

Drawing the Lines

The style of a line is by default:

\tikzset{line style/.style = {%
  line width = 0.6pt,
  color = black,
  style = solid,
  add = {.2} and {.2}%
  }}

with

\tikzset{%
add/.style args={#1 and #2}{
to path={%
($(\tikztostart)!-#1!(\tikztotarget)$)--($(\tikztotarget)!-#2!(\tikztostart)$)%
\tikztonodes}}}

Example:

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){A}
\tkzDefPoint(2,0){B}
\tkzDefPoint(1,2){C}
\tkzDefPoint(3,2){D}
\tkzDrawLines(A,B C,D A,C B,D)
\tkzLabelPoints(A,B,C,D)
\end{tikzpicture}
\end{document}
main

Example with point references

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}[scale=1.5]
\tkzDefPoint(0,0){A}
\tkzDefPoint(2,1){B}
\tkzDrawSegment[color=red,thin](A,B)
\tkzDrawPoints(A,B)
\tkzLabelPoints(A,B)
\end{tikzpicture}
\end{document}
main

Example with Extending Segment

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A,6/0/B,0.8/4/C}
\tkzDefTriangleCenter[euler](A,B,C)
\tkzGetPoint{E}
\tkzDefCircle[euler](A,B,C)\tkzGetPoints{E}{e}
\tkzDrawCircle[red](E,e)
\tkzDrawLines[add=.5 and .5](A,B A,C B,C)
\tkzDrawPoints(A,B,C,E)
\tkzLabelPoints(A,B,C,E)
\end{tikzpicture}
\end{document}
main

Adding dimensions with option dim new code from Muzimuzhi Z

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}[scale=.75]
\tkzDefPoints{0/3/A, 1/-3/B}
\tkzDrawPoints(A,B)
\tkzDrawSegment[dim={\(l_0\),1cm,right=2mm},dim style/.append style={red,dash pattern={on 2pt off 2pt}}](A,B)
\tkzDrawSegment[dim={\(l_1\),2cm,right=2mm},dim style/.append style={blue}](A,B)
\begin{scope}[ dim style/.style={orange},dim fence style/.style={dashed}]
\tkzDrawSegment[dim={\(l_2\),3cm,right=2mm}](A,B)
\tkzDrawSegment[dim={\(l_3\),-2cm,right=2mm}](A,B)
\end{scope}
\tkzLabelPoints[left](A,B)
\end{tikzpicture}
\end{document}
main

Adding dimensions with option dim part I

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}[scale=2]
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\tkzDefPoint(0,0){A}
\tkzDefPoint(3.07,0){B}
\tkzInterCC[R](A,2.37)(B,1.82)
\tkzGetPoints{C}{C'}
\tkzDefCircle[in](A,B,C) \tkzGetPoints{G}{g}
\tkzDrawCircle(G,g)
\tkzDrawPolygon(A,B,C)
\tkzDrawPoints(A,B,C)
\tkzCalcLength(A,B)\tkzGetLength{ABl}
\tkzCalcLength(B,C)\tkzGetLength{BCl}
\tkzCalcLength(A,C)\tkzGetLength{ACl}
\begin{scope}[dim style/.style={dashed,sloped,teal}]
\tkzDrawSegment[dim={\pgfmathprintnumber\BCl,6pt,text=red}](C,B)
\tkzDrawSegment[dim={\pgfmathprintnumber\ACl,6pt,}](A,C)
\tkzDrawSegment[dim={\pgfmathprintnumber\ABl,-6pt,}](A,B)
\end{scope}
\tkzLabelPoints(A,B) \tkzLabelPoints[above](C)
\end{tikzpicture}
\end{document}
main

Adding dimensions with option dim part II

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tkz-euclide}
 
\begin{document}
\begin{tikzpicture}[scale=.75]
\tkzDefPoints{0/0/O,-2/0/A,2/0/B,-2/4/C,2/4/D,2/-4/E,-2/-4/F}
\tkzDrawPolygon(C,...,F)
\tkzDrawSegments(A,B)
\tkzDrawPoints(A,...,F,O)
\tkzLabelPoints[below left](A,...,F,O)
\tkzDrawSegment[dim={ $\sqrt{5}$,2cm,}](C,E)
\tkzDrawSegment[dim={ $\frac{\sqrt{5}}{2}$,1cm,}](O,E)
\tkzDrawSegment[dim={ $2$,2cm,left=8pt}](F,C)
\tkzDrawSegment[dim={ $1$,1cm,left=8pt}](F,A)
\end{tikzpicture}
\end{document}
main