The following parsing tree is from Mathematical Logic published in 2007 and written by Ian Chiswell & Wilfrid Hodges. It looks like a forest tree, but I guess it could be typeset better by another package. How shall I typeset this?

enter image description here

  • Maybe a slight variation on this? But please provide a minimal example which at least provides the basics. It is not as if you don't know where to start!
    – cfr
    Apr 4 '16 at 21:48
  • @cfr Your link seems to be very close to what I want. This tree is so alien to plain forest that I don't know how to provide a minimal example. All I know for now is that this tree encroaches into the realm of tikz and that I may have to learn tikz from scratch. Would tikz alone be better than the combination of tikz and forest?
    – crocket
    Apr 5 '16 at 4:31
  • This has probably been realized with picture mode.
    – egreg
    Apr 5 '16 at 6:35
  • @egreg Do you mean ctan.org/pkg/picture ? What is picture mode? I need more information.
    – crocket
    Apr 5 '16 at 6:46
  • @crocket The standard \begin{picture}...\end{picture} environment defined in standard LaTeX.
    – egreg
    Apr 5 '16 at 6:48

Using more-or-less the formulae kindly transcribed from the do-it-for-me image by egreg when the OP failed to provide any help whatsoever, together with a tweaked version of the tableaux style I developed for this answer, I drew a version of the tree using Forest as follows. For the record, I think I ought not answer this question but I'm giving in to my fascination with trees.

  declare toks={wff}{},
  declare toks={cyswllt}{},
  declare toks register={nod safonol},
  nod safonol=\circ,
    for tree={
      math content,
      parent anchor=children,
      child anchor=parent,
      inner sep=0pt,
    where level=0{%
      for children={no edge},
        content'/.register=nod safonol,
        insert before/.wrap pgfmath arg={%
          [{##1}, no edge, math content, before drawing tree={x'+=7.5pt}]
        insert after/.wrap pgfmath arg={%
          [{##1}, no edge, math content, before drawing tree={x'-=7.5pt}]
        before packing={calign with current edge},
        if n=1{%
          before packing={%
            !parent.calign primary child/.process args={O}{n},
          before packing={%
            !parent.calign secondary child/.process args={O}{n},
    [, wff=((\lnot(p_1\lif(\lnot p_0)))\lif p_0), cyswllt=\lif
      [, wff=(\lnot(p_1\lif(\lnot p_0))), cyswllt=\lnot
        [, wff=(p_1\lif(\lnot p_0)), cyswllt=\lif
          [, wff=p_1]
          [, wff=(\lnot p_0), cyswllt=\lnot
            [, wff=p_0]
      [, wff=p_0]

coeden ddosbarthu (dyw neb arall yn 'sgrifennu unrhywbeth o gwbl felly, 'sbo'r Gymraeg yn iawn!)

  • I like ”safonol“ and “dosbarthu”! :)
    – egreg
    Apr 5 '16 at 22:51
  • More pronounceable than 'cyswllt'? ;)
    – cfr
    Apr 5 '16 at 22:55
  • The best I could do was drawing a plain forest tree with left labels and right labels mingled into one node, and I thought it would be hardly any different from just listing the propositional formulas line by line because the 99.9% of work lies in the clever forest/TikZ structure, but not in the propositional formulas. I thought giving you 0.01% of the work wasn't going to make anyone feel better.
    – crocket
    Apr 5 '16 at 23:52
  • @crocket Copying propositional formulae from an image in another application on another virtual desktop into my editor takes a lot of effort and time. Copying code for the same formulae takes seconds. Even for somebody with sufficient screen real estate to display the image and the editor simultaneously, it is probably annoying. To constantly need to switch applications or desktops drives me nuts. However, I didn't. I copied egreg's. A list would be good. A tree even better. Nothing sucks.
    – cfr
    Apr 5 '16 at 23:55
  • @crocket To put this another way: writing the Forest/TikZ stuff to structure the tree is the puzzle. That's interesting/challenging. Copying the content in order to set the puzzle up is boring/easy/frustrating.
    – cfr
    Apr 5 '16 at 23:58

Picture mode is sufficient; pict2e is loaded for better compatibility with newer engines.



  $((\lnot(p_1\mathbin{\to}(\lnot p_0)))\mathbin{\to}p_0)$}}%
  $(\lnot(p_1\mathbin{\to}(\lnot p_0)))$}}%
  $(p_1\mathbin{\to}(\lnot p_0))$}}%
\put(2.65,1){\makebox(0,0){\makebox[0pt][r]{$(\lnot p_0)$}}}


enter image description here

  • I appreciate the demonstration, but the code is verbose and involves lots of manual coordinate accounting that I want to automate away with a package. I want the code to reflect the logic structure to a degree concisely.
    – crocket
    Apr 5 '16 at 7:56
  • @crocket You may want something, but you're being very impolite. You asked how to typeset that diagram, not “is it possible to have a generic way to typeset alike diagrams, with minimal effort?”
    – egreg
    Apr 5 '16 at 7:58
  • Sorry for being impolite. I have used a lot of mental energy on mathematics today, so I don't have much mental energy left for socialization and diplomacy. Diplomacy and creativity require the same kind of mental energy. I think forest and pgf/tikz might be more appropriate for elegant code.
    – crocket
    Apr 5 '16 at 8:02

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.