mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Add support for package options in layout files. E.g.:
PackageOption tipa safe will load tipa with the "safe" option, if we load it.
This commit is contained in:
parent
de49a2df73
commit
1230372566
@ -1,5 +1,5 @@
|
||||
#LyX 2.1 created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 470
|
||||
\lyxformat 471
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass scrbook
|
||||
@ -110,7 +110,7 @@ End
|
||||
\use_package stmaryrd 0
|
||||
\use_package undertilde 0
|
||||
\cite_engine basic
|
||||
\cite_engine_type numerical
|
||||
\cite_engine_type default
|
||||
\biblio_style plain
|
||||
\use_bibtopic false
|
||||
\use_indices false
|
||||
@ -9437,6 +9437,134 @@ literate
|
||||
\end_inset
|
||||
|
||||
] Specifies what sort of output documents using this class will produce.
|
||||
\change_inserted 1414654397 1369315909
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted 1414654397 1369316059
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369315915
|
||||
PackageOptions
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369315909
|
||||
string
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369315919
|
||||
string
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Specifies options, given in the second string, for the package named by
|
||||
the first string.
|
||||
For example,
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Flex Code
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369315957
|
||||
PackageOptions natbib square
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
will cause
|
||||
\begin_inset Flex Code
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369315966
|
||||
natbib
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
to be loaded with the
|
||||
\begin_inset Flex Code
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369315985
|
||||
square
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
option.
|
||||
(For TeXperts, this causes LyX to output:
|
||||
\begin_inset Flex Code
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369316019
|
||||
|
||||
\backslash
|
||||
PassOptionsToPackage{natbib}{square}
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
prior to loading
|
||||
\begin_inset Flex Code
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1369316061
|
||||
natbib
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
.)
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
@ -157,6 +157,9 @@ import os, re, string, sys
|
||||
# Incremented to format 46, 15 May 2013 by gb
|
||||
# New Tag "ForceLocal"
|
||||
|
||||
# Incremented to format 47, 23 May 2013 by rgh
|
||||
# Add PackageOptions tag
|
||||
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
||||
@ -164,7 +167,7 @@ import os, re, string, sys
|
||||
# development/tools/updatelayouts.sh script to update all
|
||||
# layout files to the new format.
|
||||
|
||||
currentFormat = 46
|
||||
currentFormat = 47
|
||||
|
||||
|
||||
def usage(prog_name):
|
||||
@ -381,7 +384,7 @@ def convert(lines):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if format == 44 or format == 45:
|
||||
if format >= 44 and format <= 46:
|
||||
# nothing to do.
|
||||
i += 1
|
||||
continue
|
||||
|
@ -825,20 +825,25 @@ string const LaTeXFeatures::getPackages() const
|
||||
// also unknown packages can be requested. They are silently
|
||||
// swallowed now. We should change this eventually.
|
||||
|
||||
//
|
||||
// Output all the package option stuff we have been asked to do.
|
||||
map<string, string>::const_iterator it =
|
||||
params_.documentClass().packageOptions().begin();
|
||||
map<string, string>::const_iterator en =
|
||||
params_.documentClass().packageOptions().end();
|
||||
for (; it != en; ++it)
|
||||
if (mustProvide(it->first))
|
||||
packages << "\\PassOptionsToPackage{" << it->second << "}{"
|
||||
<< it->first << "}\n";
|
||||
|
||||
// These are all the 'simple' includes. i.e
|
||||
// packages which we just \usepackage{package}
|
||||
//
|
||||
for (int i = 0; i < nb_simplefeatures; ++i) {
|
||||
if (mustProvide(simplefeatures[i]))
|
||||
packages << "\\usepackage{"
|
||||
<< simplefeatures[i] << "}\n";
|
||||
packages << "\\usepackage{" << simplefeatures[i] << "}\n";
|
||||
}
|
||||
|
||||
//
|
||||
// The rest of these packages are somewhat more complicated
|
||||
// than those above.
|
||||
//
|
||||
|
||||
// if fontspec is used, AMS packages have to be loaded before
|
||||
// fontspec (in BufferParams)
|
||||
|
@ -61,7 +61,7 @@ namespace lyx {
|
||||
// development/tools/updatelayouts.sh script, to update the format of
|
||||
// all of our layout files.
|
||||
//
|
||||
int const LAYOUT_FORMAT = 46; // gb: New Tag "ForceLocal"
|
||||
int const LAYOUT_FORMAT = 47; //rgh: package options
|
||||
|
||||
namespace {
|
||||
|
||||
@ -197,6 +197,7 @@ enum TextClassTags {
|
||||
TC_HTMLSTYLES,
|
||||
TC_PROVIDES,
|
||||
TC_REQUIRES,
|
||||
TC_PKGOPTS,
|
||||
TC_LEFTMARGIN,
|
||||
TC_RIGHTMARGIN,
|
||||
TC_FLOAT,
|
||||
@ -256,6 +257,7 @@ LexerKeyword textClassTags[] = {
|
||||
{ "nostyle", TC_NOSTYLE },
|
||||
{ "outputformat", TC_OUTPUTFORMAT },
|
||||
{ "outputtype", TC_OUTPUTTYPE },
|
||||
{ "packageoptions", TC_PKGOPTS },
|
||||
{ "pagestyle", TC_PAGESTYLE },
|
||||
{ "preamble", TC_PREAMBLE },
|
||||
{ "provides", TC_PROVIDES },
|
||||
@ -633,6 +635,15 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
requires_.insert(req.begin(), req.end());
|
||||
break;
|
||||
}
|
||||
|
||||
case TC_PKGOPTS : {
|
||||
lexrc.next();
|
||||
string const pkg = lexrc.getString();
|
||||
lexrc.next();
|
||||
string const options = lexrc.getString();
|
||||
package_options_[pkg] = options;
|
||||
break;
|
||||
}
|
||||
|
||||
case TC_DEFAULTMODULE: {
|
||||
lexrc.next();
|
||||
|
@ -277,6 +277,8 @@ protected:
|
||||
std::set<std::string> provides_;
|
||||
/// latex packages requested by document class.
|
||||
std::set<std::string> requires_;
|
||||
///
|
||||
std::map<std::string, std::string> package_options_;
|
||||
/// default modules wanted by document class
|
||||
LayoutModuleList default_modules_;
|
||||
/// modules provided by document class
|
||||
@ -435,6 +437,9 @@ public:
|
||||
bool provides(std::string const & p) const;
|
||||
/// features required by the class?
|
||||
std::set<std::string> const & requires() const { return requires_; }
|
||||
/// package options to write to LaTeX file
|
||||
std::map<std::string, std::string> const & packageOptions() const
|
||||
{ return package_options_; }
|
||||
///
|
||||
unsigned int columns() const { return columns_; }
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user