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}

1 Answers1

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.

Marco Daniel
  • 95,681
  • I use boolexp only because it provides a nice switch syntax (see http://tex.stackexchange.com/questions/29133/how-to-create-switch-structure-comparing-strings-in-latex) which etoolbox does not provide. – Matthias Pospiech Jan 20 '12 at 21:47
  • @MatthiasPospiech: For such things I use xifinlist provided by etoolbox. (similar to ifstreq) – Marco Daniel Jan 21 '12 at 09:37
  • @MatthiasPospiech I've added an answer to that question; it uses expl3 and is independent of boolexpr and etoolbox. – egreg Jan 21 '12 at 16:48