]> git.lyx.org Git - features.git/commitdiff
GuiDocument: support also the class option reqno
authorUwe Stöhr <uwestoehr@lyx.org>
Thu, 11 May 2017 23:06:05 +0000 (01:06 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Thu, 11 May 2017 23:06:05 +0000 (01:06 +0200)
as discussed our support for the formula numbering side should be complete. There are document classes that uses left numbering as default and with the class option "reqno" this can be changed to right numbering. reqno requires the loading of amsamth.

src/BufferParams.cpp
src/BufferParams.h
src/frontends/qt4/GuiDocument.cpp
src/tex2lyx/Preamble.cpp

index bdfbc59572d17d2784f3365da33002c9ee527f24..ef6ad0a9df789da1bc0a44fdf334181fa8a5928d 100644 (file)
@@ -385,7 +385,7 @@ BufferParams::BufferParams()
        makeDocumentClass();
        paragraph_separation = ParagraphIndentSeparation;
        is_math_indent = false;
-       math_number_before = false;
+       math_number_before = "default";
        quotes_style = InsetQuotesParams::EnglishQuotes;
        dynamic_quotes = false;
        fontsize = "default";
@@ -1640,8 +1640,12 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        if (is_math_indent)
                clsoptions << "fleqn,";
 
-       if (math_number_before)
+       if (math_number_before == "true")
                clsoptions << "leqno,";
+       else if (math_number_before == "false") {
+               clsoptions << "reqno,";
+               features.require("amsmath");
+       }
 
        // language should be a parameter to \documentclass
        if (language->babel() == "hebrew"
index 1c23d6c245365218fd58c9be233132438115a9f1..be7c81459a34c52965dcf2cca3ed917fc1868c91 100644 (file)
@@ -110,8 +110,8 @@ public:
        bool is_math_indent;
 
 
-       /// number formulas before them
-       bool math_number_before;
+       /// number formulas before or not
+       std::string math_number_before;
 
        /** Whether paragraphs are separated by using a indent like in
         *  articles or by using a little skip like in letters.
index 99a248ca2c341777d2f679ddee3c728d9d285adc..055981eb7f89ea6e35f7f711b80604be0c807400 100644 (file)
@@ -1283,7 +1283,8 @@ GuiDocument::GuiDocument(GuiView & lv)
        bc().addCheckedLineEdit(mathsModule->MathIndentLE);
        mathsModule->MathNumberingPosCO->addItem(qt_("Left"));
        mathsModule->MathNumberingPosCO->addItem(qt_("Default"));
-       mathsModule->MathNumberingPosCO->setCurrentIndex(2);
+       mathsModule->MathNumberingPosCO->addItem(qt_("Right"));
+       mathsModule->MathNumberingPosCO->setCurrentIndex(1);
        
 
        // latex class
@@ -2942,14 +2943,17 @@ void GuiDocument::applyView()
        }
        switch (mathsModule->MathNumberingPosCO->currentIndex()) {
                case 0:
-                       bp_.math_number_before = true;
+                       bp_.math_number_before = "true";
                        break;
                case 1:
-                       bp_.math_number_before = false;
+                       bp_.math_number_before = "default";
+                       break;
+               case 2:
+                       bp_.math_number_before = "false";
                        break;
                default:
                        // this should never happen
-                       bp_.math_number_before = false;
+                       bp_.math_number_before = "default";
                        break;
        }
 
@@ -3415,10 +3419,12 @@ void GuiDocument::paramsToDialog()
                mathsModule->MathIndentCO->setCurrentIndex(indent);
                enableMathIndent(indent);
        }
-       if (bp_.math_number_before)
+       if (bp_.math_number_before == "true")
                mathsModule->MathNumberingPosCO->setCurrentIndex(0);
-       else 
+       else if (bp_.math_number_before == "default")
                mathsModule->MathNumberingPosCO->setCurrentIndex(1);
+       else if (bp_.math_number_before == "false")
+               mathsModule->MathNumberingPosCO->setCurrentIndex(2);
 
        map<string, string> const & packages = BufferParams::auto_packages();
        for (map<string, string>::const_iterator it = packages.begin();
index 9465331b6f1dfb59ccf49e6815909b0b8cb9ff66..cf9dab7a862d1cfcfb664e76fcd9e0f3e5a6dd6f 100644 (file)
@@ -494,7 +494,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_font_tt_scale[1]        = "100";
        //h_font_cjk
        h_is_mathindent           = "0";
-       h_math_number_before      = "0";
+       h_math_number_before      = "default";
        h_graphics                = "default";
        h_default_output_format   = "default";
        h_html_be_strict          = "false";
@@ -1692,7 +1692,12 @@ void Preamble::parse(Parser & p, string const & forceclass,
                        // formula numbering side
                        if ((it = find(opts.begin(), opts.end(), "leqno"))
                                 != opts.end()) {
-                               h_math_number_before = "1";
+                               h_math_number_before = "true";
+                               opts.erase(it);
+                       }
+                       else if ((it = find(opts.begin(), opts.end(), "reqno"))
+                                != opts.end()) {
+                               h_math_number_before = "false";
                                opts.erase(it);
                        }