6

It's related to Directory tree on multiple pages using Forest package but I want to put a very long and narrow tree in two column layout. Tried just to use \twocolumn but it wasn't so simple... :(

It appeared that \twocolumn forces a page break I don't want to. So later I tried ltxgrid but it still looked bad.

Finally I found out that I need to use multicol package but the result still was bad.

So my question is: How to get multi page two column folder tree without page break on one/two column switch? It'd be perfect if columns on the first and last page of tree were vertically aligned. I mean similar tree heights in both columns.

Code:

\documentclass[%
        12pt,
        a4paper,
%       twocolumn,              % don't use it for whole document
        ]{article}


\usepackage[%
    includehead=true,%
    includefoot=true,%
    twoside,
    textwidth=17cm,
    hmarginratio=3:2,
    textheight=25cm,
    vmarginratio=1:1,
    verbose,%
]{geometry}


\usepackage{blindtext}
%\usepackage{storebox}
\usepackage[edges]{forest}
\usepackage{adjustbox}
%\usepackage{ltxgrid}



% addaswyd o god Saso Zivanovic: http://tex.stackexchange.com/a/296771/
\def\hiddenparcommand{\par}
\newcommand\otherhiddenparcommand{\par\noindent}
\newcommand\hiddencommacommand{, }
\forestset{%
  declare keylist register={split here ids},% the list of nodes to split the tree at
  split here ids={},
  declare keylist register={split here interjects},% the list of comments to put in between the tree parts
  split here interjects={},
  declare keylist={split here auto siblings}{},% a list to hold the siblings which need edge restoration
  declare toks register=split here toks,
  declare dimen register=tmpdima,
  tmpdima'=0pt,
  declare dimen register=tmpdimb,
  tmpdimb'=0pt,
  declare dimen register=tmpdimc,
  tmpdimc'=0pt,
  to widest/.style={
    tikz+={\path (\forestregister{tempdima}, \forestoption{y}) -- (\forestregister{tempdimb}, \forestoption{y});},
  },
  hide commas/.style={%
    split here toks+={\hiddencommacommand},
    split here toks+={#1},
  },
  split dir tree pre/.style={%
    label={[text=gray, anchor=north, font=\scriptsize]below:{[cont.]}{}},
  },
  split dir tree post/.style={%
    label={[font=\scriptsize, anchor=south, text=gray]above:{[cont.]}{}},
  },
  split dir tree auto post/.style={% this gets applied to the first node after a break
    split dir tree post,
    tempkeylistc'={},
    tmpdimb/.option=y,
    for nodewalk={
      while={
        > ORw2+d _+d < On=! & {y}{tmpdimb}{##2-##1} {\textheight-#1} {n'}{1}%
      }{
        next,
        tempkeylistc/.option=name
      }%
    }{},
    % save the list
    split here auto siblings/.register=tempkeylistc,
    tikz+/.process={% this tries to redraw the edges to the following siblings
      OOw2{edge}{id}%
      {%
        \path [##1] (!u.parent anchor |- .north) ++(\forestregister{folder indent},1ex) coordinate (before ##2) |- (.child anchor);
        \edef\tempa{\foresteoption{split here auto siblings}}
        \foreach \i in \tempa \path [##1] (before ##2) |- ({forest cs:\i.child anchor});
      }%
    },
  },
  split dir tree/.code={%
    \forestset{%
      draw tree stage/.style={
        for root'={
          tempdima/.min={%
            >OOw2+d{x}{min x}{####1+####2}%
          }{tree},
          tempdimb/.max={%
            >OOw2+d{x}{max x}{####1+####2}%
          }{tree},
          for tree={%
            to widest,
          },
        },
        tempcountb'=-1,
        do until={%
          strequal((split_here_ids),"")
        }{%
          tempkeylistb'={},
          tempkeylista'={},
          split register={split here ids}{,}{tempcounta,tempkeylistb+},
          split register={split here interjects}{,}{temptoksa,tempkeylista+},
          split here ids'/.register=tempkeylistb,
          split here interjects'/.register=tempkeylista,
        % Sašo Živanović: http://chat.stackexchange.com/transcript/message/28484520#28484520
         for nodewalk={%
           draw tree processing order/.style={%
             filter={tree}{> ORw+n< OR> & {id}{tempcounta}{########1+1}{id}{tempcountb}}%
           }%
         }{},
          for root'={draw tree},
          TeX/.process={Rw{temptoksa}{\otherhiddenparcommand ####1\hiddenparcommand}},
          tempcountb'/.register=tempcounta,
        },
        for nodewalk={%
          draw tree processing order/.style={%
            filter={tree}{>OR>{id}{tempcountb}}%
          }%
        }{},
        for root'={draw tree},
      },
    }%
  },
  split dir here auto/.style n args=2{%
    split dir tree pre,
    !next node.split dir tree auto post=#2,
    split here ids+/.option=id,
%     !next node.split resume here ids+/.option=id,
    split={#1}{,}{split here toks,hide commas},
    split here interjects/.register=split here toks,
  },
  split dir tree auto/.style={%
    split dir tree,
    before drawing tree={%
      tempdima/.max={y}{tree},
      tempdimc/.register=tempdima,
      tempdimd/.min={y}{tree},
      tempdima-/.register=tempdimd,
      tempdimb'=\textheight,
      tmpdima'=10ex,
      tmpdimc'=\pagetotal,
      while={%
        >RR>{tempdima}{tempdimb}%
      }{%
        for nodewalk={%
          root',
          until={%
            > ROw2+d RRw2+d > {tempdimc}{y}{##1-##2} {tmpdima}{tmpdimc}{\textheight-##2-##1}%
          }{next node},
          previous node,
          split dir here auto/.process={R_w2{tmpdima}{continued}{{##2}{##1}}},
          next node,
          tempdima/.option=y,
          tempdimc/.register=tempdima,
          tempdima-/.register=tempdimd,
          tmpdima'=15ex,
          tmpdimc'=0pt
        }{},
      },
    },
  },
}


\begin{document}

% standard one column
\blindtext

% tree in 2 column mode
\twocolumn
%\twocolumngrid
\begin{forest}
  for tree={
    folder,
    grow'=0,
    fit=band,
  },
  split dir tree auto,
  [ XYZ
      [ XYZ
          [ XYZ
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
              ]
          ]
          [ XYZ
              [ XYZ
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
                  [ XYZ ]
              ]
              [ XYZ
                  [ XYZ ]
              ]
          ]
      ]
  ]
\end{forest}

% back to one column
\onecolumn
%\onecolumngrid

\blindtext


\end{document}

Result with \twocolumn:

And Result with ltxgrid and it's \onecolumngrid and \twocolumngrid:

  • 1
    @marmot These desiderata for breaks are extremely difficult especially if the request is for automatic breaks and for non-splitting of nodes. (If you can split nodes, it isn't difficult, but nobody wants to do that for obvious reasons.) – cfr Aug 9 '18 at 2:36
  • @marmot There is a partial success with ltxgrid but it still looks bad. I just copied this characters with the code from related topic so it's weird you can't. However I changed it the in question. – Simon Aug 9 '18 at 6:02
  • @marmot We should likely tidy up here, too. – cfr Aug 12 '18 at 23:45
  • Anyone know why the site lists four questions as linked when there only appears to be one? @marmot – cfr Aug 15 '18 at 12:41
  • I've edited my answer multiple times and am done for now. I've got the edges at the cost of hard-coding them. I don't guarantee it would work if you mixed it with manual splitting, mind, but I take it that's not required here. (So you could remove the interjects code if you wanted.) – cfr Aug 15 '18 at 12:46
7
+500

Code minimally tested.

Caveat emptor

This answers the question the asker apparently meant to ask rather than the original question. As I understand it, desiderata are (1) two columns and (2) tree to start on the same page as the text and for text to start on the last page of the tree i.e. it ought not begin on the following or end on the previous page. This complicates matters since (1) \pagetotal is set to zero within a multicols environment and (2) the temporary dimension must not be set to 0 on the first loop, but the second.

The original code also had a bug, fixed in this version, responsible for the problem shown, which had nothing to do with \twocolumn, but could be triggered just by changing the font to 12pt.

output

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
% arara: pdflatex
\pdfminorversion=7
% ateb: https://tex.stackexchange.com/a/445574/ addaswyd o ateb: http://tex.stackexchange.com/a/356922/ addaswyd o gwestiwn Sebastian Widz: http://tex.stackexchange.com/q/356749/ a chestiwn Simon: https://tex.stackexchange.com/q/445199/
% gweler hefyd forest2-1-dir-tree-split-auto{4,5,6,7}.tex
\documentclass[a4paper,12pt]{article}
\usepackage{geometry,kantlipsum,multicol}% geometry or similar is needed for correct A4 layout
\usepackage[edges]{forest}
% addaswyd o gôd Sašo Živanović: http://tex.stackexchange.com/a/296771/
\def\hiddenparcommand{\par}
\newcommand\otherhiddenparcommand{\par\noindent}
\newcommand\hiddencommacommand{, }
\makeatletter
\forestset{%
  declare keylist register={split here ids},% the list of nodes to split the tree at
  split here ids={},
  declare keylist register={split here interjects},% the list of comments to put in between the tree parts
  split here interjects={},
  declare toks register=split here toks,
  declare dimen register=tmpdima,
  tmpdima'=0pt,
  declare dimen register=tmpdimb,
  tmpdimb'=0pt,
  declare dimen register=tmpdimc,
  tmpdimc'=0pt,
  declare dimen register=tmpdimd,
  tmpdimd'=\textheight,
  declare boolean register={multicols},
  not multicols,
  declare count={split parent id}{0},
  declare count={split descendant id}{0},
  declare count register={split parent id count},
  split parent id count'=0,
  declare toks={split descendant}{},
  declare toks register={split dir tree cont},
  split dir tree cont=continued,
  declare long step={current and preceding parents}{}{filter={current and preceding nodes}{>OO={n children}{n children}}},
  declare keylist={splitter list}{},
  to widest/.style={
    tikz+={\path (\forestregister{tempdima}, \forestoption{y}) -- (\forestregister{tempdimb}, \forestoption{y});},
  },
  hide commas/.style={%
    split here toks+={\hiddencommacommand},
    split here toks+/.option=#1,
  },
  split dir tree pre/.style={%
    label={[text=gray, anchor=north, font=\scriptsize]below:{[cont.]}{}},
    tempcountd/.option=id,
    temptoksc/.option=name,
    for Nodewalk={on invalid=fake}{do until={ > O_ O_ =!=|  {split descendant id}{0} {level}{0}  }{split descendant id/.register=tempcountd, split descendant/.register=temptoksc, previous node}}{},
  },
  split dir tree post/.style={%
    label={[font=\scriptsize, anchor=south, text=gray]above:{[cont.]}{}},
    tikz+/.process={% this draws an edge to the first node after a break
      OOOw+nw3  {edge}{edge label}{id}{##1+1}%
      {%
        \path [##1] (!u.parent anchor |- .north) ++(\forestregister{folder indent},1ex) coordinate (before ##3) |- (.child anchor)##2 ;
      }%
    },
  },
  split dir tree/.code={%
    \forestset{%
      for tree={
        folder,
        grow'=0,
        edge path={},
      },
      tikz+/.process={Ow{id}{\path (.parent anchor) coordinate (before ##1);}},
      draw tree stage/.style={
        for root'={
          tempdima/.min={%
            >OOw2+d{x}{min x}{####1+####2}%
          }{tree},
          tempdimb/.max={%
            >OOw2+d{x}{max x}{####1+####2}%
          }{tree},
          for tree={%
            to widest,
          },
        },
        tempcountb'=-1,
        do until={%
          strequal((split_here_ids),"")
        }{%
          tempkeylistb'={},
          tempkeylista'={},
          split register={split here ids}{,}{tempcounta,tempkeylistb+},
          split register={split here interjects}{,}{temptoksa,tempkeylista+},
          split here ids'/.register=tempkeylistb,
          split here interjects'/.register=tempkeylista,
        % Sašo Živanović: http://chat.stackexchange.com/transcript/message/28484520#28484520
         for nodewalk={%
           draw tree processing order/.style={%
             filter={tree}{> ORw+n< OR> & {id}{tempcounta}{########1+1}{id}{tempcountb}}%
           }%
         }{},
          for root'={draw tree},
          TeX/.process={Rw{temptoksa}{\otherhiddenparcommand ####1\hiddenparcommand}},
          tempcountb'/.register=tempcounta,
        },
        for nodewalk={%
          draw tree processing order/.style={%
            filter={tree}{>OR>{id}{tempcountb}}%west
          }%
        }{},
        for root'={draw tree},
      },
    }%
  },
  split dir here auto/.style={%
    split dir tree pre,
    !next node.split dir tree post,
    split here ids+/.option=id,
    split={#1}{,}{split here toks,hide commas},
    split here interjects/.register=split here toks,
  },
  split dir tree auto/.style={%
    split dir tree,
    before drawing tree={%
%       for tree={tikz+/.process={Ow{id}{\node [blue] at (.child anchor) {##1};}}},
      tempdima/.max={y}{tree},
      tempdimc/.register=tempdima,
      tempdimd/.min={y}{tree},
      tempdima-/.register=tempdimd, % cyfanswm yr y sy'n angen
      tempdimb'=\textheight,
      tmpdima'=10ex,
      not tempboola,
      if multicols={tmpdimc=\textheight-\page@free+\multicolsep, tempboola, split dir tree cont=\relax}{tmpdimc'=\pagetotal},
      tempcounta/.option=id,
      temptoksb/.option=name,
      not tempboolb,
      tempboolc,
      while={%
        >RR>{tempdima}{tempdimb}%
      }{%
        for nodewalk={%
          id/.register=tempcounta,
          temptoksb/.option=name,
          until={%
            > ROw2+d RRRw3+d > {tempdimc}{y}{##1-##2} {tmpdima}{tmpdimc}{tmpdimd}{##3-##2-##1}%
          }{next node, split parent id/.register=tempcounta, split parent id+'=1},
          previous node,
          if={>Pn={forestloopcount}{1}}{tempcounta/.option=id, temptoksd/.option=name, for current and preceding nodes={split descendant id/.register=tempcounta, split descendant/.register=temptoksd,}}{},
          split dir here auto/.register=split dir tree cont,
          next node,
          split parent id/.option=id,
          split parent id+'=1,
          tempcounta/.option=id,
          split parent id count/.option=split parent id,
          tempdima/.option=y,
          tempdimc/.register=tempdima,
          tempdima-/.register=tempdimd,
          tmpdima'=15ex,
          if tempboola={not tempboola}{tmpdimc'=0pt},
          if={>RR&{multicols}{tempboolc}}{% 1 for odd (except first); 0 for evens; split dir tree cont changes next iteration i.e. 1 for evens; 0 for odds
            if tempboolb={
              not tempboolb, split dir tree cont=\relax,
              if={> RR_w3+dRw+d< {tempdima}{tmpdima}{10ex}{##1+##2+##3}{tempdimb}{##1+##1} }{
                not tempboolc,
                split dir tree cont=\relax,
                tempdimb/.process={Rw+d{tempdima}{##1/2}},
                tmpdimd/.register=tempdimb,
                tempdimb+/.register=tmpdima,
                tmpdimd+/.process={Rw+d{tmpdima}{##1/3}},
                tmpdima'=0pt,
              }{},
            }{
              tempboolb, split dir tree cont=continued,
            },
          }{},
        }{},
      },
      where level=0{}{
        if split parent id=0{split parent id/.register=split parent id count}{},
        if={ > OOw+n< {!u.id}{split parent id}{##1-1} }{
          tikz+/.process={ OOOw3 {edge}{edge label}{split parent id} {\path [##1] (!u.parent anchor |- before ##3) ++(\forestregister{folder indent},0pt) |- (.child anchor)##2;}}
        }{
          if={ > OOw+n= {id}{split parent id}{##1-1} }{}{
            tikz+/.process={ OOw2 {edge}{edge label} {\path [##1] (!u.parent anchor) ++(\forestregister{folder indent},0pt) |- (.child anchor)##2;}}
          },
        },
      },
      where n children=0{}{ 
        if={ > OO> {!l.id}{split descendant id} }{
          tikz+/.process={ OOw2 {edge}{split descendant} { \path [##1] (.parent anchor) ++(\forestregister{folder indent},0pt) coordinate (a) -- (a |- ##2.parent anchor) -- ++(0pt,-1ex);  }
          },
        }{},
      },
      split register={split here ids}{,}{splitter split},
    },
  },
  splitter split/.style={
    for nodewalk={id=#1}{
      tempcounta/.option=id,
      tempcountc/.option=split parent id,
      tempkeylista'=,
      for filter={current and preceding nodes}{>O_>{n children}{0}}{
        if={> OR > OR < & {!l.id}{tempcounta} {id}{tempcountc}  }{
          tempkeylista+/.option=name,
        }{},
      },
      splitter list/.register=tempkeylista,
      tikz+/.process={ 
        OOw2{split parent id}{edge}{
          \edef\tempa{\foresteoption{splitter list}}
          \foreach \i in \tempa {\path [##2] (\i.parent anchor |- before ##1) ++(\forestregister{folder indent},0pt)  coordinate (b) -- (.parent anchor -| b) -- ++(0,-1ex); }
        }
      },
    },
    if nodewalk valid={next}{temptoksa/.option=!next.name}{temptoksa'={}},
  },
}
\makeatother
\begin{document}

\kant[1-2]


\begin{multicols}{2}
\begin{forest}
  split dir tree auto,
  multicols,
  [0. XYZ [1. XYZ [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ [4. XYZ] [4. XYZ] ] [3. XYZ [4. XYZ] [4. XYZ] ] ] [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] ] [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] ] [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] ] [2. XYZ [3. XYZ] [3. XYZ] ] [2. XYZ] [2. XYZ] ] [1. XYZ] [1. XYZ [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] ] ] [1. XYZ [2. XYZ [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] ] [2. XYZ [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] ] [2. XYZ [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] ] [2. XYZ [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] [3. XYZ] [3. XYZ [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] [4. XYZ] ] ] [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] ] [2. XYZ [3. XYZ] ] ] [1. XYZ [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] ] [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] ] [2. XYZ [3. XYZ] [3. XYZ] [3. XYZ] [3. XYZ] ] ] [1. XYZ [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] ] [1. XYZ [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] ] [1. XYZ] [1. XYZ [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] [2. XYZ] ] ]
\end{forest}
\end{multicols}
\clearpage

\kant[1-2]    

\begin{multicols}{2}
\begin{forest}
  split dir tree auto,
  multicols,
  [XYZ[XYZ[XYZ[XYZ[XYZ]]][XYZ[XYZ[XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ]][XYZ[XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ]][XYZ[XYZ][XYZ][XYZ]]][XYZ[XYZ[XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ][XYZ]][XYZ[XYZ][XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ]][XYZ[XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ]]][XYZ[XYZ[XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ][XYZ][XYZ]]][XYZ[XYZ[XYZ]][XYZ[XYZ]]][XYZ[XYZ[XYZ]]][XYZ[XYZ[XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ][XYZ][XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ]]][XYZ[XYZ[XYZ][XYZ][XYZ][XYZ][XYZ][XYZ]][XYZ[XYZ]]]]]
\end{forest}
\end{multicols}

\kant[1]    
\end{document}
  • Let us continue this discussion in chat. – cfr Aug 11 '18 at 1:34
  • @marmot Please see edit above. Also, I cleaned up my comments here as they're better in the chat, really. – cfr Aug 12 '18 at 23:43
  • It looks much better now but still not perfect. I need it without page break when switching between one and two column layout. And I noticed that some connections between nodes disappeared due to splitting tree. – Simon Aug 15 '18 at 19:37
  • 1
    @Simon Well, you didn't say that.You said explicitly 'It should start on the first page after text and end equally on the last page.' Clearly, you want a page break before the tree if it is to start on the first page after the text. It isn't clear what 'equally on the last page' means, but the context suggests symmetrical i.e. page break after tree before more text. If you wanted something else, you should have asked for that. I answered the question you posed. Moreover, the edges can't disappear because they're never drawn. All nodes have appropriate connections to them as far as I can see. – cfr Aug 16 '18 at 2:02
  • 1
    Thank you very much. Your solution is great :) I will correct the question so as to remove ambiguities and to match with what I expected. – Simon Aug 21 '18 at 7:43

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.