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 framed 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
# what setspace.sty does.
Provides SetSpace 1

View File

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