[LyX/master] Do not \protect label in subfloat caption (#11950)

Juergen Spitzmueller spitz at lyx.org
Fri Aug 28 05:06:53 UTC 2020


commit 3fc095e3bc226e854f6cd9882a4c9e9039374caf
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Fri Aug 28 07:32:29 2020 +0200

    Do not \protect label in subfloat caption (#11950)
---
 src/insets/InsetFloat.cpp |    2 +-
 src/insets/InsetLabel.cpp |    5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index b0a48f2..24e06b5 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -391,11 +391,11 @@ void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
 
 		OutputParams rp = runparams_in;
 		rp.moving_arg = true;
+		rp.inFloat = OutputParams::SUBFLOAT;
 		os << getCaption(rp);
 		os << '{';
 		// The main argument is the contents of the float. This is not a moving argument.
 		rp.moving_arg = false;
-		rp.inFloat = OutputParams::SUBFLOAT;
 		InsetText::latex(os, rp);
 		os << "}";
 
diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp
index ec50d4f..2e80e26 100644
--- a/src/insets/InsetLabel.cpp
+++ b/src/insets/InsetLabel.cpp
@@ -334,7 +334,10 @@ void InsetLabel::latex(otexstream & os, OutputParams const & runparams_in) const
 	if (runparams_in.postpone_fragile_stuff)
 		runparams_in.post_macro += command;
 	else {
-		if (runparams.moving_arg)
+		// protect label in moving argument (#9404),
+		// but not in subfloat caption (#11950)
+		if (runparams.moving_arg
+		    && runparams.inFloat != OutputParams::SUBFLOAT)
 			os << "\\protect";
 		os << command;
 	}


More information about the lyx-cvs mailing list