Skip to main content
Added "external-files" tag to the question
Link
Source Link

Generating a list with macros using tasks package

I cannot figure out how to generate a list with the tasks package using macros.

If you swap the three identified lines in the MWE below, you should get the following error message: \begin{tasks} on input line 25 ended by \end{document}

Notice that the use of the enumitem and the xparse packages (along with the fancy macro definitions) don't seem to have any effect on the issue (I've tried without both packages, using only LaTeX2e's \newcommand).

Any ideas how to fix this issue (i.e. make a macro-generated tasks)? Any insight as to why this is happening would also be appreciated!

\documentclass[letterpaper, 12pt]{article}

\usepackage{enumitem}
\usepackage{tasks}
\usepackage{xparse}

\NewDocumentCommand{\macone}{s O{} +g +g}{%
  \begin{enumerate}
  %\begin{tasks}%  %% <-- USE THIS INSTEAD OF LINE ABOVE
}

\NewDocumentCommand{\mactwo}{s O{} +g +g}{%
  \item #3
  %\task #3%  %% <-- USE THIS INSTEAD OF LINE ABOVE
}

\NewDocumentCommand{\macthree}{s O{} +g +g}{%
  \end{enumerate}
  %\end{tasks}%  %% <-- USE THIS INSTEAD OF LINE ABOVE
}

\begin{document}

\macone
\mactwo{Testing 123}
\macthree

\end{document}