]> git.lyx.org Git - features.git/commitdiff
Fix interplay of memoir and geometry
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 5 Aug 2019 17:01:48 +0000 (19:01 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 6 Aug 2019 08:10:53 +0000 (10:10 +0200)
Fixes: #10970
(cherry picked from commit 65c1ae813318c128ce74f206eebc79328beb8f43)

lib/layouts/memoir.layout
src/BufferParams.cpp
status.23x

index d37248dbc25ab3aec859dac190a823ce6ffbfa0b..1fa3cd73fcf367b04cf97c72f7c08ed957c47476 100644 (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
index 199c9370e87b2576d9a0b91e4cd57417988fc4c7..1b740dc96182fd4503c539c9c3ab8dbeade46ca5 100644 (file)
@@ -1602,7 +1602,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,";
@@ -1803,8 +1803,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");
@@ -1915,31 +1914,45 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                case PAPER_DEFAULT:
                        break;
                }
-               docstring const g_options = trim(ods.str(), ",");
-               os << "\\usepackage";
-               if (!g_options.empty())
-                       os << '[' << g_options << ']';
-               os << "{geometry}\n";
-               // output this only if use_geometry is true
-               if (use_geometry) {
+               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() && !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 (!topmargin.empty())
-                               os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString());
-                       if (!bottommargin.empty())
-                               os << ",bmargin=" << from_ascii(Length(bottommargin).asLatexString());
-                       if (!leftmargin.empty())
-                               os << ",lmargin=" << from_ascii(Length(leftmargin).asLatexString());
-                       if (!rightmargin.empty())
-                               os << ",rmargin=" << from_ascii(Length(rightmargin).asLatexString());
-                       if (!headheight.empty())
-                               os << ",headheight=" << from_ascii(Length(headheight).asLatexString());
-                       if (!headsep.empty())
-                               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";
+                       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) {
+                               if (!topmargin.empty())
+                                       os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString());
+                               if (!bottommargin.empty())
+                                       os << ",bmargin=" << from_ascii(Length(bottommargin).asLatexString());
+                               if (!leftmargin.empty())
+                                       os << ",lmargin=" << from_ascii(Length(leftmargin).asLatexString());
+                               if (!rightmargin.empty())
+                                       os << ",rmargin=" << from_ascii(Length(rightmargin).asLatexString());
+                               if (!headheight.empty())
+                                       os << ",headheight=" << from_ascii(Length(headheight).asLatexString());
+                               if (!headsep.empty())
+                                       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
                   || papersize != PAPER_DEFAULT) {
index a4d3324dd51ef9697981c3330b8817fda22eeeed..e78d24aa428d08c62338b5c93e690c208d2de00d 100644 (file)
@@ -85,6 +85,8 @@ What's new
 
 - Fix direction of references with XeTeX/bidi (bug 11626).
 
+- Fix interplay of the memoir class and custom page size/geometry (bug 10970).
+
 
 * USER INTERFACE