我有以下图片:
\documentclass[preview,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{center}
\begin{small}
\begin{tikzpicture} [label distance=5pt]
\tikzstyle{every node}=[font=\small] %
\tikzstyle{every label}=[text width=2.3cm, align=center] %
\tikzstyle{mechanism}=[draw, thick, minimum height=4cm, text
width=2.3cm, fill=lightgray] %
\tikzstyle{motivation}=[draw, thick, right=of n3, text width=1.6cm,
align=center] %
\node (n1) [align=center, text width=1.8cm] {Cues in the environment}; %
\node (n2) [mechanism, right=of n1, align=center,
label={above:Acquisition mechanism}] {infer contents of norms \\[3em]
identify norm-related behavior}; %
\node (n3) [mechanism, right=of n2, align=left,
label={above:Implementation mechanism}] {norm database\\
$n_{1} \cdots\cdots\cdots$\\ $n_{2} \cdots\cdots\cdots$\\
$n_{3} \cdots\cdots\cdots$\\ $\phantom{n_{3}} \cdots\cdots\cdots$\\
$n_{z} \cdots\cdots\cdots$\smallskip\\ norm-related\\ reasoning\\
capacity}; %
\node (n4) [motivation, yshift=1.2cm] {compliance motivation} ; %
\node (n5) [motivation, yshift=-1.2cm] {punishment motivation} ; %
\path[->,thick] (n1) edge (n2) (n2) edge (n3); %
\path[->,thick] (n3) edge (n4) (n3) edge (n5); %
\end{tikzpicture}
\end{small}
\end{center}
\end{document}
输出:
我希望最右边的两个箭头是水平的,即从节点 (n3) 水平指向 (n4) 和 (n5) 的西锚点。我该如何实现?
答案1
尝试:
\draw [->,thick] (n3.east|-n4.west) -- (n4.west);
\draw [->,thick] (n3.east|-n5.west) -- (n5.west);
看13.3.1 垂直线的交点 来自 TikZ 和 PGF 手册。
答案2
|-
将绘制一条仅由垂直线段和水平线段组成的线。起始处的垂直线段将消失在节点的边界后面,因此只有水平线段可见。
\documentclass[preview,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{center}
\begin{small}
\begin{tikzpicture} [label distance=5pt]
\tikzstyle{every node}=[font=\small] %
\tikzstyle{every label}=[text width=2.3cm, align=center] %
\tikzstyle{mechanism}=[draw, thick, minimum height=4cm, text
width=2.3cm, fill=lightgray] %
\tikzstyle{motivation}=[draw, thick, right=of n3, text width=1.6cm,
align=center] %
\node (n1) [align=center, text width=1.8cm] {Cues in the environment}; %
\node (n2) [mechanism, right=of n1, align=center,
label={above:Acquisition mechanism}] {infer contents of norms \\[3em]
identify norm-related behavior}; %
\node (n3) [mechanism, right=of n2, align=left,
label={above:Implementation mechanism}] {norm database\\
$n_{1} \cdots\cdots\cdots$\\ $n_{2} \cdots\cdots\cdots$\\
$n_{3} \cdots\cdots\cdots$\\ $\phantom{n_{3}} \cdots\cdots\cdots$\\
$n_{z} \cdots\cdots\cdots$\smallskip\\ norm-related\\ reasoning\\
capacity}; %
\node (n4) [motivation, yshift=1.2cm] {compliance motivation} ; %
\node (n5) [motivation, yshift=-1.2cm] {punishment motivation} ; %
\path[->,thick] (n1) edge (n2) (n2) edge (n3); %
\draw[->,thick] (n3.east) |- (n4);
\draw[->,thick] (n3.east) |- (n5);
% \path[->,thick] (n3) edge (n4) (n3) edge (n5); %
\end{tikzpicture}
\end{small}
\end{center}
\end{document}