mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
* resolve conflicts of XeTeX with AMS by loading all AMS packages before fontspec. See
http://www.macfreek.nl/mindmaster/LaTeX_package_conflicts#Amssymb_with_Xunicode git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36777 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
68e455e7f2
commit
3518419a33
@ -1340,6 +1340,15 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|
||||
texrow.newline();
|
||||
// end of \documentclass defs
|
||||
|
||||
int nlines;
|
||||
// if we use fontspec, we have to load the AMS packages here
|
||||
string const ams = features.loadAMSPackages();
|
||||
if (useNonTeXFonts && !ams.empty()) {
|
||||
os << from_ascii(ams);
|
||||
nlines = int(count(ams.begin(), ams.end(), '\n'));
|
||||
texrow.newlines(nlines);
|
||||
}
|
||||
|
||||
if (useNonTeXFonts) {
|
||||
os << "\\usepackage{fontspec}\n";
|
||||
texrow.newline();
|
||||
@ -1352,7 +1361,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|
||||
fonts_sans_scale, fonts_typewriter_scale, useNonTeXFonts);
|
||||
if (!fonts.empty()) {
|
||||
os << from_ascii(fonts);
|
||||
texrow.newline();
|
||||
nlines =
|
||||
int(count(fonts.begin(), fonts.end(), '\n'));
|
||||
texrow.newlines(nlines);
|
||||
}
|
||||
if (fonts_default_family != "default")
|
||||
os << "\\renewcommand{\\familydefault}{\\"
|
||||
@ -1912,8 +1923,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|
||||
if (!i18npreamble.empty())
|
||||
lyxpreamble += i18npreamble + '\n';
|
||||
|
||||
int const nlines =
|
||||
int(count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
|
||||
nlines = int(count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
|
||||
texrow.newlines(nlines);
|
||||
|
||||
os << lyxpreamble;
|
||||
|
@ -589,7 +589,6 @@ char const * simplefeatures[] = {
|
||||
"enumitem",
|
||||
"endnotes",
|
||||
"ifthen",
|
||||
"amsthm",
|
||||
// listings is handled in BufferParams.cpp
|
||||
"bm",
|
||||
"pdfpages",
|
||||
@ -690,21 +689,11 @@ string const LaTeXFeatures::getPackages() const
|
||||
// than those above.
|
||||
//
|
||||
|
||||
// esint is preferred for esintoramsmath
|
||||
if ((mustProvide("amsmath")
|
||||
&& params_.use_amsmath != BufferParams::package_off)
|
||||
|| (mustProvide("esintoramsmath")
|
||||
&& params_.use_esint == BufferParams::package_off
|
||||
&& params_.use_amsmath != BufferParams::package_off)) {
|
||||
packages << "\\usepackage{amsmath}\n";
|
||||
} else {
|
||||
// amsbsy and amstext are already provided by amsmath
|
||||
if (mustProvide("amsbsy"))
|
||||
packages << "\\usepackage{amsbsy}\n";
|
||||
if (mustProvide("amstext"))
|
||||
packages << "\\usepackage{amstext}\n";
|
||||
}
|
||||
|
||||
// if fontspec is used, AMS packages have to be loaded before
|
||||
// fontspec (in BufferParams)
|
||||
if (!params_.useNonTeXFonts && !loadAMSPackages().empty())
|
||||
packages << loadAMSPackages();
|
||||
|
||||
// wasysym is a simple feature, but it must be after amsmath if both
|
||||
// are used
|
||||
// wasysym redefines some integrals (e.g. iint) from amsmath. That
|
||||
@ -759,11 +748,6 @@ string const LaTeXFeatures::getPackages() const
|
||||
if (mustProvide("setspace") && !tclass.provides("SetSpace"))
|
||||
packages << "\\usepackage{setspace}\n";
|
||||
|
||||
// amssymb.sty
|
||||
if (mustProvide("amssymb")
|
||||
|| params_.use_amsmath == BufferParams::package_on)
|
||||
packages << "\\usepackage{amssymb}\n";
|
||||
|
||||
// esint must be after amsmath and wasysym, since it will redeclare
|
||||
// inconsistent integral symbols
|
||||
if ((mustProvide("esint") || mustProvide("esintoramsmath")) &&
|
||||
@ -1039,6 +1023,35 @@ bool LaTeXFeatures::needBabelLangOptions() const
|
||||
}
|
||||
|
||||
|
||||
string const LaTeXFeatures::loadAMSPackages() const
|
||||
{
|
||||
ostringstream tmp;
|
||||
if (mustProvide("amsthm"))
|
||||
tmp << "\\usepackage{amsthm}\n";
|
||||
|
||||
// esint is preferred for esintoramsmath
|
||||
if ((mustProvide("amsmath")
|
||||
&& params_.use_amsmath != BufferParams::package_off)
|
||||
|| (mustProvide("esintoramsmath")
|
||||
&& params_.use_esint == BufferParams::package_off
|
||||
&& params_.use_amsmath != BufferParams::package_off)) {
|
||||
tmp << "\\usepackage{amsmath}\n";
|
||||
} else {
|
||||
// amsbsy and amstext are already provided by amsmath
|
||||
if (mustProvide("amsbsy"))
|
||||
tmp << "\\usepackage{amsbsy}\n";
|
||||
if (mustProvide("amstext"))
|
||||
tmp << "\\usepackage{amstext}\n";
|
||||
}
|
||||
|
||||
if (mustProvide("amssymb")
|
||||
|| params_.use_amsmath == BufferParams::package_on)
|
||||
tmp << "\\usepackage{amssymb}\n";
|
||||
|
||||
return tmp.str();
|
||||
}
|
||||
|
||||
|
||||
docstring const LaTeXFeatures::getTClassPreamble() const
|
||||
{
|
||||
// the text class specific preamble
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
std::string const getBabelPostsettings() const;
|
||||
/// Do we need to pass the languages to babel directly?
|
||||
bool needBabelLangOptions() const;
|
||||
/// Load AMS packages when appropriate
|
||||
std::string const loadAMSPackages() const;
|
||||
/// The definitions needed by the document's textclass
|
||||
docstring const getTClassPreamble() const;
|
||||
/// The language dependent definitions needed by the document's textclass
|
||||
|
Loading…
Reference in New Issue
Block a user