4

Consider the following example:

\documentclass[tikz,border=5pt]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
  for tree={
    draw,
  }
  [center,calign=center
    [first, parent anchor=west, calign=child edge
      [ABC, child anchor=west]
    ]
  ]
\end{forest}
\end{document}

My understanding of the documentation is that the west of the third node (ABC) should be aligned with the west of the second node (first) because this is what calign=child edge is supposed to do (manual, 28):

calign=child edge s-aligns the parent anchor of the parent and the child anchor of the primary child.

But this is not how I imagined it:

non-aligned

As discussed in chat with Gonzalo, adding a sibling causes the alignments to work as expected:

\begin{forest}
  for tree={
    draw,
  }
  [center,calign=center
    [first, parent anchor=west, calign=child edge
      [ABC, child anchor=west]
      []
    ]
  ]
\end{forest}

aligned

Is this expected? Is it a bug? What am I missing?

closed as off-topic by cfr, user13907, Werner, Jesse, Gonzalo Medina Jul 16 '15 at 3:05

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    I'm voting to close this question as off-topic because the problem described in the question is due to a bug in the package and a fixed version will be available from CTAN shortly. (Source: personal communication with package author.) – cfr Jul 15 '15 at 23:52
3

You have just defined the anchor of the connection (something like where to leave and where to reach...), not the anchor of the node it self.

Here you are:

% arara: pdflatex

\documentclass[border=5pt]{standalone}
\usepackage{forest}

\begin{document}
    \begin{forest}
        for tree={draw}
        [center%,calign=center
        [first, parent anchor=west, anchor=west, calign=child edge
        [ABC, child anchor=west, anchor=west]
        ]
        ]
    \end{forest}
\end{document}

enter image description here


The manual is miss-leading though. I would report it.

  • Trying around to get the first two nodes centred, I got the feeling that there is something really buggy. calign=midpoint in the root destroys the alignment I just managed to get for the last two nodes. – LaRiFaRi Jul 14 '15 at 12:41
  • That was precisely what led to this question. I was trying to construct the tree you created in an earlier forest question using a standard direction of growth and alignment. Not being able to led me here. If you think the manual is buggy, what do you think the description should be? Presumably, calign=child edge should do something different from calign=child. If it is not what it seems to say, what do you think it is meant to do? I guess I'm not convinced that using anchor here is supposed to be required... – cfr Jul 14 '15 at 12:47
  • @cfr me neither. If the manual was the fault, they should change "parent anchor" to "anchor" and "child anchor" to "anchor". But as I said, I think it is a real bug, not a bad description. calign should just effect the relation between current node and specified child. But it effects the whole forest here. – LaRiFaRi Jul 14 '15 at 12:50
  • Also, the manual says that anchor should only have an observable effect when a node has a sibling which obviously isn't the case here. – cfr Jul 14 '15 at 13:11
  • 1
    I've updated the question: try adding a sibling and everything magically works! So I don't think that parent anchor and child anchor can be intended only as anchors of the connection (something like where to leave and where to reach...) but not to affect the alignment of the node itself ;). – cfr Jul 15 '15 at 21:39
3

I emailed the package author, Sašo Živanović, to ask whether this behaviour is intended or a bug.

Sašo has confirmed that it is a bug.

... it was a bug, child alignment was not run in nodes with a single child. ... I have fixed the bug and I'm posting the fixed version to ctan.

So a new version should make it to CTAN shortly and be available by updating TeX installations in a couple of days.

EDIT

Here are the two trees whose code was given in the question, compiled with version 1.09 of forest.

The second 'control' tree with the additional child:

control

And the first test tree which previously showed the bug:

corrected test tree with fixed package

The version of the package with the fix is now available from CTAN and via TeX Live's tlmgr.

  • It's nice to finally know the answer. Thanks for writing to Sašo and for reporting his answer here. – Gonzalo Medina Jul 16 '15 at 1:53
  • @GonzaloMedina He said he's hoping to finish the new version this summer. It is nice to know I'm not nuts and horribly misconstruing the documentation ;). – cfr Jul 16 '15 at 2:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.