4

I want to make a vertical tree with brackets like the one bellow.

enter image description here

I tried \overbrace but I can't connect the 2nd row nodes (\Omega_{r} and \Omega_{m}) with the first.

\begin{tabular}{l|c c c}
Total matter&& $\Omega$ &\\
Different equations of state &$\Omega_{m}$&$\Omega_{r}$&$\Omega_{\Lambda}$\\
Difefrent species &$\overbrace{\Omega_{b}\quad\Omega_{c}}^{}$&
 $\overbrace{\Omega_{\gamma}\quad\Omega_{\nu}}^{}$&
\end{tabular}

I get

enter image description here

4 Answers4

3

A solution playing with \raisebox (by trial ans errors!):

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{tabular}{l|c c c}
Total matter & \multicolumn{3}{c}{\enspace\raisebox{-3.3ex}[0pt][2.6ex]{$ \overbrace{\vphantom{-}\hspace{9.5em}}^{\textstyle \Omega}$}}\\
Different equations of state & $\Omega_{m}$&$\Omega_{r}$&$\Omega_{\Lambda}$\\
Different species &$\overbrace{\Omega_{b}\quad\Omega_{c}}^{}$&
 $\overbrace{\Omega_{\gamma}\quad\Omega_{\nu}}^{}$&
\end{tabular}

\end{document} 

enter image description here

Bernard
  • 271,350
3

I am not quite certain if this is feasible via \overbrace. I think \overbrace can only span things contained within the same math environment (at least I have not found any information indicating otherwise; but I have admittedly not had any personal experience with this particular command).

I have tried out an alternative approach, usint TikZ trees. The result looks as follows: code result

The code:

    \documentclass[margin=3mm,tikz]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
    level distance=10mm,
    level 1/.style={sibling distance=30mm},
    level 2/.style={sibling distance=15mm},
    ]
    % The main tree
    \node (omega) {$\Omega$} [draw=white]
        child {
            node (w_m) {$\Omega_{m}$}
            child {node (w_b) {$\Omega_{b}$}}
            child {node (w_c) {$\Omega_{c}$}}
        }
        child {
            node (w_r) {$\Omega_{r}$}
            child {node (w_gamma) {$\Omega_{\gamma}$}}
            child {node (w_nu)    {$\Omega_{\nu}$}}
        }
        child {node (w_lambda) {$\Omega_{\Lambda}$}}
    ;

    \begin{scope}[
        every path/.append style={
            decorate,decoration={brace,raise=2mm}}
        ]
        \draw (w_m.north west)     -- (w_lambda.north east);
        \draw (w_b.north west)     -- (w_c.north east);
        \draw (w_gamma.north west) -- (w_nu.north east);
    \end{scope}

    % Text on left  side is put in a tree  as well, thus
    % ensuring that the vertical spacing is identical to
    % the actual tree.
    \begin{scope}[
        every node/.append style={
            text width=50mm,
            align=left,
            draw=none
            },
            every child/.append style={draw=white},
        ]
        \node[left=50mm of omega] (tot_matter) {Total Matter}
            child {
                node (d_eqs) {Different equations of state}
                child {node (d_species) {Different species}}
            }
            ;
    \end{scope}

    % Vertical separator line
    \draw (tot_matter.north east) -- (d_species.south east);

\end{tikzpicture}
\end{document}

The placement in this example was done by hand, which is of course a bit crude, and could use some further optimization, but you get the idea.

Jake goes into a bit more detail on the brace decoration for TikZ in this answer: https://tex.stackexchange.com/a/34450/131649

You can also find more information on it in the PGF manual in Section 21 -- Making Trees Grow, on p.316ff: http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf

Of course, if there is an nice way to just do this via a tabular and some nicely-scaling braces, that would probably be easier. The nice thing about using TikZ for drawing trees is that they scale very easily. But not every situation needs that, admittedly.

Oh, and welcome to TeX.sx!

alpenwasser
  • 2,455
3

If it is a tree, it could be a Forest ....

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{forest}
\begin{document}
\begin{forest}
  for tree={
    math content,
    fit=band,
    edge path'={
      (.parent first) -- (!ul.parent last)
    },
    edge+={decorate, decoration={brace}},
    l sep'=0pt,
  },
  for n=1{
    tikz+={
      \node (n) [fit to=tree] {};
      \draw (n.north east) -- (n.south east);
    },
  },
  for nodewalk={
    1,
    descendants
  }{no edge, plain content, anchor=mid west},
  for nodewalk={2,descendants}{
    before typesetting nodes={
      if content={}{
        content=\Omega
      }{
        content/.wrap value=\Omega_{#1},
        before packing={
          text width/.process={OOPw3{max x}{min x}{width("$\Omega$")}{#3+.25*(#1-#2)}},
          text centered,
          typeset node,
        },
      },
      anchor=mid,
      if n=1{}{no edge},
    },
  },
  [, phantom
    [Total matter
      [Different equations of state
        [Different species]
      ]
    ]
    [
      [m
        [b]
        [c]
      ]
      [r
        [\gamma]
        [\nu]
      ]
      [\Lambda]
    ]
  ]
\end{forest}
\end{document}

bracket edges

cfr
  • 198,882
2

With TABstacks (no trial and error \raiseboxing)

\documentclass{article}
\usepackage{tabstackengine,amsmath}
\TABstackMath% PROCESS TABstacks IN MATH MODE (REGULAR STACKS IN TEXT MODE)
%\fixTABwidth{T}% MAKE TABstack COLUMNS EQUAL WIDTH
\setstacktabbedgap{\tabcolsep}% GAP BETWEEN COLUMNS
\setstackgap{L}{1.8\normalbaselineskip}% BASELINESKIP BETWEEN ROWS
\renewcommand\stacktype{L}% DEFAULT TO "LONG" STACKS
\begin{document}
\begin{tabular}{c|c}
\Longunderstack[l]{Total matter\\Different equations of state\\Different species}
&
\stackunder{$\Omega$}{$\overbrace{\tabbedLongunderstack{
  \Omega_m & \Omega_r & \Omega_\Lambda\\
  \overbrace{\Omega_b\quad\Omega_c}&
  \overbrace{\Omega_\gamma\quad\Omega_\nu}&
}}$}
\end{tabular}
\end{document}

enter image description here

If I uncomment the one line in the preamble, to force all column widths equal,

enter image description here