\path[clip] 破坏了现有的图表

\path[clip] 破坏了现有的图表

我有一个节点图,我想在其中添加两个图像。我正在使用,\path[clip]但只有在没有其他图像的情况下才有效\path[clip]。我甚至添加了\begin{pgfinterruptboundingbox}将图像与其他图像隔离开来,但仍然不起作用。只有当我删除其中一个图像时,它才有效。示例取自邮政。

目标是让图像存在于两个矩阵节点中。

\documentclass[11pt]{report}
%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{backgrounds, fit, matrix, positioning}
\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},
every edge/.style = {draw, thick, -stealth},
    box/.style={draw=red, rounded corners,
            text width=24mm, minimum height=12mm,
            align=center, font=\sffamily},
  FIT/.style args = {#1/#2}{draw, rounded corners, dashed, fill=yellow!30,
            inner xsep=1em, inner ysep=2em, yshift=1em,
            label={[anchor=north]north:#1},
            fit=#2}
}
\usepackage[export]{adjustbox}
\begin{document}
    \begin{figure}
    \centering
\begin{tikzpicture}
\matrix (m) [matrix of nodes,
             column sep=3.5em, row sep=0.5cm,
             nodes={box, anchor=center},
             row 1/.style={nodes={2}},
             row 2/.style={nodes={3}},
             row 3/.style={nodes={4}}
             ]
{
Social Methods  & Technical Methods \\
Social Data     & Technical Data    \\
Social Analysis & Technical analysis\\
};
    \begin{scope}[on background layer]
\node (F1) [FIT=Social design/(m-1-1)(m-3-1)] {};
\node (F2) [FIT=Technical design/(m-1-2)(m-3-2)]    {};
    \end{scope}
\node (F3)  [FIT=/(m-1-1)(m-3-1), yshift=-1em, inner sep=0pt] {};
\node (model)   [box, text width=32mm,
                 above=22mm of m]  {Socio-technical theory or model};
% arrows
\foreach \X in {1,2}
{
\draw   (model)   edge (F\X)
        (m-1-\X)  edge (m-2-\X) 
        (m-2-\X)  edge (m-3-\X);
}
\draw   (m-3-1.east)    edge (m-3-1.south -| F1.east) 
        (m-3-2.west)    edge (m-3-2.south -| F2.west) 
        (m-1-2)         edge (m-2-1);
% image in clip
\begin{pgfinterruptboundingbox}

\path[clip]
    (F3.south west) |- (F3.north east) |- (F3.south east);
\node at (F3) {\includegraphics[scale=1.3]{example-image-duck}};
\end{pgfinterruptboundingbox}
\begin{pgfinterruptboundingbox}
\path[clip]
    (F2.south west) |- (F2.north east) |- (F2.south east);
\node at (F2) {\includegraphics[scale=1.3]{example-image-duck}};
\end{pgfinterruptboundingbox}

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

答案1

您需要将每个剪辑放入不同的范围内。

\documentclass[11pt]{report}
%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{backgrounds, fit, matrix, positioning}
\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},
every edge/.style = {draw, thick, -stealth},
    box/.style={draw=red, rounded corners,
            text width=24mm, minimum height=12mm,
            align=center, font=\sffamily},
  FIT/.style args = {#1/#2}{draw, rounded corners, dashed, fill=yellow!30,
            inner xsep=1em, inner ysep=2em, yshift=1em,
            label={[anchor=north]north:#1},
            fit=#2}
}
\usepackage[export]{adjustbox}
\begin{document}
    \begin{figure}
    \centering
\begin{tikzpicture}
\matrix (m) [matrix of nodes,
             column sep=3.5em, row sep=0.5cm,
             nodes={box, anchor=center},
             row 1/.style={nodes={2}},
             row 2/.style={nodes={3}},
             row 3/.style={nodes={4}}
             ]
{
Social Methods  & Technical Methods \\
Social Data     & Technical Data    \\
Social Analysis & Technical analysis\\
};
    \begin{scope}[on background layer]
\node (F1) [FIT=Social design/(m-1-1)(m-3-1)] {};
\node (F2) [FIT=Technical design/(m-1-2)(m-3-2)]    {};
    \end{scope}
\node (F3)  [FIT=/(m-1-1)(m-3-1), yshift=-1em, inner sep=0pt] {};
\node (model)   [box, text width=32mm,
                 above=22mm of m]  {Socio-technical theory or model};
% arrows
\foreach \X in {1,2}
{
\draw   (model)   edge (F\X)
        (m-1-\X)  edge (m-2-\X) 
        (m-2-\X)  edge (m-3-\X);
}
\draw   (m-3-1.east)    edge (m-3-1.south -| F1.east) 
        (m-3-2.west)    edge (m-3-2.south -| F2.west) 
        (m-1-2)         edge (m-2-1);
% image in clip

\begin{scope}
\path[clip]
    (F3.south west) |- (F3.north east) |- (F3.south east);
\node at (F3) {\includegraphics[scale=1.3]{example-image-duck}};
\end{scope}

\begin{scope}
\path[clip]
    (F2.south west) |- (F2.north east) |- (F2.south east);
\node at (F2) {\includegraphics[scale=1.3]{example-image-duck}};
\end{scope}

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

演示

相关内容