I'm writing a package but I'm having a little trouble. Right now, the package goes:
%!TEX encoding = UTF-8 Unicode
\def\fileversion{0.2}
\def\filedate{%
Mon 2014-04-01
}
\def\Copyright{**********************************************
Quest'opera è stata rilasciata con licenza Creative Commons Attribuzione - Non commerciale - Non opere derivate 3.0 Unported. Per leggere una copia della licenza visita il sito web http://creativecommons.org/licenses/by-nc-nd/3.0/ o spedisci una lettera a Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
(C) MGorini
**********************************************
}
\NeedsTeXFormat{LaTeX2e}[1996/06/01]
\typeout{Package `Mworks' <\filedate>.}
\typeout{\Copyright}
\ProvidesPackage{mworks}
\RequirePackage{amsmath,amssymb,amsfonts}
\RequirePackage{multirow}
\RequirePackage{xparse}
\RequirePackage{thmtools}
\newcount\gbb
\gbb=0
\DeclareOption{gbb}{\gbb=1}
\ifnum\gbb=1{
\ExplSyntaxOn
\NewDocumentCommand{\@ag}{O{0.85}oO{}}
{\str_if_eq:nnTF{#1}{n}
{\IfValueTF#2
{#2{\scalebox{0.85}[0.85]{$#3\alpha$}}}
{\errmessage{Too few arguments}\errhelp{If you specify `n' as the first argument, the second optional argument must be specified, otherwise use a number as the first argument or specify no optional argument.}}
}{\str_if_eq:nnTF{#1}{e}
{\IfValueTF#2
{#2{\scalebox{0.65}[0.65]{$#3\alpha$}}}
{\scalebox{0.65}[0.65]{$#3\alpha$}}
}{\str_if_eq:nnTF{#1}{b}
{\IfValueTF#2
{#2{#3\alpha}}
{{#3\alpha}}
}{\IfValueTF#2
{#2{\scalebox{#1}[#1]{$#3\alpha$}}}
{\scalebox{#1}[#1]{$#3\alpha$}}
}}}}
\providecommand{\ag}{\@ag}}\else{}\fi
\ExplSyntaxOff
\ProcessOptions\relax
\endinput
So when I type \usepackage[gbb]{mworks}
, I expect LaTeX 1) to find the package 2) to set \gbb
to 1 and therefore 3) to find \ag
and have it available in my document. Trouble is, step 1 goes fine, step 2 just won't work. And therefore I always get Undefined control sequence
for \ag
. Why does that happen?
\ProcessOptions
before doing the conditional definition of\ag
. When LaTeX finds\ifnum\gbb=1
the counter still has value 0.