Fix interplay of memoir and geometry

Fixes: #10970
This commit is contained in:
Juergen Spitzmueller 2019-08-05 19:01:48 +02:00
parent 231b36d950
commit 65c1ae8133
2 changed files with 43 additions and 27 deletions

View File

@ -17,6 +17,9 @@ PageStyle Headings
Provides makeidx 1 Provides makeidx 1
Provides framed 1 Provides framed 1
Provides subscript 1 Provides subscript 1
# Geometry is supported, but the package options and paper sizes
# are ignored
Provides geometry-light 1
# Memoir has support for line spacing, but uses different names from # Memoir has support for line spacing, but uses different names from
# what setspace.sty does. # what setspace.sty does.
Provides SetSpace 1 Provides SetSpace 1

View File

@ -1630,7 +1630,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
&& papersize != PAPER_A5 && papersize != PAPER_A5
&& papersize != PAPER_B5; && papersize != PAPER_B5;
if (!use_geometry) { if (!use_geometry || features.isProvided("geometry-light")) {
switch (papersize) { switch (papersize) {
case PAPER_A4: case PAPER_A4:
clsoptions << "a4paper,"; clsoptions << "a4paper,";
@ -1854,8 +1854,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
os << "}\n"; os << "}\n";
} }
if (!features.isProvided("geometry") if (use_geometry || nonstandard_papersize) {
&& (use_geometry || nonstandard_papersize)) {
odocstringstream ods; odocstringstream ods;
if (!getGraphicsDriver("geometry").empty()) if (!getGraphicsDriver("geometry").empty())
ods << getGraphicsDriver("geometry"); ods << getGraphicsDriver("geometry");
@ -1966,31 +1965,45 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
case PAPER_DEFAULT: case PAPER_DEFAULT:
break; break;
} }
docstring const g_options = trim(ods.str(), ","); docstring g_options = trim(ods.str(), ",");
os << "\\usepackage"; // geometry-light means that the class works with geometry, but overwrites
if (!g_options.empty()) // the package options and paper sizes (memoir does this).
os << '[' << g_options << ']'; // In this case, all options need to go to \geometry
os << "{geometry}\n"; // and the standard paper sizes need to go to the class options.
// output this only if use_geometry is true if (!features.isProvided("geometry")) {
if (use_geometry) { os << "\\usepackage";
if (!g_options.empty() && !features.isProvided("geometry-light")) {
os << '[' << g_options << ']';
g_options.clear();
}
os << "{geometry}\n";
}
if (use_geometry || features.isProvided("geometry")
|| features.isProvided("geometry-light")) {
os << "\\geometry{verbose"; os << "\\geometry{verbose";
if (!topmargin.empty()) if (!g_options.empty())
os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString()); // Output general options here with "geometry light".
if (!bottommargin.empty()) os << "," << g_options;
os << ",bmargin=" << from_ascii(Length(bottommargin).asLatexString()); // output this only if use_geometry is true
if (!leftmargin.empty()) if (use_geometry) {
os << ",lmargin=" << from_ascii(Length(leftmargin).asLatexString()); if (!topmargin.empty())
if (!rightmargin.empty()) os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString());
os << ",rmargin=" << from_ascii(Length(rightmargin).asLatexString()); if (!bottommargin.empty())
if (!headheight.empty()) os << ",bmargin=" << from_ascii(Length(bottommargin).asLatexString());
os << ",headheight=" << from_ascii(Length(headheight).asLatexString()); if (!leftmargin.empty())
if (!headsep.empty()) os << ",lmargin=" << from_ascii(Length(leftmargin).asLatexString());
os << ",headsep=" << from_ascii(Length(headsep).asLatexString()); if (!rightmargin.empty())
if (!footskip.empty()) os << ",rmargin=" << from_ascii(Length(rightmargin).asLatexString());
os << ",footskip=" << from_ascii(Length(footskip).asLatexString()); if (!headheight.empty())
if (!columnsep.empty()) os << ",headheight=" << from_ascii(Length(headheight).asLatexString());
os << ",columnsep=" << from_ascii(Length(columnsep).asLatexString()); if (!headsep.empty())
os << "}\n"; os << ",headsep=" << from_ascii(Length(headsep).asLatexString());
if (!footskip.empty())
os << ",footskip=" << from_ascii(Length(footskip).asLatexString());
if (!columnsep.empty())
os << ",columnsep=" << from_ascii(Length(columnsep).asLatexString());
}
os << "}\n";
} }
} else if (orientation == ORIENTATION_LANDSCAPE } else if (orientation == ORIENTATION_LANDSCAPE
|| papersize != PAPER_DEFAULT) { || papersize != PAPER_DEFAULT) {