- bool add = false;
- if (command) {
- FullCommand const & cmd =
- possible_textclass_commands['\\' + name];
- if (preamble.find(cmd.def) != docstring::npos)
- add = true;
- } else if (theorem) {
- FullCommand const & thm =
- possible_textclass_theorems[name];
- if (preamble.find(thm.def) != docstring::npos)
- add = true;
- } else {
- FullEnvironment const & env =
- possible_textclass_environments[name];
- if (preamble.find(env.beg) != docstring::npos &&
- preamble.find(env.end) != docstring::npos)
- add = true;
+ bool const package_cmd = dpre.empty();
+ bool match_req = false;
+ if (package_cmd) {
+ std::set<std::string> mreqs = it->second->required();
+ if (!mreqs.empty())
+ cmd_reqs.insert(mreqs.begin(), mreqs.end());
+ for (auto const & pack : cmd_reqs) {
+ // If a requirement of the module matches a used package
+ // we load the module except if we have an auto-loaded package
+ // which is only required generally by the module, and the module
+ // does not provide the [inset]layout we are looking for.
+ // This heuristics should
+ // * load modules if the provide a style we don't have in the class
+ // * load modules that provide a package support generally (such as fixltx2e)
+ // * not unnecessarily load modules just because they require a package which we
+ // load anyway.
+ if (preamble.isPackageUsed(pack)
+ && (found_style || !preamble.isPackageAutoLoaded(pack))) {
+ if (found_style)
+ match_req = true;
+ else
+ potential_modules.push_back(module);
+ break;
+ }
+ }
+ }
+ bool add = match_req;
+ if (preamble_def) {
+ if (command) {
+ FullCommand const & cmd =
+ possible_textclass_commands['\\' + name];
+ if (dpre.find(cmd.def) != docstring::npos)
+ add = true;
+ } else if (theorem) {
+ FullCommand const & thm =
+ possible_textclass_theorems[name];
+ if (dpre.find(thm.def) != docstring::npos)
+ add = true;
+ } else {
+ FullEnvironment const & env =
+ possible_textclass_environments[name];
+ if (dpre.find(env.beg) != docstring::npos &&
+ dpre.find(env.end) != docstring::npos)
+ add = true;
+ }