commit 039de52ad94f47dc86c5a02cc1d7d8bcf991cc99 Author: Enrico Forestieri <for...@lyx.org> Date: Wed Nov 8 23:59:43 2023 +0100
Amend 58103cf2 The \underbar macro is a text mode macro that can also be used in math mode. However, when inserting it in mathed, LyX helpfully wraps it in a \text inset. One can dissolve such text inset and the macro would appear in math mode without any problem. But the output routine thinks that the user is shooting itself in the foot and tries to protect him by wrapping \underbar in the \lyxmathsym macro, whose definition is normally added to the preamble when an unicode character is used in math mode. Of course, this is not the case for \underbar and a compile error arises. The easier solution is to simply add lyxmathsym as a requirement for \underbar in lib/symbols, but this means that the definition of \lyxmathsym would be added even when not necessary (because in the validation routine we miss the info about the current mode). The correct solution is acknowledging the dual nature of \underbar as a text-mode macro that can also be used in math mode. Luckily the correct solution is almost as easy as the easier one and is what is done in this commit. --- lib/symbols | 2 +- src/mathed/InsetMathDecoration.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/symbols b/lib/symbols index f1fa587..aac3ee3 100644 --- a/lib/symbols +++ b/lib/symbols @@ -58,7 +58,7 @@ overline decoration none overrightarrow decoration none tilde decoration none uline decoration none ulem -underbar decoration none +underbar decoration everymode underbrace decoration none underleftarrow decoration none amsmath underleftrightarrow decoration none amsmath diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp index 614904c..960b6b7 100644 --- a/src/mathed/InsetMathDecoration.cpp +++ b/src/mathed/InsetMathDecoration.cpp @@ -182,7 +182,8 @@ void InsetMathDecoration::draw(PainterInfo & pi, int x, int y) const void InsetMathDecoration::write(TeXMathStream & os) const { bool needs_mathmode = currentMode() == MATH_MODE; - bool textmode_macro = currentMode() == TEXT_MODE; + bool textmode_macro = currentMode() == TEXT_MODE + && key_->extra != "everymode"; MathEnsurer ensurer(os, needs_mathmode, true, textmode_macro); if (os.fragile() && protect()) os << "\\protect"; -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs