General part
This comment indicates, that a more general answer might be useful.
If LaTeX loads a package foo
, then it defines macro \ver@foo.sty
(containing version date and information). At the next loading request (\RequirePackage{foo}
, \usepackage{foo}
) it sees that \ver@foo.sty
is defined and does not load the package again. That would be quite fatal, if the
package uses \newcommand
(which a good package should do ...).
But it checks the options. LaTeX's understanding of an option is that an option adds/enables an additional feature. Therefore, if subsequent \RequirePackage
and \usepackage
calls of the same package do not contain new options, LaTeX is happy and continues. Otherwise, if LaTeX sees a new option, it cannot load the package again to enable the new option. And LaTeX complains. Example:
\usepackage[ngerman]{babel}
\usepackage[english]{babel}
LaTeX stops with an error:
! LaTeX Error: Option clash for package babel.
Pressing h
at the prompt reveals:
The package babel has already been loaded with options:
[ngerman]
There has now been an attempt to load it with options
[english]
Adding the global options:
ngerman,english
to your \documentclass declaration may fix this.
Or without global options:
\usepackage[ngerman,english]{babel}
or if the first package loading is hidden in a class or package:
\PassOptionsToPackage{ngerman,english}{babel}
\documentclass{...}
Now, we reached \PassOptionsToPackage
. It is useful before the package is loaded the first time, otherwise LaTeX options code does not see the subsequent option additions. And it should be noted:
\PassOptionsToPackage
does not check, if the package will be loaded at all.
- Also it does not check, whether the package is already loaded.
(Perhaps a warning could be given in this case. A package could later
check for new options, but
\@ifpackagewith
is limited to the preamble.)
Specific problem
You have the following package loading order:
* \usepackage[smalltab]{russian_post}
* \RequirePackage{form_110}
* \RequirePackage{russian_post}
The problem is that russian_post
is again requested for loading before the first loading is completed. The package file is not loaded, but LaTeX has still to deal with the options.
Workaround: Delay the loading of package form_110
with \AtEndOfPackage
, then
the nested loading of russain_post
is late enough to get LaTeX's option stuff of the first loading finished:
Package russian_post
contains then:
\AtEndOfPackage{RequirePackage{form_110}}
The loading order/nesting of the test file is then:
* \usepackage[smalltab]{russian_post}
* \RequirePackage{form_110}
* \usepackage{russian_post}
Thus the second \usepackage{russian_post}
is not longer inside the scope of its first loading.
Best Answer
Here is a skeleton for an own package: