Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use "fit" to make two small rectangles inside a bigger rectangle. And then add some words at the top of the bigger one, which causes a large blank space at the bottom of the bigger rectangle as showed in the following photo. However, I wish to get the graph that there is no blank at the bottom of the outside rectangle and almost no space between word and the top small rectangle. Could some one Help me? enter image description here

\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} 
share|improve this question
2  
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Kurt Feb 15 '13 at 14:19
    
@Kurt I have edited it and added the MWE,THANKS –  sweetyBaby Feb 15 '13 at 14:29
    
@Jake thanks for reminder :) have added it. –  sweetyBaby Feb 15 '13 at 14:30

1 Answer 1

up vote 3 down vote accepted

The blank space at the bottom does not come from the label, but from the fact that you're using minimum height=4cm for the ab node. What I would do is to add the label first using a node that's placed above a, and then fit the large box around the two boxes and the label node:

\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} 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.