8

I created a tree with the help of cases environments. The MWE is this:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\begin{document}

\tiny
\hyphenpenalty10000%
\[
  \begin{cases}
    \parbox{1.5cm}{Doctrina de\\ los elementos}
    \begin{cases}
      \parbox{1.5cm}{Estética\\ trascendental}\\
      \parbox{1.5cm}{Lógica\\ trascendental}
      \begin{cases}
        \parbox{1.5cm}{Analítica\\ trascendental}
        \begin{cases}
          \begin{minipage}{6em}
            Analítica de los conceptos\\[2pt]
            Analítica de los principios
          \end{minipage}
        \end{cases}\\
        \parbox{1.5cm}{Dialéctica\\ trascendental}
        \begin{cases}
          \parbox{1.5cm}{Conceptos de\\ la razón pura}\\[6pt]
          \parbox{1.5cm}{Inferencias\\ dialécticas de\\ la razón pura}
          \begin{cases}
            \begin{minipage}{6em}\raggedright
                Paralogismos  de la razón pura\\[3pt]
                Antinomia de la razón\\
                Ideal de la razón pura
          \end{minipage}
          \end{cases}
        \end{cases}
      \end{cases}
    \end{cases}
    \vspace*{12pt}\\
    \parbox{1.5cm}{Doctrina\\ del método}
    \begin{cases}
      \begin{minipage}{6em}\raggedright
        Disciplina\\[2pt]
        Canon\\[2pt]
        Arquitectónica\\[2pt]
        Historia de la razón pura
    \end{minipage}
    \end{cases}
  \end{cases}
\]

\end{document}

The result is this: enter image description here However, I'm not very happy with the result. For example, in the second-to-last 'column', the first brace is too close to the second brace. Notice also the \\[2pt] codes, to forcefully adjust spacing.

I wonder if there is a better way of setting this tree. (I have tried out some TikZ, but with no avail.)

  • That's a very complicated way to build a tree. Have you searched the site of ways of building trees more automatically? For example, forest is a very nice package for this kind of task. – Alenanno Jun 8 '16 at 14:23
  • Yes, I know. But the forest package typesets fork trees, rather than "brace" trees. – NVaughan Jun 8 '16 at 14:29
  • You can customize the appearance of the joining lines, of course. But the question is: if there is a brace, where are the children supposed to be located? Evenly spread across the brace? – Alenanno Jun 8 '16 at 14:30
  • Yes. Indeed, I would like to have more control as to the vertical placement of the children. – NVaughan Jun 8 '16 at 14:34
  • 1
    I'd use schemata for this - not forest. – cfr Jun 8 '16 at 16:03
6

As I suggested in my comment, the use of my answer here, Multiple brackets or parentheses with a text inside, can eliminate the squeezed groups noticed by the OP. Plus, it allows item markers as well as variable column width definitions, so that manual line breaking is not necessary (though here, all columns are fixed at 0.6in).

EDITED to improve that answer in two ways:

  1. I have loaded amsmath to correct scaled-brace width issues. RE-EDITED because even with amsmath, the issue arose that the width of a \left\{ varied with the height of the associated element, causing misalignment. I have introduced \def\fudgeheight{3} which is used by a revised \skipcol to set the height of the phantom \left\{. Hopefully, it can be left alone at that value.

  2. Since the item marks in any given column should be the same to achieve proper spacing, I have allowed the definition of item marks for a whole column at a time, rather than requiring their specification for each \BL item. The default can still be overridden with an optional argument.

Here is the MWE.

\documentclass{article}
\usepackage{amsmath}% FIXES WIDTH OF \left\{
\newcounter{levelcount}
\def\levelwidth   {.6in}%NOT USED HERE, WITHOUT LEADING TEXT
\def\levelwidthi  {.6in}
\def\levelwidthii {.6in}
\def\levelwidthiii{.6in}
\def\levelwidthiv {.6in}
\def\levelwidthv  {.6in}
\def\levelmarki  {$\dag$}
\def\levelmarkii {$-$}
\def\levelmarkiii{$+$}
\def\levelmarkiv {$\bullet$}
\def\levelmarkv  {*}
\def\fudgeheight{3}
\newcommand\BL[2][\csname levelmark\romannumeral\thelevelcount\endcsname]{#1\,\parbox[t]{%
  \csname levelwidth\romannumeral\thelevelcount\endcsname}{\raggedright#2}}
\def\level#1{\stepcounter{levelcount}%
  \unskip$\left\{\vcenter{\hbox{\shortstack{#1}}}\right.$%
  \addtocounter{levelcount}{-1}\ignorespaces}
\newcommand\skipcol[2][\relax]{%
  \ifx\relax#1\skipcolhelp{\csname levelmark\romannumeral#2\endcsname}%
  \else\skipcolhelp{#1}\fi}
\newcommand\skipcolhelp[1]{%
  \smash{\phantom{\level{\BL[#1]{\rule{1pt}{\fudgeheight\baselineskip}}}}}}
\begin{document}
\scriptsize
  \level{
    \BL{Doctrina de los elementos} 
      \level{
        \BL{Estetica trascendental}\skipcol{3}\skipcol{4}\skipcol{5}\cr
        \BL{Logica trascendental}
          \level{
             \BL{Analitica trascendental}
               \level{
                 \BL{Analitica de los conceptos}\cr
                 \BL{Analitica de los principios}\cr
               }\skipcol{5}\cr
             \BL{Dialectica trascendental}
               \level{\cr
                 \BL{Conceptos de la razon pura}\skipcol{5}\cr
                 \BL{Inferencias dialecticas de la rason pura}
                   \level{
                     \BL{Paralogismos de la razon pura}\cr
                     \BL{Antinomia de la razon}\cr
                     \BL{Ideal de la razon pura}
                   }
               }
          }
      }
  \cr 
    \BL{Doctrina del metodo}
      \level{
        \BL{Disciplina}\cr
        \BL{Architecture}\cr
        \BL{History de la razon pura}
      }\skipcol{3}\skipcol{4}\skipcol{5}
  }
\end{document}

enter image description here

The OP prefers the answer without item markers. That is easily accomplished by setting

\def\levelmarki  {}
\def\levelmarkii {}
\def\levelmarkiii{}
\def\levelmarkiv {}
\def\levelmarkv  {}

in the preamble. But without the visual cue provided by the markers, one may want some additional vertical separation between items. That can be done by using a extra one or two \crs added beteen \BL items, as shown in this MWE below.

\documentclass{article}
\usepackage{amsmath}% FIXES WIDTH OF \left\{
\newcounter{levelcount}
\def\levelwidth   {.6in}%NOT USED HERE, WITHOUT LEADING TEXT
\def\levelwidthi  {.6in}
\def\levelwidthii {.6in}
\def\levelwidthiii{.6in}
\def\levelwidthiv {.6in}
\def\levelwidthv  {.6in}
\def\levelmarki  {}
\def\levelmarkii {}
\def\levelmarkiii{}
\def\levelmarkiv {}
\def\levelmarkv  {}
\def\fudgeheight{3}
\newcommand\BL[2][\csname levelmark\romannumeral\thelevelcount\endcsname]{#1\,\parbox[t]{%
  \csname levelwidth\romannumeral\thelevelcount\endcsname}{\raggedright#2}}
\def\level#1{\stepcounter{levelcount}%
  \unskip$\left\{\vcenter{\hbox{\shortstack{#1}}}\right.$%
  \addtocounter{levelcount}{-1}\ignorespaces}
\newcommand\skipcol[2][\relax]{%
  \ifx\relax#1\skipcolhelp{\csname levelmark\romannumeral#2\endcsname}%
  \else\skipcolhelp{#1}\fi}
\newcommand\skipcolhelp[1]{%
  \smash{\phantom{\level{\BL[#1]{\rule{1pt}{\fudgeheight\baselineskip}}}}}}
\begin{document}
\scriptsize
  \level{
    \BL{Doctrina de los elementos} 
      \level{
        \BL{Estetica trascendental}\skipcol{3}\skipcol{4}\skipcol{5}\cr
        \BL{Logica trascendental}
          \level{
             \BL{Analitica trascendental}
               \level{
                 \BL{Analitica de los conceptos}\cr\cr
                 \BL{Analitica de los principios}\cr\cr
               }\skipcol{5}\cr
             \BL{Dialectica trascendental}
               \level{\cr
                 \BL{Conceptos de la razon pura}\skipcol{5}\cr
                 \BL{Inferencias dialecticas de la rason pura}
                   \level{
                     \BL{Paralogismos de la razon pura}\cr\cr
                     \BL{Antinomia de la razon}\cr\cr
                     \BL{Ideal de la razon pura}
                   }
               }
          }
      }
  \cr 
    \BL{Doctrina del metodo}
      \level{
        \BL{Disciplina}\cr\cr\cr
        \BL{Architecture}\cr\cr\cr
        \BL{History de la razon pura}
      }\skipcol{3}\skipcol{4}\skipcol{5}
  }
\end{document}

enter image description here

  • That's very nice. However, I think the bullets are unnecesary here. – NVaughan Jun 8 '16 at 16:25
  • @NVaughan Then one can just set \def\levelmarki {} \def\levelmarkii {} \def\levelmarkiii{} \def\levelmarkiv {} \def\levelmarkv {} – Steven B. Segletes Jun 8 '16 at 16:27
  • @NVaughan I would also note that, without the visual cue afforded by item markers, one can achieve a little extra vertical separation between items with a double \cr\cr between \BL items, when needed. – Steven B. Segletes Jun 8 '16 at 16:29
  • Why is the "Logica trascendental" text a bit indented? – NVaughan Jun 8 '16 at 16:51
  • 1
    @NVaughan I believe I have corrected the issue (see EDIT). It arose because the width of \left\{ varies with the height of the contents, and this was throwing off the uniform width of the columns. – Steven B. Segletes Jun 8 '16 at 19:23
12

Schemata is a package designed to draw, well, schemata basically. It defines a series of macros to facilitate the drawing and adjustment of this type of diagram.

The easiest way to use it is to follow the manual. Create a basic schemata first using only \schema and \schemabox. Then adjust as required from right to left, adding a \smallskip or so between right-hand leaves. Then change \schema to \Schema as appropriate, always working from right to left to avoid needing to redo your adjustments. The manual explains this process much better than I can do here.

Here's a rough first-pass version of the finished result, based on your MWE.

schemata

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amssymb}
\usepackage{schemata}
\begin{document}
\Schema{4.5ex}{19ex}{%
}{%
  \Schema{-16.75ex}{9.25ex}{%
    \schemabox{Doctrina de\\los elementos}
  }{%
    \schemabox{%
      Estética\\trascendental
    }%
    \Schema{-8ex}{9ex}{%
      \schemabox{Lógica\\trascendental}
    }{%
      \schema{%
        \schemabox{Analítica\\ trascendental}
      }{%
        \schemabox{%
          Analítica de\\los conceptos
        }\smallskip
        \schemabox{%
          Analítica de\\los principios
        }
      }\smallskip
      \Schema{-5.5ex}{7.5ex}{% change this \schema to \Schema first
        \schemabox{%
          Dialéctica\\
          trascendental
        }%
      }{%
        \schemabox{%
          Conceptos de\\
          la razón pura
        }\smallskip
        \schema{%
          \schemabox{%
            Inferencias\\
            dialécticas de\\
            la razón pura\\
          }%
        }{%
          \schemabox{%
            \schemabox{%
              Paralogismos\\
              de la razón\\
              pura
            }\smallskip\\
            \schemabox{%
              Antinomia\\
              de la razón\\
              Ideal de la\\
              razón pura
            }%
          }%
        }
      }%
    }%
  }\smallskip
  \schema{%
    \schemabox{Doctrina\\del método}
  }{%
    \schemabox{%
      Disciplina\\
      Canon\\
      Arquitectónica\\
      Historia de la razón pura
    }
  }
}
\end{document}
  • Thanks. Very nice and clean. I had already taken a look at your recommendation. – NVaughan Jun 8 '16 at 22:15
  • Your solution is wonderful but although I've read the schema package instruction I still cannot understand the rule of opening a new parenthesis nested in another. – Luca trying to write in LaTex Dec 23 '18 at 10:35
  • @LucatryingtowriteinLaTex I just did it by starting with the very simplest case and then building it up. Basically, you're slotting boxes into boxes, as far as I remember. It's a while since I used it. You should ask a specific question if you get stuck, though. – cfr Dec 30 '18 at 2:38
7

I can offer no flexible solution, but two different ones. The first creates something similar to your original MWE, but with better spacing. I placed everything in minipages to stay uniform, you might want to change that:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\begin{document}

\tiny
\hyphenpenalty10000%

\[
    \left\{
        \begin{aligned}
            &\begin{minipage}{1.5cm}\raggedright{Doctrina de\\ los elementos}\end{minipage}
            \left\{
                \begin{aligned}
                    &\begin{minipage}{1.5cm}\raggedright{Estética\\ trascendental}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Lógica\\ trascendental}\end{minipage}
                    \left\{
                        \begin{aligned}
                            &\begin{minipage}{1.5cm}\raggedright{Analítica\\ trascendental}\end{minipage}
                            \left\{
                                \begin{aligned}
                                    &\begin{minipage}{1.5cm}\raggedright{Analítica de\\ los conceptos}\end{minipage}
                                \\
                                    &\begin{minipage}{1.5cm}\raggedright{Analítica de\\ los principos}\end{minipage}
                                \end{aligned}
                            \right.
                        \\
                            &\begin{minipage}{1.5cm}\raggedright{Dialéctica\\ trascendental}\end{minipage}
                            \left\{
                                \begin{aligned}
                                    &\begin{minipage}{1.5cm}\raggedright{Conceptos de\\ la razón pura}\end{minipage}
                                \\
                                    &\begin{minipage}{1.5cm}\raggedright{Inferencias\\ dialécticas de\\ la razón pura}\end{minipage}
                                    \left\{
                                        \begin{aligned}
                                            &\begin{minipage}{1.5cm}\raggedright{Paralogismos\\ de la razón\\ pura}\end{minipage}
                                        \\
                                            &\begin{minipage}{1.5cm}\raggedright{Antinomia de la razón}\end{minipage}
                                        \\
                                            &\begin{minipage}{1.5cm}\raggedright{Ideal de la razón pura}\end{minipage}
                                        \end{aligned}
                                    \right.
                                \end{aligned}
                            \right.
                        \end{aligned}
                    \right.
                \end{aligned}
            \right.
        \\
            &\begin{minipage}{1.5cm}\raggedright{Doctrina\\ del método}\end{minipage}
            \smash[b]{\left\{
                \begin{aligned}
                    &\begin{minipage}{1.5cm}\raggedright{Disciplina}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Canon}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Arquitectónica}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Historia de la\\ razón pura}\end{minipage}
                \end{aligned}
            \right.}
        \end{aligned}
    \right.
\]

Full braces

The second one is more to my personal taste, but it comes with its own problems. It works for this example, but problems will arise when opposing branches overlap, so this is not a generalizable thing:

\[
    \left\{
        \begin{aligned}
            &\begin{minipage}{1.5cm}\raggedright{Doctrina de\\ los elementos}\end{minipage}
            \smash[t]{\left\{
                \begin{aligned}
                    &\begin{minipage}{1.5cm}\raggedright{Estética\\ trascendental}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Lógica\\ trascendental}\end{minipage}
                    \smash[b]{\left\{
                        \begin{aligned}
                            &\begin{minipage}{1.5cm}\raggedright{Analítica\\ trascendental}\end{minipage}
                            \smash[t]{\left\{
                                \begin{aligned}
                                    &\begin{minipage}{1.5cm}\raggedright{Analítica de\\ los conceptos}\end{minipage}
                                \\
                                    &\begin{minipage}{1.5cm}\raggedright{Analítica de\\ los principos}\end{minipage}
                                \end{aligned}
                            \right.}
                        \\
                            &\begin{minipage}{1.5cm}\raggedright{Dialéctica\\ trascendental}\end{minipage}
                            \smash[b]{\left\{
                                \begin{aligned}
                                    &\begin{minipage}{1.5cm}\raggedright{Conceptos de\\ la razón pura}\end{minipage}
                                \\
                                    &\begin{minipage}{1.5cm}\raggedright{Inferencias\\ dialécticas de\\ la razón pura}\end{minipage}
                                    \smash[b]{\left\{
                                        \begin{aligned}
                                            &\begin{minipage}{1.5cm}\raggedright{Paralogismos\\ de la razón\\ pura}\end{minipage}
                                        \\
                                            &\begin{minipage}{1.5cm}\raggedright{Antinomia de la razón}\end{minipage}
                                        \\
                                            &\begin{minipage}{1.5cm}\raggedright{Ideal de la razón pura}\end{minipage}
                                        \end{aligned}
                                    \right.}
                                \end{aligned}
                            \right.}
                        \end{aligned}
                    \right.}
                \end{aligned}
            \right.}
        \\
            &\begin{minipage}{1.5cm}\raggedright{Doctrina\\ del método}\end{minipage}
            \smash[b]{\left\{
                \begin{aligned}
                    &\begin{minipage}{1.5cm}\raggedright{Disciplina}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Canon}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Arquitectónica}\end{minipage}
                \\
                    &\begin{minipage}{1.5cm}\raggedright{Historia de la\\ razón pura}\end{minipage}
                \end{aligned}
            \right.}
        \end{aligned}
    \right.
\]

\end{document}

Smaller braces

5

Using TikZ, this would be another option (following this answer):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.pathreplacing}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\begin{document}

\begin{tikzpicture}
\hyphenpenalty10000

\node (main) {};
\begin{scope}[node distance=1em, text width=4em, align=left]
    \node [right=of main, yshift=6em]   (a1) {Doctrina de los elementos};
    \node [right=of main, yshift=-6em]   (a2) {Doctrina del método};
\end{scope}
 \draw[decorate,decoration={brace, mirror}] (a1.north west) -- (a2.south west);

\begin{scope}[node distance=1em, text width=6em, align=left]
    \node [right=of a1, yshift= 2em] (b1) {Estética trascendental};
    \node [right=of a1, yshift= -2em] (b2) {Lógica trascendental};
\end{scope}
\draw[decorate,decoration={brace,mirror}] (b1.north west) -- (b2.south west);

\begin{scope}[node distance=1em, text width=2cm, align=left]
    \node [right=of b2, yshift= 6em] (c1) {Analítica trascendental};
    \node [right=of b2, yshift= -6em] (c2) {Dialéctica trascendental};
\end{scope}
\draw[decorate,decoration={brace,mirror}] (c1.north west) -- (c2.south west);

\begin{scope}[node distance=1em, text width=2cm, align=left]
    \node [right=of c1, yshift= 3em] (d1) {Analítica de los conceptos};
    \node [right=of c1, yshift= -3em] (d2) {Analítica de los principios};
\end{scope}
\draw[decorate,decoration={brace,mirror}] (d1.north west) -- (d2.south west);

\begin{scope}[node distance=1em, text width=5em, align=left]
    \node [right=of c2, yshift= 3em] (d3) {Conceptos de la razón pura};
    \node [right=of c2, yshift= -3em] (d4) {Inferencias dialécticas de la razón pura};
\end{scope}
\draw[decorate,decoration={brace,mirror}] (d3.north west) -- (d4.south west);

\begin{scope}[node distance=1em, text width=2cm, align=left]
    \node [right=of d4, yshift= 4em] (e1) {Paralogismos de la razón pura};
    \node [right=of d4] (e2) {Antinomia de la razón};
    \node [right=of d4, yshift= -4em] (e3) {Ideal de la razón pura};
\end{scope}
\draw[decorate,decoration={brace,mirror}] (e1.north west) -- (e3.south west);

\begin{scope}[node distance=1em, text width=2cm, align=left]
    \node [right=of a2, yshift= 4em] (b3) {Disciplina};
    \node [right=of a2, yshift= 2em] (b4) {Canon};
    \node [right=of a2, yshift= 0em] (b5) {Arquitectónica};
    \node [right=of a2, yshift= -3em] (b6) {Historia de la razón pura};
\end{scope}
\draw[decorate,decoration={brace,mirror}] (b3.north west) -- (b6.south west);

\end{tikzpicture}

\end{document}

The result is: enter image description here

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.