commit 850e1038b84b5d8fd26ab5f78c54e94b26a71499 Author: Koji Yokota <yok...@lyx.org> Date: Fri May 2 11:38:16 2025 +0900
Add LaTeX support for \intertext and \shortintertext --- lib/symbols | 2 ++ src/Cursor.cpp | 3 ++- src/Makefile.am | 2 ++ src/insets/Inset.cpp | 1 + src/insets/InsetCode.h | 34 ++++++++++++++++++---------------- src/mathed/InsetMath.h | 3 +++ src/mathed/InsetMathBox.cpp | 2 ++ src/mathed/InsetMathNest.cpp | 2 ++ src/mathed/MathFactory.cpp | 3 +++ 9 files changed, 35 insertions(+), 17 deletions(-) diff --git a/lib/symbols b/lib/symbols index 689bd0d203..7c4cb76963 100644 --- a/lib/symbols +++ b/lib/symbols @@ -248,6 +248,8 @@ overset overset none mbox mbox forcetext tag mbox forcetext tag* mbox forcetext +intertext intertext forcetext +shortintertext intertext forcetext #newcommand newcommand none #label label none #left left none diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 1547c53eec..b15b7ed3f8 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1816,7 +1816,8 @@ bool Cursor::macroModeClose(bool cancel) || (it != words.end() && (it->second.inset == "font" || it->second.inset == "oldfont" || it->second.inset == "textsize" - || it->second.inset == "mbox")); + || it->second.inset == "mbox" + || it->second.inset == "intertext")); bool ert_macro = !user_macro && it == words.end() && atomAsMacro; if (in && in->currentMode() == Inset::TEXT_MODE diff --git a/src/Makefile.am b/src/Makefile.am index 7117232822..f3edd9d339 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -430,6 +430,8 @@ liblyxmathed_a_SOURCES = \ mathed/InsetMathGrid.h \ mathed/InsetMathHull.cpp \ mathed/InsetMathHull.h \ + mathed/InsetMathIntertext.cpp \ + mathed/InsetMathIntertext.h \ mathed/InsetMathKern.cpp \ mathed/InsetMathKern.h \ mathed/InsetMathLefteqn.cpp \ diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index d60e4a8078..8884906b8e 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -147,6 +147,7 @@ static void build_translator() insetnames[MATH_GRID_CODE] = InsetName("mathgrid"); insetnames[MATH_CODE] = InsetName("math"); insetnames[MATH_HULL_CODE] = InsetName("mathhull"); + insetnames[MATH_INTERTEXT_CODE] = InsetName("mathintertext"); insetnames[MATH_KERN_CODE] = InsetName("mathkern"); insetnames[MATH_LEFTEQN_CODE] = InsetName("mathlefteqn"); insetnames[MATH_LIM_CODE] = InsetName("mathlim"); diff --git a/src/insets/InsetCode.h b/src/insets/InsetCode.h index 6082e76395..e7d113ef1a 100644 --- a/src/insets/InsetCode.h +++ b/src/insets/InsetCode.h @@ -165,11 +165,13 @@ enum InsetCode { /// MATH_HULL_CODE, /// + MATH_INTERTEXT_CODE, + /// MATH_KERN_CODE, /// - MATH_LEFTEQN_CODE, + MATH_LEFTEQN_CODE, // 75 /// - MATH_LIM_CODE, // 75 + MATH_LIM_CODE, /// MATH_MATRIX_CODE, /// @@ -177,9 +179,9 @@ enum InsetCode { /// MATH_NEST_CODE, /// - MATH_NUMBER_CODE, + MATH_NUMBER_CODE, // 80 /// - MATH_OVERSET_CODE, // 80 + MATH_OVERSET_CODE, /// MATH_PAR_CODE, /// @@ -187,9 +189,9 @@ enum InsetCode { /// MATH_REF_CODE, /// - MATH_ROOT_CODE, + MATH_ROOT_CODE, // 85 /// - MATH_SCRIPT_CODE, // 85 + MATH_SCRIPT_CODE, /// MATH_SIZE_CODE, /// @@ -197,9 +199,9 @@ enum InsetCode { /// MATH_SPECIALCHAR_CODE, /// - MATH_SPLIT_CODE, + MATH_SPLIT_CODE, // 90 /// - MATH_SQRT_CODE, // 90 + MATH_SQRT_CODE, /// MATH_STACKREL_CODE, /// @@ -207,9 +209,9 @@ enum InsetCode { /// MATH_SUBSTACK_CODE, /// - MATH_SYMBOL_CODE, + MATH_SYMBOL_CODE, // 95 /// - MATH_TABULAR_CODE, // 95 + MATH_TABULAR_CODE, /// MATH_TEXTSIZE_CODE, /// @@ -217,9 +219,9 @@ enum InsetCode { /// MATH_UNKNOWN_CODE, /// - MATH_XARROW_CODE, + MATH_XARROW_CODE, // 100 /// - MATH_XYMATRIX_CODE, // 100 + MATH_XYMATRIX_CODE, /// MATH_MACRO_CODE, /// @@ -227,9 +229,9 @@ enum InsetCode { /// PREVIEW_CODE, /// - MATH_DIAGRAM_CODE, + MATH_DIAGRAM_CODE, // 105 /// - SCRIPT_CODE, // 105 + SCRIPT_CODE, /// IPA_CODE, /// @@ -237,9 +239,9 @@ enum InsetCode { /// IPADECO_CODE, /// - MATH_CLASS_CODE, + MATH_CLASS_CODE, // 110 /// - COUNTER_CODE, // 110 + COUNTER_CODE, /// INDEXMACRO_CODE, /// diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h index f812bac8e2..4ed3da0cbe 100644 --- a/src/mathed/InsetMath.h +++ b/src/mathed/InsetMath.h @@ -88,6 +88,7 @@ class InsetMathFrac; class InsetMathFont; class InsetMathGrid; class InsetMathHull; +class InsetMathIntertext; class InsetMathMatrix; class InsetMathNest; class InsetMathScript; @@ -170,6 +171,8 @@ public: virtual InsetMathGrid const * asGridInset() const { return nullptr; } virtual InsetMathHull * asHullInset() { return nullptr; } virtual InsetMathHull const * asHullInset() const { return nullptr; } + virtual InsetMathIntertext * asIntertextInset() { return nullptr; } + virtual InsetMathIntertext const * asIntertextInset() const { return nullptr; } virtual InsetMathMacro * asMacro() { return nullptr; } virtual InsetMathMacro const * asMacro() const { return nullptr; } virtual InsetMathMacroTemplate * asMacroTemplate() { return nullptr; } diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index 17415adcbf..97d813f2e6 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -128,6 +128,8 @@ void InsetMathBox::validate(LaTeXFeatures & features) const if (name_ == "tag" || name_ == "tag*") features.require("amsmath"); + if (name_ == "shortintertext") + features.require("mathtools"); InsetMathNest::validate(features); } diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 9472a3a22d..fb34e63ed5 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -2546,6 +2546,8 @@ MathCompletionList::MathCompletionList(Cursor const & cur) globals.push_back(from_ascii("\\infer")); globals.push_back(from_ascii("\\atop")); globals.push_back(from_ascii("\\lefteqn")); + // globals.push_back(from_ascii("\\intertext")); + // globals.push_back(from_ascii("\\shortintertext")); globals.push_back(from_ascii("\\boldsymbol")); globals.push_back(from_ascii("\\bm")); globals.push_back(from_ascii("\\color")); diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index f03915925e..f39bef3d96 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -27,6 +27,7 @@ #include "InsetMathFont.h" #include "InsetMathFontOld.h" #include "InsetMathFrac.h" +#include "InsetMathIntertext.h" #include "InsetMathLefteqn.h" #include "InsetMathOverset.h" #include "InsetMathPhantom.h" @@ -568,6 +569,8 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf) return MathAtom(new InsetMathBox(buf, l->name)); // if (inset == "fbox") // return MathAtom(new InsetMathFBox(l)); + if (inset == "intertext") + return MathAtom(new InsetMathIntertext(buf, l->name)); if (inset == "style") return MathAtom(new InsetMathSize(buf, l)); if (inset == "font") -- lyx-cvs mailing list lyx-cvs@lists.lyx.org https://lists.lyx.org/mailman/listinfo/lyx-cvs