Why does every path style affect also the node borders?

by CarLaTeX   Last Updated January 13, 2018 23:23 PM

If I add rounded corners to every path/.style, the option affects also the node borders. Why?

Is creating a style to use in a scope environment the correct way to avoid it? (The actual flowchart has, of course, more \draws than the MWE).

\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{
    shapes.geometric,
    matrix, 
    arrows.meta}
\begin{document}
    \begin{tikzpicture}[
    basenode/.style={
        draw=gray, align=center,
        text=black, very thick,
        anchor=center,   
        align=center,
    },
    block/.style={
        basenode,  text width=7em, 
        minimum height=8ex,
        inner sep=0pt,
    },
    decision/.style={
        basenode,
        minimum width=12em,
        minimum height=16ex,
        diamond,  
        anchor=center,
        shape aspect=2,
        text width=5em,
        inner sep=0pt,
    },
    %myarrow/.style={
    every path/.style={
        gray, 
        very thick,
        rounded corners,
        -{Triangle[width=5pt]}
    },
    ]
    \matrix[
        matrix of nodes, row sep=5ex, column sep=-2em,
        ] {
     |[decision](a)| A \\
     & |[block](b)| B \\
    };
    %\begin{scope}[myarrow]
    \draw (a) -| (b);
    %\end{scope}
    \end{tikzpicture}
\end{document}

enter image description here



Answers 1


\node is an abbreviation of \path[node], cf. section 15.1 in the manual, so I don't think it should be a surprise.

An alternative might be to add

every node/.append style={sharp corners}

to the tikzpicture options. It doesn't seem like this would override a rounded corners in a node style.

output of code

\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{
    shapes.geometric,
    matrix, 
    arrows.meta}
\begin{document}
    \begin{tikzpicture}[
    basenode/.style={
        draw=gray, align=center,
        text=black, very thick,
        anchor=center,   
        align=center,
    },
    block/.style={
        basenode,  text width=7em, 
        minimum height=8ex,
        inner sep=0pt,
    },
    decision/.style={
        basenode,
        minimum width=12em,
        minimum height=16ex,
        diamond, 
        anchor=center,
        shape aspect=2,
        text width=5em,
        inner sep=0pt,
    },
    %myarrow/.style={
    every path/.style={
        gray, 
        very thick,
        rounded corners,
        -{Triangle[width=5pt]}
    },
    % addition:
    every node/.append style={sharp corners}
    ]
    \matrix[
        matrix of nodes, row sep=5ex, column sep=-2em,
        ] {
     |[decision](a)| A \\
     & |[block](b)| B \\
    };
    %\begin{scope}[myarrow]
    \draw (a) -| (b);
    %\end{scope}
    \end{tikzpicture}
\end{document}
Torbjørn T.
Torbjørn T.
January 13, 2018 23:09 PM

Related Questions



Tikz Edge: Distance from other nodes?

Updated April 07, 2015 18:09 PM

TikZ: remove side-bearing from text node

Updated July 22, 2016 08:09 AM

How to rotate the box

Updated June 06, 2016 08:09 AM