使用 tikz 树的数字系统插图

使用 tikz 树的数字系统插图

我想为像这样的数字系统创建一个插图

在此处输入图片描述

这是我的 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} 

说到“自然”,我就失去了踪迹。

已编辑:使用以下代码,叶子重叠

\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}

答案1

如果我正确理解了你的问题,一致的缩进应该使嵌套分区的逻辑关系变得简单。

\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 Numbers\footnotemark[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} 

树状图

我忍不住对树上的一些节点进行了一番修改。(尽管如此,我还是没有在“Even”和“Odd”之前写上“Positive”,因为这样会破坏布局。)

相关内容