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 finally managed to make a genealogy tree with Tikz, but there are some spaces that I can't figure out how to increase between nodes:

\documentclass[a4paper,12pt,DIV=calc,headings=small{scrreprt}%,chapterprefix=true,numbers=noenddot
\usepackage{scrpage2}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Numbers=OldStyle]{Minion Pro}
\setsansfont[Numbers=OldStyle, Ligatures=Rare]{Minion Pro}
\setmonofont[Scale=MatchLowercase]{Consolas}
\usepackage{polyglossia}
\setmainlanguage{brazil}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{mindmap,shadows,trees}



\begin{document}


\begin{tikzpicture}[draw, every node/.style={fill=Green, rectangle, rounded     corners},sibling distance=4cm,
level 6/.style={sibling distance=6cm}
]
\node {Maomé}
child {node (fatima) {Fátima}}
child {node (ali) {1. Ali} edge from parent [draw=none]
child {node {2. Hasan}}
child {node {3. Husayn} 
child {node {4. Ali Zaynu'l-Abidin}
child {node {Zayd} child {node [fill=green!30]{Zayditas}}}
child {node {5. Muhammad al-Baqir}
child {node {6. Jaafar al-Sadiq}
child {node {7. Ismail} child {node [fill=green!30] {Califado Ismaelita Fatímida do Egito}} child {node [fill=green!30]{Xiitas Ismaelitas}}}
child {node {7. Musa al-Kazim}
child {node {8. Ali al-Rida}
child {node {9. Muhammad al-Taqi}
child {node {10. Ali al-Hadi}
child {node {11. Hasan al-Askari}
child {node {12. Imam Mahdi}
child {node [fill=green!30] {Xiitas Duodecimais}}
}}}}}}}}}}};

\draw (fatima) -- (ali);
\end{tikzpicture}




\end{document}

Which looks like this:

enter image description here

I've tried, but I can't increase space between 7-8. Is there any way I can get a more even space between those nodes?

share|improve this question

3 Answers 3

up vote 7 down vote accepted

You can supply level distance=<larger value> to the child that starts the eighth level. This will influence all levels that follow, so you will need to reset it using level distance=<old value> for the next child.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees}

\begin{document}
\begin{tikzpicture}[
    draw,
    every node/.style={
        fill=green!70!black,
         rectangle,
        rounded corners
    },
    sibling distance=4cm,
    level distance=12mm,
    level 6/.style={
        sibling distance=6cm
    }
]
\node {Maomé}
child {node (fatima) {Fátima}}
child {node (ali) {1. Ali} edge from parent [draw=none]
child {node {2. Hasan}}
child {node {3. Husayn} 
child {node {4. Ali Zaynu'l-Abidin}
child {node {Zayd} child {node [fill=green!30]{Zayditas}}}
child {node {5. Muhammad al-Baqir}
child {node {6. Jaafar al-Sadiq}
child {node {7. Ismail} child {node [fill=green!30] {Califado Ismaelita Fatímida do Egito}} child {node [fill=green!30]{Xiitas Ismaelitas}}}
child {node {7. Musa al-Kazim}
child [level distance=24mm] {node {8. Ali al-Rida}
child [level distance=12mm] {node {9. Muhammad al-Taqi}
child {node {10. Ali al-Hadi}
child {node {11. Hasan al-Askari}
child {node {12. Imam Mahdi}
child {node [fill=green!30] {Xiitas Duodecimais}}
}}}}}}}}}}};

\draw (fatima) -- (ali);
\end{tikzpicture}


\end{document}
share|improve this answer

My answer is no direct answer to your question, but tries to provide a different approach to draw your tree. Here, this genealogy tree is made with the genealogytree package. The main differences to the original TikZ tree are that you can have more than one parent (usally two per family) and that the nodes are placed by an auto-layout algorithm which should give a nicer spacing.

enter image description here

\documentclass[a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{geometry}
\usepackage[all]{genealogytree}

\begin{document}

\begin{genealogypicture}[processing=tcbox*,
  level size=5mm,
  node size from=5mm to 50mm,
  child distance=8mm,parent distance=8mm,further distance=8mm,
  box={size=fbox,boxrule=0pt,frame hidden,colback=Green,arc=3pt},
  edges={rounded=1mm,foreground={black,line width=0.3mm},background={white,line width=0.8mm}},
]
child{ g{Maomé}
  child{ g{Fátima} p{1. Ali} c{2. Hasan}
    child{ g{3. Husayn}
      child{ g{4. Ali Zaynu'l-Abidin}
        child{ g{Zayd} c[box={colback=green!30}]{Zayditas}
        }
        child{ g{5. Muhammad al-Baqir}
          child{ g{6. Jaafar al-Sadiq}
            child{ g{7. Ismail}
              c[box={colback=green!30}]{Califado Ismaelita Fatímida do Egito}
              c[box={colback=green!30}]{Xiitas Ismaelitas}
            }
            child{ g{7. Musa al-Kazim}
              child{ g{8. Ali al-Rida}
                child{ g{9. Muhammad al-Taqi}
                  child{ g{10. Ali al-Hadi}
                    child{ g{11. Hasan al-Askari}
                      child{ g{12. Imam Mahdi}
                        c[box={colback=green!30}]{Xiitas Duodecimais}
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
\end{genealogypicture}

\end{document}

For completeness: changing the level distance would be possible, but would affect all nodes of a level to keep the auto-layout algorithm working. Therefore, if there should be a generation jump between 7 and 8, you could insert an invisible linking node by

child{ g[phantom*,box={height=0mm}]{} ... }

which gives:

enter image description here

Full code:

\documentclass[a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{geometry}
\usepackage[all]{genealogytree}

\begin{document}

\begin{genealogypicture}[processing=tcbox*,
  level size=5mm,
  node size from=5mm to 50mm,
  child distance=8mm,parent distance=8mm,further distance=8mm,
  box={size=fbox,boxrule=0pt,frame hidden,colback=Green,arc=3pt},
  edges={rounded=1mm,foreground={black,line width=0.3mm},background={white,line width=0.8mm}},
]
child{ g{Maomé}
  child{ g{Fátima} p{1. Ali} c{2. Hasan}
    child{ g{3. Husayn}
      child{ g{4. Ali Zaynu'l-Abidin}
        child{ g{Zayd} c[box={colback=green!30}]{Zayditas}
        }
        child{ g{5. Muhammad al-Baqir}
          child{ g{6. Jaafar al-Sadiq}
            child{ g{7. Ismail}
              c[box={colback=green!30}]{Califado Ismaelita Fatímida do Egito}
              c[box={colback=green!30}]{Xiitas Ismaelitas}
            }
            child{ g{7. Musa al-Kazim}
              child{ g[phantom*,box={height=0mm}]{} child{ g{8. Ali al-Rida}
                child{ g{9. Muhammad al-Taqi}
                  child{ g{10. Ali al-Hadi}
                    child{ g{11. Hasan al-Askari}
                      child{ g{12. Imam Mahdi}
                        c[box={colback=green!30}]{Xiitas Duodecimais}
}}}}}}}}}}}}}
\end{genealogypicture}

\end{document}
share|improve this answer

A solution using the power of forest. This demonstrates how to use fit=band to get some separation between subtrees (separating the nodes at 7/8) and how to use tikz to draw the connection between siblings.

Two styles are defined to manage the numbering:

  • next increments the number and numbers the node
  • again numbers the node without increasing the number

The pale green style is used for the paler nodes.

forest family

\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass[tikz,12pt,border=5pt]{standalone}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
% use default fonts as I don't have proper Minion except for (pdf)TeX
\usepackage{polyglossia}
\setmainlanguage{brazil}
\usetikzlibrary{shadows,trees}
\usepackage{forest}

\begin{document}
\newcounter{mycount}
\begin{forest}
  pale green/.style={fill=green!30},
  next/.style={
    before typesetting nodes={
      TeX/.wrap pgfmath arg={\stepcounter{mycount}\def\mycounted{\themycount. ##1}}{content()},
      content/.expanded={\mycounted},
    }
  },
  again/.style={
    before typesetting nodes={
      TeX/.wrap pgfmath arg={\def\mycounted{\themycount. ##1}}{content()},
      content/.expanded={\mycounted},
    }
  },
  for tree={
    fill=Green,
    draw,
    rounded corners,
    drop shadow,
    edge=thick,
  }
  [Maomé
    [Fátima, tikz={\draw [thick] () -- (!n);}]
    [Ali, no edge, next
      [Hasan, next]
      [Husayn, next
        [Ali Zaynu'l-Abidin, next
          [Zayd
            [Zayditas, pale green]]
          [Muhammad al-Baqir, next
            [Jaafar al-Sadiq, next, for children={fit=band}
            [Ismail node, for children={pale green}, next
              [Califado Ismaelita Fatímida do Egito]
              [Xiitas Ismaelitas]
            ]
            [Musa al-Kazim, again
              [Ali al-Rida, next
                [Muhammad al-Taqi, next
                  [Ali al-Hadi, next
                    [Hasan al-Askari, next
                      [Imam Mahdi, next
                        [Xiitas Duodecimais, pale green]
  ]]]]]]]]]]]]
\end{forest}
\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.