In my continued search for various ways of creating conditional text, I'm looking for a good way to handle a case statements. One way of handling it is to use nested if statements, but the more cases your have the uglier/more-cumbersome it becomes, and I am also getting a weird spacing issue where the text is placed (large spacing after the colon).
Is there a smarter way of handling this?
Thank you for taking the time to read and reply,
Alan
Example nested statement, spacing issue
Code: Select all
\documentclass{article}
\usepackage{etoolbox}
\begin{document}
\newbool{customer1}
\newbool{customer2}
%...
\newbool{customerN}
This is general text all customers get.
\booltrue{customer1}
This is special information:
\ifboolexpr{bool{customer1}}{
customer1 specific information
}{
\ifboolexpr{bool{customer2}}{
customer2 specific information
}{
\ifboolexpr{bool{customer2}}{
customerN specific information
}{
No previous customers were matched
}}}
\boolfalse{customer1}
\booltrue{customerN}
Notice the larger spacing after the colon using customerN
This is special information:
\ifboolexpr{bool{customer1}}{
customer1 specific information
}{
\ifboolexpr{bool{customer2}}{
customer2 specific information
}{
\ifboolexpr{bool{customerN}}{
customerN specific information
}{
No previous customers were matched
}}}
\bigskip
If the text is on a new line, no spacing issue
\booltrue{customer1}
\boolfalse{customerN}
\ifboolexpr{bool{customer1}}{
customer1 specific information
}{
\ifboolexpr{bool{customer2}}{
customer2 specific information
}{
\ifboolexpr{bool{customer2}}{
customerN specific information
}{
No previous customers were matched
}}}
\boolfalse{customer1}
\booltrue{customerN}
\ifboolexpr{bool{customer1}}{
customer1 specific information
}{
\ifboolexpr{bool{customer2}}{
customer2 specific information
}{
\ifboolexpr{bool{customerN}}{
customerN specific information
}{
No previous customers were matched
}}}
\end{document}