Define a custom description environment

descriptionenumitemenvironmentslists

I want to define a new "custom-description" environment, say my description that taken in one length argument and produces the result that is achieved by the following code:

\documentclass{article}

\usepackage{enumitem}
\usepackage{calc}

\begin{document}
    
    Here's some text before the list.
    
    \begin{description}[align=right, itemindent=0cm, leftmargin=\labelsep+3cm, font=\ttfamily]
        \item [The first item] Math is so good!
        \item [Here's the second one!] Let's do some math!
    \end{description}

    And here's something for after the list.
    
\end{document}

Here, in leftmargin=3cm+\labelsep, 3cm is where I want to pass my "length" parameter.

The output of the above code looks like this:

enter image description here

Another thing: It'd be super convenient if I can also pass another parameter to control the value font among \ttfamily, bfseries, etc.

Best Answer

Just

% definition
\NewDocumentEnvironment{my desp}{ m m }{%
  \begin{description}[align=right, itemindent=0cm, leftmargin=\labelsep+#1, font=#2]
}{
  \end{description}%
}

% usage
\begin{my desp}{3cm}{\ttfamily}
  \item ...
  \item ...
\end{my desp}

?

Full example

\documentclass{article}
\usepackage{enumitem}
\usepackage{calc}

\NewDocumentEnvironment{my desp}{ m m }{%
  \begin{description}[align=right, itemindent=0cm, leftmargin=\labelsep+#1, font=#2]
}{
  \end{description}%
}

\begin{document}
    
    Here's some text before the list.
    
    \begin{description}[align=right, itemindent=0cm, leftmargin=\labelsep+3cm, font=\ttfamily]
        \item [The first item] Math is so good!
        \item [Here's the second one!] Let's do some math!
    \end{description}

    And here's something for after the list.
    
    \begin{my desp}{3cm}{\ttfamily}
        \item [The first item] Math is so good!
        \item [Here's the second one!] Let's do some math!
    \end{my desp}
\end{document}

enter image description here