我想畫一個包含箭頭的框,其定義Infographic Box with Arrow
為這個連結。我想更新下圖以產生從上到下的圖。
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric, arrows}
\begin{document}
\begin{tikzpicture}[font=\small, node distance=2cm]
\tikzstyle{block} = [rectangle, draw, text width=12cm, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\node [block] (step1) {Alpha process};
\node [block, below of=step1] (step2) {Beta analysis};
\node [block, below of=step2] (step3) {Gamma results};
\path [line] (step1) -- (step2);
\path [line] (step2) -- (step3);
\end{tikzpicture}
\end{document}
有沒有辦法更新我的盒子並使它們看起來如下圖所示。
答案1
shapes.arrows
Ti自備的庫kZ 有一個arrow box
形狀你可以嘗試:
\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{shapes.arrows}
\begin{document}
\begin{tikzpicture}
\tikzset{
font=\small,
node distance=2cm,
block/.style={
arrow box,
draw,
text width=12cm,
text centered,
minimum height=4em,
arrow box arrows={south:0.5cm}
},
last block/.style={
block,
arrow box arrows={south:0cm}
}
}
\node[block] (step1) {Alpha process};
\node[block, below of=step1] (step2) {Beta analysis};
\node[last block, below of=step2] (step3) {Gamma results};
\end{tikzpicture}
\end{document}
請注意,您應該使用\tikzset
而不是\tikzstyle
.
或者,您可以手動繪製節點的邊框,或為了避免程式碼中的重複,請建立一個\pic
:
\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{shapes.arrows}
\begin{document}
\begin{tikzpicture}
\tikzset{
font=\small,
node distance=2cm,
pics/box with arrow/.style={
code={
\node[pic actions, text centered] (-node) {#1};
\draw[rounded corners]
([xshift=-0.25em]-node.south) -| (-node.north west) -|
(-node.south east) -- ([xshift=0.25em]-node.south);
\draw ([xshift=-0.25em]-node.south) |- ++(-0.25em,-0.5em) --
++(0.5em,-0.5em) -- ++(0.5em,0.5em) -| ++(-0.25em,0.5em);
}
},
pics/box without arrow/.style={
code={
\node[pic actions, text centered] (-node) {#1};
\draw[rounded corners]
(-node.south east) rectangle (-node.north west);
}
}
}
\pic[text width=12cm, minimum height=4em]
(step1) {box with arrow={Alpha process}};
\pic[below of=step1-node, text width=12cm, minimum height=4em]
(step2) {box with arrow={Beta analysis}};
\pic[below of=step2-node, text width=12cm, minimum height=4em]
(step3) {box without arrow={Gamma results}};
\end{tikzpicture}
\end{document}