4

Consider the following picture: enter image description here

and the code at the bottom. I'm happy with the result on the left; now I've started with digraphs and I need arrows; I'm trying to get the - for me - best possible style. I would like to achieve the following:

  1. The arrow head should have 1pt separation from the bullet, but the tail should have no space and also the normal edges should not, of course
  2. [DONE] The head should be like the one in the following post (and not a triangle as in my attempt): pgfplots: custom axis arrow head
  3. [DONE] And the standard head should not appear
  4. Since I generate the picture out of python, the formatting of the arrow should be encapsulated in a style, as I do for the nodes with the style bullet, see my try with myarrow

.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{subcaption}

\begin{document}

\begin{figure}[hbt]
\begin{subfigure}[b]{0.49000\textwidth}
\centering
\begin{tikzpicture}[bullet/.style={circle, fill,minimum size=4pt,inner sep=0pt, outer sep=0pt}]\useasboundingbox (-2,-2)rectangle(2,2);\node[bullet] at (2.00000,0.00000) (0) {};
\node[bullet] at (1.00000,1.73205) (1) {};
\node[bullet] at (-1.00000,1.73205) (2) {};
\node[bullet] at (-2.00000,0.00000) (3) {};
\node[bullet] at (-1.00000,-1.73205) (4) {};
\node[bullet] at (1.00000,-1.73205) (5) {};
\draw (0) -- (1); \draw (1) -- (2); \draw (2) -- (3); \draw (3) -- (4); \draw (4) -- (5); \draw (5) -- (0); \end{tikzpicture}\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.49000\textwidth}
\centering
\begin{tikzpicture}
[bullet/.style={circle, fill,minimum size=4pt,inner sep=0pt, outer sep=0pt}]
[myarrow/.style={-{Stealth[length=2mm, width=2mm]}}]
\useasboundingbox (-2,-2)rectangle(2,2);\node[bullet] at (2.00000,0.00000) (0) {};
\node[bullet] at (1.00000,1.73205) (1) {};
\node[bullet] at (-1.00000,1.73205) (2) {};
\node[bullet] at (-2.00000,0.00000) (3) {};
\node[bullet] at (-1.00000,-1.73205) (4) {};
\node[bullet] at (1.00000,-1.73205) (5) {};
\draw (0) -- (1); \draw (1) -- (2); \draw (2) -- (3); \draw (3) -- (4); \draw[myarrow] (4) -- (5); \draw[-{Stealth[length=2mm, width=2mm]}] (5) -- (0); \end{tikzpicture}\caption{}
\end{subfigure}
\caption{}
\end{figure}

\end{document}

3 Answers 3

4

You should include myarrow/.style inside the first square brackets in order to define the style. In the style you can specify the arrow tip distance from the node with the sep=1pt option as in the example below.

If the myarrow style is to be used in multiple tikzpicture environments, you can define the style in the preamble with \tikzset{myarrow/.style={...}} instead of defining it inside the optional arguments to each individual environment.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{subcaption}

 % Definition of myarrow style to be used in multiple tikzpictures
 % \tikzset{myarrow/.style={-{Stealth[length=2mm, width=2mm, sep=1pt]}}} 

\begin{document}

\begin{figure}[hbt]
\begin{subfigure}[b]{0.49000\textwidth}
\centering
\begin{tikzpicture}[bullet/.style={circle, fill,minimum size=4pt,inner sep=0pt, outer sep=0pt}]\useasboundingbox (-2,-2)rectangle(2,2);\node[bullet] at (2.00000,0.00000) (0) {};
\node[bullet] at (1.00000,1.73205) (1) {};
\node[bullet] at (-1.00000,1.73205) (2) {};
\node[bullet] at (-2.00000,0.00000) (3) {};
\node[bullet] at (-1.00000,-1.73205) (4) {};
\node[bullet] at (1.00000,-1.73205) (5) {};
\draw (0) -- (1); \draw (1) -- (2); \draw (2) -- (3); \draw (3) -- (4); \draw (4) -- (5); \draw (5) -- (0); \end{tikzpicture}\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.49000\textwidth}
\centering
\begin{tikzpicture}
[bullet/.style={circle, fill,minimum size=4pt,inner sep=0pt, outer sep=0pt},
 myarrow/.style={-{Stealth[length=2mm, width=2mm, sep=1pt]}}]
\useasboundingbox (-2,-2)rectangle(2,2);\node[bullet] at (2.00000,0.00000) (0) {};
\node[bullet] at (1.00000,1.73205) (1) {};
\node[bullet] at (-1.00000,1.73205) (2) {};
\node[bullet] at (-2.00000,0.00000) (3) {};
\node[bullet] at (-1.00000,-1.73205) (4) {};
\node[bullet] at (1.00000,-1.73205) (5) {};
\draw (0) -- (1); \draw (1) -- (2); \draw (2) -- (3); \draw (3) -- (4); \draw[myarrow] (4) -- (5); \draw[myarrow] (5) -- (0); \end{tikzpicture}\caption{}
\end{subfigure}
\caption{}
\end{figure}

\end{document}

Resulting output

0
2

With use regular polygon for determining coordinates of bullets (named dot in MWE below) and loops for drawing lines in sub figure b. Styles for arrows and nodes' shapes are common for both picture. Arrows are defined by

arr/.style = {-{Stealth[length=2mm, width=2mm]},shorten >=1pt},

MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                shapes.geometric}
\usepackage{subcaption}


\begin{document}

\begin{figure}[hbt]
\tikzset{
    dot/.style = {circle, fill, inner sep=2pt},
    arr/.style = {-{Stealth[length=2mm, width=2mm]},shorten >=1pt},
    HEX/.style = {regular polygon, regular polygon sides=6,
                  minimum size=33mm, rotate=-60,
                  node contents={}}
        }
\begin{subfigure}[b]{0.49\textwidth}
\centering
    \begin{tikzpicture}
\node (n0) [HEX,draw];
\foreach \i in {1,...,6}
\node[dot] at (n0.corner \i) {};
    \end{tikzpicture}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\begin{tikzpicture}
\node (n0) [HEX];
\foreach \i in {1,...,6}
\node (n\i) [dot] at (n0.corner \i) {};
\foreach \i [count=\j from 2] in {1,...,4}
    \draw (n0.corner \i) -- (n0.corner \j);
\draw[arr] (n5) -- (n6);
\draw[arr] (n6) -- (n1);
    \end{tikzpicture}
\caption{}
\end{subfigure}
    \caption{}
\end{figure}

\end{document}

enter image description here

0
1

You can use shorten > as an option or in a style. enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \i in {0,...,5}
\fill (60*\i:2) circle(2pt) coordinate (A\i); 

\draw (A0)--(A1)--(A2)--(A3)--(A4);
\draw[-stealth, shorten >=3pt] (A4)--(A5);
\draw[-stealth, shorten >=3pt] (A5)--(A0);
\end{tikzpicture}

\begin{tikzpicture}[myarr/.style={-stealth, shorten >=3pt}]
\foreach \i in {0,...,5}
\fill (60*\i:2) circle(2pt) coordinate (A\i); 

\draw (A0)--(A1)--(A2)--(A3)--(A4);
\draw[myarr] (A4)--(A5);
\draw[myarr] (A5)--(A0);
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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