3

How can I adjust the path \path (a) edge [edge, loop left] node {$1_a$} (a) so that both the beginning and end of the path are near the node, but not so near that there is an overlap between the node text and the node's content. I tried to use shorten in the edge style, but it seems to only work for one end of the edge.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary {calc}
\usetikzlibrary {automata}
\usetikzlibrary {positioning}
\usetikzlibrary {fit}

\begin{document}
\tikzset{edge/.style={
    thin,
    black,
    ->,
    shorten >=8pt,
    shorten <=8pt }
}
\tikzset{node-element/.style={
    inner sep=1.5mm,
    minimum size=1cm,
    }
}

\begin{tikzpicture}[scale=1.5]
    \coordinate (a) at (0,0);
    \coordinate (b) at (2,0);
    \coordinate (c) at (1,2);
    \node [node-element] at (a) {a};
    \node [node-element] at (b) {b};
    \node [node-element] at (c) {c};
    \draw[edge, bend left] (a) to node[above, pos=0.5] {$f$} (b);
    \draw[edge, bend left] (b) to node[below, pos=0.5] {$f^{-1}$} (a);
    \draw[edge] (c) to node[left, pos=0.5] {$h$} (a);
    \draw[edge] (c) to node[right, pos=0.5] {$h^{-1}$} (b);
    \path (a) edge [edge, loop left] node {$1_a$} (a)
          (b) edge [edge, loop right] node {$1_b$} (b);
\end{tikzpicture}
\end{document}

enter image description here

1 Answer 1

6

Solved by defining a, b, c as node names, not as zero-sized coordinates.

\documentclass[tikz]{standalone}

\begin{document}
\tikzset{
  edge/.style={
    thin,
    black,
%    ->,
%    shorten >=8pt,
%    shorten <=8pt
  },
  node-element/.style={
%    inner sep=1.5mm,
%    minimum size=1cm,
  }
}

\begin{tikzpicture}[scale=1.5]
    \node [node-element] (a) at (0,0) {a};
    \node [node-element] (b) at (2,0) {b};
    \node [node-element] (c) at (1,2) {c};
    \draw[edge, bend left] (a) to node[above, pos=0.5] {$f$} (b);
    \draw[edge, bend left] (b) to node[below, pos=0.5] {$f^{-1}$} (a);
    \draw[edge] (c) to node[left, pos=0.5] {$h$} (a);
    \draw[edge] (c) to node[right, pos=0.5] {$h^{-1}$} (b);
    \path (a) edge [edge, loop left] node {$1_a$} ()
          (b) edge [edge, loop right] node {$1_b$} ();
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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