From: André Pönitz Date: Thu, 6 Mar 2003 11:07:55 +0000 (+0000) Subject: John's AMS patch X-Git-Tag: 1.6.10~17342 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a0c3878e3184d5f8a7e89a39ff29ab9a49077c43;p=features.git John's AMS patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6365 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 3fd6158480..8f6dc0597c 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -197,7 +197,8 @@ string const LaTeXFeatures::getPackages() const // if (isRequired("amsmath") - && ! tclass.provides(LyXTextClass::amsmath)) { + && !tclass.provides(LyXTextClass::amsmath) + && params.use_amsmath != BufferParams::AMS_OFF) { packages << "\\usepackage{amsmath}\n"; } @@ -263,7 +264,7 @@ string const LaTeXFeatures::getPackages() const } // amssymb.sty - if (isRequired("amssymb") || params.use_amsmath) + if (isRequired("amssymb") || params.use_amsmath == BufferParams::AMS_ON) packages << "\\usepackage{amssymb}\n"; // url.sty if (isRequired("url") && ! tclass.provides(LyXTextClass::url)) diff --git a/src/buffer.C b/src/buffer.C index f61df89085..d004ff5869 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -516,7 +516,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, #endif } else if (token == "\\end_inset") { - lyxerr << "Solitary \\end_inset. Missing \\begin_inset?.\n" + lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n" + << "Missing \\begin_inset?.\n" << "Last inset read was: " << last_inset_read << endl; // Simply ignore this. The insets do not have @@ -754,7 +755,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, params.use_geometry = lex.getInteger(); } else if (token == "\\use_amsmath") { lex.nextToken(); - params.use_amsmath = lex.getInteger(); + params.use_amsmath = static_cast( + lex.getInteger()); } else if (token == "\\use_natbib") { lex.nextToken(); params.use_natbib = lex.getInteger(); @@ -2809,7 +2811,8 @@ void Buffer::validate(LaTeXFeatures & features) const } // AMS Style is at document level - if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath)) + if (params.use_amsmath == BufferParams::AMS_ON + || tclass.provides(LyXTextClass::amsmath)) features.require("amsmath"); for_each(paragraphs.begin(), paragraphs.end(), diff --git a/src/bufferparams.C b/src/bufferparams.C index 53b06e6e85..a2a6a3eefd 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -55,7 +55,7 @@ BufferParams::BufferParams() paperpackage = PACKAGE_NONE; orientation = ORIENTATION_PORTRAIT; use_geometry = false; - use_amsmath = false; + use_amsmath = AMS_AUTO; use_natbib = false; use_numerical_citations = false; tracking_changes = false; diff --git a/src/bufferparams.h b/src/bufferparams.h index db49714f78..8fc163efff 100644 --- a/src/bufferparams.h +++ b/src/bufferparams.h @@ -211,8 +211,14 @@ public: void readLanguage(LyXLex &); /// void readGraphicsDriver(LyXLex &); - /// - bool use_amsmath; + + /// use AMS package, not, or auto + enum AMS { + AMS_OFF, + AMS_AUTO, + AMS_ON + }; + AMS use_amsmath; /// bool use_natbib; /// diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index 6b261c589f..26169e9e85 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -238,8 +238,12 @@ void QDocument::apply() params.graphicsDriver = fromqstr(dialog_->packagesModule->psdriverCO->currentText()); - params.use_amsmath = - dialog_->packagesModule->amsCB->isChecked(); + if (dialog_->packagesModule->amsautoCB->isChecked()) { + params.use_amsmath = BufferParams::AMS_AUTO; + } else { + params.use_amsmath = + dialog_->packagesModule->amsCB->isChecked(); + } // layout params.textclass = @@ -477,7 +481,9 @@ void QDocument::update_contents() dialog_->packagesModule->amsCB->setChecked( - params.use_amsmath); + params.use_amsmath == BufferParams::AMS_YES); + dialog_->packagesModule->amsautoCB->setChecked( + params.use_amsmath == BufferParams::AMS_AUTO); switch (params.spacing.getSpace()) { case Spacing::Other: nitem = 3; break; diff --git a/src/frontends/qt2/ui/PackagesModuleBase.ui b/src/frontends/qt2/ui/PackagesModuleBase.ui index 6bbeec9da1..506db62c03 100644 --- a/src/frontends/qt2/ui/PackagesModuleBase.ui +++ b/src/frontends/qt2/ui/PackagesModuleBase.ui @@ -13,7 +13,7 @@ 0 0 - 357 + 353 231 @@ -38,9 +38,9 @@ title - Packages + AMS - + margin 11 @@ -49,7 +49,22 @@ spacing 6 - + + QCheckBox + + name + amsautoCB + + + text + &Use AMS math package automatically + + + checked + false + + + QCheckBox name @@ -57,10 +72,10 @@ text - Use AMS &math + Use AMS &math package - + QGroupBox @@ -118,8 +133,16 @@ + + + amsautoCB + toggled(bool) + amsCB + setDisabled(bool) + + - amsCB + amsautoCB psdriverCO diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 32b4d90142..95e8d9b617 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -281,7 +281,7 @@ void FormDocument::build() // disable for read-only documents bc().addReadOnly(options_->counter_secnumdepth); bc().addReadOnly(options_->counter_tocdepth); - bc().addReadOnly(options_->check_use_amsmath); + bc().addReadOnly(options_->choice_ams_math); bc().addReadOnly(options_->check_use_natbib); bc().addReadOnly(options_->choice_citation_format); bc().addReadOnly(options_->input_float_placement); @@ -292,6 +292,9 @@ void FormDocument::build() fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED); + fl_addto_choice(options_->choice_ams_math, + _("Never | Automatically | Yes ")); + for (int n = 0; tex_graphics[n][0]; ++n) { fl_addto_choice(options_->choice_postscript_driver, tex_graphics[n]); @@ -794,7 +797,8 @@ bool FormDocument::options_apply(BufferParams & params) bool redo = false; params.graphicsDriver = getString(options_->choice_postscript_driver); - params.use_amsmath = fl_get_button(options_->check_use_amsmath); + params.use_amsmath = static_cast( + fl_get_choice(options_->choice_ams_math) - 1); params.use_natbib = fl_get_button(options_->check_use_natbib); params.use_numerical_citations = fl_get_choice(options_->choice_citation_format) - 1; @@ -963,7 +967,7 @@ void FormDocument::options_update(BufferParams const & params) fl_set_choice_text(options_->choice_postscript_driver, params.graphicsDriver.c_str()); - fl_set_button(options_->check_use_amsmath, params.use_amsmath); + fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1); fl_set_button(options_->check_use_natbib, params.use_natbib); fl_set_choice(options_->choice_citation_format, int(params.use_numerical_citations)+1); diff --git a/src/frontends/xforms/forms/form_document.fd b/src/frontends/xforms/forms/form_document.fd index 54de2d0c38..6b721417c6 100644 --- a/src/frontends/xforms/forms/form_document.fd +++ b/src/frontends/xforms/forms/form_document.fd @@ -1453,54 +1453,54 @@ argument: 0 -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 185 185 25 25 +box: 185 225 25 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Use AMS Math|#M +label: Use Natbib|#N shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: check_use_amsmath +name: check_use_natbib callback: C_FormBaseInputCB argument: 0 -------------------- -class: FL_CHECKBUTTON -type: PUSH_BUTTON -box: 185 225 25 25 -boxtype: FL_NO_BOX -colors: FL_COL1 FL_YELLOW +class: FL_CHOICE +type: NORMAL_CHOICE +box: 185 265 140 25 +boxtype: FL_FRAME_BOX +colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Use Natbib|#N +label: Citation style:|#i shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: check_use_natbib +name: choice_citation_format callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 185 265 140 25 +box: 185 185 140 25 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Citation style:|#i +label: Use AMS Math:|#M shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: choice_citation_format +name: choice_ams_math callback: C_FormBaseInputCB argument: 0