LyX 2.3 will support the document class option fleqn so I thin the other
generic math document class option "leqno" should be supported as well.
Attached is the patch.
There shouldn't be controversies except of the place of the combobox (an
the name of its label of course ;-) ). I put it in the document settings
math panel because i thinks it belongs there together with the fleqn
setting (that is currently in the text layout panel).
regards Uwe
lib/lyx2lyx/lyx_2_3.py | 43 ++++++++++++++++++-
src/BufferParams.cpp | 7 +++
src/BufferParams.h | 3 ++
src/frontends/qt4/GuiDocument.cpp | 24 ++++++++++-
src/frontends/qt4/ui/MathsUi.ui | 90 +++++++++++++++++++++++++++------------
src/tex2lyx/Preamble.cpp | 9 ++++
src/tex2lyx/Preamble.h | 1 +
src/version.h | 4 +-
8 files changed, 150 insertions(+), 31 deletions(-)
diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py
index e03b2b9ee6..f89f73c4a5 100644
--- a/lib/lyx2lyx/lyx_2_3.py
+++ b/lib/lyx2lyx/lyx_2_3.py
@@ -2123,6 +2123,45 @@ def revert_rotfloat(document):
i = i + 1
+def convert_mathnumberside(document):
+ " add the \\math_number_left tag "
+ # check if the document uses the class option "leqno"
+ k = find_token(document.header, "\\quotes_style", 0)
+ regexp = re.compile(r'^.*leqno.*')
+ i = find_re(document.header, regexp, 0)
+ if i != -1:
+ document.header.insert(k, "\\math_number_left 1")
+ # delete the found option
+ document.header[i] = document.header[i].replace(",leqno", "")
+ document.header[i] = document.header[i].replace(", leqno", "")
+ document.header[i] = document.header[i].replace("leqno,", "")
+ j = find_re(document.header, regexp, 0)
+ if i == j:
+ # then we have fleqn as the only option
+ del document.header[i]
+ else:
+ document.header.insert(k, "\\math_number_left 0")
+
+
+def revert_mathnumberside(document):
+ " add the document class option leqno"
+ regexp = re.compile(r'(\\math_number_left 1)')
+ i = find_re(document.header, regexp, 0)
+ if i == -1:
+ regexp = re.compile(r'(\\math_number_left)')
+ j = find_re(document.header, regexp, 0)
+ del document.header[j]
+ else:
+ k = find_token(document.header, "\\options", 0)
+ if k != -1:
+ document.header[k] = document.header[k].replace("\\options",
"\\options leqno,")
+ del document.header[i]
+ else:
+ l = find_token(document.header, "\\use_default_options", 0)
+ document.header.insert(l, "\\options leqno")
+ del document.header[i + 1]
+
+
##
# Conversion hub
#
@@ -2160,10 +2199,12 @@ convert = [
[537, []],
[538, [convert_mathindent]],
[539, []],
- [540, []]
+ [540, []],
+ [541, [convert_mathnumberside]]
]
revert = [
+ [540, [revert_mathnumberside]],
[539, [revert_rotfloat]],
[538, [revert_baselineskip]],
[537, [revert_mathindent]],
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 9f05fe8156..305f6a8b6b 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -385,6 +385,7 @@ BufferParams::BufferParams()
paragraph_separation = ParagraphIndentSeparation;
is_math_indent = false;
math_indentation = "default";
+ math_number_left = false;
quotes_style = InsetQuotesParams::EnglishQuotes;
dynamic_quotes = false;
fontsize = "default";
@@ -839,6 +840,8 @@ string BufferParams::readToken(Lexer & lex, string const &
token,
lex >> is_math_indent;
} else if (token == "\\math_indentation") {
lex >> math_indentation;
+ } else if (token == "\\math_number_left") {
+ lex >> math_number_left;
} else if (token == "\\quotes_style") {
string qstyle;
lex >> qstyle;
@@ -1339,6 +1342,7 @@ void BufferParams::writeFile(ostream & os, Buffer const *
buf) const
os << "\n\\is_math_indent " << is_math_indent;
if (is_math_indent && math_indentation != "default")
os << "\n\\math_indentation " << math_indentation;
+ os << "\n\\math_number_left " << math_number_left;
os << "\n\\quotes_style "
<< string_quotes_style[quotes_style]
<< "\n\\dynamic_quotes " << dynamic_quotes
@@ -1623,6 +1627,9 @@ bool BufferParams::writeLaTeX(otexstream & os,
LaTeXFeatures & features,
if (is_math_indent)
clsoptions << "fleqn,";
+ if (math_number_left)
+ clsoptions << "leqno,";
+
// language should be a parameter to \documentclass
if (language->babel() == "hebrew"
&& default_language->babel() != "hebrew")
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 437d00b700..6fdfe3ad31 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -108,6 +108,9 @@ public:
/// the indentation of formulas
std::string math_indentation;
+ /// number formulas left or right
+ bool math_number_left;
+
/** 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 691bb2c924..7faf0472d0 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -1280,6 +1280,12 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(mathsModule->allPackagesNotPB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(mathsModule->MathNumberingSideCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+
+ mathsModule->MathNumberingSideCO->addItem(qt_("Left"));
+ mathsModule->MathNumberingSideCO->addItem(qt_("Right"));
+ mathsModule->MathNumberingSideCO->setCurrentIndex(2);
// latex class
@@ -2918,7 +2924,19 @@ void GuiDocument::applyView()
if (rb->isChecked())
bp_.use_package(it->first, BufferParams::package_off);
}
-
+ switch (mathsModule->MathNumberingSideCO->currentIndex()) {
+ case 0:
+ bp_.math_number_left = true;
+ break;
+ case 1:
+ bp_.math_number_left = false;
+ break;
+ default:
+ // this should never happen
+ bp_.math_number_left = false;
+ break;
+ }
+
// Page Layout
if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
bp_.pagestyle = "default";
@@ -3401,6 +3419,10 @@ void GuiDocument::paramsToDialog()
textLayoutModule->MathIndentCO->setCurrentIndex(MathIndent);
setMathIndent(MathIndent);
}
+ if (bp_.math_number_left)
+ mathsModule->MathNumberingSideCO->setCurrentIndex(0);
+ else
+ mathsModule->MathNumberingSideCO->setCurrentIndex(1);
map<string, string> const & packages = BufferParams::auto_packages();
for (map<string, string>::const_iterator it = packages.begin();
diff --git a/src/frontends/qt4/ui/MathsUi.ui b/src/frontends/qt4/ui/MathsUi.ui
index 691d2055ff..bacc90ff5b 100644
--- a/src/frontends/qt4/ui/MathsUi.ui
+++ b/src/frontends/qt4/ui/MathsUi.ui
@@ -13,30 +13,7 @@
<property name="windowTitle">
<string/>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0" colspan="4">
- <widget class="QTableWidget" name="packagesTW">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="columnCount">
- <number>4</number>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>false</bool>
- </attribute>
- <attribute name="verticalHeaderVisible">
- <bool>false</bool>
- </attribute>
- <column/>
- <column/>
- <column/>
- <column/>
- </widget>
- </item>
+ <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="allPakcagesLA">
<property name="text">
@@ -44,27 +21,86 @@
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="1" column="1" colspan="2">
<widget class="QPushButton" name="allPackagesAutoPB">
<property name="text">
<string>Load A&utomatically</string>
</property>
</widget>
</item>
- <item row="1" column="2">
+ <item row="1" column="3">
<widget class="QPushButton" name="allPackagesAlwaysPB">
<property name="text">
<string>Load Alwa&ys</string>
</property>
</widget>
</item>
- <item row="1" column="3">
+ <item row="1" column="4" colspan="2">
<widget class="QPushButton" name="allPackagesNotPB">
<property name="text">
<string>Do &Not Load</string>
</property>
</widget>
</item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QLabel" name="MathNumberingSideL">
+ <property name="minimumSize">
+ <size>
+ <width>115</width>
+ <height>18</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Formula numbering side:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="5">
+ <spacer name="horizontalSpacer_1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>268</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="2" colspan="3">
+ <widget class="QComboBox" name="MathNumberingSideCO">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>Size of the indentation</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="6">
+ <widget class="QTableWidget" name="packagesTW">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="columnCount">
+ <number>4</number>
+ </property>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <column/>
+ <column/>
+ <column/>
+ <column/>
+ </widget>
+ </item>
</layout>
</widget>
<includes>
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 08d019c49e..1d8b9e1fe1 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -494,6 +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_left = "0";
h_graphics = "default";
h_default_output_format = "default";
h_html_be_strict = "false";
@@ -1293,6 +1294,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc,
string const & outfiled
os << "\\is_math_indent " << h_is_mathindent << "\n";
if (!h_mathindentation.empty())
os << "\\math_indentation " << h_mathindentation << "\n";
+ os << "\\math_number_left " << h_math_number_left << "\n";
os << "\\quotes_style " << h_quotes_style << "\n"
<< "\\dynamic_quotes " << h_dynamic_quotes << "\n"
<< "\\papercolumns " << h_papercolumns << "\n"
@@ -1687,6 +1689,13 @@ void Preamble::parse(Parser & p, string const &
forceclass,
h_is_mathindent = "1";
opts.erase(it);
}
+ // formula numbering side
+ if ((it = find(opts.begin(), opts.end(), "leqno"))
+ != opts.end()) {
+ h_math_number_left = "1";
+ opts.erase(it);
+ }
+
// paper orientation
if ((it = find(opts.begin(), opts.end(), "landscape"))
!= opts.end()) {
h_paperorientation = "landscape";
diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h
index 68842b68b4..63503853d1 100644
--- a/src/tex2lyx/Preamble.h
+++ b/src/tex2lyx/Preamble.h
@@ -154,6 +154,7 @@ private:
std::string h_font_cjk;
std::string h_use_microtype;
std::string h_is_mathindent;
+ std::string h_math_number_left;
std::string h_mathindentation;
std::string h_graphics;
std::string h_default_output_format;
diff --git a/src/version.h b/src/version.h
index ff15d4d973..e81d311eae 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 540 // uwestoehr: enable placement for rotated floats
-#define LYX_FORMAT_TEX2LYX 540
+#define LYX_FORMAT_LYX 541 // uwestoehr: support for class option leqno
+#define LYX_FORMAT_TEX2LYX 541
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER