1

I have got a forest in two subfloats as bellow:

\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}

where did I miss a tab, extra column, etc that I am getting this error:

extra alignment tab has been changed to cr
10
  • Please post complete code we can (try to!) compile!
    – cfr
    Commented Aug 28, 2016 at 15:13
  • done @cfr. Sorry
    – Amir
    Commented Aug 28, 2016 at 15:33
  • @amir That's not complete code; it's still a fragment. Complete code includes \documentclass{...} and \begin/end{document}.
    – Alan Munn
    Commented Aug 28, 2016 at 15:57
  • 1
    Note that you should not give h as the sole specifier to a float ever. It means 'put it here, if there's room'. What if there isn't room? Then there is nowhere to put it at all!
    – cfr
    Commented Aug 29, 2016 at 0:10
  • 1
    Are you really trying to split the tree into two columns? If so, see my edit below (also for a simpler, updated definition of dir tree).
    – cfr
    Commented Aug 29, 2016 at 0:53

1 Answer 1

1

Ampersands must be preceded by backslashes outside array, tabular etc. environments and within those environments if an ampersand should be typeset.

\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}

directory contents listing

Note that current Forest provides built-in methods for drawing this type of tree and dir tree is no longer necessary or may be significantly simplified.

The following example updates dir tree to a very simple definition using the new library and demonstrates how to split the tree into two columns, since I gather that maybe what you are really trying to do with the sub-floats.

Rather than splitting the tree, we simply move part of it to another position and alter the edge path where necessary.

\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}

split tree

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .