Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
Since both define \ifboolexpr, I guess they don't go well together. :( –  egreg Jan 20 '12 at 21:11
3  
That's because both define similar commands. Why do you need boolexpr? –  Werner Jan 20 '12 at 21:11
    
@Werner: for a switch structure as linked in the comment of the first answer. –  Matthias Pospiech Jan 20 '12 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 '12 at 22:06
add comment

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
I use boolexp only because it provides a nice switch syntax (see tex.stackexchange.com/questions/29133/…) 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 9: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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.