- also add flyx2lyx feature to import existing document class option as requested by JMarc
- also don't use a real default indentation length
* Format incremented to 538: support for document class option "fleqn"
and for length \mathindent.
New buffer parameters
- - \is_formula_indent
- - \formula_indentation
+ - \is_math_indent
+ - \math_indentation
2017-04-04 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 537: support for \xout.
def convert_mathindent(document):
- " add the \\is_formula_indent tag "
+ " add the \\is_math_indent tag "
+ # check if the document uses the class option "fleqn"
k = find_token(document.header, "\\quotes_style", 0)
- document.header.insert(k, "\\is_formula_indent 0")
+ regexp = re.compile(r'^.*fleqn.*')
+ i = find_re(document.header, regexp, 0)
+ if i != -1:
+ document.header.insert(k, "\\is_math_indent 1")
+ # delete the found option
+ document.header[i] = document.header[i].replace(",fleqn", "")
+ document.header[i] = document.header[i].replace(", fleqn", "")
+ document.header[i] = document.header[i].replace("fleqn,", "")
+ 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, "\\is_math_indent 0")
def revert_mathindent(document):
" Define mathindent if set in the document "
# first output the length
- regexp = re.compile(r'(\\formula_indentation)')
+ regexp = re.compile(r'(\\math_indentation)')
i = find_re(document.header, regexp, 0)
if i != -1:
- value = get_value(document.header, "\\formula_indentation" , i).split()[0]
+ value = get_value(document.header, "\\math_indentation" , i).split()[0]
add_to_preamble(document, ["\\setlength{\\mathindent}{" + value + '}'])
del document.header[i]
# now set the document class option
- regexp = re.compile(r'(\\is_formula_indent)')
+ regexp = re.compile(r'(\\is_math_indent)')
i = find_re(document.header, regexp, 0)
value = "1"
if i == -1:
params().headheight.erase();
params().headsep.erase();
params().footskip.erase();
- params().formula_indentation.erase();
+ params().math_indentation.erase();
params().columnsep.erase();
params().fonts_cjk.erase();
params().listings_params.clear();
*/
HSpace indentation;
VSpace defskip;
- HSpace formula_indentation;
+ HSpace math_indentation;
PDFOptions pdfoptions;
LayoutFileIndex baseClass_;
FormatList exportableFormatList;
cite_engine_type_ = ENGINE_TYPE_DEFAULT;
makeDocumentClass();
paragraph_separation = ParagraphIndentSeparation;
- is_formula_indent = false;
- formula_indentation = "30pt";
+ is_math_indent = false;
+ math_indentation = "default";
quotes_style = InsetQuotesParams::EnglishQuotes;
dynamic_quotes = false;
fontsize = "default";
}
-HSpace const & BufferParams::getFormulaIndentation() const
+HSpace const & BufferParams::getMathIndentation() const
{
- return pimpl_->formula_indentation;
+ return pimpl_->math_indentation;
}
-void BufferParams::setFormulaIndentation(HSpace const & indent)
+void BufferParams::setMathIndentation(HSpace const & indent)
{
- pimpl_->formula_indentation = indent;
+ pimpl_->math_indentation = indent;
}
if (pimpl_->defskip.kind() == VSpace::DEFSKIP)
// that is invalid
pimpl_->defskip = VSpace(VSpace::MEDSKIP);
- } else if (token == "\\is_formula_indent") {
- lex >> is_formula_indent;
- } else if (token == "\\formula_indentation") {
+ } else if (token == "\\is_math_indent") {
+ lex >> is_math_indent;
+ } else if (token == "\\math_indentation") {
lex.next();
- string formula_indentation = lex.getString();
- pimpl_->formula_indentation = HSpace(formula_indentation);
+ string math_indentation = lex.getString();
+ pimpl_->math_indentation = HSpace(math_indentation);
} else if (token == "\\quotes_style") {
string qstyle;
lex >> qstyle;
os << "\n\\paragraph_indentation " << getIndentation().asLyXCommand();
else
os << "\n\\defskip " << getDefSkip().asLyXCommand();
- os << "\n\\is_formula_indent " << is_formula_indent;
- if (is_formula_indent)
- os << "\n\\formula_indentation " << getFormulaIndentation().asLyXCommand();
+ os << "\n\\is_math_indent " << is_math_indent;
+ if (is_math_indent)
+ os << "\n\\math_indentation " << getMathIndentation().asLyXCommand();
os << "\n\\quotes_style "
<< string_quotes_style[quotes_style]
<< "\n\\dynamic_quotes " << dynamic_quotes
&& orientation == ORIENTATION_LANDSCAPE)
clsoptions << "landscape,";
- if (is_formula_indent)
+ if (is_math_indent)
clsoptions << "fleqn,";
// language should be a parameter to \documentclass
}
}
- if (is_formula_indent) {
+ if (is_math_indent) {
// when formula indentation
- // only output something when it is not the default of 30pt
- if (getFormulaIndentation().asLyXCommand() != "30pt") {
+ // only output something when it is not the default
+ if (getMathIndentation().asLyXCommand() != "default") {
os << "\\setlength{\\mathindent}{"
- << from_utf8(getFormulaIndentation().asLatexCommand())
+ << from_utf8(getMathIndentation().asLatexCommand())
<< "}\n";
}
}
void setDefSkip(VSpace const & vs);
///
- HSpace const & getFormulaIndentation() const;
+ HSpace const & getMathIndentation() const;
///
- void setFormulaIndentation(HSpace const & indent);
+ void setMathIndentation(HSpace const & indent);
/// Whether formulas are indented
- bool is_formula_indent;
+ bool is_math_indent;
/// the indentation of formulas
- std::string formula_indentation;
+ std::string math_indentation;
/** Whether paragraphs are separated by using a indent like in
* articles or by using a little skip like in letters.
connect(textLayoutModule->justCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
- connect(textLayoutModule->FormulaIndentCB, SIGNAL(toggled(bool)),
+ connect(textLayoutModule->MathIndentCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
- connect(textLayoutModule->FormulaIndentLE, SIGNAL(textChanged(const QString &)),
+ connect(textLayoutModule->MathIndentCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
- connect(textLayoutModule->FormulaIndentCO, SIGNAL(activated(int)),
+ connect(textLayoutModule->MathIndentCO, SIGNAL(activated(int)),
+ this, SLOT(setMathIndent(int)));
+ connect(textLayoutModule->MathIndentLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->MathIndentLengthCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
- textLayoutModule->FormulaIndentLE->setValidator(new LengthValidator(
- textLayoutModule->FormulaIndentLE));
+
+ textLayoutModule->MathIndentCO->addItem(qt_("Default"));
+ textLayoutModule->MathIndentCO->addItem(qt_("Custom"));
+ textLayoutModule->MathIndentLE->setValidator(new LengthValidator(
+ textLayoutModule->MathIndentLE));
// initialize the length validator
- bc().addCheckedLineEdit(textLayoutModule->FormulaIndentLE);
+ bc().addCheckedLineEdit(textLayoutModule->MathIndentLE);
- // LaTeX's default for FormulaIndent is 30pt
- textLayoutModule->FormulaIndentCO->setCurrentItem(Length::PT);
-
textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
textLayoutModule->lspacingLE));
textLayoutModule->indentLE->setValidator(new LengthValidator(
setSkip(textLayoutModule->skipCO->currentIndex());
}
+void GuiDocument::setMathIndent(int item)
+{
+ bool const enable = (item == 1);
+ textLayoutModule->MathIndentLE->setEnabled(enable);
+ textLayoutModule->MathIndentLengthCO->setEnabled(enable);
+ isValid();
+}
+
void GuiDocument::setMargins()
{
if (rb->isChecked())
bp_.use_package(it->first, BufferParams::package_off);
}
- bp_.is_formula_indent = textLayoutModule->FormulaIndentCB->isChecked();
- // if formulas are indented
- if (bp_.is_formula_indent) {
- // fill value if empty to avoid LaTeX errors
- if (textLayoutModule->FormulaIndentLE->text().isEmpty())
- textLayoutModule->FormulaIndentLE->setText("0");
- HSpace FormulaIndentation = HSpace(
- widgetsToLength(textLayoutModule->FormulaIndentLE,
- textLayoutModule->FormulaIndentCO)
+ bp_.is_math_indent = textLayoutModule->MathIndentCB->isChecked();
+ // if math is indented
+ if (bp_.is_math_indent) {
+ HSpace MathIndentation = HSpace(
+ widgetsToLength(textLayoutModule->MathIndentLE,
+ textLayoutModule->MathIndentLengthCO)
);
- bp_.setFormulaIndentation(FormulaIndentation);
+ bp_.setMathIndentation(MathIndentation);
}
// Page Layout
}
}
+ if (textLayoutModule->MathIndentCB->isChecked()) {
+ // if formulas are indented
+ switch (textLayoutModule->MathIndentCO->currentIndex()) {
+ case 0:
+ bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
+ break;
+ case 1: {
+ HSpace MathIndent = HSpace(
+ widgetsToLength(textLayoutModule->MathIndentLE,
+ textLayoutModule->MathIndentLengthCO)
+ );
+ bp_.setMathIndentation(MathIndent);
+ break;
+ }
+ default:
+ // this should never happen
+ bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
+ break;
+ }
+ }
+
bp_.options =
fromqstr(latexModule->optionsLE->text());
updateModuleInfo();
// math
- if (bp_.is_formula_indent) {
- textLayoutModule->FormulaIndentCB->setChecked(bp_.is_formula_indent);
- string FormulaIndentation = bp_.getFormulaIndentation().asLyXCommand();
- if (!FormulaIndentation.empty()) {
- lengthToWidgets(textLayoutModule->FormulaIndentLE,
- textLayoutModule->FormulaIndentCO,
- FormulaIndentation, default_unit);
+ if (bp_.is_math_indent) {
+ textLayoutModule->MathIndentCB->setChecked(bp_.is_math_indent);
+ string MathIndentation = bp_.getMathIndentation().asLyXCommand();
+ int MathIndent = 0;
+ if (MathIndentation != "default") {
+ lengthToWidgets(textLayoutModule->MathIndentLE,
+ textLayoutModule->MathIndentLengthCO,
+ MathIndentation, default_unit);
+ MathIndent = 1;
}
+ textLayoutModule->MathIndentCO->setCurrentIndex(MathIndent);
+ setMathIndent(MathIndent);
}
map<string, string> const & packages = BufferParams::auto_packages();
void enableIndent(bool);
void setSkip(int);
void enableSkip(bool);
+ void setMathIndent(int);
void browseLayout();
void browseMaster();
void classChanged();
</widget>
</item>
<item row="4" column="0">
- <widget class="QCheckBox" name="FormulaIndentCB">
+ <widget class="QCheckBox" name="MathIndentCB">
<property name="toolTip">
<string>Indent displayed formulas instead of centering</string>
</property>
</widget>
</item>
<item row="4" column="1">
- <widget class="QLineEdit" name="FormulaIndentLE">
+ <widget class="QComboBox" name="MathIndentCO">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="toolTip">
+ <string>Size of the indentation</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2" colspan="2">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>203</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLineEdit" name="MathIndentLE">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string/>
+ </property>
<property name="text">
- <string notr="true">30</string>
+ <string notr="true"/>
</property>
</widget>
</item>
- <item row="4" column="2">
- <widget class="lyx::frontend::LengthCombo" name="FormulaIndentCO">
+ <item row="5" column="2">
+ <widget class="lyx::frontend::LengthCombo" name="MathIndentLengthCO">
<property name="enabled">
<bool>false</bool>
</property>
</property>
</widget>
</item>
- <item row="4" column="3">
+ <item row="5" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
- <item row="5" column="0" colspan="4">
+ <item row="6" column="0" colspan="4">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
<resources/>
<connections>
<connection>
- <sender>FormulaIndentCB</sender>
- <signal>toggled(bool)</signal>
- <receiver>FormulaIndentCO</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>59</x>
- <y>274</y>
- </hint>
- <hint type="destinationlabel">
- <x>289</x>
- <y>273</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>FormulaIndentCB</sender>
+ <sender>MathIndentCB</sender>
<signal>toggled(bool)</signal>
- <receiver>FormulaIndentLE</receiver>
+ <receiver>MathIndentCO</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
</hint>
<hint type="destinationlabel">
<x>182</x>
- <y>273</y>
+ <y>270</y>
</hint>
</hints>
</connection>
h_font_tt_scale[0] = "100";
h_font_tt_scale[1] = "100";
//h_font_cjk
- h_is_formulaindent = "0";
+ h_is_mathindent = "0";
h_graphics = "default";
h_default_output_format = "default";
h_html_be_strict = "false";
os << "\\defskip " << h_defskip << "\n";
else
os << "\\paragraph_indentation " << h_paragraph_indentation << "\n";
- os << "\\is_formula_indent " << h_is_formulaindent << "\n";
- if (!h_formulaindentation.empty())
- os << "\\formula_indentation " << h_formulaindentation << "\n";
+ os << "\\is_math_indent " << h_is_mathindent << "\n";
+ if (!h_mathindentation.empty())
+ os << "\\math_indentation " << h_mathindentation << "\n";
os << "\\quotes_style " << h_quotes_style << "\n"
<< "\\dynamic_quotes " << h_dynamic_quotes << "\n"
<< "\\papercolumns " << h_papercolumns << "\n"
handle_opt(opts, known_languages, h_language);
delete_opt(opts, known_languages);
- // formula indentation
+ // math indentation
if ((it = find(opts.begin(), opts.end(), "fleqn"))
!= opts.end()) {
- h_is_formulaindent = "1";
+ h_is_mathindent = "1";
opts.erase(it);
}
// paper orientation
else
h_defskip = translate_len(content);
} else if (name == "\\mathindent") {
- h_formulaindentation = translate_len(content);
+ h_mathindentation = translate_len(content);
} else
h_preamble << "\\setlength{" << name << "}{" << content << "}";
}
bool h_font_cjk_set;
std::string h_font_cjk;
std::string h_use_microtype;
- std::string h_is_formulaindent;
- std::string h_formulaindentation;
+ std::string h_is_mathindent;
+ std::string h_mathindentation;
std::string h_graphics;
std::string h_default_output_format;
std::string h_html_be_strict;