2

I found this answer by cfr but when I use the code it gives me error. Also I need dots but I couldn't do it. All I could do was to draw a hexagon with vertices labeled. How do we colour the edges and put dots on each edge ?

\begin{tikzpicture}
\tkzDefPoint(0,0){O}\tkzDefPoint(2,0){A}
\tkzDefPointsBy[rotation=center O angle 360/6](A,B,C,D,E){B,C,D,E,F}
\tkzDrawPoints[fill ={black,red},size=5,color=black](A,B,C,D,E,F)
\tkzLabelPoints[above](B,C)
\tkzLabelPoints[right](A)
\tkzLabelPoints[left](D)
\tkzLabelPoints[below](E,F)
\tkzDrawPolygon[ultra thick](A,B,C,D,E,F)
\end{tikzpicture}
  • 1
    Welcome to TeX.SE! Please show the code you have tried so far! – Kurt Mar 6 at 9:54
  • added the code ! – never_mind Mar 6 at 10:19
  • 1
    Please read how we are adding a MWE (minimal working example) here : tex.meta.stackexchange.com/q/228/120578. Also, to add code in your question (as separate part of your text and not as "inline code") don't use " ` ", but select all the code pasted and press the button "{}" – koleygr Mar 6 at 10:23
  • The code is not compileable ! – AndréC Mar 6 at 10:43
2

Like this?

\documentclass[tikz,border=4mm]{standalone}

%-----------------------------------------------------------------------
\usepackage{tkz-euclide}
\usetkzobj{all}
%-----------------------------------------------------------------------
\begin{document}
\def\sc{1.5pt}
\begin{tikzpicture}
\tkzDefPoint(0,0){O}\tkzDefPoint(2,0){A}
\tkzDefPointsBy[rotation=center O angle 360/6](A,B,C,D,E){B,C,D,E,F}
\tkzLabelPoints[above](B,C)
\tkzLabelPoints[right](A)
\tkzLabelPoints[left](D)
\tkzLabelPoints[below](E,F)
\tkzDrawPolygon[white](A,B,C,D,E,F)
\tkzDrawSegment[blue](A,B)
\tkzDrawSegment[red](B,C)
\tkzDrawSegment[yellow](C,D)
\tkzDrawSegment[magenta](D,E)
\tkzDrawSegment[cyan](E,F)
\tkzDrawSegment[orange](F,A)
\tkzMarkSegment[color=blue,pos=0.5,mark=*,size=\sc](A,B)
\tkzMarkSegment[color=red,pos=0.5,mark=*,size=\sc](B,C)
\tkzMarkSegment[color=yellow,pos=0.5,mark=*,size=\sc](C,D)
\tkzMarkSegment[color=magenta,pos=0.5,mark=*,size=\sc](D,E)
\tkzMarkSegment[color=cyan,pos=0.5,mark=*,size=\sc](E,F)
\tkzMarkSegment[color=orange,pos=0.5,mark=*,size=\sc](F,A)
\tkzDrawPoints[fill ={black,red},size=6,color=black](A,B,C,D,E,F)
\end{tikzpicture}
\end{document}

enter image description here

0

A short code using a loop to do this :

\documentclass[tikz,border=7pt]{standalone}
\begin{document}
  \tikz[p/.style={circle,inner sep=.7pt,fill}]
    \draw foreach[count=\i from 0,count=\j]
      \l/\c in {A/blue,B/red,C/yellow,D/magenta,E/cyan,F/orange}{
        (\i*60:1.5) edge[\c] node[p]{} (\j*60:1.5) node[p]{} (\i*60:1.8) node{\l}
    } (\j*60:1.5) node[p]{};
\end{document}

enter image description here

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.