1

I want to declare an option in my package that, if provided, will require another package. However, just doing

\DeclareOption{requiresomething}{
    \RequirePackage{somepackage}
}

does not work, as you can't mix package requiring with the Option Section. Is there any simple solution to this? Am I doing something wrong?

aachh
  • 13

1 Answers1

4

You can use a conditional:

\ProvidesPackage{aachh}

\newif\ifaachh@array \DeclareOption{array}{\aachh@arraytrue}

\ProcessOptions\relax

\ifaachh@array \RequirePackage{array} \fi

\endinput

or define a macro

\ProvidesPackage{aachh}

\DeclareOption{array}{\let\aachh@array@empty}

\ProcessOptions\relax

@ifundefined{aachh@array}{}{% \RequirePackage{array}% }

\endinput

The latter method is less memory intensive, but nowadays it's not really important.

egreg
  • 1,121,712