11

I'm attempting to draw a simple diagram comprised of three nodes arrange in a triangle. I'm having a difficulty with getting the arrows to "connect" to one of the nodes, there's a small space between the arrow and the node itself which I can't seem to remove. I've used the search function was unsuccessful.

Here's the code I'm using:

\documentclass[10pt]{standalone}

% AMS Libraries

\usepackage{amsmath}

% Graphics Packages

\usepackage{tikz}

% Font Packages

\usepackage{concrete}
\usepackage[small,euler-digits]{eulervm}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[kerning,spacing,babel,final]{microtype}

% TiKz Options

\usetikzlibrary{positioning,arrows,calc}
\tikzset{
    % general settings for a modal logic diagram
    modal/.style={>=stealth', auto, very thick, align=center, anchor=center,
        transform shape,font=\scriptsize},
    % define the style for the events of an update model
    event/.style={rectangle, rounded corners, draw, minimum size=0.5cm},
    Event/.style={double, rectangle, rounded corners, draw, minimum size=0.5cm},
    % define the styles for reflexive arcs in a Kripke structure or update model
    reflexive above/.style={->, loop, looseness=7, in=120, out=60},
    reflexive below/.style={->, loop, looseness=7, in=240, out=300},
    reflexive left/.style={->, loop, looseness=7, in=150, out=210},
    reflexive right/.style={->, loop, looseness=7, in=30, out=330},
    symmetric/.style={<->}
}

\begin{document}

\begin{tikzpicture}[modal]
    % define the points of the Kripke structure
    \node[Event] (e1) {$\varepsilon_{1}$};
    \node[event] (e2) [right=2cm of e1] {$\varepsilon_{2}$};
    \coordinate (mid) at ($(e1)!0.5!(e2)$);
    \node[event] (e3) [below=1cm of mid] {$\varepsilon_{3}$};

    % define the accessibility relations of the Kripke structure
    \path[symmetric] (e1) edge node[midway,above] {$B$}  (e2);
    \path[reflexive left] (e1) edge node[midway,left] {$A$} (e1);
    \path[->] (e1) edge node[sloped,below] {$B,C$} (e3);
    \path[reflexive right] (e2) edge node[midway,right] {$A$} (e2);
    \path[->] (e2) edge node[sloped,below] {$B,C$} (e3);
\end{tikzpicture}

\end{document}

I suspect that I'm missing something trivial, and if possible I'd like a solution that's elaboration tolerant as I need to have quite a few more examples along the same lines.

Here's a copy of the image:

enter image description here

2
  • The reason is because you have the rounded corners on your nodes, but the anchors are set to be where the corner would be if you had sharp corners... as for how to fix it, I don't know! Hopefully someone with better TikZ-fu will be able to help :-) Welcome to TeX.SX! Great question!
    – darthbith
    Commented Apr 6, 2015 at 20:22
  • In case you want to use a rectangle with rounded corners and proper anchor points look at Rounded corners in TikZ trees
    – Ignasi
    Commented Apr 7, 2015 at 7:42

1 Answer 1

9

This is simply because your are using rounded corners rectangles. So, you should compensate for the trim effect (if you want the arrows to touch the rectangles) by issuing the option shorten >= -2pt, shorten <= -2pt. You can manually control the shorten distance. Note that you need only to compensate the two edges to node e3.

Here is the modified code:

\documentclass[tikz,10pt]{standalone}
\usepackage{amsmath}
% Font Packages
\usepackage{concrete}
\usepackage[small,euler-digits]{eulervm}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[kerning,spacing,babel,final]{microtype}
% TiKz Options
\usetikzlibrary{positioning,arrows,calc}
\tikzset{
    % general settings for a modal logic diagram
    modal/.style={>=stealth', auto, very thick, align=center, anchor=center,
        transform shape,font=\scriptsize},
    % define the style for the events of an update model
    event/.style={rectangle,rounded corners, draw, minimum size=0.5cm},
    Event/.style={double, rectangle, rounded corners, draw, minimum size=0.5cm},
    % define the styles for reflexive arcs in a Kripke structure or update model
    reflexive above/.style={->, loop, looseness=7, in=120, out=60},
    reflexive below/.style={->, loop, looseness=7, in=240, out=300},
    reflexive left/.style ={->, loop, looseness=7, in=150, out=210},
    reflexive right/.style={->, loop, looseness=7, in=30,  out=330},
    symmetric/.style={<->}
}
\begin{document}

\begin{tikzpicture}[modal]
    % define the points of the Kripke structure
    \node[Event] (e1) {$\varepsilon_{1}$};
    \node[event] (e2) [right=2cm of e1] {$\varepsilon_{2}$};
    \coordinate (mid) at ($(e1)!0.5!(e2)$);
    \node[event] (e3) [below=1cm of mid] {$\varepsilon_{3}$};

    % define the accessibility relations of the Kripke structure
    \path[symmetric] (e1) edge node[midway,above] {$B$}  (e2);
    \path[reflexive left] (e1) edge node[midway,left] {$A$} (e1);
    \path[->,shorten >= -2pt, shorten <= -2pt] (e1) edge node[sloped,below] {$B,C$} (e3);
    \path[reflexive right] (e2) edge node[midway,right] {$A$} (e2);
    \path[->,shorten >= -2pt, shorten <= -2pt] (e2) edge node[sloped,below] {$B,C$} (e3);
\end{tikzpicture}

\end{document}

Here is the output:

enter image description here

1
  • This makes sense to me but now there's a space between the reflexive arc on node labeled by $\varepsilon_{2}$. Is there a general way to set "magnets" like in OmniGraffle or "attachment points"? Commented Apr 9, 2015 at 13:09

You must log in to answer this question.

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