TransWikia.com

Illustration for number system using tikz tree

TeX - LaTeX Asked on March 18, 2021

I want to create an illustration for number systems like this one

enter image description here

Here is my MWE.

documentclass[landscape]{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}

usepackage[margin=1in]{geometry}
usepackage{tikz-qtree}
usetikzlibrary{shadows,trees}
begin{document}
tikzset{font=small,
edge from parent fork down,
level distance=1.75cm,
every node/.style=
    {top color=white,
    bottom color=blue!25,
    rectangle,rounded corners,
    minimum height=8mm,
    draw=blue!75,
    very thick,
    drop shadow,
    align=center,
    text depth = 0pt
    },
edge from parent/.style=
    {draw=blue!50,
    thick
    }}

centering
begin{tikzpicture}
Tree [.{Real Numbers}
        [.{Rational $a$}
          [.{Integers}
              [.{Negative Integers} ]
              [.{Whole Numbers} 
                [.Zero ]
                [.{Natural}
                  [.Even
                  [.Odd ]
                ]
            ] ]]
          [.Fraction
            ] 
            ]
        [.{Irrational $a$} 
]
]
]
end{tikzpicture}
end{document} 

After "natural" I lost track.

Edited: Using the following code, the leaves overlap

documentclass[a4paper,10pt]{article}
usepackage{tikz}
usepackage{fullpage}
usetikzlibrary{positioning,shadows,arrows,trees,shapes,fit}
begin{document}
begin{tikzpicture}
[font=small, edge from parent fork down,
every node/.style={top color=white, bottom color=blue!25,
rectangle,rounded corners, minimum size=6mm, draw=blue!75,
very thick, drop shadow, align=center},
edge from parent/.style={draw=blue!50,thick},
level 1/.style={sibling distance=6cm},
level 2/.style={sibling distance=2.5cm},
level 3/.style={sibling distance=2.5cm},
level distance=2cm,
]
node {Real} % root
    child { node {Rational}
        child { node {Int}
        child { node {negative}}
        child { node {whole}
        child { node {zero}}
        child { node {natural} 
        child { node {even}
        child { node {prime}}
        child { node {composit}}
        }
        child { node {odd}
         child { node {1}}
         child { node {prime}}
         child { node {composit}}
        }}
        }}
        child { node {frac}}
        } 
    child { node {irrational}}
;
end{tikzpicture} 
end{document}

One Answer

If I understand your question correctly, consistent indentation should make the logical relationship of the nested partitions straightforward.

documentclass[landscape]{article}
usepackage{libertinus}

usepackage[margin=1in]{geometry}
usepackage{tikz-qtree}
usetikzlibrary{shadows,trees}
begin{document}
tikzset{font=small,
edge from parent fork down,
level distance=1.75cm,
every node/.style=
    {top color=white,
    bottom color=blue!25,
    rectangle,rounded corners,
    minimum height=8mm,
    draw=blue!75,
    very thick,
    drop shadow,
    align=center,
    text depth = 0pt
    },
edge from parent/.style=
    {draw=blue!50,
    thick
    }}

centering
begin{tikzpicture}
Tree [.{Real Numbers}
        [.{Rational Numbers  ( left{ -5, frac{-7}{3}, 0, frac{5}{6} right} )}
          [.{Integers  ( { -50, -1, 0, 1, 2, 17 } )}
            [.{Negative Integers  ( { -1,-2,-96 } )}
            ]
            [.{Natural Numbersfootnotemark[1]  ( { 0, 1, 2, 27 } )}
              [.{Even Numbers}
                [.{(0)}
                ]
                [.{(2)}
                ]
                [.{Even Composites}
                ]
              ]
              [.{Odd Numbers}
                [.{(1)}
                ]
                [.{Odd Primes  ( { 3, 5, 7, 11 } )}
                ]
                [.{Odd Composites  ( { 9, 15, 25, 27 } )}
                ]
              ]
            ]
          ]
          [.{Non-Integers  ( left{ frac{1}{2}, frac{5}{3}, frac{7}{5} right} )}
          ]
        ]
        [ .{Irrational Numbers  ( left{ sqrt{2}, sqrt{3}, pi, right} )}
        ]
      ]
end{tikzpicture}

footnotetext[1]{Not all mathematicians consider (0) a natural number.}
end{document} 

Tree diagram

I could not help myself from pedantically correcting some nodes of the tree. (Even so, I didn’t write “Positive” before “Even” and “Odd”, because it spoils the layout.)

Correct answer by Davislor on March 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP