]> git.lyx.org Git - lyx.git/commitdiff
Amend 58103cf2
authorEnrico Forestieri <forenr@lyx.org>
Wed, 8 Nov 2023 22:59:43 +0000 (23:59 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 8 Nov 2023 23:21:21 +0000 (00:21 +0100)
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
src/mathed/InsetMathDecoration.cpp

index f1fa587e3fe76686f778e2cd2f17a59d413e7071..aac3ee3b6c93fe50b3510df6333ba738005b9f5b 100644 (file)
@@ -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
index 614904c4bc8b8a48490fdbb79a2fabea98b4cff2..960b6b78ab282af767ca4ef711e5323a84cb280f 100644 (file)
@@ -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";