Am Mittwoch, dem 22.03.2023 um 22:39 +0000 schrieb Udicoudco:
> In some cases, e.g. displayed equation,
> LyX wraps a forceLTR inset like so:
> 
> \LRE{
> \[
> a+b=c
> \]
> } continuous text here...
> 
> which might cause undesired space
> if the user is not careful.
> 
> Attached a LyX file to demonstrate the problem and a patch to fix it.

Thanks. Could you try if the attached patch works for you? It employs
the slightly more elegant texstream methods rather than literal comment
chars.

-- 
Jürgen
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index c43421b376..655a415696 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -1091,6 +1091,8 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
 	}
 
 	bool close = false;
+	bool const nlinset = inset->getLayout().latextype() == InsetLaTeXType::ENVIRONMENT
+			|| runparams.inDisplayMath;
 	odocstream::pos_type const len = os.os().tellp();
 
 	if (inset->forceLTR(runparams)
@@ -1110,6 +1112,8 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
 		else
 			// babel classic
 			os << "\\L{";
+		if (nlinset)
+			os << safebreakln;
 		close = true;
 	}
 
@@ -1187,8 +1191,11 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
 		throw;
 	}
 
-	if (close)
+	if (close) {
 		os << '}';
+		if (nlinset)
+			os << safebreakln;
+	}
 
 	if (os.texrow().rows() > previous_row_count) {
 		os.texrow().start(owner_->id(), i + 1);
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to