[LyX/master] \protect substack in fragile context

Juergen Spitzmueller spitz at lyx.org
Mon Dec 27 10:09:58 UTC 2021


commit 596b2d16ee6e9534e39fe58d10b1c4ad66cac620
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Mon Dec 27 11:37:59 2021 +0100

    \protect substack in fragile context
    
    (\cprotect'ion not needed then).
---
 src/Paragraph.cpp                |    1 -
 src/mathed/InsetMathSubstack.cpp |    2 ++
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index f09143a..17c68fa 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4125,7 +4125,6 @@ bool Paragraph::needsCProtection(bool const fragile) const
 		if (!im || im->cell(0).empty())
 			continue;
 		switch(im->cell(0)[0]->lyxCode()) {
-		case MATH_SUBSTACK_CODE:
 		case MATH_ENV_CODE:
 		case MATH_XYMATRIX_CODE:
 			// these need cprotection
diff --git a/src/mathed/InsetMathSubstack.cpp b/src/mathed/InsetMathSubstack.cpp
index ed90338..11678b5 100644
--- a/src/mathed/InsetMathSubstack.cpp
+++ b/src/mathed/InsetMathSubstack.cpp
@@ -100,6 +100,8 @@ void InsetMathSubstack::infoize(odocstream & os) const
 void InsetMathSubstack::write(TeXMathStream & os) const
 {
 	MathEnsurer ensurer(os);
+	if (os.fragile())
+		os << "\\protect";
 	os << "\\substack{";
 	bool open = os.startOuterRow();
 	InsetMathGrid::write(os);


More information about the lyx-cvs mailing list