This patch adds support for \textcolor to tex2lyx. It takes also care of self-defined colors. Attached is also the file I'll add as testcase to SVN.
regards Uwe
\documentclass[a4paper,12pt]{article} \usepackage[T1]{fontenc} \usepackage[latin9]{inputenc} \usepackage{amsmath} \usepackage{color} \setlength{\parskip}{3mm} \setlength{\parindent}{0sp} \usepackage{setspace} \setstretch{1.2} \setlength{\fboxsep}{3mm} \definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5} \begin{document} \tableofcontents \section{Boxes} \subsection{Frameless Boxes} blabla \mbox{test} blabla blabla \makebox{test} blabla blabla \makebox[3cm]{test} blabla blabla \makebox[3cm][l]{test} blabla \begin{figure}[ht] \centering \setlength{\unitlength}{.2in} \begin{picture}(8,6) \put(0,0){\makebox(0,0)[tr]{AAA}} \put(8,0){\makebox(0,0){BBB}} \put(1,0){\line(1,0){6}} \end{picture} \end{figure} \raisebox {8.5mm}{test}\raisebox {-6.5mm}{tset} \subsection{Framed Boxes} blabla \fbox{test} blabla blabla \framebox[3cm]{test} blabla blabla \framebox[3cm][l]{test} blabla Dies ist ein Beispieltext. % \framebox{% \begin{minipage}[c][1\totalheight][s]{0.2\columnwidth}% \begin{center} Der Boxinhalt \par\end{center} \begin{center} ist über die \par\end{center} \begin{center} Boxhöhe \par\end{center} \begin{center} gleichmäßig verteilt. \par\end{center}% \end{minipage}} Dies ist ein Beispieltext. $\boxed{\int A=B}$ \section{Colors} \subsection{Predefined Colors} 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} \subsection{Custom Colors} test \textcolor{darkgreen}{dark green} test \definecolor{violet}{rgb}{0.5, 0, 1} test \textcolor{violet}{violet} test \end{document}
Index: preamble.cpp =================================================================== --- preamble.cpp (revision 24371) +++ preamble.cpp (working copy) @@ -238,6 +238,7 @@ // roman fonts if (is_known(name, known_roman_fonts)) h_font_roman = name; + if (name == "fourier") { h_font_roman = "utopia"; // when font uses real small capitals @@ -246,8 +247,10 @@ } if (name == "mathpazo") h_font_roman = "palatino"; + if (name == "mathptmx") h_font_roman = "times"; + // sansserif fonts if (is_known(name, known_sans_fonts)) { h_font_sans = name; @@ -270,6 +273,7 @@ else if (name == "amsmath" || name == "amssymb") h_use_amsmath = "1"; + else if (name == "babel" && !opts.empty()) { // check if more than one option was used - used later for inputenc // in case inputenc is parsed before babel, set the encoding to auto @@ -298,8 +302,10 @@ h_quotes_language = h_language; } } + else if (name == "fontenc") ; // ignore this + else if (name == "inputenc") { // only set when there is not more than one inputenc option // therefore check for the "," character @@ -312,10 +318,18 @@ else h_inputencoding = opts; options.clear(); + } else if (name == "makeidx") ; // ignore this + else if (name == "verbatim") ; // ignore this + + else if (name == "color") + // with the following command this package is only loaded when needed for + // undefined colors, since we only support the predefined colors + h_preamble << "[EMAIL PROTECTED] {\\usepackage{color}}{}\n"; + else if (name == "graphicx") ; // ignore this else if (is_known(name, known_languages)) { @@ -348,6 +362,7 @@ } } else if (name == "jurabib") { h_cite_engine = "jurabib"; + } else if (options.empty()) h_preamble << "\\usepackage{" << name << "}\n"; else { Index: text.cpp =================================================================== --- text.cpp (revision 24371) +++ text.cpp (working copy) @@ -1847,6 +1847,23 @@ eat_whitespace(p, os, context, false); } + else if (t.cs() == "textcolor") { + // scheme is \textcolor{color name}{text} + string const color = p.verbatim_item(); + // we only support the predefined colors of the color package + if (color == "black" || color == "blue" || color == "cyan" + || color == "green" || color == "magenta" || color == "red" + || color == "white" || color == "yellow") { + context.check_layout(os); + os << "\n\\color " << color << "\n"; + parse_text_snippet(p, os, FLAG_ITEM, outer, context); + context.check_layout(os); + os << "\n\\color inherit\n"; + } else + // for custom defined colors + handle_ert(os, t.asInput() + "{" + color + "}", context); + } + else if (t.cs() == "underbar") { // Do NOT handle \underline. // \underbar cuts through y, g, q, p etc.,