2

In my package I need to use all of geometry package options, I can define one option landscape like this

\DeclareOption{landscape}{
    \geometry{landscape}
} 

\ProcessOptions\relax

My hope is to find a simple way to insert all of them as options in my package

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mypackage}[2018/02/14]

\RequirePackage{etoolbox}
\RequirePackage[margin=2cm]{geometry}
\RequirePackage{amsmath,amsfonts,amssymb}
\RequirePackage{tikz}
\RequirePackage[totpages,user]{zref}
\RequirePackage[explicit,compact]{titlesec}
\RequirePackage{fancyhdr}


\DeclareOption{landscape}{
    \geometry{landscape}
}

\DeclareOption*{\PackageWarning{mypackage}{Unknown ‘\CurrentOption’ option}}

\ProcessOptions\relax

\def\foo{foo}

\endinput  
2
  • I don't know a way to do this automatically for all Options. But you should use something like \DeclareVoidOption{}{}{} for declaring Option without a value and the command \PassOptionsToPackage{}{} for telling the package what to do. Here an example: \DeclareVoidOption{landscape}{\PassOptionsToPackage{landscape}{geometry}}.
    – baghira
    Feb 16, 2018 at 9:25
  • I forgot to mention that if you use \DeclareVoidOption{}{} you need the package kvoptions.
    – baghira
    Feb 16, 2018 at 9:41

1 Answer 1

2

If it is only one package you need all the options then you can do something like this:

\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{geometry}}

Because \DeclareOption* is the command which is used when no other previous defined option was detected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .