关于Tikz矩阵添加文本的问题

关于Tikz矩阵添加文本的问题

我已经创建了大部分所需的图表,但需要一些帮助来添加一些内容:

此代码:

\documentclass[11pt]{report}

%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, positioning, fit, backgrounds, matrix, shadows, arrows.meta, positioning, chains, scopes}

\tikzset{
    1/.style={fill=red!30},
    2/.style={fill=blue!30},
    3/.style={fill=orange!30},
    4/.style={fill=green!30},
    5/.style={fill=red},
    arrow/.style={thick,->,>=stealth},
}

%% Define block styles
\tikzset{%
    materia/.style={draw, fill=blue!20, text width=6.0em, text centered, minimum height=1.5em,drop shadow},
    etape/.style={materia, text width=16em, minimum width=10em, minimum height=3em, rounded corners, drop shadow},
    linepart/.style={draw, thick, color=black!50, -LaTeX, dashed},
    line/.style={draw, thick, color=black!50, -LaTeX},
    ur/.style={draw, text centered, minimum height=0.01em},
    back group/.style={fill=yellow!20,rounded corners, draw=black!50, dashed, inner xsep=15pt, inner ysep=10pt},
}

\newcommand{\transreceptor}[3]{%
    \path [linepart] (#1.east) -- node [above] {\scriptsize #2} (#3);}

\begin{document}

\begin{figure}
    \centering

    \begin{tikzpicture}
    \matrix(m)[matrix of nodes,column sep=1cm, row sep=1cm,
    nodes={rectangle, rounded corners, text width=4cm, minimum height=1cm,text centered, draw=black,anchor=west},
    ]{
        \node[draw=none](int){};                        & \node[1](model){Socio-technical theory or model};     &       \node[draw=none](int){};\\
        \node[2](social-methods){Social Methods};       & \node[draw=none](int){};                              &       \node[3](technical-methods){Technical Methods};\\
        \node[2](social-data){Social Data};             & \node[draw=none](int){};                              &       \node[3](technical-data){Technical Data};\\
        \node[draw=none](int){};                        & \node[1](socio-analysis){Socio-technical analysis};   &       \node[draw=none](int){};\\
    };

    \draw [arrow] (model) -- (social-methods);
    \draw [arrow] (model) -- (technical-methods);
    \draw [arrow] (social-methods) -- (technical-methods);
    \draw [arrow] (social-methods) -- (technical-data);
    \draw [arrow] (technical-methods) -- (social-data);
    \draw [arrow] (social-methods) -- (social-data);
    \draw [arrow] (technical-methods) -- (technical-data);
    \draw [arrow] (social-data) -- (socio-analysis);
    \draw [arrow] (technical-data) -- (socio-analysis);

    \begin{scope}[on background layer]
    \node (bk3) [back group] [fit=(social-methods) (social-data) (technical-methods) (technical-data) (socio-analysis)] {};
    \end{scope}

    \end{tikzpicture}

    \caption{A conceptual model for socio-technical research (reproduced from ...) } 
    \label{fig:socio-technical model}
\end{figure}

\end{document}

产生如下结果:

在此处输入图片描述

但是,我试图重现这一点:

在此处输入图片描述

问题

我如何在后面的图中添加文本“社会技术设计”以及指向它的箭头?

谢谢你!

答案1

\documentclass[11pt]{report}

%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{ positioning, fit, backgrounds, matrix}

\tikzset{
    1/.style={fill=red!30},
    2/.style={fill=blue!30},
    3/.style={fill=orange!30},
    4/.style={fill=green!30},
    5/.style={fill=red},
    arrow/.style={thick,->,>=stealth},
}

%% Define block styles
\tikzset{%
    materia/.style={draw, fill=blue!20, text width=6.0em, text centered, minimum height=1.5em,drop shadow},
    etape/.style={materia, text width=16em, minimum width=10em, minimum height=3em, rounded corners, drop shadow},
    linepart/.style={draw, thick, color=black!50, -LaTeX, dashed},
    line/.style={draw, thick, color=black!50, -LaTeX},
    ur/.style={draw, text centered, minimum height=0.01em},
    back group/.style={fill=yellow!20,rounded corners, draw=black!50, dashed, inner xsep=15pt, inner ysep=10pt},
}

\newcommand{\transreceptor}[3]{%
    \path [linepart] (#1.east) -- node [above] {\scriptsize #2} (#3);}

\begin{document}

\begin{figure}
    \centering

    \begin{tikzpicture}
    \matrix(m)[matrix of nodes,column sep=-1cm, row sep=1cm,
    nodes={rectangle, rounded corners, text width=4cm, minimum height=1cm,text centered, draw=black,anchor=west},
    ]{
                               & |[1,alias=model]|Socio-technical theory or
                               model     &      \\[2em]
        |[2,alias=social-methods]|Social Methods       &                              &       |[3,alias=technical-methods]|Technical Methods\\
        |[2,alias=social-data]|Social Data             &                              &       |[3,alias=technical-data]|Technical Data\\
                               & |[1,alias=socio-analysis]|Socio-technical analysis   &      \\
    };

    \draw [arrow] (model.-160) -- (social-methods);
    \draw [arrow] (model.-20) -- (technical-methods);
    \draw [arrow] (social-methods) -- (technical-methods);
    \draw [arrow] (social-methods) -- (technical-data);
    \draw [arrow] (technical-methods) -- (social-data);
    \draw [arrow] (social-methods) -- (social-data);
    \draw [arrow] (technical-methods) -- (technical-data);
    \draw [arrow] (social-data) -- (socio-analysis);
    \draw [arrow] (technical-data) -- (socio-analysis);

    \begin{scope}[on background layer]
    \node (bk3) [back group] 
    [fit=(social-methods) (social-data) (technical-methods) (technical-data)
    (socio-analysis),inner ysep=2em,yshift=1em] {};
    \end{scope}
    \node[anchor=north,yshift=-1ex] (Socio-technical design) at (bk3.north) {Socio-technical design};
    \draw [arrow] (model) -- (Socio-technical design);
    \end{tikzpicture}

    \caption{A conceptual model for socio-technical research (reproduced from
    \dots).} 
    \label{fig:socio-technical model}
\end{figure}

\end{document}

在此处输入图片描述

另一种方法是将所有内容放入矩阵中。

\documentclass[11pt]{report}

%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{ positioning, fit, backgrounds, matrix}

\tikzset{
    1/.style={fill=red!30},
    2/.style={fill=blue!30},
    3/.style={fill=orange!30},
    4/.style={fill=green!30},
    5/.style={fill=red},
    arrow/.style={thick,->,>=stealth},
}

%% Define block styles
\tikzset{%
    materia/.style={draw, fill=blue!20, text width=6.0em, text centered, minimum height=1.5em,drop shadow},
    etape/.style={materia, text width=16em, minimum width=10em, minimum height=3em, rounded corners, drop shadow},
    linepart/.style={draw, thick, color=black!50, -LaTeX, dashed},
    line/.style={draw, thick, color=black!50, -LaTeX},
    ur/.style={draw, text centered, minimum height=0.01em},
    back group/.style={fill=yellow!20,rounded corners, draw=black!50, dashed, inner xsep=15pt, inner ysep=10pt},
}

\newcommand{\transreceptor}[3]{%
    \path [linepart] (#1.east) -- node [above] {\scriptsize #2} (#3);}

\begin{document}

\begin{figure}
    \centering

    \begin{tikzpicture}
    \matrix(m)[matrix of nodes,column sep=-1cm, row sep=1cm,
    nodes={rectangle, rounded corners, text width=4cm, minimum height=1cm,text centered, draw=black,anchor=west},
    column 1/.style={nodes=2},column 2/.style={nodes=1},column 3/.style={nodes=3},
    ]{
                               & |[alias=model]|Socio-technical theory or model 
                                  &      \\
                               & |[draw=none,fill=none,alias=Socio-technical design]| Socio-technical design & \\[-1.5em]
        |[alias=social-methods]|Social Methods       &                              &       |[alias=technical-methods]|Technical Methods\\
        |[alias=social-data]|Social Data             &                              &       |[alias=technical-data]|Technical Data\\
                               & |[alias=socio-analysis]|Socio-technical analysis   &      \\
    };

    \draw [arrow] (model.-160) -- (social-methods);
    \draw [arrow] (model.-20) -- (technical-methods);
    \draw [arrow] (model) -- (Socio-technical design);
    \draw [arrow] (social-methods) -- (technical-methods);
    \draw [arrow] (social-methods) -- (technical-data);
    \draw [arrow] (technical-methods) -- (social-data);
    \draw [arrow] (social-methods) -- (social-data);
    \draw [arrow] (technical-methods) -- (technical-data);
    \draw [arrow] (social-data) -- (socio-analysis);
    \draw [arrow] (technical-data) -- (socio-analysis);

    \begin{scope}[on background layer]
    \node (bk3) [back group] 
    [fit=(social-methods) (social-data) (technical-methods) (technical-data)
    (socio-analysis)(Socio-technical design),inner ysep=1ex] {};
    \end{scope}
    \end{tikzpicture}

    \caption{A conceptual model for socio-technical research (reproduced from
    \dots).} 
    \label{fig:socio-technical model}
\end{figure}

\end{document}

在此处输入图片描述

答案2

作为对上述答案的补充,这里有一个(几乎)完全复制照片中人物的例子。


\documentclass[11pt]{report}

%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{fit, backgrounds, matrix}

\tikzset{
    1/.style={},
    arrow/.style={thick,->,>=stealth},
}

%% Define block styles
\tikzset{%
    back group/.style={thick, draw=black, inner xsep=5pt, inner ysep=2.5pt},
}

\begin{document}

\begin{figure}
    \centering

    \begin{tikzpicture}
    \matrix(m)[matrix of nodes,column sep=-1cm, row sep=1cm,
    nodes={rectangle, thick, text width=4cm, minimum height=1cm, text centered, draw=black, anchor=west},
    ]{
                               & |[1,alias=model]|Socio-technical theory or model                       &      \\
                               & |[1,draw=none, alias=socio-technical-design]|Socio-technical design    &      \\[-2em]
        |[1,alias=social-methods]|Social Methods       &                              &       |[1,alias=technical-methods]|Technical Methods\\
        |[1,alias=social-data]|Social Data             &                              &       |[1,alias=technical-data]|Technical Data\\
                               & |[1,alias=socio-analysis]|Socio-technical analysis   &      \\
    };

    % inner box
    \begin{scope}[on background layer]
    \node (bk3) [back group] 
    [alias=inner-box, fit=(socio-technical-design) (social-methods) (social-data) (technical-methods) (technical-data)
    (socio-analysis), inner ysep=1.5em, yshift=-1em] {};
    \end{scope}

    % outer box
    \begin{scope}[on background layer]
    \node (bk3) [back group] 
    [fit=(model) (socio-technical-design) (social-methods) (social-data) (technical-methods) (technical-data)
    (socio-analysis), inner ysep=2em, inner xsep=1em, yshift=-1em] {};
    \end{scope}

    % relationships
    \draw [arrow] (model) -- (inner-box);
    \draw [arrow] (social-methods) -- (technical-methods);
    \draw [arrow] (technical-methods) -- (social-methods);
    \draw [arrow] (social-methods) -- (technical-data);
    \draw [arrow] (technical-methods) -- (social-data);
    \draw [arrow] (social-methods) -- (social-data);
    \draw [arrow] (technical-methods) -- (technical-data);
    \draw [arrow] (social-data) -- (socio-analysis);
    \draw [arrow] (technical-data) -- (socio-analysis);

    \end{tikzpicture}

    \caption{A conceptual model for socio-technical research (reproduced from
    \dots).}
    \label{fig:socio-technical model}
\end{figure}

\end{document}

在此处输入图片描述

相关内容