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 drew a family tree using TikZ with the positioning library, following in the footsteps of Gonzalo.

The problem is that there is a blank page generated before the family tree. Can anyone explain why it is there and how to get rid of it? I've tried fiddling with the code to shrink the tree with no success. I put a bounding box around the figure, but the box is on the same page.

I've left out the connecting edges for brevity. It is still quite long. If necessary I could probably strip it down further, but if I do, this also increases the risk that a fix may not work on the actual example.

@DavidCarlisle suggested the workaround

\setlength{\textheight}{.8\maxdimen}

This suppresses the blank page, but also suppresses any additional pages.

\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usetikzlibrary{positioning}
\setlength{\oddsidemargin}{-0.6in}
\setlength{\evensidemargin}{-0.10in}
\setlength{\topmargin}{-0.5in}
\setlength{\headsep}{0.0in}
\pagenumbering{gobble}
\begin{document}

\tikzset{
every node/.style={rectangle,draw,minimum height=3em,text width=2.0cm},
female/.style = {fill=red!20, rounded corners},
male/.style = {fill=blue!20},
neutral/.style = {fill=green!20}
}
\begin{tikzpicture}[node distance=8pt and 33pt]

% GEN 1

\node[female] (Female1) {Female1};
\node[male,below=of Female1] (Male1) {Male1};

% GEN 2

 \node[female,above right=of Female1, yshift=5cm] (Female2) {Female2};
 \node[female,below=of Female2, yshift=-2cm] (Female3) {Female3};
 \node[male,below=of Female3, yshift=-2cm] (Male2) {Male2};
 \node[male,below=of Male2, yshift=-2cm] (Male3) {Male3};
 \node[female,below=of Male3, yshift=-4cm] (Female5) {Female5};

 % % GEN 2 SPOUSES

 \node[male,above=of Female2] (Male4) {Male4};
 \node[male,above=of Female3] (Male5) {Male5};
 \node[male,above=of Male2] (Male2-wife) {Wife};
 \node[female,above=of Male3] (Female6) {Female6};
 \node[male,below=of Female5] (Male6) {Male6};

% GEN 3

 \node[female,above right=of Female2, yshift=4cm] (Female7) {Female7};
 \node[male,below=of Female7, yshift=-1.5cm] (Male7) {Male7};
 \node[female,below=of Male7, yshift=-1cm] (Female8) {Female8};
 \node[male,below=of Female8, yshift=-1cm] (Male8) {Male8};
 \node[male,right=of Female3] (Female9) {Female9};

 \node[female,above right=of Male3, yshift=4cm] (Female10) {Female10};
 \node[female,below=of Female10, yshift=-3cm] (Female11) {Female11};
 \node[male,below=of Female11, yshift=-1.5cm] (Male9) {Male9};
 \node[male,below=of Male9, yshift=-0.5cm] (Male10) {Male10};

 \node[male,right=of Male6] (Male11) {Male11};

 % GEN 3 SPOUSES

 \node[male,above=of Female7] (Male12) {Male12};
 \node[male,below=of Female7] (Female7-husband) {husband};
 \node[male,below=of Female10] (Male13) {Male13};
 \node[male,above=of Female11] (Male14) {Male14};
 \node[male,below=of Female11] (Male15) {Male15};
 \node[female,below=of Male10] (Female12) {Female12};

% GEN 4

 \node[female,right=of Male12] (Female7-daughter1) {daughter};
 \node[female,below=of Female7-daughter1] (Female7-daughter2) {daughter};
 \node[male,right=of Female9, yshift=0.5cm] (Male16) {Male16};
 \node[male,right=of Female10, yshift=0.5cm] (Male17) {Male17};
 \node[female,below=of Male17] (Female18) {Female18};
 \node[male,right=of Male14, yshift=1cm] (Male18) {Male18};
 \node[female,right=of Female11, yshift=0.1cm] (Female19) {Female19};
 \node[male,right=of Male15] (Male19) {Male19};
 \node[female,right=of Male10, yshift=0.5cm] (Female20) {Female20};
 \node[male,below=of Female20] (Male20) {Male20};

 % GEN 5

 \node[male,right=of Male20, yshift=1cm] (Male20-son1) {son};
 \node[male,below=of Male20-son1] (Male20-son2) {son};
 \node[male,below=of Male20-son2] (Male20-son3) {son};
 \node[female,below=of Male20-son3] (Male20-daughter1) {daughter};

\end{tikzpicture}
\end{document}

UPDATE:

Thanks to Harish and Gonzalo for the solutions. They both work, and it was difficult to pick one, but I liked the simplicity of \usepackage[a4paper,margin=1in]{geometry}, so I'm currently using that.

share|improve this question
    
Your problem is Overfull \vbox (147.53874pt too high) has occurred while \output is active... –  Paul Gaborit Feb 9 at 15:06
    
@PaulGaborit Ok, and what I am doing that is causing that? –  Faheem Mitha Feb 9 at 15:08

2 Answers 2

up vote 3 down vote accepted

Your tikzpicture is too big to fit in the page vertically. LaTeX tries its best to fit it in the first page and throws the error:

Overfull \vbox (147.53874pt too high) has occurred while \output is active

Being unsuccessful, it pushes the picture to the second page leaving first one empty.

What to do? Make the first page bit bigger using geometry:

\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usetikzlibrary{positioning}
%\setlength{\oddsidemargin}{-0.6in}
%\setlength{\evensidemargin}{-0.10in}
%\setlength{\topmargin}{-0.5in}
%\setlength{\headsep}{0.0in}
\pagenumbering{gobble}
\usepackage[a4paper,margin=1in]{geometry}    %%% this line added.
\begin{document}    
\tikzset{
every node/.style={rectangle,draw,minimum height=3em,text width=2.0cm},
female/.style = {fill=red!20, rounded corners},
male/.style = {fill=blue!20},
neutral/.style = {fill=green!20}
}
\noindent
\begin{tikzpicture}[node distance=8pt and 33pt]
% GEN 1
\node[female] (Female1) {Female1};
\node[male,below=of Female1] (Male1) {Male1};
% GEN 2
 \node[female,above right=of Female1, yshift=5cm] (Female2) {Female2};
 \node[female,below=of Female2, yshift=-2cm] (Female3) {Female3};
 \node[male,below=of Female3, yshift=-2cm] (Male2) {Male2};
 \node[male,below=of Male2, yshift=-2cm] (Male3) {Male3};
 \node[female,below=of Male3, yshift=-4cm] (Female5) {Female5};
 % % GEN 2 SPOUSES
 \node[male,above=of Female2] (Male4) {Male4};
 \node[male,above=of Female3] (Male5) {Male5};
 \node[male,above=of Male2] (Male2-wife) {Wife};
 \node[female,above=of Male3] (Female6) {Female6};
 \node[male,below=of Female5] (Male6) {Male6};
% GEN 3
 \node[female,above right=of Female2, yshift=4cm] (Female7) {Female7};
 \node[male,below=of Female7, yshift=-1.5cm] (Male7) {Male7};
 \node[female,below=of Male7, yshift=-1cm] (Female8) {Female8};
 \node[male,below=of Female8, yshift=-1cm] (Male8) {Male8};
 \node[male,right=of Female3] (Female9) {Female9};
 \node[female,above right=of Male3, yshift=4cm] (Female10) {Female10};
 \node[female,below=of Female10, yshift=-3cm] (Female11) {Female11};
 \node[male,below=of Female11, yshift=-1.5cm] (Male9) {Male9};
 \node[male,below=of Male9, yshift=-0.5cm] (Male10) {Male10};
 \node[male,right=of Male6] (Male11) {Male11};
 % GEN 3 SPOUSES
 \node[male,above=of Female7] (Male12) {Male12};
 \node[male,below=of Female7] (Female7-husband) {husband};
 \node[male,below=of Female10] (Male13) {Male13};
 \node[male,above=of Female11] (Male14) {Male14};
 \node[male,below=of Female11] (Male15) {Male15};
 \node[female,below=of Male10] (Female12) {Female12};
% GEN 4
 \node[female,right=of Male12] (Female7-daughter1) {daughter};
 \node[female,below=of Female7-daughter1] (Female7-daughter2) {daughter};
 \node[male,right=of Female9, yshift=0.5cm] (Male16) {Male16};
 \node[male,right=of Female10, yshift=0.5cm] (Male17) {Male17};
 \node[female,below=of Male17] (Female18) {Female18};
 \node[male,right=of Male14, yshift=1cm] (Male18) {Male18};
 \node[female,right=of Female11, yshift=0.1cm] (Female19) {Female19};
 \node[male,right=of Male15] (Male19) {Male19};
 \node[female,right=of Male10, yshift=0.5cm] (Female20) {Female20};
 \node[male,below=of Female20] (Male20) {Male20};
\end{tikzpicture}
\end{document}

enter image description here

The options [a4paper,margin=1in] provide a bigger paper than the default. Hence the picture fits in.

Or you can use standalone class directly to get the picture.

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning}
\tikzset{
every node/.style={rectangle,draw,minimum height=3em,text width=2.0cm},
female/.style = {fill=red!20, rounded corners},
male/.style = {fill=blue!20},
neutral/.style = {fill=green!20}
}
\begin{document}
\begin{tikzpicture}[node distance=8pt and 33pt]
% GEN 1
\node[female] (Female1) {Female1};
\node[male,below=of Female1] (Male1) {Male1};
% GEN 2
 \node[female,above right=of Female1, yshift=5cm] (Female2) {Female2};
 \node[female,below=of Female2, yshift=-2cm] (Female3) {Female3};
 \node[male,below=of Female3, yshift=-2cm] (Male2) {Male2};
 \node[male,below=of Male2, yshift=-2cm] (Male3) {Male3};
 \node[female,below=of Male3, yshift=-4cm] (Female5) {Female5};
 % % GEN 2 SPOUSES
 \node[male,above=of Female2] (Male4) {Male4};
 \node[male,above=of Female3] (Male5) {Male5};
 \node[male,above=of Male2] (Male2-wife) {Wife};
 \node[female,above=of Male3] (Female6) {Female6};
 \node[male,below=of Female5] (Male6) {Male6};
% GEN 3
 \node[female,above right=of Female2, yshift=4cm] (Female7) {Female7};
 \node[male,below=of Female7, yshift=-1.5cm] (Male7) {Male7};
 \node[female,below=of Male7, yshift=-1cm] (Female8) {Female8};
 \node[male,below=of Female8, yshift=-1cm] (Male8) {Male8};
 \node[male,right=of Female3] (Female9) {Female9};
 \node[female,above right=of Male3, yshift=4cm] (Female10) {Female10};
 \node[female,below=of Female10, yshift=-3cm] (Female11) {Female11};
 \node[male,below=of Female11, yshift=-1.5cm] (Male9) {Male9};
 \node[male,below=of Male9, yshift=-0.5cm] (Male10) {Male10};
 \node[male,right=of Male6] (Male11) {Male11};
 % GEN 3 SPOUSES
 \node[male,above=of Female7] (Male12) {Male12};
 \node[male,below=of Female7] (Female7-husband) {husband};
 \node[male,below=of Female10] (Male13) {Male13};
 \node[male,above=of Female11] (Male14) {Male14};
 \node[male,below=of Female11] (Male15) {Male15};
 \node[female,below=of Male10] (Female12) {Female12};
% GEN 4
 \node[female,right=of Male12] (Female7-daughter1) {daughter};
 \node[female,below=of Female7-daughter1] (Female7-daughter2) {daughter};
 \node[male,right=of Female9, yshift=0.5cm] (Male16) {Male16};
 \node[male,right=of Female10, yshift=0.5cm] (Male17) {Male17};
 \node[female,below=of Male17] (Female18) {Female18};
 \node[male,right=of Male14, yshift=1cm] (Male18) {Male18};
 \node[female,right=of Female11, yshift=0.1cm] (Female19) {Female19};
 \node[male,right=of Male15] (Male19) {Male19};
 \node[female,right=of Male10, yshift=0.5cm] (Female20) {Female20};
 \node[male,below=of Female20] (Male20) {Male20};
\end{tikzpicture}
\end{document}
share|improve this answer
    
That works, thanks. However, can you elaborate on how this works. I tried adjusting the top margin myself, but that didn't make any difference. By setting \setlength{\topmargin}{-0.5in} and trying different values. From the docs, it looks like \usepackage[a4paper,margin=1in]{geometry} makes all margins 1 in. Is that right? Also, how could I use standalone directly, and would it cut off later pages? –  Faheem Mitha Feb 9 at 15:34
    
@FaheemMitha a4paper is longer than letterpaper. –  Harish Kumar Feb 9 at 16:17
    
I thought I was using letterpaper. –  Faheem Mitha Feb 9 at 16:23
    
Something I don't understand: You wrote "LaTeX tries its best to fit it in the first page and throws the error:" [snip] "Being unsuccessful, it pushes the picture to the second page leaving first one empty." But I don't see why the second page is a better fit than the first page. By this logic, shouldn't it keep pushing the figure forward ad-infinitum? –  Faheem Mitha Feb 9 at 16:43
    
@FaheemMitha It won't push infinitely but the next page with lot of mis-alignments. –  Harish Kumar Feb 9 at 16:47

Besides the vertical problem, there's also an overful \hbox since the figure is too wide and you forgot tu suppress indentation with a \noindent. You can also solve these problems, without using additional packages by hiding the width, height and depth of the figure using \raisebox and \makebox:

\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usetikzlibrary{positioning}
\setlength{\oddsidemargin}{-0.6in}
\setlength{\evensidemargin}{-0.10in}
\setlength{\topmargin}{-0.5in}
\setlength{\headsep}{0.0in}
\pagenumbering{gobble}
\begin{document}

\tikzset{
every node/.style={rectangle,draw,minimum height=3em,text width=2.0cm},
female/.style = {fill=red!20, rounded corners},
male/.style = {fill=blue!20},
neutral/.style = {fill=green!20}
}

\noindent\raisebox{-\height}[0pt][0pt]{%
  \makebox[\linewidth][l]{%
\begin{tikzpicture}[node distance=8pt and 33pt]

% GEN 1

\node[female] (Female1) {Female1};
\node[male,below=of Female1] (Male1) {Male1};

% GEN 2

 \node[female,above right=of Female1, yshift=5cm] (Female2) {Female2};
 \node[female,below=of Female2, yshift=-2cm] (Female3) {Female3};
 \node[male,below=of Female3, yshift=-2cm] (Male2) {Male2};
 \node[male,below=of Male2, yshift=-2cm] (Male3) {Male3};
 \node[female,below=of Male3, yshift=-4cm] (Female5) {Female5};

 % % GEN 2 SPOUSES

 \node[male,above=of Female2] (Male4) {Male4};
 \node[male,above=of Female3] (Male5) {Male5};
 \node[male,above=of Male2] (Male2-wife) {Wife};
 \node[female,above=of Male3] (Female6) {Female6};
 \node[male,below=of Female5] (Male6) {Male6};

% GEN 3

 \node[female,above right=of Female2, yshift=4cm] (Female7) {Female7};
 \node[male,below=of Female7, yshift=-1.5cm] (Male7) {Male7};
 \node[female,below=of Male7, yshift=-1cm] (Female8) {Female8};
 \node[male,below=of Female8, yshift=-1cm] (Male8) {Male8};
 \node[male,right=of Female3] (Female9) {Female9};

 \node[female,above right=of Male3, yshift=4cm] (Female10) {Female10};
 \node[female,below=of Female10, yshift=-3cm] (Female11) {Female11};
 \node[male,below=of Female11, yshift=-1.5cm] (Male9) {Male9};
 \node[male,below=of Male9, yshift=-0.5cm] (Male10) {Male10};

 \node[male,right=of Male6] (Male11) {Male11};

 % GEN 3 SPOUSES

 \node[male,above=of Female7] (Male12) {Male12};
 \node[male,below=of Female7] (Female7-husband) {husband};
 \node[male,below=of Female10] (Male13) {Male13};
 \node[male,above=of Female11] (Male14) {Male14};
 \node[male,below=of Female11] (Male15) {Male15};
 \node[female,below=of Male10] (Female12) {Female12};

% GEN 4

 \node[female,right=of Male12] (Female7-daughter1) {daughter};
 \node[female,below=of Female7-daughter1] (Female7-daughter2) {daughter};
 \node[male,right=of Female9, yshift=0.5cm] (Male16) {Male16};
 \node[male,right=of Female10, yshift=0.5cm] (Male17) {Male17};
 \node[female,below=of Male17] (Female18) {Female18};
 \node[male,right=of Male14, yshift=1cm] (Male18) {Male18};
 \node[female,right=of Female11, yshift=0.1cm] (Female19) {Female19};
 \node[male,right=of Male15] (Male19) {Male19};
 \node[female,right=of Male10, yshift=0.5cm] (Female20) {Female20};
 \node[male,below=of Female20] (Male20) {Male20};

 % GEN 5

 \node[male,right=of Male20, yshift=1cm] (Male20-son1) {son};
 \node[male,below=of Male20-son1] (Male20-son2) {son};
 \node[male,below=of Male20-son2] (Male20-son3) {son};
 \node[female,below=of Male20-son3] (Male20-daughter1) {daughter};

\end{tikzpicture}%
  }%
}

\clearpage
\end{document}

enter image description here

share|improve this answer
    
Thanks for the answer, Gonzalo. Minor typo: \noindet should be \noindent. I tried your modification on the figure, but the text following the figure (on another page) was then superimposed on the figure, with everything on one page. Should I add some text after my example? –  Faheem Mitha Feb 9 at 15:55
    
@FaheemMitha add a \clearpage command; I've added it to my updated answer. –  Gonzalo Medina Feb 9 at 15:56
    
Apologies for the nuisance, but I modified my original figure too much, as I figured. My original figure gets pushed off to the left. I've added something to my figure to show the problem. –  Faheem Mitha Feb 9 at 16:22
    
@FaheemMitha no need to apologize! :) Please see my updated answer. (change c to l in the specification for \makebox.) –  Gonzalo Medina Feb 9 at 16:34
    
That looks good, thanks. Can you elaborate on what "hiding the width, height and depth of the figure" means? Also, another minor typo - "tu" instead of "to". –  Faheem Mitha Feb 9 at 16:37

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.