我使用“fit”在一个大矩形内制作两个小矩形。然后在大矩形的顶部添加一些单词,这会导致大矩形底部出现较大的空白,如下图所示。但是,我希望得到这样的图形:外部矩形的底部没有空白,单词和顶部小矩形之间几乎没有空间。有人能帮帮我吗?
\documentclass[tikz]{standalone}
\usetikzlibrary{
shapes.geometric,
positioning,
fit,
calc
}
\usetikzlibrary{decorations.markings}
\usepackage{tikz}
\newcommand*{\Shift}{0.6ex}
\begin{document}
\tikzset{
my box/.style = {draw, minimum width = 3em, minimum height=1em},
}
\begin{tikzpicture}[node distance=5mm]
\node[my box,align=center](a) {get flight\\(gf)};
\node[my box,align=center,below=of a] (b) {book flight\\(bf)};
\draw[->] (a) -- (b);
\node[draw, fit=(a) (b),minimum height=4cm] (ab) {};
\node[below=0.3mm of ab.north,align=center](flight) {ontessage\\ jeusts};
\end{tikzpicture}
\end{document}
答案1
底部的空白不是来自标签,而是来自您用于minimum height=4cm
节点的事实ab
。我要做的是先使用放置在上方的节点添加标签a
,然后将大框放在两个框和标签节点周围:
\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{
shapes.geometric,
positioning,
fit,
calc
}
\usetikzlibrary{decorations.markings}
\usepackage{tikz}
\newcommand*{\Shift}{0.6ex}
\begin{document}
\tikzset{
my box/.style = {draw, minimum width = 3em, minimum height=1em},
}
\begin{tikzpicture}[node distance=5mm]
\node [my box,align=center](a) {get flight\\(gf)};
\node [my box,align=center,below=of a] (b) {book flight\\(bf)};
\node [above=1ex of a, align=center] (c) {ontessage\\jeusts};
\draw[->] (a) -- (b);
\node[draw, fit=(a) (b) (c)] (ab) {};
\end{tikzpicture}
\end{document}