On Mon, Sep 07, 2020 at 07:02:39PM +0200, Enrico Forestieri wrote:
> On Mon, Sep 07, 2020 at 12:43:35PM +0200, Jean-Marc Lasgouttes wrote:
> > Le 07/09/2020 à 01:15, Scott Kostyshak a écrit :
> > > I think this might have caused a change in LaTeX exported in some cases.
> > > In the attached .lyx file, if you load with 2.3.x, it does not use the
> > > package esint. But if you load with master, it does.
> > > 
> > > I think this is related to the following ticket:
> > > 
> > >    http://www.lyx.org/trac/ticket/9498
> > 
> > The following patch fixes the issue: \intop is declared as requiring either
> > esint or amsmath. Enrico, does that sound OK to you? I am not sure of the
> > reason why one wants one of these packages.
> 
> I am not sure, either. Strictly speaking, those package should be required
> only when using multiple integrals or cyclic integrals.

I think this is done for consistency.

> > And if this is OK, I should do the same for iint, iiint and iiiint, right?
> 
> Yes, this fixes it, but also reveals another problem. If a macro appears
> in the expansion of a \def, its requirements are also taken into account.
> This is wrong, because the \def is only meant for on-screen representation
> and not for output. So, the correct patch would be fixing this glitch.
> This time you incurred in it, but I bet it will bite again.

The attached patch works for me.

-- 
Enrico
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index bf363b61db..5743dd0e45 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -967,7 +967,16 @@ void InsetMathMacro::validate(LaTeXFeatures & features) 
const
 
        // validate the cells and the definition
        if (displayMode() == DISPLAY_NORMAL) {
-               d->definition_.validate(features);
+               // Don't update requirements if the macro comes from
+               // the symbols file and has not been redefined.
+               MathWordList const & words = mathedWordList();
+               MathWordList::const_iterator it = words.find(name());
+               MacroNameSet macros;
+               buffer().listMacroNames(macros);
+               if (it == words.end() || it->second.inset != "macro"
+                   || macros.find(name()) != macros.end()) {
+                       d->definition_.validate(features);
+               }
                InsetMathNest::validate(features);
        }
 }
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to