Say I want to define an environment like "color description" which would be the same as "description" except that one could add an optional color background to the label: \begin{colordescription}[red] ...
My question is inspired by the following: description (at least with enumitem
) also has "normal" optional arguments (e.g. [style=...]
) so, to ensure the new "colordescription" environment works the same way, I'd need to place the new optional arguments before (or after) the known ones, like \begin{colordescription}[red][style=...]
.
I'd like to visually separate the "new" optionals, which is why I thought of syntax like \begin{colordescription}<red>[style=...]
: I think there are few occasions where the body of an environment would start with <
, so the angle brackets wouldn't be confused with regular text. Maybe there's a way to consume the character after \begin{...}
and do a special parse if this character is a <
?
xparse
: it enables you to defines commands or environments with various types of arguments, among which thed
type (argument with delimiters). – Bernard Mar 12 '20 at 14:25