0

I am trying to write a macro like this:

\usePackage{xparse}
\NewDocumentEnvironment{myenv}{}
  {
    \NewDocumentCommand{\myarrow}{g}{\IfNoValueTF{#1}{\to}{\xrightarrow{#1}}}
    \begin{enumerate}
  }
  {\end{enumerate}}

But I got the error:

/usr/local/texlive/2021/texmf-dist/tex/latex/base/report.cls:26: Illegal parameter number in definition of \environment myenv code. [  {\end{enumerate}}]

How to avoid this illegal parameter error..? I want to make LaTeX recognize #1 as the parameter of myarrow, not of myenv. I tried to resolve it with \expandafter, but failed and I have no idea what to do...

Thank you.

0 Answers0