How to pass argument to an environment in command form

I have defined

\newenvironment{cvolist}[1][2.25cm]{\setlength{\pwd {#1}\enumerate}
{\endenumerate \aftergroup\ignorespacesafterend\vspace{-1.5em}}


That way I can have a list in an environment (this may sound complicated and it is but it is part of a bigger project that I do not control, so do not argue with the complication, please).

What I would really like to write is

\newenvironmenth{cvolist}[1][2.25cm]{\setlength{\pwd}{#1}\enumerate[leftmargin=2cm]}
{\endenumerate \aftergroup\ignorespacesafterend\vspace{-1.5em}}


so that I can actually choose the left margin for the items. However, this gives an error when I call the \item (without the argument for enumerate I get no error).

Any idea on how I can pass an argument in command form?

I write in command form because I have read that nested environments give errors.

• \setlist[enumerate]{leftmargin=2cm} before calling \enumerate? – TeXnician May 1 '18 at 17:06
• Thanks @TeXnician, but I am afraid what that does is printing [enumerate]leftmargin=2cm just before the list starts. – Jesus Martinez Garcia May 1 '18 at 17:09
• Are you doing \usepackage{enumitem}? Where did you learn \aftergroup\ignorespacesafterend? – egreg May 1 '18 at 17:20
• It would be very helpful to have a compilable example rather than this snippet. Then we could test real suggestions. – TeXnician May 1 '18 at 17:26
• Thank you @egreg I was missing calling enumitem package. Now Texnician's solution works. As for the \aftergroup stuff, I am really modifying an old cls file which was given to us at an old job to format our CVs consistenly. – Jesus Martinez Garcia May 1 '18 at 17:26