Skip to main content
Change intro text.
Source Link

AFirst a quick answer, just to make the example compile. To be updatedAnalysis below.

To make the code work in v2 without compat, replace the original for={Lu}{...} by

if n children={0}{for parent={if={n_children==1}{l sep+=30pt}{}}}{} 

A quick answer, just to make the example compile. To be updated.

First a quick answer, just to make the example compile. Analysis below.

To make the code work in v2 without compat, replace the original for={Lu}{...} by

if n children={0}{for parent={if={n_children==1}{l sep+=30pt}{}}}{} 
add analysis
Source Link

Analysis

OP's brave attempts to fight my package were thwarted by no less than four bugs.

  • A bug in compat=1.0-forstep. An internal macro \forest@nodewalk@config@oninvalid, which the compatibility mode is supposed to save and restore, was not initialized during package loading. The workaround is to define this macro before loading the package, as shown at the top of this answer.

  • Incomplete implementation of compat=1.0-forstep. While this compat key made forest silently ingore a step (above, L) to an invalid node, making a further step (above, u) resulted in error, unlike in v1. The workaround is given in quick edit 1 above.

  • A bug in for group. While group within a nodewalk expects an argument, for group does not. This bug also affects to next on tier, previous on tier (which I have discovered actually contain two more bugs ... )

  • A bug in compat=1.0-stages (which is included in compat=1.0-all), introduced in v2.0.2: the given options are not processed at all.

OP made a single mistake in her fight: trying to use on invalid incorrectly. This key takes not one but two arguments: the mode and the keys to be executed in this mode. (But the documentation is partially wrong here, as well!)

Final detail: where level={1}{s+=-20pt}{} worked only due to a bug in v1. The proper way to increase the s-distance between siblings is to increase s sep of their parent, as shown in quick edit 2 above.

Analysis

OP's brave attempts to fight my package were thwarted by no less than four bugs.

  • A bug in compat=1.0-forstep. An internal macro \forest@nodewalk@config@oninvalid, which the compatibility mode is supposed to save and restore, was not initialized during package loading. The workaround is to define this macro before loading the package, as shown at the top of this answer.

  • Incomplete implementation of compat=1.0-forstep. While this compat key made forest silently ingore a step (above, L) to an invalid node, making a further step (above, u) resulted in error, unlike in v1. The workaround is given in quick edit 1 above.

  • A bug in for group. While group within a nodewalk expects an argument, for group does not. This bug also affects to next on tier, previous on tier (which I have discovered actually contain two more bugs ... )

  • A bug in compat=1.0-stages (which is included in compat=1.0-all), introduced in v2.0.2: the given options are not processed at all.

OP made a single mistake in her fight: trying to use on invalid incorrectly. This key takes not one but two arguments: the mode and the keys to be executed in this mode. (But the documentation is partially wrong here, as well!)

Final detail: where level={1}{s+=-20pt}{} worked only due to a bug in v1. The proper way to increase the s-distance between siblings is to increase s sep of their parent, as shown in quick edit 2 above.

The code now produces exactly the OP's intended result
Source Link

Quick edit 2, fixing the s distance of the root's children. Replace where level={1}{s+=-20pt}{} by s sep+=20pt.

The complete v2 code yielding exactly the same result as v1:

\documentclass[tikz,border=10pt]{standalone} \makeatletter \def\forest@nodewalk@config@oninvalid{fake} \makeatother \usepackage[compat=1.0-forstep]{forest} \begin{document} \begin{forest} for tree={ font=\sffamily\scriptsize, line width=1pt, draw, anchor=west, child anchor=west, parent anchor=east, grow'=east, align=center, edge path={ \noexpand\path[line width=1pt, ->, \forestoption{edge}] (!u.parent anchor) -| +(5pt,0) -- +(5pt,0) |- (.child anchor) \forestoption{edge label}; }, % for={last leaf',u}{if={n_children==1}{l sep+=10pt}{}}, for last leaf={for parent={if={n_children==1}{l sep+=10pt}{}}}, }, % where level={1}{s+=-20pt}{} s sep+=20pt, [Here\\Village, name=pc [There village\\your bird, name=arid ] [, phantom [Bananas, name=fb, xshift=-15pt, where n children=0{tier=sk}{} [Pineapple, name=sf [Middling\\villages?, name=solar [Current\\paper, name=cp, edge label={node [font=\sffamily\scriptsize, near end, auto, xshift=-1.5pt] {Imprudent}} ] ] [Creative\\endearments?, name=apple [Fantastic\\imaginations, name=su, edge label={node [font=\sffamily\scriptsize, near end, auto, xshift=-1.5pt] {Basic}} ] ] [Heathen\\hopscotch?, name=pear [Beneficent\\benevolence, name=cl, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Higher}}, edge={draw=none} ] ] ] [Zoological, name=gf [Orange\\kangaroos?, name=star [Strawberry\\seeker, name=rs, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Lower}} ] ] [Fragility of\\foundations?, name=hercules [Memorial\\cooks, name=ws, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Earthling}} ] ] [Best\\antelopes?, name=astro [Stellar\\horizons, name=ca, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Martian}} ] ] ] ] ] [Bad hollows\\spotty slugs, name=avid ] ] \begin{scope}[line width=1pt, ->] \draw (solar.east) -- (solar.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (su.west); \draw (apple.east) -| +(5pt,0) -- +(5pt,0) |- (cp.west); \draw (pear.east) -- (pear.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cp.west); \draw (pear.east) -- (pear.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (su.west); \draw (star.east) -- (star.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cl.west); \draw (star.east) -- (star.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ws.west); \draw (star.east) -- (star.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ca.west); \draw (astro.east) -- (astro.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cl.west); \draw (astro.east) -- (astro.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (rs.west); \draw (astro.east) -- (astro.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ws.west); \draw (hercules.east) -- (hercules.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cl.west); \draw (hercules.east) -- (hercules.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (rs.west); \draw (hercules.east) -- (hercules.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ca.west); \draw (avid.north) -- (avid.north |- fb.south); \draw (arid.south -| avid.north) -- (avid.north |- fb.north); \end{scope} \end{forest} \end{document} 

Quick edit 2, fixing the s distance of the root's children. Replace where level={1}{s+=-20pt}{} by s sep+=20pt.

The complete v2 code yielding exactly the same result as v1:

\documentclass[tikz,border=10pt]{standalone} \makeatletter \def\forest@nodewalk@config@oninvalid{fake} \makeatother \usepackage[compat=1.0-forstep]{forest} \begin{document} \begin{forest} for tree={ font=\sffamily\scriptsize, line width=1pt, draw, anchor=west, child anchor=west, parent anchor=east, grow'=east, align=center, edge path={ \noexpand\path[line width=1pt, ->, \forestoption{edge}] (!u.parent anchor) -| +(5pt,0) -- +(5pt,0) |- (.child anchor) \forestoption{edge label}; }, % for={last leaf',u}{if={n_children==1}{l sep+=10pt}{}}, for last leaf={for parent={if={n_children==1}{l sep+=10pt}{}}}, }, % where level={1}{s+=-20pt}{} s sep+=20pt, [Here\\Village, name=pc [There village\\your bird, name=arid ] [, phantom [Bananas, name=fb, xshift=-15pt, where n children=0{tier=sk}{} [Pineapple, name=sf [Middling\\villages?, name=solar [Current\\paper, name=cp, edge label={node [font=\sffamily\scriptsize, near end, auto, xshift=-1.5pt] {Imprudent}} ] ] [Creative\\endearments?, name=apple [Fantastic\\imaginations, name=su, edge label={node [font=\sffamily\scriptsize, near end, auto, xshift=-1.5pt] {Basic}} ] ] [Heathen\\hopscotch?, name=pear [Beneficent\\benevolence, name=cl, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Higher}}, edge={draw=none} ] ] ] [Zoological, name=gf [Orange\\kangaroos?, name=star [Strawberry\\seeker, name=rs, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Lower}} ] ] [Fragility of\\foundations?, name=hercules [Memorial\\cooks, name=ws, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Earthling}} ] ] [Best\\antelopes?, name=astro [Stellar\\horizons, name=ca, edge label={node [font=\sffamily\scriptsize, near end, xshift=-1.5pt, below] {Martian}} ] ] ] ] ] [Bad hollows\\spotty slugs, name=avid ] ] \begin{scope}[line width=1pt, ->] \draw (solar.east) -- (solar.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (su.west); \draw (apple.east) -| +(5pt,0) -- +(5pt,0) |- (cp.west); \draw (pear.east) -- (pear.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cp.west); \draw (pear.east) -- (pear.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (su.west); \draw (star.east) -- (star.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cl.west); \draw (star.east) -- (star.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ws.west); \draw (star.east) -- (star.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ca.west); \draw (astro.east) -- (astro.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cl.west); \draw (astro.east) -- (astro.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (rs.west); \draw (astro.east) -- (astro.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ws.west); \draw (hercules.east) -- (hercules.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (cl.west); \draw (hercules.east) -- (hercules.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (rs.west); \draw (hercules.east) -- (hercules.east -| apple.east) -| +(5pt,0) -- +(5pt,0) |- (ca.west); \draw (avid.north) -- (avid.north |- fb.south); \draw (arid.south -| avid.north) -- (avid.north |- fb.north); \end{scope} \end{forest} \end{document} 
Better approximation of OP's intended result
Source Link
Loading
Source Link
Loading