From 7185c39fb169d75afd56fe5b9945ca37100d0fce Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Fri, 4 Nov 2011 21:24:05 +0000 Subject: [PATCH] \color may have an optional argument (part of bug #6567). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40134 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/Preamble.cpp | 11 ++++++++--- src/tex2lyx/test/box-color-size-space-align.tex | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index f084ad33a3..dace26f0e3 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -1003,17 +1003,22 @@ void Preamble::parse(Parser & p, string const & forceclass, } else if (t.cs() == "color") { + string const space = + (p.hasOpt() ? p.getArg('[', ']') : string()); string argument = p.getArg('{', '}'); // check the case that a standard color is used - if (is_known(argument, known_basic_colors)) { + if (space.empty() && is_known(argument, known_basic_colors)) { h_fontcolor = rgbcolor2code(argument); preamble.registerAutomaticallyLoadedPackage("color"); - } else if (argument == "document_fontcolor") + } else if (space.empty() && argument == "document_fontcolor") preamble.registerAutomaticallyLoadedPackage("color"); // check the case that LyX's document_fontcolor is defined // but not used for \color else { - h_preamble << t.asInput() << '{' << argument << '}'; + h_preamble << t.asInput(); + if (!space.empty()) + h_preamble << '[' << space << ']'; + h_preamble << '{' << argument << '}'; // the color might already be set because \definecolor // is parsed before this h_fontcolor = ""; diff --git a/src/tex2lyx/test/box-color-size-space-align.tex b/src/tex2lyx/test/box-color-size-space-align.tex index ef4dd8c8ee..094242804e 100644 --- a/src/tex2lyx/test/box-color-size-space-align.tex +++ b/src/tex2lyx/test/box-color-size-space-align.tex @@ -38,6 +38,8 @@ \definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5} +\color[rgb]{0,0,0} + \usepackage{ifpdf} % part of the hyperref bundle \ifpdf % if pdflatex is used