我有一个类似于的 TikZ 矩阵这:
\documentclass[11pt]{report}
%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{positioning,fit,matrix, backgrounds}
\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},
back group/.style={fill=yellow!20,rounded corners, draw=black!50, dashed, inner xsep=15pt, inner ysep=10pt},
}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[box/.style={rectangle, rounded corners,
text width=2.5cm, minimum height=1cm,text centered, draw=black},
font=\sffamily]
\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}},]
(mat){
Social Methods & Technical Methods\\
Social Data & Technical Data\\
Social Analysis & Technical analysis\\
};
\begin{scope}[on background layer,nodes={back group}]
\node[fit=(mat-1-1)(mat.north-|mat-1-1)(mat.south-|mat-1-1),inner
xsep=1em,inner ysep=1.5em,draw,yshift=1ex,
label={[anchor=north west]north west:Social design}](F1){};
\node[fit=(mat-1-2)(mat.north-|mat-1-2)(mat.south-|mat-1-2),inner
xsep=1em,inner ysep=1.5em,draw,yshift=1ex,
label={[anchor=north west]north west:Technical design}](F2){};
\end{scope}
\node[box,above=3em of mat,text width=3.2cm,minimum height=1.3cm,1](model)
{Socio-technical theory or model};
\begin{scope}[arrow]
\foreach \X in {1,2}
{\draw (model) -- (F\X);
\draw (mat-1-\X) -- (mat-2-\X);
\draw (mat-2-\X) -- (mat-3-\X);
}
\draw (mat-3-1.east) -- ([yshift=-1em]mat-3-1.east-|F1.east);
\draw (mat-3-2.west) -- ([yshift=-1em]mat-3-2.west-|F2.west);
\draw (mat-1-2) -- (mat-2-1);
\end{scope}
\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
\path[clip]
(F3.south west) |- (F3.north east) |- (F3.south east);
\node at (F3) {\includegraphics[scale=1.3]{example-image-duck}};
\end{tikzpicture}
\caption{A conceptual model for socio-technical research (reproduced from
\dots).}
\label{fig:socio-technical model}
\end{figure}
\end{document}
答案2
\includegraphics{some image}
您可以在 (F1) 处和节点内部添加一个节点。
\documentclass[11pt]{report}
%% Package for creating diagrams
\usepackage{tikz}
\usetikzlibrary{positioning,fit,matrix, backgrounds}
\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},
back group/.style={fill=yellow!20,rounded corners, draw=black!50, dashed, inner xsep=15pt, inner ysep=10pt},
}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[box/.style={rectangle, rounded corners,
text width=2.5cm, minimum height=1cm,text centered, draw=black},
font=\sffamily]
\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}},]
(mat){
Social Methods & Technical Methods\\
Social Data & Technical Data\\
Social Analysis & Technical analysis\\
};
\begin{scope}[on background layer,nodes={back group}]
\node[fit=(mat-1-1)(mat.north-|mat-1-1)(mat.south-|mat-1-1),inner
xsep=1em,inner ysep=1.5em,draw,yshift=1ex,
label={[anchor=north west]north west:Social design}](F1){};
\node[fit=(mat-1-2)(mat.north-|mat-1-2)(mat.south-|mat-1-2),inner
xsep=1em,inner ysep=1.5em,draw,yshift=1ex,
label={[anchor=north west]north west:Technical design}](F2){};
\end{scope}
\node[box,above=3em of mat,text width=3.2cm,minimum height=1.3cm,1](model)
{Socio-technical theory or model};
\begin{scope}[arrow]
\foreach \X in {1,2}
{\draw (model) -- (F\X);
\draw (mat-1-\X) -- (mat-2-\X);
\draw (mat-2-\X) -- (mat-3-\X);
}
\draw (mat-3-1.east) -- ([yshift=-1em]mat-3-1.east-|F1.east);
\draw (mat-3-2.west) -- ([yshift=-1em]mat-3-2.west-|F2.west);
\draw (mat-1-2) -- (mat-2-1);
\end{scope}
\node [below=4pt,anchor=center] at (F1) {\includegraphics[width=2.8cm,height=4.1cm]{example-image}};
\end{tikzpicture}
\caption{A conceptual model for socio-technical research (reproduced from
\dots).}
\label{fig:socio-technical model}
\end{figure}
\end{document}