我想创建一个具有多个输入到下一个块的块图,但似乎根本无法使其工作。我想像这样制作它:
这就是我现在所拥有的:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\tikzstyle{block} = [rectangle, draw,
text width=5em, text centered, rounded corners, minimum height=5em]
\tikzstyle{halfblock} = [rectangle, draw,
text width=5em, text centered, rounded corners, minimum height=2em]
\tikzstyle{line} = [draw, -latex']
\begin{document}
\centering
\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [halfblock, yshift= 1cm] (1a) {1a};
\node [halfblock, yshift= -1cm] (1b) {1b};
\node [block, right of=1a, right of=1b] (2) {2};
\node [block, right of=2] (3) {3};
\path [line] (1a) -- (2);
\path [line] (1b) -- (2);
\path [line] (2) -- (3);
\end{tikzpicture}
\end{document}
答案1
新年快乐!
请尝试以下操作:
\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{arrows.meta,
positioning}
\begin{document}
\begin{tikzpicture}[ % <--- used style are moved here
node distance = 0mm and 5mm,
block/.style = {draw, rounded corners, minimum height=5em, text width=5em, align=center},
halfblock/.style = {block, minimum height=2em},
line/.style = {draw, -Latex}
]
% Place nodes
\node (n1) [block] {2};
\node (n2) [block, right=of n1] {3}; % <--- for positioning is used syntax of the positioning library
% input half boxes
\node (n1a) [halfblock, below left=of n1.north west] {1a};
\node (n1b) [halfblock, above left=of n1.south west] {1b};
% arrows
\path [line] (n1) edge (n2)
(n1a) edge (n1.west |- n1a)
(n1b) -- (n1.west |- n1b);
\end{tikzpicture}
\end{document}