# [Tex/LaTex] Optional Parameters in xparse: \IfBooleanTF vs \IfNoValueTF

macrosoptional argumentsxparse

I tend to get \IfBooleanTF and \IfNoValueTF (and the other similar macros) mixed up and wondering which is the correct ones to use for the following optional parameters:
s,
o,
d,
g,
k_ (and k^) and
t_ (and t^).
From the documenation it seems that one should use:

• \IfBooleanTF: s, t
• \IfNoValueTF: o, d, g, k

## Questions:

1. Is the above list of macros to use correct?
2. What is the intention of distinguishing between \IfBooleanTF and \IfNoValueTF? Wouldn't it make sense to just have one macro that does both jobs? Or, is there a case where a distinction is required? t and k using different macros is especially confusing to me.

My reason for asking is: If I can understand the logic behind this, perhaps I'll be able to remember to use the correct ones.

## References:

Yes, the above is correct.

The two cases are logically distinct as you are passing different information. The aim of xparse is to make this structural information clear.

For \IfBoolean(TF), the argument is a single token which can only be one of two values: TRUE and FALSE. A value is always returned by the t (and s) argument types, and the test is there to see which it is. One may also reverse the logic returned here using \ReverseBoolean: the presence of the token does not have to map to logically TRUE.

\DeclareDocumentCommand \foo { >{ \ReverseBoolean } s }
{
\IfBooleanTF #1
{ Star not present }
{ Star present }
}


On the other hand, argument types which grab 'some tokens' may not be present (so yield \NoValue), be present-but-empty or be present-and-non-empty. The logic that something is present cannot be reversed so \IfNoValue will always be true only if the optional argument was not given at all.

The k-type argument has recently been adjusted: you now want e-type. This one is somewhat specialised and the team have had quite a bit of discussion about the correct form here.