josephwright / etoolbox

Tool-box for LaTeX programmers using e-TeX
LaTeX Project Public License v1.3c
41 stars 7 forks source link

options processing + ifbool not working? #30

Open devangel77b opened 4 years ago

devangel77b commented 4 years ago

Not sure if this is a bug; has anyone else seen problems when using booltrue+DeclareOption, and ifbool... seeing that the booleans are not being set? I have not yet been able to tell if it is an issue with options or with booleans in etoolbox; when done on their own in a simple article with no options etoolbox booleans seem to work correctly, but when done within options declared in a package they seem not to be set.

josephwright commented 4 years ago

Please can you post an example?

devangel77b commented 4 years ago
\documentclass{article}

\usepackage[option1]{mwe}

\begin{document}
\checkMweOptions
\end{document}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mwe}[mwe testing for bug in etoolbox with DeclareOption]

\RequirePackage{etoolbox}
\newbool{booloption0}
\newbool{booloption1}
\newbool{booloption2}
\DeclareOption{option0}{\booltrue{booloption0}}
\DeclareOption{option1}{\booltrue{booloption1}}
\DeclareOption{option2}{\booltrue{booloption2}}
\ExecuteOptions{}
\ProcessOptions\relax

\newcommand{\checkMweOptions}{
\ifbool{booloption0}{option0}{notoption0}
\ifbool{booloption1}{option1}{notoption1}
\ifbool{booloption2}{option2}{notoption2}
}
devangel77b commented 4 years ago

Hmmm now the MWE is working. It's something with my installation or a side effect with something else I am using in my actual files. Sorry to have bothered you.

devangel77b commented 4 years ago

Is there any known reason I wouldhave to also do \documentclass[option1]{article} to get the booleans to be set correctly during options processing?

josephwright commented 4 years ago

I'm not sure what you mean

muzimuzhi commented 4 years ago

@devangel77b article is one of the standard classes, hence normally you cannot add new class options to it. Instead, you can define your own document class based on article.