[Tex/LaTex] etoolbox: environment hooks in boolean switch


What did I wrong, that the following does not work here:

(Edit: I mixed up the true and false parts, but I don't want to change the code, because the answers refer to this in a way confusing one.)






\ifbool{tightspace}{% true part empty - should do nothing
}{% false part:




Because of \textcolor{black}{\itshape{\textbackslash}setbool\{tightspace\}\{true\}}
the line spacing should be very narrow ...
Don't wonder at \textcolor{red}{the missing line breaks:}

And now, with \textcolor{black}{\itshape{\textbackslash}setbool\{tightspace\}\{false\}},
it should have \textcolor{red}{the document's line stretch ...}



It seem's, that the boolean switch has no effect – or is there another thing I didn't realize?

Best Answer

You check the boolean switch once in the preamble and make the definition, which is not changed later.

It would work as expected if you would make the test later, such as:


However, I would make the spacing value a variable instead. And I guess you meant your tightspace check the other way round as in the original code.