I create a package: one common file that includes others. In common package file (russian_post.sty
) I define options:
\DeclareOption{times}{\@seriffalse}
\DeclareOption{landscape}{\@lscapetrue}
\DeclareOption{portrait}{\@lscapefalse}
\DeclareOption{smalltab}{\PassOptionsToPackage{smalltab}{form_110}}
\DeclareOption{tinytab}{\PassOptionsToPackage{tinytab}{form_110}}
\DeclareOption*{\PackageWarning{russian_post}{Unknown option `\CurrentOption'}}
\ProcessOptions\relax
after that I include packages, the interesting is
\RequirePackage{form_110}
In file form_110.sty
I define them again:
\DeclareOption{smalltab}{\@smallt@btrue}
\DeclareOption{tinytab}{\@tinyt@btrue}
\ProcessOptions\relax
And in my file.tex
I try to use my package with this options:
\usepackage[times,tinytab]{russian_post}
This cause latex errors:
! LaTeX Error: Unknown option `times' for package `russian_post'.
! LaTeX Error: Unknown option `tinytab' for package `russian_post'.
in spite of that I've already defined default action for unknown options (just show warning).
The weird things come later: after ignoring these errors I get a right pdf-file.
If I move all \RequirePackage
before options declaration block, latex works without errors but options don't pass to package. I know, that I can use global variables from russian_post.sty
in other packages, but what if I would like to use that package alone?
How can this be so? And how can I omit such errors?
UPD:*
Thanks to @Werner. I add minimal example:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{russian_post.sty}
\DeclareOption{smalltab}{\PassOptionsToPackage{smalltab}{form_110}}
\DeclareOption{tinytab}{\PassOptionsToPackage{tinytab}{form_110}}
\DeclareOption*{\PackageWarning{russian_post}{Unknown option `\CurrentOption'}}
\ProcessOptions\relax
\RequirePackage{form_110}
\end{filecontents*}
\begin{filecontents*}{form_110.sty}
\newif\if@smallt@b\newif\if@tinyt@b
\@smallt@bfalse\@tinyt@bfalse
\DeclareOption{smalltab}{\@smallt@btrue}
\DeclareOption{tinytab}{\@tinyt@btrue}
\ProcessOptions\relax
\RequirePackage{russian_post}
\def\testsmall{\if@smallt@b TRUE\else FALSE\fi}
\def\testtiny{\if@tinyt@b TRUE\else FALSE\fi}
\end{filecontents*}
\usepackage[smalltab]{russian_post}
\begin{document}
small: \testsmall
tiny: \testtiny
\end{document}
It seems that the problem is in multiple inclusion of russian_post.sty
. But latex should prevent such things when you're using \RequirePackage
or \usepackage
. I don't understand anything!!!
UPD2: it's more and more weird!
If I move this options to \documentclass
, all works fine! What is it?
form_110
? In the LaTeX companion book, page 880, there is a footnote saying "It is the responsibility of the package writer to actually load such packages. LaTEX does not check that packages receiving options via\PassOptionsToPackage
are actually loaded later on."\RequirePackage
inrussian_post
.opt
passed", as expected. It would be great if you could widdle down your current setup to something minimal and self-contained that you can post here.\RequirePackage{russian_post}
inform_110.sty
. It is become now more weird: latex should omit such multiple inclusion...