From 19cc4a1fcbd0786406b0207dbff43badb93d32ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Fri, 12 May 2017 01:06:05 +0200 Subject: [PATCH] GuiDocument: support also the class option reqno 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 | 8 ++++++-- src/BufferParams.h | 4 ++-- src/frontends/qt4/GuiDocument.cpp | 18 ++++++++++++------ src/tex2lyx/Preamble.cpp | 9 +++++++-- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index bdfbc59572..ef6ad0a9df 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -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" diff --git a/src/BufferParams.h b/src/BufferParams.h index 1c23d6c245..be7c81459a 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -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. diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 99a248ca2c..055981eb7f 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -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 const & packages = BufferParams::auto_packages(); for (map::const_iterator it = packages.begin(); diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 9465331b6f..cf9dab7a86 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -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); } -- 2.39.2