7

How can I realize this proof tree in LaTeX?

enter image description here

Does anyone have an idea how to achieve this?

  • you could use the braces-environment from the amsmath-package. – naphaneal Jan 2 '17 at 23:28
  • You can use nested cases environments, also from amsmath – AboAmmar Jan 2 '17 at 23:40
  • Please provide a minimal example when asking a question. It makes it much easier to help if you don't have to try to discern the details from a graphic and can just copy-paste the node contents as text. – cfr Jan 3 '17 at 2:46
  • 1
    Possible duplicate of Brace diagram in TikZ – Cragfelt Dec 16 '17 at 4:14
4
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\DeclareMathOperator{\bfR}{\mathbf{R}}

\begin{document}
  \begin{equation*}
S_1 \bfR_5\begin{cases}
              S_2  \bfR_2 & \begin{cases} 
                        S_4 \bfR_1 & \\
                        & \\
                        S_5 \bfR_3 & \quad S_6 \bfR_4
                \end{cases} \\
              S_3 \bfR_6 &
      \end{cases}
  \end{equation*}
\end{document}

enter image description here

10
\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation*}
  S_1 \mathbf{R_5}
  \begin{cases}
    S_2 \mathbf{R_2} 
      \begin{cases}
        S_4 \mathbf{R_1} & \\
        S_5 \mathbf{R_3} & S_6 \mathbf{R_4}
      \end{cases}  \\
    S_3 \mathbf{R_6}
  \end{cases}
\end{equation*}

\end{document}

enter image description here

6

I suggest to define the command

\infer{conclusion}{premise1\\premise2\\...}

as

\newcommand\infer[2]{#1\left\{\begin{array}{@{}l@{}}#2\end{array}\right.}

Moreover, we use the abbreviation

\newcommand\claim[2]{S_{#1}\;\mathbf{R}_{#2}}

to typeset the proof items.

enter image description here

\documentclass{article}
\newcommand\infer[2]{#1\left\{\begin{array}{@{}l@{}}#2\end{array}\right.}
\newcommand\claim[2]{S_{#1}\;\mathbf{R}_{#2}}
\begin{document}
\[\infer
    {\claim15}% from
    {\infer
       {\claim22}% from
       {\claim41
       \\% and
        \claim53\quad\claim64
       }
    \\% and
     \claim36
    }
\]
\end{document}
  • Or just use schemata? – cfr Jan 3 '17 at 2:44
  • 1
    @cfr Yes, indeed, this package can also be used. This is one of the things that I like here: you constantly learning something new. For an answer, though, I prefer basic solutions. Typical answers like "use this package" or esoteric code are potentially harmful as they convey the image that LaTeX cannot be mastered by anyone except by seven gurus. I consider it a bonus if an answer shows that a problem can be solved by means that can be found in a LaTeX intro (like Lamport's book) or in a TeX primer. – gernot Jan 3 '17 at 8:45
  • I'm not sure that being found in a TeX primer makes it accessible to the non-guru. And, actually, using well-documented packages is often easier than doing it from scratch. Reinventing the wheel is overrated, I think. – cfr Jan 3 '17 at 16:18
  • @cfr When seeing the same elements over and over again, sometimes reading a bit in the docs, you get a basic vocabulary. This does not happen if you are constantly offered new packages, some of them with idiosyncratic syntax (fueled by the flexibility of TikZ) . The docs of the packages are apparently over-rated: most people don't read them; otherwise we would see only half of the questions. In this particular case my solution uses only elementary commands that can be found in any LaTeX intro. – gernot Jan 3 '17 at 16:29
  • Most people don't read a LaTeX intro either and nobody suggested TikZ as far as I can tell. And many packages are extremely well-documented and often more accessible than most general introductions. There are very good introductions, of course, but it is not always easy to know which parts to use or how to use them. I'm not saying it is bad to provide such solutions. Just that disparaging off-the-peg solutions for particular problems, when well documented, is unjustified. I would encourage users to use existing, well-tested wheels before experimenting with their visions of triangular ones. – cfr Jan 3 '17 at 23:34
3

This is only likely to be of interest if either you need to draw lots of trees like this or you are familiar with Forest already. In the former case, it would be worth learning enough Forest for the sake of the very concise tree specifications it allows. In the latter, you might want to make the most of existing knowledge since it does allow really very concise specifications of trees.

The format of the node content as S with a subscript and bold R with a subscript is, I assume merely indicative. Hence, you would need to modify this for your particular needs. If the nodes fit a template model, the specification can be all the more concise, of course, as shown below.

The code below sets up a style proof schema tree which expects the content of the tree to be specified as pairs of integers separated by a colon. The content of each node is then split, the first part being taken as the first subscript and the second part as the second. This is then formatted appropriately and the curly brackets added using a non-standard edge path and the brace decoration from the decorations.pathreplacing library.

The upshot is that the tree can be specified with just

\begin{forest}
  proof schema tree,
  [1:5
    [3:6
      [5:3
        [6:4]
      ]
      [4:1]
    ]
    [2:2]
  ]
\end{forest}

proof schema tree

Complete code:

\documentclass[border=10pt,tikz]{standalone}
\usepackage{forest}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\forestset{
  declare count={s content}{0},
  declare count={r content}{0},
  proof schema tree/.style={
    for tree={
      math content,
      grow=0,
      child anchor=parent,
      parent anchor=children,
      l sep'=7.5pt,
    },
    for nodewalk={
      fake=r,
      descendants
    }{
      if={>On>On=&{!u.n children}{1}{n}{1}}{
        edge+={decorate, decoration={brace, amplitude=5pt}},
        edge path'={(.child anchor |- .south) -- (!ul.child anchor |- !ul.north)},
      }{no edge},
    },
    before typesetting nodes={
      for tree={
        split option={content}{:}{s content,r content},
        content/.process={OOw2{s content}{r content}{S_{##1} \mathbf{R_{##2}}}},
      },
    },
  },
}
\begin{forest}
  proof schema tree,
  [1:5
    [3:6
      [5:3
        [6:4]
      ]
      [4:1]
    ]
    [2:2]
  ]
\end{forest}
\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.