3

enter image description here
I just started working with latex last week, and there are some things I would like to improve on this Hasse diagram. I am trying to do two things correctly.

  1. That the image is shifted more to the left side and a little more upward so that it can be seen completely.

  2. That the edges do not touch any other node, but the only two which I intend to connect. It looks very messy the way it appears.

I have not finished the diagram, since when noticing these problems,did not want to continue. I am very grateful for any help I can get.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pdflscape}
\begin{document}
\thispagestyle{empty}
\begin{landscape}
\begin{tikzpicture}[every node/.style={circle,draw=black}]
\node(tre1)[circle,draw,scale=0.5]{
\begin{tikzpicture}
\node(tree1){1}
 child{node{2}}
 child{node{3}}
 child{node{4}};
\end{tikzpicture}
};
\node(tre2)[circle,draw,scale=0.5] [right of=tre1,xshift=6.2cm]{
\begin{tikzpicture}
\node(tree2){1}
 child{node{2}
 child{node{4}}}
 child{node{3}};
\end{tikzpicture}
};
\node(tre3)[circle,draw,scale=0.5][right of=tre2,xshift=6.2cm] {
\begin{tikzpicture}
\node(tree3){1}
 child{node{3}
 child{node{4}}}
 child{node{2}};
\end{tikzpicture}
};
\node(tre4)[circle,draw,scale=0.5][right of=tre3,xshift=6.2cm] {
\begin{tikzpicture}
\node(tree4){1}
 child{node{2}
 child{node{3}}}
 child{node{4}};
\end{tikzpicture}
};
\node(tre5)[circle,draw,scale=0.4][right of=tre4,xshift=7.3cm] {
\begin{tikzpicture}
\node(tree5){1}
 child{node{2}
 child{node{3}
 child{node{4}}}};
\end{tikzpicture}
};
\node(tre6)[circle,draw,scale=0.5][right of=tre5,xshift=5.7cm] {
\begin{tikzpicture}
\node(tree6){1}
 child{node{2}
 child{node{3}}
 child{node{4}}};
\end{tikzpicture}
};
\node at ($(tre1) + (-3.5,-4.5)$)[circle,draw,scale=0.65](tr1){
\begin{tikzpicture}
\node{1}
 child{node{2}}
 child{node{3}};
 \node[xshift=1cm]{4};
\end{tikzpicture}
};
\node(tr2)[circle,draw,scale=0.65][right of=tr1,xshift=2.8cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{2}}
 child{node{4}};
 \node[right of=one]{3};
\end{tikzpicture}
};
\node(tr3)[circle,draw,scale=0.75][right of=tr2,xshift=2.25cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{2}};
 \node[right of=one]{3}
      child{node{4}};
\end{tikzpicture}
};
\node(tr4)[circle,draw,scale=0.65][right of=tr3,xshift=2.8cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{3}}
 child{node{4}};
 \node[right of=one]{2};
\end{tikzpicture}
};
\node(tr5)[circle,draw,scale=0.75][right of=tr4,xshift=2.25cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{3}};
 \node[right of=one]{2}
      child{node{4}};
\end{tikzpicture}
};          
\node(tr6)[circle,draw,scale=0.75][right of=tr5,xshift=2.25cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{4}};
 \node[right of=one]{2}
      child{node{3}};
\end{tikzpicture}
};   
\node(tr7)[circle,draw,scale=0.5][right of=tr6,xshift=3.8cm]{
\begin{tikzpicture}
\node{1}
 child{node(two){2}
 child{node{3}}};
 \node[right of=two]{4};
\end{tikzpicture}
};   
\node(tr8)[circle,draw,scale=0.65][right of=tr7,xshift=2.8cm]{
\begin{tikzpicture}
\node(two){2}
 child{node(three){3}}
 child{node{4}};
 \node[right of=two]{4};
\end{tikzpicture}
};      
\node(tr9)[circle,draw,scale=0.5][right of=tr8,xshift=3.8cm]{
\begin{tikzpicture}
\node{1}
 child{node(two){2}
 child{node{4}}};
 \node[right of=two]{3};
\end{tikzpicture}
};      
\node(tr10)[circle,draw,scale=0.5][right of=tr9,xshift=3.8cm]{
\begin{tikzpicture}
\node{1}
 child{node(three){3}
 child{node{4}}};
 \node[right of=three]{2};
\end{tikzpicture}
};       
\node(tr11)[circle,draw,scale=0.5][right of=tr10,xshift=3.8cm]{
\begin{tikzpicture}
\node{2}
 child{node(three){3}
 child{node{4}}};
 \node[left of=three]{1};
\end{tikzpicture}
};     
\node at ($(tre1) + (0,-9)$)[circle,draw,scale=0.75](t1){
\begin{tikzpicture}
\node(one){1}
 child{node(two){2}};
 \node[right of=one]{3};
 \node[right of=two]{4};
\end{tikzpicture}
}; 
\node at ($(tre2) + (0,-9)$)[circle,draw,scale=0.75](t2){
\begin{tikzpicture}
\node(one){1}
 child{node(three){3}};
 \node[right of=one]{2};
 \node[right of=three]{4};
\end{tikzpicture}
};      
\node at ($(tre3) + (0,-9)$)[circle,draw,scale=0.75](t3){
\begin{tikzpicture}
\node(one){1}
 child{node(four){4}};
 \node[right of=one]{2};
 \node[right of=four]{3};
\end{tikzpicture}
};        
\node at ($(tre4) + (0,-9)$)[circle,draw,scale=0.75](t4){
\begin{tikzpicture}
\node(two){2}
 child{node(three){3}};
 \node[left of=two]{1};
 \node[left of=three]{4};
\end{tikzpicture}
};      
\node at ($(tre5) + (0,-9)$)[circle,draw,scale=0.75](t5){
\begin{tikzpicture}
\node(two){2}
 child{node(four){4}};
 \node[left of=two]{1};
 \node[left of=four]{3};
\end{tikzpicture}
};        
\node at ($(tre6) + (0,-9)$)[circle,draw,scale=0.75](t6){
\begin{tikzpicture}
\node(three){3}
 child{node(four){4}};
 \node[left of=three]{1};
 \node[left of=four]{2};
\end{tikzpicture}
};
\node at ($(tre3) + (2,-13.5)$)(root)[circle,draw,scale=0.9]{
\begin{tikzpicture}  
\node(one){1};
\node[below of=one](two){2};
\node[right of=one]{3};
\node[right of=two]{4};
\end{tikzpicture}
};   
\path[thick](tre1)edge(tr1)
              edge(tr2)
              edge(tr4);
\path[thick](tre2)edge(tr5)
              edge(tr9)
              edge(tr10);      
\path[thick](root)edge(t1)
              edge(t2)
              edge(t3)
              edge(t4)
              edge(t5)
              edge(t6);            
\end{tikzpicture}
\end{landscape}
\end{document}
1
  • 3
    Welcome! Note that nesting tikzpictures is not supported and is expected to yield the unexpected and the undesirable.
    – cfr
    Jul 23 '18 at 23:55
2

The tikz drawing is shifted because it draws in a determinated scale, when you draw it on a text environment, it is not scaled to the \linewidth, you have two options: [1] Using scale=0.75,every node/.append style={transform shape} in the principal tikzpicture environment, that scales all the tikzpicture to fit in the page. [2] Compile your tikz code in standalone document class, then import the pdf output to the main document using \includegraphics[width=\textwidth]{Tikz_drawing_in_standalone_doc_class.pdf} within figure environment, like in those examples: Overlapping nodes in TikZ - Not enough space on paper, How can i rotate circuitkz figure vertical?, Scaling different components of tikzpicture together.

RESULT: enter image description here

MWE:

% arara: pdflatex: {synctex: yes, action: nonstopmode}
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pdflscape}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]
\thispagestyle{empty}
\begin{landscape}
\begin{tikzpicture}[every node/.style={circle,draw=black},scale=0.75,every node/.append style={transform shape}]
\node(tre1)[circle,draw,scale=0.5]{
\begin{tikzpicture}
\node(tree1){1}
 child{node{2}}
 child{node{3}}
 child{node{4}};
\end{tikzpicture}
};
\node(tre2)[circle,draw,scale=0.5] [right of=tre1,xshift=6.2cm]{
\begin{tikzpicture}
\node(tree2){1}
 child{node{2}
 child{node{4}}}
 child{node{3}};
\end{tikzpicture}
};
\node(tre3)[circle,draw,scale=0.5][right of=tre2,xshift=6.2cm] {
\begin{tikzpicture}
\node(tree3){1}
 child{node{3}
 child{node{4}}}
 child{node{2}};
\end{tikzpicture}
};
\node(tre4)[circle,draw,scale=0.5][right of=tre3,xshift=6.2cm] {
\begin{tikzpicture}
\node(tree4){1}
 child{node{2}
 child{node{3}}}
 child{node{4}};
\end{tikzpicture}
};
\node(tre5)[circle,draw,scale=0.4][right of=tre4,xshift=7.3cm] {
\begin{tikzpicture}
\node(tree5){1}
 child{node{2}
 child{node{3}
 child{node{4}}}};
\end{tikzpicture}
};
\node(tre6)[circle,draw,scale=0.5][right of=tre5,xshift=5.7cm] {
\begin{tikzpicture}
\node(tree6){1}
 child{node{2}
 child{node{3}}
 child{node{4}}};
\end{tikzpicture}
};
\node at ($(tre1) + (-3.5,-4.5)$)[circle,draw,scale=0.65](tr1){
\begin{tikzpicture}
\node{1}
 child{node{2}}
 child{node{3}};
 \node[xshift=1cm]{4};
\end{tikzpicture}
};
\node(tr2)[circle,draw,scale=0.65][right of=tr1,xshift=2.8cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{2}}
 child{node{4}};
 \node[right of=one]{3};
\end{tikzpicture}
};
\node(tr3)[circle,draw,scale=0.75][right of=tr2,xshift=2.25cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{2}};
 \node[right of=one]{3}
      child{node{4}};
\end{tikzpicture}
};
\node(tr4)[circle,draw,scale=0.65][right of=tr3,xshift=2.8cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{3}}
 child{node{4}};
 \node[right of=one]{2};
\end{tikzpicture}
};
\node(tr5)[circle,draw,scale=0.75][right of=tr4,xshift=2.25cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{3}};
 \node[right of=one]{2}
      child{node{4}};
\end{tikzpicture}
};          
\node(tr6)[circle,draw,scale=0.75][right of=tr5,xshift=2.25cm]{
\begin{tikzpicture}
\node(one){1}
 child{node{4}};
 \node[right of=one]{2}
      child{node{3}};
\end{tikzpicture}
};   
\node(tr7)[circle,draw,scale=0.5][right of=tr6,xshift=3.8cm]{
\begin{tikzpicture}
\node{1}
 child{node(two){2}
 child{node{3}}};
 \node[right of=two]{4};
\end{tikzpicture}
};   
\node(tr8)[circle,draw,scale=0.65][right of=tr7,xshift=2.8cm]{
\begin{tikzpicture}
\node(two){2}
 child{node(three){3}}
 child{node{4}};
 \node[right of=two]{4};
\end{tikzpicture}
};      
\node(tr9)[circle,draw,scale=0.5][right of=tr8,xshift=3.8cm]{
\begin{tikzpicture}
\node{1}
 child{node(two){2}
 child{node{4}}};
 \node[right of=two]{3};
\end{tikzpicture}
};      
\node(tr10)[circle,draw,scale=0.5][right of=tr9,xshift=3.8cm]{
\begin{tikzpicture}
\node{1}
 child{node(three){3}
 child{node{4}}};
 \node[right of=three]{2};
\end{tikzpicture}
};       
\node(tr11)[circle,draw,scale=0.5][right of=tr10,xshift=3.8cm]{
\begin{tikzpicture}
\node{2}
 child{node(three){3}
 child{node{4}}};
 \node[left of=three]{1};
\end{tikzpicture}
};     
\node at ($(tre1) + (0,-9)$)[circle,draw,scale=0.75](t1){
\begin{tikzpicture}
\node(one){1}
 child{node(two){2}};
 \node[right of=one]{3};
 \node[right of=two]{4};
\end{tikzpicture}
}; 
\node at ($(tre2) + (0,-9)$)[circle,draw,scale=0.75](t2){
\begin{tikzpicture}
\node(one){1}
 child{node(three){3}};
 \node[right of=one]{2};
 \node[right of=three]{4};
\end{tikzpicture}
};      
\node at ($(tre3) + (0,-9)$)[circle,draw,scale=0.75](t3){
\begin{tikzpicture}
\node(one){1}
 child{node(four){4}};
 \node[right of=one]{2};
 \node[right of=four]{3};
\end{tikzpicture}
};        
\node at ($(tre4) + (0,-9)$)[circle,draw,scale=0.75](t4){
\begin{tikzpicture}
\node(two){2}
 child{node(three){3}};
 \node[left of=two]{1};
 \node[left of=three]{4};
\end{tikzpicture}
};      
\node at ($(tre5) + (0,-9)$)[circle,draw,scale=0.75](t5){
\begin{tikzpicture}
\node(two){2}
 child{node(four){4}};
 \node[left of=two]{1};
 \node[left of=four]{3};
\end{tikzpicture}
};        
\node at ($(tre6) + (0,-9)$)[circle,draw,scale=0.75](t6){
\begin{tikzpicture}
\node(three){3}
 child{node(four){4}};
 \node[left of=three]{1};
 \node[left of=four]{2};
\end{tikzpicture}
};
\node at ($(tre3) + (2,-13.5)$)(root)[circle,draw,scale=0.9]{
\begin{tikzpicture}  
\node(one){1};
\node[below of=one](two){2};
\node[right of=one]{3};
\node[right of=two]{4};
\end{tikzpicture}
};   
\path[thick,out=-90,in=90,in looseness=0.4, out looseness=0.3](tre1.south)edge(tr1)
              edge(tr2)
              edge(tr4);
\path[thick,in=90,out=-90,in looseness=0.4, out looseness=0.3](tre2)
        edge(tr5)
              edge(tr9.north)
              edge(tr10.north);      
\path[thick,out=90,in=-90,in looseness=0.4, out looseness=0.3](root)
        edge(t1)
              edge(t2)
              edge(t3)
              edge(t4)
              edge(t5)
              edge(t6);            
\end{tikzpicture}
\end{landscape}
\end{document}
5
  • 1
    I would like to upvote this nice answer but I cannot since you are nesting tikzpictures. Could you please create saveboxes for all the graphs and use them inside the nodes?
    – user121799
    Jul 24 '18 at 5:38
  • Since compiling without reporting errors, do not take the usual time to modify all that code; if as you observe it is a bad practice, it should not remain as a logical imposition, so you should explain why, or where the cases or the theory about it are documented.
    – J Leon V.
    Jul 24 '18 at 6:28
  • 1
    It never produces errors but the options and styles of the ambient node (or tikzpicture) may interfere with the content of the inner tikzpicture. See e.g. this discussion for details. Note that even though in your code things may be fine, anybody trying to use your answer and modifying it may run into problems. And, most importantly, @cfr, who is always right, also made a comment in this direction ;-)
    – user121799
    Jul 24 '18 at 6:36
  • 1
    @marmot Hmmm.... A questionable claim. However, for whatever it is worth, I've provided a solution which avoids nesting. Note that nesting tikzpictures jolly well can cause errors. Try combinations involving forest environments. (This is not precisely the problem you're talking about, but it is pertinent given how many third-party wrappers exist for tikzpicture.)
    – cfr
    Jul 27 '18 at 1:30
  • @cfr +1 for your solution. Ironically, a bit later that day I answered this question....
    – user121799
    Jul 27 '18 at 6:03
4

Here's another option.

  • This one uses Forest (so it is somewhat delayed as I had to code all the bits from scratch). This permits a much more concise syntax for specifying trees, is very powerful and generally excels at producing compact trees. (There are some exceptions but they don't apply here.)

  • It avoids nesting tikzpictures. Not only is nesting them bad in general, it is fatal if Forest is involved i.e. fails with compilation errors. Even if you don't use Forest, you should avoid the nesting.

  • It has some debugging options for helping keep track of what's what. You may not need these, since the contents has meaning for you, but I needed them and I often find things easier even when the content is meaningful for me, so perhaps you will, too. At any rate, I left them in commented as you said you'd not finished the diagram.

  • It uses a matrix of nodes to place the individual Forests in relation to each other and a few \foreach loops to connect them.

The code provides a wrapper for making each forest and saving it in a box.

\makeme[<suffix for box name>]{<nodewalk>}{<tree specification>}

The <suffix for box name> is appended to treebox to create a new box to save the forest in. This argument is optional, but should only be omitted if you don't need to save another tree before typesetting this one.

<nodewalk> has the sense specified in forest's manual.

<tree specification> uses the bracket syntax specified in forest's manual.

append to me, insert after me and insert before me are convenience styles which may be useful in specifying the tree.

One important point to note is that a phantom root will be added to the trees automatically. This means you can add a sibling to your root using insert after me or insert before me and it will work, even though a tree must have a single root and the result will appear not to. (It will have an invisible, phantom root which takes no space in the end.)

\makeme[]{}{} is used as follows to construct the trees required in this case:

\makeme[1]{tree}{[[][][]]}
\makeme[b]{tree}{[, insert after me=!l[][][]]}
\makeme[c]{tree}{[, insert after me=!{n=2}[][][]]}
\makeme[d]{tree}{[, insert after me=!{n=2}[][, append to me=!rL][]]}
\makeme[e]{tree}{[, insert after me=!1[][][]]}
\makeme[2]{tree breadth-first}{[[[]][]]}
\makeme[g]{tree breadth-first}{[, insert after me=!1[[]][]]}
\makeme[a]{tree }{[, insert after me=!1[[]][]]}
\makeme[k]{tree }{[[, insert after me=!L, calign with current[[, no edge]]]]}
\makeme[f]{tree }{[, insert before me=!1[[][]]]}
\makeme[h]{tree breadth-first}{[ [, calign with current []][, no edge]]}
\makeme[j]{tree breadth-first reversed}{[ [, calign with current []][, no edge]]}
\makeme[l]{tree }{[, insert after me=!1, before drawing tree={y/.option=!r21.y}[, no edge[[]]]]}
\makeme[3]{tree breadth-first reversed}{[ [ []][]]}
\makeme[4]{tree }{[[[]][]]}
\makeme[5]{tree }{[[[[]]]]}
\makeme[6]{tree }{[[[][]]]}
\makeme[d1]{tree}{[, insert after me=!{n=2}[][, append to me=!rL][,no edge]]}
\makeme[a2]{tree }{[, insert after me=!1[[, no edge]][]]}
\makeme[g2]{tree breadth-first}{[, insert after me=!1[[, no edge]][]]}
\makeme[g1]{tree breadth-first}{[, insert after me=!1[[]][, no edge]]}
\makeme[a1]{tree }{[, insert after me=!1[[]][, no edge]]}
\makeme[d2]{tree}{[, insert after me=!{n=2}[, no edge][, append to me=!rL][]]}
\makeme[d3]{tree}{for tree=no edge[, insert after me=!{n=2}[][, append to me=!rL][]]}

A second wrapper

\showme{<suffix for box name>}

takes the suffix, adds it to \treebox<suffix> and then typesets the box. It is safe to use this within a tikzpicture (or forest) because the contents is typeset when the box is made and not when the box is shown i.e. no nesting is going on.

The code for the actual diagram is then a matrix of Forests:

\begin{tikzpicture}
  \matrix (m) [matrix of nodes, row sep=75pt, every node/.append style={inner ysep=0pt}]
  {
    &&  \showme{1}  & \showme{2} & \showme{3} & \showme{4} & \showme{5}  &\showme{6} \\
    \showme{b} & \showme{c} & \showme{d} & \showme{e} & \showme{g} & \showme{a} & \showme{k} & \showme{f} & \showme{h} & \showme{j} & \showme{l}\\
    && \showme{d1} & \showme{g1} & \showme{a1} & \showme{a2} & \showme{g2} & \showme{d2}\\
    && & & & \showme{d3}\\
  };
  \begin{scope}[rounded corners=15pt, thick]
    \foreach \i in {1,2,4} \draw (m-1-3.south) -- ++(0,-60pt) -| (m-2-\i);
    \foreach \i in {5,9,10} \draw (m-1-4.south) -- ++(0,-50pt) -| (m-2-\i);
    \foreach \i in {3,...,8} \draw (m-4-6.north) -- ++(0,50pt) -| (m-3-\i);
  \end{scope}
\end{tikzpicture}

matrix of Forests

Which is, I think, relatively succinct and, I hope, fairly customisable.

\documentclass[border=10pt]{standalone} 
\usepackage{forest}
\usetikzlibrary{matrix}
\forestset{
  declare boolean register={debug me},
  no debug me,
  declare toks register={name me},
  name me=,
  count walk/.style={
    for tree={circle, l'=0pt,  draw, inner sep=1pt, font=\sffamily\bfseries},
    delay={
      tempcounta'=0,
      for nodewalk={#1}{tempcounta'+=1, content/.register=tempcounta},
    },
    before typesetting nodes={
      replace by={[, phantom, append, tikz+={\node [circle, draw, fit to=descendants, minimum size=95pt, inner sep=1pt] {};},]},
    },
    before drawing tree={
      debug me toggle,
      if debug me={
        tikz+={\node [font=\Large\sffamily\bfseries, color=blue, opacity=.25] at (current bounding box.center) {\foresteregister{name me}};}
      }{},
    },
  },
  debug me toggle/.style={
    if debug me={TeX={\gdef\debugmakeme##1{\expandafter\usebox\csname treebox##1\endcsname}}}{TeX={\gdef\debugmakeme##1{\relax}}},
  },
  append to me/.style={before packing={append=#1}},
  insert after me/.style={before packing={insert after=#1}},
  insert before me/.style={before packing={insert before=#1}},
%   debug me,% uncomment this to switch on debug mode, which will show the names of the boxes and, optionally, print a complete list as they are created (see below what to uncomment for this option)
}
\newsavebox\treebox
\newcommand\debugmakeme{}%
\newcommand*\makeme[3][]{%
  \edef\tempa{#1}\edef\tempb{}%
  \ifx\tempa\tempb\else\expandafter\newsavebox\csname treebox#1\endcsname\fi
  \expandafter\sbox\csname treebox#1\endcsname{%
    \begin{forest}
      count walk=#2,
      name me=treebox#1,
      #3
    \end{forest}%
  }%
%   \debugmakeme{#1}% uncomment this to typeset the box immediately when in debug mode
}
\newcommand*\showme[1]{\expandafter\usebox\csname treebox#1\endcsname}
\makeme[1]{tree}{[[][][]]}
\makeme[b]{tree}{[, insert after me=!l[][][]]}
\makeme[c]{tree}{[, insert after me=!{n=2}[][][]]}
\makeme[d]{tree}{[, insert after me=!{n=2}[][, append to me=!rL][]]}
\makeme[e]{tree}{[, insert after me=!1[][][]]}
\makeme[2]{tree breadth-first}{[[[]][]]}
\makeme[g]{tree breadth-first}{[, insert after me=!1[[]][]]}
\makeme[a]{tree }{[, insert after me=!1[[]][]]}
\makeme[k]{tree }{[[, insert after me=!L, calign with current[[, no edge]]]]}
\makeme[f]{tree }{[, insert before me=!1[[][]]]}
\makeme[h]{tree breadth-first}{[ [, calign with current []][, no edge]]}
\makeme[j]{tree breadth-first reversed}{[ [, calign with current []][, no edge]]}
\makeme[l]{tree }{[, insert after me=!1, before drawing tree={y/.option=!r21.y}[, no edge[[]]]]}
\makeme[3]{tree breadth-first reversed}{[ [ []][]]}
\makeme[4]{tree }{[[[]][]]}
\makeme[5]{tree }{[[[[]]]]}
\makeme[6]{tree }{[[[][]]]}
\makeme[d1]{tree}{[, insert after me=!{n=2}[][, append to me=!rL][,no edge]]}
\makeme[a2]{tree }{[, insert after me=!1[[, no edge]][]]}
\makeme[g2]{tree breadth-first}{[, insert after me=!1[[, no edge]][]]}
\makeme[g1]{tree breadth-first}{[, insert after me=!1[[]][, no edge]]}
\makeme[a1]{tree }{[, insert after me=!1[[]][, no edge]]}
\makeme[d2]{tree}{[, insert after me=!{n=2}[, no edge][, append to me=!rL][]]}
\makeme[d3]{tree}{for tree=no edge[, insert after me=!{n=2}[][, append to me=!rL][]]}
\begin{document}
\begin{tikzpicture}
  \matrix (m) [matrix of nodes, row sep=75pt, every node/.append style={inner ysep=0pt}]
  {
    &&  \showme{1}  & \showme{2} & \showme{3} & \showme{4} & \showme{5}  &\showme{6} \\
    \showme{b} & \showme{c} & \showme{d} & \showme{e} & \showme{g} & \showme{a} & \showme{k} & \showme{f} & \showme{h} & \showme{j} & \showme{l}\\
    && \showme{d1} & \showme{g1} & \showme{a1} & \showme{a2} & \showme{g2} & \showme{d2}\\
    && & & & \showme{d3}\\
  };
  \begin{scope}[rounded corners=15pt, thick]
    \foreach \i in {1,2,4} \draw (m-1-3.south) -- ++(0,-60pt) -| (m-2-\i);
    \foreach \i in {5,9,10} \draw (m-1-4.south) -- ++(0,-50pt) -| (m-2-\i);
    \foreach \i in {3,...,8} \draw (m-4-6.north) -- ++(0,50pt) -| (m-3-\i);
  \end{scope}
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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