我想通过节点的边缘来连接它们,也就是说让 abc 末端的箭头接触矩形的左边距。它完美地运行,wordsa
但我还没有找到合适的方法abc
。
平均能量损失
\documentclass[
11pt
]{scrartcl}
\usepackage{
tikz,
relsize,
tgheros
}
\usetikzlibrary{
calc,trees,shadows,positioning,arrows,chains,shapes.geometric,
decorations.pathreplacing,decorations.pathmorphing,shapes,
matrix,shapes.symbols,patterns,intersections%,fit
}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\tikzset{
rolle/.style=
{
rectangle,
drop shadow={opacity=0.5},
minimum width=4em,
minimum height=4em,
text width=4cm,
draw=black!80,
very thick,
fill=black!40,
font=\sffamily\bfseries,
align=center
},
einheit/.style=
{
rectangle,
rounded corners,
minimum height=2em,
minimum width=4em,
draw=black!80,
fill=black!20,
font=\sffamily
},
}
\begin{document}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small,node distance=0.5cm]
\matrix (m) [
matrix of nodes,
nodes in empty cells,
row sep=7mm,
column sep=3mm,
inner sep=7pt
] {
%
\node[rolle] {123}; & \node[rolle] {456}; & \node[rolle] {789}; \\
%
\node[einheit] {words}; & & \node[minimum width=3cm] (abc) {}; \\
%
& \node[einheit] (wordsa) {wordsa}; & \\
%
& \node[einheit] (wordsb) {wordsb}; & \\
%
& \node[einheit] {companies}; & \\
%
\node[einheit] {thing}; & & \node[minimum width=3cm] (xyz) {};\\
};
%
\draw[thick] (current bounding box.north west) rectangle (current bounding box.south east);
\draw[thick,fill=black!20] (current bounding box.north west) rectangle ([yshift=1cm]current bounding box.north east) node[midway] {Something Important};
%
\draw[einheit] (abc.north east) rectangle (xyz.south west) node[midway] (new) {abc};
%
\draw[thick,dashed,<->] (new.west) -- (wordsa.east);
%
\end{tikzpicture}
\end{center}
\end{document}
答案1
添加,minimum width=3cm
到node[midway]
行中
\draw[einheit] (abc.north east) rectangle (xyz.south west) node[midway] (new) {abc};
对于一些外观上的改变,考虑shorten <=2pt,shorten >=2pt
添加
\draw[thick,dashed,<->] (new.west) -- (wordsa.east);
=>
\documentclass[
11pt
]{scrartcl}
\usepackage{
tikz,
relsize,
tgheros
}
\usetikzlibrary{
calc,trees,shadows,positioning,arrows,chains,shapes.geometric,
decorations.pathreplacing,decorations.pathmorphing,shapes,
matrix,shapes.symbols,patterns,intersections%,fit
}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\tikzset{
rolle/.style=
{
rectangle,
drop shadow={opacity=0.5},
minimum width=4em,
minimum height=4em,
text width=4cm,
draw=black!80,
very thick,
fill=black!40,
font=\sffamily\bfseries,
align=center
},
einheit/.style=
{
rectangle,
rounded corners,
minimum height=2em,
minimum width=4em,
draw=black!80,
fill=black!20,
font=\sffamily
},
}
\begin{document}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small,node distance=0.5cm]
\matrix (m) [
matrix of nodes,
nodes in empty cells,
row sep=7mm,
column sep=3mm,
inner sep=7pt
] {
%
\node[rolle] {123}; & \node[rolle] {456}; & \node[rolle] {789}; \\
%
\node[einheit] {words}; & & \node[minimum width=3cm] (abc) {}; \\
%
& \node[einheit] (wordsa) {wordsa}; & \\
%
& \node[einheit] (wordsb) {wordsb}; & \\
%
& \node[einheit] {companies}; & \\
%
\node[einheit] {thing}; & & \node[minimum width=3cm] (xyz) {};\\
};
%
\draw[thick] (current bounding box.north west) rectangle (current bounding box.south east);
\draw[thick,fill=black!20] (current bounding box.north west) rectangle ([yshift=1cm]current bounding box.north east) node[midway] {Something Important};
%
\draw[einheit] (abc.north east) rectangle (xyz.south west) node[midway,minimum width=3cm] (new) {abc};
%
\draw[thick,dashed,<->,shorten >=2pt,shorten <=2pt] (new.west) -- (wordsa.east);
%
\end{tikzpicture}
\end{center}
\end{document}