« first day (408 days earlier)      last day (151 days later) » 

12:04 AM
@cfr You've got a really complicated case here. First, there are many nested ifs. Second, you need to assign to more than one key (and even that, only in some of the if branches). I'll post several pieces of code below.
@cfr About 'if such-and-such, use option so-and-so; otherwise, use some other option'. This can be done fairly easily:
\begin{forest}
  delay={
    tempcounta=1,
    content/.process={
        _R=
        ?
        O
      }
      {1}{tempcounta}
      {parent anchor}{child anchor}
  }
  [X,parent anchor=south,child anchor=north]
\end{forest}
^^ As the result of ?, either the true or the false argument, remains on the right, you can directly use it as an option name of O.
@cfr Below, I have modified your code so that if iteration is done within .process (but only for the current node's edge label). The complicated call of .process is commented, I hope that helps.
\begin{forest}
  for tree={
    math content,
    grow'=0,
    calign primary child=1,
    calign primary angle=-30,
    calign=last,
    delay={
      if iteration={}{iteration/.option=level, is auto iteration}{},
    },
  },
  before typesetting nodes={
    for tree={
      if n=1{
        if content={}{
          content/.process={Ow}{iteration}{w_#1},
          if is auto iteration={
            edge label/.process={
              Ow+n % compute "iteration-1", even if we don't need it in all cases
@cfr The following is what I'd do to achieve your goal of avoiding repetition of code: I'd simply use styles.
\begin{forest}
  for tree={
    math content,
    grow'=0,
    calign primary child=1,
    calign primary angle=-30,
    calign=last,
    delay={
      if iteration={}{iteration/.option=level, is auto iteration}{},
    },
  },
  this edge label/.style 2 args={% #1 = additional node options, #2 = denominator
    edge label={node [midway, anchor=south east, xshift=-2.5pt, font=\scriptsize, #1] {$\frac{2}{#2}$}}
  },
  parent edge label/.style 2 args={% #1 = numerator, #2 = denominator
    !u.edge label={node [midway, below, font=\scriptsize] {$\frac{#1}{#2}$}},
@cfr About the second issue of fixed edges angles. What you have in your tree doesn't work as calign=last essentially overrides all the previous calign related keys. This is what works:
    calign primary angle=0,
    calign secondary angle=30,
    calign=fixed edge angles,
The full code for fixed edge angles:
\begin{forest}
  for tree={
    math content,
    grow'=0,
    calign primary angle=0,
    calign secondary angle=30,
    calign=fixed edge angles,
    delay={
      if iteration={}{iteration/.option=level, is auto iteration}{},
    },
  },
  this edge label/.style 2 args={% #1 = additional node options, #2 = denominator
    edge label={node [midway, anchor=south east, xshift=-5pt, font=\scriptsize, #1] {$\frac{2}{#2}$}}
  },
  parent edge label/.style 2 args={% #1 = numerator, #2 = denominator
@cfr By the way, I have discovered a little bug while working on this. The items returned by process instruction u have one layer of braces too many. This doesn't cause a problem for in the code above, but it could be a problem in some other situations.
@cfr And another little thing I'll change in the patch release. Process instruction P (pgfmath) currently does not accept forestmath expressions, i.e. you cannot start your pgfmath expression by > to indicate that it's actually a(n embedded) call to the argument processor. I have no idea why I thought this would be wise. Allowing forestmath there would make it possible to nest conditionals in .process. I'll send you the new forest runtime files and an example once I have the issue fixed.
 
cfr
1:14 AM
@SašoŽivanović Why is @barbarabeeton always so quiet?
@SašoŽivanović That sounds very good. I have definitely wished I could do this! I find it too confusing trying to mix forestmath and pgfmath :(.
@SašoŽivanović Thanks for looking at this. I actually only used calign=last in desperation.
 
@cfr How would I know? ;-)
 
cfr
@SašoŽivanović No idea. I thought you might know if she was interested in Forest.
 
@cfr I realize now why I didn't do it. It's more complicated as it seems, as the embedded .process will need to return multiple items. Working on it right now.
 
cfr
@SašoŽivanović Do you want to answer the question?
 
@cfr The General probability trees in latex? I guess it's best if you simply update your answer as you wish. You can link to this chat if you want. I'll rather do some programming. ;-)
@cfr Ahh, I see, she's in the room. Dunno.
 
 
2 hours later…
cfr
3:37 AM
@SašoŽivanović Do you know why using
  for tree={
    math content,
    grow'=0,
    calign primary angle=0,
    calign secondary angle=30,
    calign=fixed edge angles,
    delay={
      if iteration={}{iteration/.option=level, is auto iteration}{},
    },
  },
with my before typesetting nodes doesn't work?
Actually, my result with your code, my amended code and my original code all seem very similar. Here are the first two:
This is better, but it still doesn't line things up. I guess that's not a problem with the angles, though.
 
3:58 AM
@cfr Just to be clear if I understand. If you take your original code and change just the angles stuff to what I proposed, it does work? Doesn't work how? Doesn't compile? (It does for me.) Or doesn't look right?
@cfr Yes I had actually checked that while I was writing. All should be the same except the one with fixed angles.
 
cfr
@SašoŽivanović It doesn't look right. It looks better. How do I align the w_p with the other w_i s and keep the edge angles fixed?
@SašoŽivanović If it doesn't make sense, ignore me. I'm very tired ... too late/early.
 
@cfr What are you trying to line up, precisely? (Maybe the depth of "p" is a problem?)
 
4:35 AM
@cfr There are two things at work here.
(1) When w_i is packed, the edge to w_{i+1} is "in the way", so w_i and its sibling are pushed a bit apart. (This is true even for w_5. Even the invisible edge to phantom "w_6" influences the packing.) For w_p, there is no edge going down from its sibling, so w_p and its sibling are not pushed further apart. This can be resolved by specifying ignore edge for the entire tree. (And you will want to increase s sep.)
(2) Letter "p" is a bit deeper than the numbers, and the packing mechanism measures the distance between the bottom of the index number / p and the (coordinate) sibling. So "w_p" has to be pushed a bit up. This can be resolved by putting the index in a zero-depth box.
Points (1) and (2) actually cancel out a bit, but not precisely. But when I fixed (1), (2) became quite obvious. Here's the entire code:
\begin{forest}
  for tree={
    math content,
    grow'=0,
    calign primary angle=0,
    calign secondary angle=30,
    calign=fixed edge angles,
    delay={
      if iteration={}{iteration/.option=level, is auto iteration}{},
    },
  },
  this edge label/.style 2 args={% #1 = additional node options, #2 = denominator
    edge label={node [midway, anchor=south east, xshift=-5pt, font=\scriptsize, #1] {$\frac{2}{#2}$}}
  },
  parent edge label/.style 2 args={% #1 = numerator, #2 = denominator
 
 
13 hours later…
5:44 PM
I'll try being serious for once. :) This is one of my favourite packages! I use it a lot, specially when writing beamer presentation. I like a tree structure when trying to explain things to people, so this package makes my life so easy! Thank you very much @Sašo and everybody that makes this package possible!
 
@PauloCereda Well, such a serious proclamation surely gives me energy for work!!!
And I'm serious, too! ;-)
 
6:17 PM
@SašoŽivanović awww <3
@Sašo: this was my talk in this year's UK-TUG meeting, it's crowded with forest diagrams: vimeo.com/187525063 :)
 
7:05 PM
@PauloCereda It really is!
 
 
4 hours later…
cfr
10:38 PM
@PauloCereda I also use it especially in Beamer presentations. I've never actually used prooftrees, but I do use Forest. @SašoŽivanović
@SašoŽivanović I'm testing 2.1.1 rc1 now ...
 
cfr
11:06 PM
@SašoŽivanović My test file looks OK with the rc version ;).
 

« first day (408 days earlier)      last day (151 days later) »