-1

I have the following environment taking four arguments, the latter two being optional. Things look as expected. Would I have to test for #4 in my case ?

\NewDocumentEnvironment{Statement}{mmoO{orange}}
  {
    \IfNoValueTF {#3}
        { \noindent #1 \ #2 \, }
      { \noindent #1 \ #2 \ (#3)
        \vspace{0.1cm} \par \noindent \ignorespaces }
    \color{#4}
  }
  { \vspace{0.3cm} }
2

1 Answer 1

3

You don't have to test for #4 as it's never empty it will always have a value, but you can not change that value from orange without also setting #3 as you have made the adjacent options #3 and #4 both optional.

It would be better to make the color #1

\NewDocumentEnvironment{Statement}{O{orange}mmo}

Then:

A blue statement with no title

\begin{Statement}[blue]{aa}{bb}

A red statement with (title)

\begin{Statement}[red]{aa}{bb}[title]

A statement with default color and a title

\begin{Statement}{aa}{bb}[title]


With this structure the two options can be set independently.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .