如何使用 Tikz 绘制这幅图?
这是我已完成的事情。
- 我无法将块向右对齐。解决了
- 如何制作划掉的圆圈?解决了
- 如何在绘图中画出曲线?
梅威瑟:
\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{arrows, positioning, calc}
\usepackage{fontawesome5}
\begin{document}
\begin{tikzpicture}[>=stealth', thick, node distance=2.0em, on grid,
tt/.style={rectangle, align=center},
el/.style={circle, draw=black, minimum height=2.6em}
]
\node[rectangle, draw=black, minimum height=11em, minimum width=20em](uop){};
\node[tt, at={($(uop.north) + (0,-0.75em)$)}](uopt){\bfseries Unified Operating Manual};
%
\node[el, below=of uop.north, xshift=-5em](uope1){1};
\node[el, below=of uop.north](uope2){2};
\node[el, below=of uop.north, xshift=5em, fill=green](uope3){3};
%
\node[el, below=of uop.north, below=of uope1, yshift=-1em](uope4){4};
\node[el, below=of uop.north, below=of uope2, yshift=-1em](uope5){5};
\node[el, below=of uop.north, below=of uope3, yshift=-1em](uope6){6};
%
\node[el, below=of uop.north, below=of uope4, yshift=-1em](uope7){7};
\node[el, below=of uop.north, below=of uope5, yshift=-1em](uope8){8};
\node[el, below=of uop.north, below=of uope6, yshift=-1em](uope9){$N_f$};
\node (tt) at ($(uope8)!0.5!(uope9)$) {\ldots};
%
\node[left=of uope3, xshift=15em](user){\Huge\faIcon{user}};
\draw[<-, line width=3pt, loosely dotted, green] (uope3) -- (user) node[midway, xshift = 2em, above, black] {Changes};
%
\node[rectangle, draw=black, minimum height=11em, minimum width=17em, anchor=north east, below=of uop.south east](man1){};
\node[tt, at={($(man1.north) + (0,-0.75em)$)}](man1t){\bfseries Manual №1};
%
\node[el, below=of man1.north, xshift=-5em](uope11){1};
\node[el, below=of man1.north](uope21){2};
\node[el, below=of man1.north, xshift=5em, fill=green](uope31){3};
%
\node[el, below=of man1.north, below=of uope11, yshift=-1em](uope41){4};
\node[el, below=of man1.north, below=of uope21, yshift=-1em](uope51){5};
\node[el, below=of man1.north, below=of uope31, yshift=-1em](uope61){6};
%
\node[el, below=of man1.north, below=of uope41, yshift=-1em](uope71){7};
\node[el, below=of man1.north, below=of uope51, yshift=-1em](uope81){8};
\node[el, below=of man1.north, below=of uope61, yshift=-1em](uope91){$N_f$};
\node (tt) at ($(uope81)!0.5!(uope91)$) {\ldots};
\end{tikzpicture}
\end{document}
答案1
使用 s 可以最好地避免重复代码\pic
。因此,解决方案是使用这些(结合和库matrix
以及包fit
提供的小伙伴tikzpeople
):
\documentclass[border=10pt]{standalone}
\usepackage{tikzpeople} % loads tikz
\usetikzlibrary{matrix, fit, shapes.misc}
\tikzset{
pics/my matrix/.style={
code={
\tikzset{my matrix/.cd, #1}
\matrix (-m) at (0,0) [
name prefix ..,
ampersand replacement=\&,
matrix of nodes,
row sep=0.5cm,
column sep=0.75cm,
every node/.style={
circle,
draw,
minimum width=2.5em,
inner sep=0pt,
text depth=0.1em,
},
row 1 column 3/.style={
every node/.append style={
green!50!black,
fill,
text=white,
}
},
my matrix/matrix,
] {
1 \& 2 \& 3 \\
4 \& 5 \& 6 \\
7 \& 8 \& $N_{f}$ \\
};
\path (-m-3-2) -- (-m-3-3)
node[midway] {$\ldots$};
\node[above] (-header) at (-m.north) {
\pgfkeysvalueof{/tikz/my matrix/header}
};
\node[
fit={(-m) (-header)},
draw,
my matrix/box,
] (-box) {};
}
},
my matrix/header/.initial={},
my matrix/matrix/.style={},
my matrix/box/.style={
minimum width=5.5cm
},
crossed out/.style 2 args={
row #1 column #2/.style={
every node/.append style={
green!50!black,
path picture={
\draw
(path picture bounding box.north west) --
(path picture bounding box.south east)
(path picture bounding box.south west) --
(path picture bounding box.north east);
}
}
}
}
}
\begin{document}
\begin{tikzpicture}
\pic (matrix 1) at (0,0) {my matrix={
header={\textbf{Unified Operating Manual}},
matrix/.style={
xshift=-1cm
},
box/.style={
minimum width=7.5cm
}
}};
\pic (matrix 2) at (0,-5) {my matrix={
header={Manual №1},
matrix/.style={
crossed out={2}{3},
crossed out={3}{3},
crossed out={3}{2},
}
}};
\pic (matrix 3) at (0,-10) {my matrix={
header={Manual №2},
matrix/.style={
crossed out={2}{2},
crossed out={3}{3},
crossed out={3}{2},
}
}};
\pic (matrix 4) at (0,-16) {my matrix={
header={Manual №$N_{0}$},
matrix/.style={
crossed out={2}{3},
crossed out={3}{1},
}
}};
\path (matrix 3-box.south) -- (matrix 4-box.north)
node[midway] {$\vdots$};
\draw[-stealth] ([xshift=-3.25cm]matrix 1-box.south) |- (matrix 4-box.west);
\draw[-stealth] ([xshift=-3cm]matrix 1-box.south) |- (matrix 3-box.west);
\draw[-stealth] ([xshift=-2.75cm]matrix 1-box.south) |- (matrix 2-box.west);
\node[bob, mirrored, minimum size=1.25cm] (bob)
at ([xshift=5cm]matrix 1-m-1-3) {User};
\draw[ultra thick, green!50!black, dashed, -stealth]
(bob.west) -- (matrix 1-m-1-3)
node[pos=0.25, above, black] {Changes};
\draw[ultra thick, green!50!black, dashed, -stealth]
(matrix 1-m-1-3) to[bend left=70] (matrix 2-m-1-3);
\draw[ultra thick, green!50!black, dashed, -stealth]
(matrix 1-m-1-3) to[bend left=70] (matrix 3-m-1-3);
\draw[ultra thick, green!50!black, dashed, -stealth]
(matrix 1-m-1-3) to[bend left=70] (matrix 4-m-1-3);
\end{tikzpicture}
\end{document}
答案2
这是实现此目的的方法。关键是这一行:
- 从 (uope3) 开始
- 向侧面移动,-20 度,5 厘米(作为新的起点)
- 至 (uope31),给出角和入角
这通常比使用..controls..
\draw[->,arr] (uope3) --+(-20:5) to[out=-20,in=0] (uope31);
PS:您可以放置更多的中间点,当然还可以用 来替换 - - 以获得更多曲线。
\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{arrows, positioning, calc}
\usepackage{fontawesome5}
\begin{document}
\begin{tikzpicture}[
>=stealth', thick, node distance=2.0em, on grid,
tt/.style={rectangle, align=center},
el/.style={circle, draw=black, minimum height=2.6em},
el2/.style={el, below=of uop.north},
arr/.style={line width=3pt, loosely dotted, green},
]
\node[rectangle, draw=black, minimum height=11em, minimum width=20em](uop){};
\node[tt, at={($(uop.north) + (0,-0.75em)$)}](uopt){\bfseries Unified Operating Manual};
%
\node[el2, xshift=-5em] (uope1){1};
\node[el2] (uope2){2};
\node[el2, xshift=5em, fill=green] (uope3){3};% <<<
%
\node[el, below=of uop.north, below=of uope1, yshift=-1em](uope4){4};
\node[el, below=of uop.north, below=of uope2, yshift=-1em](uope5){5};
\node[el, below=of uop.north, below=of uope3, yshift=-1em](uope6){6};
%
\node[el, below=of uop.north, below=of uope4, yshift=-1em](uope7){7};
\node[el, below=of uop.north, below=of uope5, yshift=-1em](uope8){8};
\node[el, below=of uop.north, below=of uope6, yshift=-1em](uope9){$N_f$};
\node (tt) at ($(uope8)!0.5!(uope9)$) {\ldots};
%
\node[left=of uope3, xshift=15em](user){\Huge\faIcon{user}};
% ~~~ upper linear vector ~~~~~~~~~~~~~~~~~~~
\draw[<-, arr] (uope3) -- (user) node[midway, xshift = 2em, above, black] {Changes};
%
\node[rectangle, draw=black, minimum height=11em, minimum width=17em, anchor=north east, below=of uop.south east](man1){};
\node[tt, at={($(man1.north) + (0,-0.75em)$)}](man1t){\bfseries Manual №1};
%
\node[el, below=of man1.north, xshift=-5em] (uope11){1};
\node[el, below=of man1.north] (uope21){2};
\node[el, below=of man1.north, xshift=5em, fill=green](uope31){3};% <<<
%
\node[el, below=of man1.north, below=of uope11, yshift=-1em](uope41){4};
\node[el, below=of man1.north, below=of uope21, yshift=-1em](uope51){5};
\node[el, below=of man1.north, below=of uope31, yshift=-1em](uope61){6};
%
\node[el, below=of man1.north, below=of uope41, yshift=-1em](uope71){7};
\node[el, below=of man1.north, below=of uope51, yshift=-1em](uope81){8};
\node[el, below=of man1.north, below=of uope61, yshift=-1em](uope91){$N_f$};
\node (tt) at ($(uope81)!0.5!(uope91)$) {\ldots};
% ~~~ connectiong both nodes containing "3" ~~~~~~~~~
%\draw[->,arr] (uope3) -- (uope31); % normal way to do it: straight
\draw[->,arr] (uope3) --+(-20:5) to[out=-20,in=0] (uope31);
\end{tikzpicture}
\end{document}