买者自负

买者自负

@cfr 制作了一幅令人惊叹的森林树,它延伸了好几页这个很好的答案。这是一项了不起的成就,因为它有效地传播了 TiZ 图片分布在几页上。(当然,从技术上讲,tikzpicture每页只有一张,更准确的说法是,巨幅图片的内容tikzpicture分布在几页上。)我还没见过其他帖子能做到这一点。

如果看一下结果,就会发现由于树非常窄,一些空间显然被“浪费”了。因此,人们可能想知道是否可以在具有两列的文档中执行此操作。

关于此问题非常相似,它有一个 MWE 可以玩。这个问题和我的问题的区别在于,我正在寻找一个使用 switch 的解决方案\twocolumn,而在这个问题multicols要求使用解决方案。我不会提供 MWE(除非我被要求)因为这个很好的答案除开关外,其中已包含所有东西twocolumn

请注意,我知道 @cfr 能够做到这一点。我提出“问题”的目的是找到一种方法来与社区分享这个令人惊叹的代码。我不想为此获得任何荣誉(因为我不值得),所以如果你有投票,请将它们用在答案上,而不是我的问题上。请注意,如果你不是 @cfr 并且正在阅读这篇文章并且有一个聪明的解决方案,我当然也会对它非常感兴趣。

答案1

marmot 要求的答案在下面的“原始答案”中给出。这个答案有点不同。

下面的代码尝试

  1. 替换更多边
  2. 仅在右侧列添加“继续”
  3. 即使树在同一页上开始/结束(其中文本也是双列)也能工作
  4. 保留该multicols选项,但不会在编译中添加任何重要的内容(我认为)
  5. 即使一棵树直接跟在另一棵树后面也能工作(可能很脆弱?我让它工作了,但我不确定我找到了根本原因)

此代码自行判断是否处于twocolumn模式,如果处于模式,则判断是位于左列还是右列。至少理论上如此。

买者自负

更新输出

% atebion: https://tex.stackexchange.com/a/44557,84,446899 addaswyd o ateb: http://tex.stackexchange.com/a/356922/ addaswyd o gwestiwn Sebastian Widz: http://tex.stackexchange.com/q/356749/ a chestiynnau Simon: https://tex.stackexchange.com/q/445199/ a marmot: https://tex.stackexchange.com/q/446759/
% gweler hefyd forest2-1-dir-tree-split-auto{4,5,6,7,8}.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 boolean register={two column},
  not two column,
  declare boolean register={first column},
  not first column,
  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={%
    \hskip0pt\otherhiddenparcommand
    \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,
    TeX={%
      \if@twocolumn\forestset{two column}\else\forestset{not two column}\fi
    },
    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,
      tempcounta/.option=id,
      temptoksb/.option=name,
      not tempboolb,
      tempboolc,
      if two column={
        tmpdimc/.process={dd>?d {\pagetotal}{\@colht}{\pagetotal-\@colht}{\pagetotal}},
        TeX={\if@firstcolumn\ifdim\pagetotal>\@colht\forestset{not first column}\else\forestset{first column}\fi\else\ifdim\pagetotal>\@colht\forestset{first column}\else\forestset{not first column}\fi\fi},
      }{
        if multicols={tmpdimc=\textheight-\page@free+\multicolsep, tempboola, split dir tree cont=\relax}{tmpdimc'=\pagetotal},
      },
      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,}}{},
          if two column={if first column={split dir tree cont=\relax, not first column}{split dir tree cont=continued, first column}}{},
          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}
\twocolumn
\kant[1-2]


\begin{forest}
  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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.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}


\kant[2]    
\end{document}

原始答案

此代码对所有边进行硬编码,并忽略一些节点选项变体。但是,它会替换来自节点的边以及到节点的边。至少,它目前替换了一些,希望很快就会替换其他。

输出

完整代码:

\documentclass[a4paper,12pt]{article}
\usepackage{geometry,blindtext}% 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{, }
\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 count={split parent id}{0},
  declare count={split descendant id}{0},
  declare toks={split descendant}{},
  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+={#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={%
      tempdima/.max={y}{tree},
      tempdimc/.register=tempdima,
      tempdimd/.min={y}{tree},
      tempdima-/.register=tempdimd, % cyfanswm yr y sy'n angen
      tempdimb'=\textheight,
      tmpdima'=10ex,
      tmpdimc'=\pagetotal,
      tempcounta/.option=id,
      temptoksb/.option=name,
      while={%
        >RR>{tempdima}{tempdimb}%
      }{%
        for nodewalk={%
          id/.register=tempcounta,
          temptoksb/.option=name,
          until={%
            > ROw2+d RRw2+d > {tempdimc}{y}{##1-##2} {tmpdima}{tmpdimc}{\textheight-##2-##1}%
          }{next node, split parent id/.register=tempcounta, split parent id+'=1},
          previous node,
          split dir here auto=continued,%tmpdima,
          next node,
          split parent id/.option=id,
          split parent id+'=1,
          tempcounta/.option=id,
          tempcountb/.option=split parent id,
          tempdima/.option=y,
          tempdimc/.register=tempdima,
          tempdima-/.register=tempdimd,
          tmpdima'=15ex,
          tmpdimc'=0pt,
        }{},
      },
      where level=0{}{
        if split parent id=0{split parent id/.register=tempcountb}{},
        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);  }
          },
        }{},
      },
      temptoksa/.option=!r.name,
      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'={}},
  },
}
\begin{document}
\blindtext
\twocolumn

\begin{forest}
  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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