# Overlapping edges from nodes are bigger than normal edges in matrix

I wanted to create template from the business model canvas using a matrix in Tikz (maybe there is a more intelligent approach).

So far it works okay. However, as I have to make some multi-rows and multicolumns using the fit library from tikz the edges from these nodes are overlapping in some way and therefore there seems to be very big:

Have somebody an idea to solve this issue?

Here is the minimalistic code:

\documentclass[tikz]{standalone}
\usetikzlibrary{matrix, fit}
\begin{document}
\begin{tikzpicture}
[
rectangle_block/.append style={drop shadow, rounded corners=0, minimum height=4cm, text width=3cm}
]
\matrix  [column sep=0cm,row sep=0cm, ampersand replacement=\&,  nodes in empty cells] (table) at (0,0)
{
% row 1
\node [rectangle_block] (11) {};  \& [0cm]
\node [rectangle_block,] (12) {Schlüsselaktivitäten}; \& [0cm]
\node [rectangle_block] (13) {};\& [0cm]
\node [rectangle_block] (14) {Kundenbeziehungen};\& [0cm]
\node [rectangle_block] (15) {};\\[0cm]

% row 2
\node [rectangle_block] (21) {};\&
\node [rectangle_block] (22) {Schlüsselressourcen}; \&
\node [rectangle_block] (23) {};\&
\node [rectangle_block] (24) {Kundenkanäle};\&
\node [rectangle_block] (25) {};\\

% row 3
\node [rectangle_block] (31) {};\&
\node [rectangle_block] (32) {}; \&
\node [rectangle_block] (33) {};\&
\node [rectangle_block] (34) {};\&
\node [rectangle_block] (35) {};\\
};
%\path[draw=red] (0,0) rectangle ++(16cm,5cm);

\node[fit=(11.north)(21.south), rectangle_block,minimum height=8cm](kp){Schlüsselpartner};
\node[fit=(13.north)(23.south), rectangle_block,minimum height=8cm](wa){Wertangebot};
\node[fit=(15.north)(25.south), rectangle_block,minimum height=8cm](ks){Kundensegment};
\node[fit=(31.west)(33.center), rectangle_block,minimum height=4cm, text width=7.5cm](cs){Kostenstruktur};
\node[fit=(33.center)(35.east), rectangle_block,minimum height=4cm, text width=7.5cm](rs){Erlösmodell};

\end{tikzpicture}
\end{document}

• I guess you only need to set the inner sep to -\pgflinewidth/2 or sth like that. – marmot Sep 10 '18 at 17:14

in your mwe i would make the following changes:

• define special style for "fit" nodes with inner sep=0pt and outer sep=0pt
• definition of matrix nodes move to options of the matrix
• add anchor=center to nodes' style

with those changes the table code become more clear and concise, and of course, your problem is avoided:

    \documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{fit, matrix}

\begin{document}
\begin{tikzpicture}[
FIT/.style={fit=#1,
draw, fill=white,
inner sep=0pt, outer sep=0pt, node contents={}
},
every label/.append style = {font=\ttfamily}
]
\matrix (m) [matrix of nodes,
nodes in empty cells,
nodes={draw, minimum height=4cm, text width=3cm,
font=\ttfamily, align=center, anchor=center},
column sep=0pt,
row sep=0pt
]
{
% row 1
&   |[fill=red!30]| Schlüsselaktivitäten
&   &   Kundenbeziehungen   &   \\
% row 2
&   Schlüsselressourcen     &   &   Kundenkanäle        &   \\
% row 3
&                           &   &                       &   \\
};
% nodes over two cells
\node (kp) [FIT=(m-1-1) (m-2-1), label=center:Schlüsselpartner];
\node (wa) [FIT=(m-1-3) (m-2-3), label=center:Wertangebot];
\node (ks) [FIT=(m-1-5) (m-2-5), label=center:Kundensegment];
\node (rs) [FIT=(m-3-1) (m-3-3.center), label=center:Kostenstruktur];
\node (cs) [FIT=(m-3-3.center) (m-3-5),
draw=red, fill=yellow!30, label=center:Erlösmodell];
\end{tikzpicture}
\end{document}


edit:
according to your comment below, now is changed:

• font family to \ttfamily
• added manual break of to long texts in nodes (this should be done with use of babel, but i haven't installed it for German language)
• Many thanks for your answer. Your solution seems great. One question: Is it still possible to define "styles" for some nodes of the matrix? I defined some special styles for colouring specific nodes, however your solution sets some kind of global style for each node. Is it still possbile in some way to for example colour 'schlüsselaktivitäen' in red os set a style just for this 'cell'? – SRel Sep 10 '18 at 19:12
• yes, it is possible, in this particular cell you add your style addition as |[<style addition]|. if you explain me, for one cell what this had to be, i will add this to my answer. – Zarko Sep 10 '18 at 19:38
• For example I want to mark four aspects in the picture. I defined reactangle_res/.style ={rectangle_block, fill=yellow!\colourdepth}, for the three blocks in the upper left corner (Schlüsselpartner, Schlüsselaktivitäten, Schlüsselressourcen) and for the other nodes respectively – SRel Sep 10 '18 at 19:50
• @SRel, i not understand what you mean with "four aspect". if some changes go to nodes determined outside to matrix, this changes put to FIT nods, for nodes in matrix, inside nodes as i mentioned in previous comment. i will show this for two nodes asap – Zarko Sep 10 '18 at 19:56
• I try to change the familyfont of the nodes. Adding font=\ttfamily either in the FIT definition or in the row \node (kp) [FIT=.... doesn't matter, it does not effect the FIT-nodes. However the normal nodes of the matrix are changed correctly.... Can this can be due to label=? – SRel Sep 11 '18 at 1:04

An alternative for more or less regular boxes distributions like this one could be tcbposter from tcolorbox package. This particular case could look like:

\documentclass[border=2mm]{standalone}

\usepackage[most]{tcolorbox}
\usepackage[german]{babel}
\usepackage{lmodern}
\usepackage{lipsum}
%\usepackage{geometry}

\standaloneenv{tcbposter}

%\pagestyle{empty}
\begin{document}

\begin{tcbposter}[%
poster = {columns=5, rows=3, width=16cm, height=12cm, spacing=-1mm},% showframe},
boxes = {%
size=small,
colback=white,
sharp corners,
halign=center,
valign=center,
fontupper=\small,
}
]
\posterbox{column=1, row=1, rowspan=2}{Schüsselpartner}
\posterbox[colback=orange!30]{column=2, row=1}{Schüsselaktivitäten}
\posterbox{column=2, row=2}{Schüsselressourcen}
\posterbox{column=3, row=1, rowspan=2}{Wertangebot}
\posterbox{column=4, row=1}{Kundenbeziehungen}
\posterbox{column=4, row=2}{Kundenkanäle}
\posterbox[colframe=red, colback=red!30]{column=5, row=1, rowspan=2}{Kundensegment}
\posterbox{column=1, row=3, span=2.5}{Kostenstruktur}
\posterbox{column*=5, row=3, span=2.5}{Eslösmodell}
\end{tcbposter}

\end{document}
`