节点的重叠边比矩阵中的正常边大

节点的重叠边比矩阵中的正常边大

我想从商业模式画布在 Tikz 中使用矩阵(也许有更智能的方法)。

到目前为止,它运行良好。但是,由于我必须使用 tikz 中的 fit 库来创建一些多行和多列,这些节点的边缘在某种程度上重叠,因此似乎非常大: 在此处输入图片描述

有人有办法解决这个问题吗?

以下是最简洁的代码:

\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}

答案1

在您的 MWE 中我将做出以下更改:

  • 为“适合”节点定义特殊样式,inner sep=0ptouter sep=0pt
  • 矩阵节点的定义移至矩阵的选项
  • 添加anchor=center到节点的样式

通过这些更改,表格代码变得更加清晰和简洁,当然,您的问题也避免了:

    \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}

在此处输入图片描述

编辑:
根据您下面的评论,现在已更改:

  • 字体系列\ttfamily
  • 在节点中添加了对长文本的手动拆分(这应该使用 babel 来完成,但我还没有为德语安装它)

答案2

类似这样的更常规的盒子分布的替代方案可能是tcbpostertcolorbox包。这个特殊情况可能看起来像:

\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}

在此处输入图片描述

相关内容