dirtree 编译问题(额外的对齐标签已更改为 \cr)

dirtree 编译问题(额外的对齐标签已更改为 \cr)

我有两个子浮点数的森林,如下所示:

\documentclass[prodmode,acmtecs]{acmsmall} % Aptara syntax

% Package to generate and customize Algorithm as per ACM style
\usepackage[ruled]{algorithm2e}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage{bm}
\usepackage{rotating}
\usepackage{tablefootnote}
\usepackage{array}
\usepackage{multirow}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\renewcommand{\algorithmcfname}{ALGORITHM}
\SetAlFnt{\small}
\SetAlCapFnt{\small}
\SetAlCapNameFnt{\small}
\SetAlCapHSkip{0pt}
\IncMargin{-\parindent}
\include{definitions}

% DOI
\doi{0000001.0000001}

%ISSN
\issn{1234-56789}

% Document starts
\begin{document}


\forestset{
  dir tree/.style={
    for tree={
      parent anchor=south west,
      child anchor=west,
      anchor=mid west,
      inner ysep=-3pt,
      grow'=0,
      align=left,
      edge path={
        \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) ++(1em,0) |- (.child anchor)\forestoption{edge label};
      },
      %font=\sffamily,
      if n children=0{}{
        delay={
          prepend={[,phantom, calign with current]}
        }
      },
      fit=rectangle,
      before computing xy={
        l=2em
      }
    },
  }
}
\begin{figure}[h!]
\centering

\subfloat{
\label{fig:contribution_left}
\begin{forest}
  dir tree
  [\textbf{Paper Organization} 
    [\textbf{\pmb{\S} \ref{sec:promises and challenges} Promises and challenges}
        [optimization benefits]
        [Optimization space
            [The selection]
            [The phase-ordering]    
        ]    
    ]    
    [\textbf{\pmb{\S} \ref{sec:characterization techniques} Characterization}
      [Hybrid]
      [Dimension Reduction Techniques
        [Principal Component Analysis]
      ]
    ]
  ]
\end{forest}}

\subfloat{
\label{fig:contribution_right}
\begin{forest}
  dir tree
  [
   [\textbf{\pmb{\S}  \ref{sec:predication_classes}  Prediction Classifications}
      [Feature predictors]
   ]
   [\textbf{\pmb{\S} \ref{sec:DSE} Design Space Exploration}            
        [Compilation]   
   ]
   [\textbf{\pmb{\S} \ref{sec:Target Domain} Target Domain}
      [Target architecture
          [Embedded systems]
          [Workstations & HPC domain]
      ]
      [Target Compiler 
          [GCC]
      ] 
    ] 
     [\textbf{\pmb{\S} \ref{sec:Evaluations} Evaluations}
        [Performance comparisons]     
     ]
    % [\textbf{\pmb{\S} \ref{sec:conclusion} Conclusion and future challenges}]
  ]
\end{forest}}
\caption{Organization of the paper in different sections}
\end{figure}

\end{document}

我在哪里错过了标签、额外的列等等,导致出现此错误:

extra alignment tab has been changed to cr

答案1

array在“与”符号之外,tabular以及在需要排版“与”符号的情况下,在这些环境内,“与”符号前面必须加上反斜杠。

\documentclass{article}
\usepackage{forest}
\usepackage{subfig}
\usepackage{amsmath}
\forestset{
  dir tree/.style={
    for tree={
      parent anchor=south west,
      child anchor=west,
      anchor=mid west,
      inner ysep=-3pt,
      grow'=0,
      align=left,
      edge path={
        \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) ++(1em,0) |- (.child anchor)\forestoption{edge label};
      },
      %font=\sffamily,
      if n children=0{}{
        delay={
          prepend={[,phantom, calign with current]}
        }
      },
      fit=rectangle,
      before computing xy={
        l=2em
      }
    },
  }
}
\begin{document}
\begin{figure}[h!]
\centering

\subfloat{%
% \label{fig:contribution_left}% no point in using a label here
\begin{forest}
  dir tree
  [\textbf{Paper Organization}
    [\textbf{\pmb{\S} \ref{sec:promises and challenges} Promises and challenges}
        [optimization benefits]
        [Optimization space
            [The selection]
            [The phase-ordering]
        ]
    ]
    [\textbf{\pmb{\S} \ref{sec:characterization techniques} Characterization}
      [Hybrid]
      [Dimension Reduction Techniques
        [Principal Component Analysis]
      ]
    ]
  ]
\end{forest}
}

\subfloat{%
\begin{forest}
  dir tree
  [
   [\textbf{\pmb{\S}  \ref{sec:predication_classes}  Prediction Classifications}
      [Feature predictors]
   ]
   [\textbf{\pmb{\S} \ref{sec:DSE} Design Space Exploration}
        [Compilation]
   ]
   [\textbf{\pmb{\S} \ref{sec:Target Domain} Target Domain}
      [Target architecture
          [Embedded systems]
          [Workstations \& HPC domain]
      ]
      [Target Compiler
          [GCC]
      ]
    ]
     [\textbf{\pmb{\S} \ref{sec:Evaluations} Evaluations}
        [Performance comparisons]
     ]
%     % [\textbf{\pmb{\S} \ref{sec:conclusion} Conclusion and future challenges}]
  ]
\end{forest}
}
\caption{Organization of the paper in different sections}\label{fig:contributions}% label needs to follow caption
\end{figure}
\end{document}

目录内容列表

请注意,当前的 Forest 提供了绘制此类树的内置方法,dir tree不再需要或可能会显著简化。

下面的示例dir tree使用新库更新为一个非常简单的定义,并演示了如何将树分成两列,因为我知道这也许是您真正想用子浮点数做的事情。

我们不需要分割树,而只需将其一部分移动到另一个位置并edge path在必要时进行修改。

\documentclass{article}
\usepackage[edges]{forest}
\usepackage{amsmath}
\forestset{%
  dir tree/.style={%
    for tree={%
      folder,
      grow'=0,
      s sep'-=5pt,
    },
    where={level()<2}{font=\bfseries}{},
  },
}
\begin{document}
\begin{figure}% never use h as the sole specifier
\centering
\begin{forest}
  dir tree
  [Paper Organization
    [\pmb{\S} \ref{sec:promises and challenges} Promises and challenges
        [optimization benefits]
        [Optimization space
            [The selection]
            [The phase-ordering]
        ]
    ]
    [\pmb{\S} \ref{sec:characterization techniques} Characterization
      [Hybrid]
      [Dimension Reduction Techniques
        [Principal Component Analysis]
      ]
    ]
    [\pmb{\S}  \ref{sec:predication_classes}  Prediction Classifications,
      before drawing tree={%
        tempdima/.max={(x)+(max_x)}{r,tree},
        tempdimb={y("!r1")-y()},
        for current and following nodes={%
          x+/.register=tempdima,
          y+/.register=tempdimb,
        },
        for current and following siblings={%
          edge path'={%
            (!r.parent anchor) +({\forestregister{tempdima}+\forestregister{folder indent}},0) |- (.child anchor)
          },
        },
      }
      [Feature predictors]
    ]
    [\pmb{\S} \ref{sec:DSE} Design Space Exploration
        [Compilation]
    ]
    [\pmb{\S} \ref{sec:Target Domain} Target Domain
      [Target architecture
          [Embedded systems]
          [Workstations \& HPC domain]
      ]
      [Target Compiler
          [GCC]
      ]
    ]
    [\textbf{\pmb{\S} \ref{sec:Evaluations} Evaluations}
        [Performance comparisons]
    ]
  ]
\end{forest}
\caption{Organization of the paper in different sections}\label{fig:contributions}% label needs to follow caption
\end{figure}
\end{document}

分裂树

相关内容