3

I use this code to check for existing column style (see also this question)

But it fails as soon as I load the package boolexpr. Is this incompatible with etoolbox?

\documentclass[]{scrbook}

\RequirePackage{etoolbox}
\makeatletter
\expandafter\let\csname columntype@p\endcsname\@empty
\newcommand\CheckIfColumntypeDefined[1]{%
  \providebool{tpl@coltype@#1}
  \ifcsdef{NC@find@\string#1}%
    {\setbool{tpl@coltype@#1}{true}}%
    {\ifcsdef{columntype@\string#1}
      {\setbool{tpl@coltype@#1}{true}}%
      {\setbool{tpl@coltype@#1}{false}}%
    }%
}
\newcommand\isColumntypeDefined[1]{tpl@coltype@#1}
\newcommand\IfColumntypeDefined[3]{%
  \CheckIfColumntypeDefined{#1}
  \ifboolexpr{ bool{\isColumntypeDefined{#1}} }{#2}{#3}%
}
\makeatother

\RequirePackage{boolexpr}

\begin{document}
\IfColumntypeDefined{p}{p column defined}{p not defined}%
\end{document}
4
  • 1
    Since both define \ifboolexpr, I guess they don't go well together. :(
    – egreg
    Jan 20, 2012 at 21:11
  • 3
    That's because both define similar commands. Why do you need boolexpr?
    – Werner
    Jan 20, 2012 at 21:11
  • @Werner: for a switch structure as linked in the comment of the first answer. Jan 20, 2012 at 21:59
  • @MatthiasPospiech: If you use the load order \RequirePackage{boolexpr}\let\ifboolexpr\relax\RequirePackage{etoolbox}, can you still use the switch structure? I don't have an example to test.
    – Werner
    Jan 20, 2012 at 22:06

1 Answer 1

5

I answer this question also in relation to the commands. First of all both packages define the command \ifboolexpr. The package boolexpr overwrite the existings definition by his own. This can be seen by the warning message defined in line 78 of boolexpr.sty

\PackageWarning{boolexpr}{\string\ifboolexpr\space has been defined
                          by etoolbox (I suppose) - Overwritting}

So your test which works with etoolbox fails because at the point of executing the definition of the package boolexpr will be used. The package boolexpr isn't such stable as etoolbox.

I recommend the using of etoolbox instead of boolexpr.

3
  • I use boolexp only because it provides a nice switch syntax (see tex.stackexchange.com/questions/29133/…) which etoolbox does not provide. Jan 20, 2012 at 21:47
  • @MatthiasPospiech: For such things I use xifinlist provided by etoolbox. (similar to ifstreq) Jan 21, 2012 at 9:37
  • @MatthiasPospiech I've added an answer to that question; it uses expl3 and is independent of boolexpr and etoolbox.
    – egreg
    Jan 21, 2012 at 16:48

You must log in to answer this question.

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