3

enter image description here

I am trying to create this image with latex, and I specifically add the red points in the interior of the regular hexagon as well as make the outer edges of the regular hexagon blue.

I am able to create the following regular hexagon but I do not know how to color the outer edges blue or add the points in the interior (these points should specifically be on the intersection points of the diagonals):

\begin{tikzpicture}[
        dot/.style={circle,fill, inner sep=1.5pt, outer sep=0pt},
every label/.style={inner sep=0pt}] 
\newdimen\R
\R=1.3cm
\draw[red]
    (300:\R) \foreach \x in {360,60} {  -- (\x:\R) };
\foreach \i [count=\j] in {1,2,3,4,5,6}
{
    \node (n\j) [dot] at (60*\j:\R) {};
}
\foreach \i in {1,...,6}
{
\ifnum\i=1
    \foreach \j in {2,...,6}
    \draw (n\i) -- (n\j);
\else
   \foreach \j in {\i,...,6}
   \draw (n\i) -- (n\j);
\fi
}
    \end{tikzpicture}

enter image description here

1
9

So here it is. Using my previous answers to two of your questions, here's a way to find intersections between lines defined between nodes:

\node at (intersection of n2--n6 and n1--n3) (A) {}; is pretty straightforward to understand. You named your nodes n1 to n6, you then put a node named A (not mandatory to name it, but allow you to use it afterwards) at the intersection of the line through nodes n2 and n6 and the line through n1 and n3.

I let you make the remaining ones. Note that you can also do them with a foreach loop, if you want to shorten your code.

another regular hexagon

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{backgrounds}

\begin{document}

    \begin{tikzpicture}[
        dot/.style={black,circle,fill, inner sep=1.5pt, outer sep=0pt,text=white},
        innode/.style={inner sep=1.5pt,outer sep=0pt,circle,fill=red},
        every label/.style={inner sep=0pt}] 
        \newdimen\R
        \R=1.3cm
        
        \draw[cyan,line width=1pt] (0:\R) \foreach \x [count=\i] in {60,120,...,360} {  -- (\x:\R) node[dot] (n\i) {} };
        
        \begin{scope}[on background layer]      
            \foreach \i in {1,...,6}
                {
                \ifnum\i=1      % Part with \if is useless here, but anyway
                    \foreach \j in {2,...,6}
                    \draw (n\i.center) -- (n\j.center);
                \else
                   \foreach \j in {\i,...,6}
                   \draw (n\i.center) -- (n\j.center);
                \fi
                }       
        \end{scope}

        \node[innode] at (intersection of  n2--n6 and n1--n3) (A) {};
        \node[innode] at (intersection of  n2--n5 and n1--n3) (B) {};
    \end{tikzpicture}
   
\end{document}
4

You might also like a Metapost version, perhaps?

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
beginfig(1);
    path h;
    h = for t=0 upto 5: 72 dir 60t -- endfor cycle;

    z0 = whatever[point 0 of h, point 2 of h] = whatever[point 1 of h, point 5 of h];
    z1 = whatever[point 0 of h, point 2 of h] = whatever[point 1 of h, point 3 of h];
    z2 = whatever[point 5 of h, point 2 of h] = whatever[point 1 of h, point 3 of h];
    z3 = whatever[point 5 of h, point 3 of h] = whatever[point 2 of h, point 4 of h];
    z4 = whatever[point 5 of h, point 3 of h] = whatever[point 0 of h, point 4 of h];
    z5 = whatever[point 5 of h, point 2 of h] = whatever[point 0 of h, point 4 of h];
    
    draw h withpen pencircle scaled 3 withcolor 3/4[blue, white];
    
    for i=0 upto 5:
        for j=i+1 upto 5:
            draw point i of h -- point j of h;
        endfor
    endfor
    
    for i=0 upto 5:
        drawdot point i of h withpen pencircle scaled 5;
        drawdot z[i]         withpen pencircle scaled 5 withcolor 2/3 red;
    endfor
endfig;
\end{mplibcode}
\end{document}

This is wrapped up in luamplib, so compile with lualatex.

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.