The attached bug adds support for \textcolor to tex2lyx. This fixes http://bugzilla.lyx.org/show_bug.cgi?id=2457

Attached is also a TeX-file as testcase for the patch.

regards Uwe
Index: text.cpp
===================================================================
--- text.cpp	(revision 24310)
+++ text.cpp	(working copy)
@@ -1847,6 +1847,15 @@
 				eat_whitespace(p, os, context, false);
 		}
 
+		else if (t.cs() == "textcolor") {
+			// scheme is \textcolor{color name}{text}
+			context.check_layout(os);
+			os << "\n\\color " << p.getArg('{', '}') << "\n";
+			parse_text_snippet(p, os, FLAG_ITEM, outer, context);
+			context.check_layout(os);
+			os << "\n\\color inherit\n";
+		}
+
 		else if (t.cs() == "underbar") {
 			// Do NOT handle \underline.
 			// \underbar cuts through y, g, q, p etc.,
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{color}

\usepackage{babel}

\begin{document}

test \textcolor{blue}{blue} test \textcolor{red}{red red red} test 
\textcolor{green}{bla}\textcolor{magenta}{blub}
test
\textcolor{green}{c}%
\textcolor{red}{o}%
\textcolor{blue}{l}%
\textcolor{green}{o}%
\textcolor{red}{r}

\end{document}

Reply via email to