Am Dienstag, den 02.01.2018, 15:22 +0000 schrieb José Abílio Matos:
> Hi,
>       in the last couple of months I had been busy working with
> beamer. A co-worker had a problem with the "Example Block" in beamer.
> The easiest recipe to replicate is:
>  
> 1) In a beamer document select the "Example Block". Write some text
> and then select some text and change its color to "No color". When
> lyx exports to latex the exported text range is transformed into
> "\textcolor{none}{...}". LaTeX rightly (IMHO) complains that 
>  
> Package xcolor Error: Undefined color `none'.
>  
> Without searching further I suspect that this is related with the
> fact the "Example Block" is painted as green. So I suspect that this
> is a general problem and not necessarily specific of beamer.

http://www.lyx.org/trac/ticket/5870

Fix attached.

Jürgen


>  
> Regards,
> -- 
> José Abílio
diff --git a/src/Font.cpp b/src/Font.cpp
index 450d67fa3a..5ac0328ea5 100644
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -362,6 +362,8 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
 
 	FontInfo f = bits_;
 	f.reduce(base.bits_);
+	FontInfo p = bits_;
+	p.reduce(prev.bits_);
 
 	if (f.family() != INHERIT_FAMILY) {
 		os << '\\'
@@ -385,10 +387,16 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
 		env = true; //We have opened a new environment
 	}
 	if (f.color() != Color_inherit && f.color() != Color_ignore) {
-		os << "\\textcolor{"
-		   << from_ascii(lcolor.getLaTeXName(f.color()))
-		   << "}{";
-		count += lcolor.getLaTeXName(f.color()).length() + 13;
+		if (f.color() == Color_none && p.color() != Color_none) {
+			// Color none: Close previous color, if any
+			os << '}';
+			++count;
+		} else if (f.color() != Color_none) {
+			os << "\\textcolor{"
+			   << from_ascii(lcolor.getLaTeXName(f.color()))
+			   << "}{";
+			count += lcolor.getLaTeXName(f.color()).length() + 13;
+		}
 		env = true; //We have opened a new environment
 	}
 	// FIXME: uncomment this when we support background.
@@ -489,7 +497,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
 		++count;
 		env = true; // Size change need not bother about closing env.
 	}
-	if (f.color() != Color_inherit && f.color() != Color_ignore) {
+	if (f.color() != Color_inherit && f.color() != Color_ignore && f.color() != Color_none) {
 		os << '}';
 		++count;
 		env = true; // Size change need not bother about closing env.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to