I'm able to generate a complex tree item in LaTeX with dirtree manually (see MWE below). In order to avoid the recurrent repetition of code, I tried to set the declaration of each tree item within a LaTeX command. However, I get the error ! Use of \next doesn't match its definition.
Here the expected result:

Here the minimum working example (MWE) without the use of command:
\documentclass[8pt]{scrartcl}
\usepackage{dirtree}
\usepackage{floatrow}
\usepackage{blindtext}
\thisfloatsetup{%
objectset=raggedright,
}
\begin{document}
\dirtree{%
.1 node1 \hfill \begin{minipage}[t]{1cm}
{ }
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
long comment multiline line number 1
\end{minipage}.
.2 node2 \hfill \begin{minipage}[t]{1cm}
type 0
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
long comment multiline line number 2
\end{minipage}.
.3 leaf1 \hfill \begin{minipage}[t]{1cm}
type 1
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
long comment multiline line number 3
\end{minipage}.
.3 leaf2 \hfill \begin{minipage}[t]{1cm}
type 1
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
long comment multiline line number 4
\end{minipage}.
.2 node3 \hfill \begin{minipage}[t]{1cm}
type 0
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
very very very very long comment multiline line number 5
\end{minipage}.
.3 leaf3 \hfill \begin{minipage}[t]{1cm}
type 2
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
long comment multiline line number 6
\end{minipage}.
.3 leaf4 \hfill \begin{minipage}[t]{1cm}
{}
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
no type specified
\end{minipage}.
}
\end{document}
Here the attempt of defining a command \treedef to avoid the repetition of redundant code
\documentclass[8pt]{scrartcl}
\usepackage{dirtree}
\usepackage{floatrow}
\usepackage{blindtext}
% #1: Level
% #2: Name
% #3: Type
% #4: Comment
\newcommand{\treedef}[4]{
.{#1} {#2} \hfill \begin{minipage}[t]{1cm}
{#3}
\end{minipage} \hfill \begin{minipage}[t]{3.5cm}
{#4}
\end{minipage}.
}
\thisfloatsetup{%
objectset=raggedright,
}
\begin{document}
\dirtree{%
\treedef{1}{node1}{}{long comment multiline line number 1}
\treedef{2}{node2}{type 0}{long comment multiline line number 2}
\treedef{3}{leaf1}{type 1}{long comment multiline line number 3}
\treedef{3}{leaf2}{type 1}{long comment multiline line number 4}
\treedef{2}{node3}{type 0}{very very very very long comment multiline line number 5}
\treedef{3}{leaf3}{type 2}{long comment multiline line number 6}
\treedef{3}{leaf4}{}{no type specified}
}
\end{document}
\dirtreemacro does not expand things inside it, which makes the user-defined macro not expanded. ■ Be careful with%and spaces: https://tex.stackexchange.com/questions/7453/ – user202729 Feb 16 '23 at 08:56