In the following code, I write two macros for \begin{enumerate}...\end{enumerate}. In trying to get more than one optional argument, I used the method in More than one optional argument for newcommand. However, when I add an extra linebreak between \items, the \NewDocumentCommand macro fails while the original \begin{enumerate}...\end{enumerate} is fine, and \newcommand macro is also fine.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
% if do enumitem before enumerate, cause error????? https://tex.stackexchange.com/questions/238691/enumitem-always-throwing-errors
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\newcommand{\myenumerate}[2][4]{\begin{enumerate}[(a), leftmargin=0.2in,parsep=0pt,itemsep=#1pt]
#2
\end{enumerate}}
\NewDocumentCommand{\myenumeratebad}{ O{10} O{a} m }{\begin{enumerate}[(#2),leftmargin=0.3in,parsep=0pt,itemsep=#1pt,topsep=8pt]
#3
\end{enumerate}}
\begin{document}
\begin{enumerate}[(i),leftmargin=0.3in,parsep=0pt,itemsep=4pt,topsep=8pt]
\item awef
\item awef
\end{enumerate}
\myenumerate[10]{
\item awe
\item awf
}
\myenumeratebad[10][i]{
\item awe
\item awf
}
\myenumeratebad[10][i]{
\item awe
\item awf
}
\end{document}
P.S. in making my MWE, there was an issue putting enumitem before enumerate, but not the other way around. I only learned about this from a comment here Enumitem always throwing errors.
enumerateat all. If you have two packages one does\def\qqq{a}the other does\def\qqq{b}then you can not load both packages and have\qqqmagically beaandbat the same time. You loadenumitemsecond so it wins and loadingenumeratefirst just makes things slower. – David Carlisle Oct 05 '22 at 15:58