3

When compiling the following TikZ flowchart there is a small space between the diamond shape and the line which should be connecting it. Then sharp edge of the diamond isn't nicely connecting to the line:

gap between the diamond and the line

I was thinking line join=bevel would fix that, but it's even worse then. Doesn know how I can fix this connection?

MWE

\documentclass[dvipsnames,tikz]{standalone}
\usepackage{tikz}
\usepackage{cmbright}      % sansfont
\usetikzlibrary{shapes,positioning}

\tikzset{main/.style={color=black}}

\begin{document}
    \begin{tikzpicture}[font=\small,thick]
        %% Nodes
        \node[
            draw,
            main,
            diamond,
            minimum width=2.5cm,
            minimum height=1.5cm,
            inner sep=0] (keuze1) {$a > 20$};

        \node[xshift=-0.5cm,
            inner sep = 0,
            right=of keuze1] (false) {\color{OrangeRed}False};
        \node[xshift=0.5cm,
            inner sep = 0,
            left=of keuze1] (true) {\color{ForestGreen}True};
        
        \node[draw,
            main,
            below left=of keuze1,
            minimum width=2.7cm,
            minimum height=0.8cm] (vriest) { $b = a^2 - 2 \cdot a$ };
        \node[draw,
            main,
            below right =of keuze1,
            minimum width=2.7cm,
            minimum height=0.8cm] (dooit) { $b = a^2 + 2 \cdot a$ };
        
        %% Connections
        \draw[main] (keuze1) -- (true);
        \draw[-stealth,main] (true) -| (vriest);
        \draw[main] (keuze1) -- (false);
        \draw[-stealth, main] (false) -| (dooit);
    \end{tikzpicture}
\end{document}
2
  • 3
    please try 'outer sep = 0'
    – Black Mild
    Commented Aug 11 at 12:35
  • 1
    That worked, thnx! If you would turn this into an answer, I will gladly accept that.
    – dietervdf
    Commented Aug 11 at 12:45

1 Answer 1

3

Your problem is already solved by suggestion in the @Black Mild comment, so here is only some suggestion, how you can draw your flowchart:

\documentclass[margin=3mm,
               dvipsnames]{standalone}
\usepackage{tikz}
\usepackage{cmbright}      % sansfont
\usetikzlibrary{arrows.meta,
                positioning,
                shapes,
                }

\begin{document}
    \begin{tikzpicture}[
node distance = 3mm and 9mm,
   arr/.style = {-Stealth, thick},
  base/.style = {draw, thick, minimum width=22mm, minimum height=8mm},
    if/.style = {diamond, base, inner sep=0pt, outer sep=0pt},  % <---  @Black Mild suggestion
   lbl/.style = {color=#1, fill=white, inner sep=1pt},
     N/.style = {base},
         font = \small,
                        ]
%% Nodes
\node[if] (keuze1) {$a > 20$};
\node[N, below  left=of keuze1] (vriest) { $b = a^2 - 2a$ };
\node[N, below right=of keuze1] (dooit)  { $b = a^2 + 2a$ };
%% Connections
\draw[arr] (keuze1) -| (vriest) node[pos=0.25, lbl=ForestGreen] {True};
\draw[arr] (keuze1) -| (dooit)  node[pos=0.25, lbl=OrangeRed]  {False};
    \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 .