From 2a8dcf2b10d5a5175c4e9bda1cc77413088181db Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Mon, 24 Oct 2011 00:29:59 +0000 Subject: [PATCH] tex2lyx: - support for box background color, document fontcolor and background color (note_fontcolor was already supported) - add colors and a nested box to the testfile git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39949 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/TODO.txt | 4 ---- src/tex2lyx/preamble.cpp | 20 ++++++++++++++++++- .../test/box-color-size-space-align.tex | 9 +++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index 6f235e1f03..368c3aa562 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -52,7 +52,6 @@ Format LaTeX feature LyX feature 347 tabular valign InsetTabular 348 \phantom, \hphantom, \vphantom InsetPhantom 350 ? \default_output_format -351 ? \backgroundcolor 353 \printsubindex InsetIndex 354 \printindex*, \printsubindex* InsetIndex 358 custom bibtex command \bibtex_command @@ -73,9 +72,6 @@ Format LaTeX feature LyX feature 378 revision info InsetInfo 380 ? InsetPreview 381 \xymatrix@!{0,R,C} InsetMathXYMatrix -382 note_fontcolor InsetNote -384 document font color \fontcolor -385 shaded box background color \boxbgcolor 386 LyX version InsetInfo 390 forward/reverse search \forward_search, \forward_macro 391 decimal alignment in tables InsetTabular diff --git a/src/tex2lyx/preamble.cpp b/src/tex2lyx/preamble.cpp index 5e26bfb336..719969452a 100644 --- a/src/tex2lyx/preamble.cpp +++ b/src/tex2lyx/preamble.cpp @@ -212,6 +212,9 @@ string h_use_bibtopic = "false"; string h_paperorientation = "portrait"; string h_suppress_date = "false"; string h_use_refstyle = "0"; +string h_backgroundcolor; +string h_boxbgcolor; +string h_fontcolor; string h_notefontcolor; string h_secnumdepth = "3"; string h_tocdepth = "3"; @@ -764,8 +767,14 @@ void end_preamble(ostream & os, TextClass const & /*textclass*/) << "\\paperorientation " << h_paperorientation << '\n' << "\\suppress_date " << h_suppress_date << '\n' << "\\use_refstyle " << h_use_refstyle << '\n'; + if (!h_fontcolor.empty()) + os << "\\fontcolor " << h_fontcolor << '\n'; if (!h_notefontcolor.empty()) os << "\\notefontcolor " << h_notefontcolor << '\n'; + if (!h_backgroundcolor.empty()) + os << "\\backgroundcolor " << h_backgroundcolor << '\n'; + if (!h_boxbgcolor.empty()) + os << "\\boxbgcolor " << h_boxbgcolor << '\n'; os << h_margins << "\\secnumdepth " << h_secnumdepth << "\n" << "\\tocdepth " << h_tocdepth << "\n" @@ -1127,9 +1136,18 @@ void parse_preamble(Parser & p, ostream & os, string const color = p.getArg('{', '}'); string const space = p.getArg('{', '}'); string const value = p.getArg('{', '}'); - if (color == "note_fontcolor" && space == "rgb") { + if (color == "document_fontcolor" && space == "rgb") { + RGBColor c(RGBColorFromLaTeX(value)); + h_fontcolor = X11hexname(c); + } else if (color == "note_fontcolor" && space == "rgb") { RGBColor c(RGBColorFromLaTeX(value)); h_notefontcolor = X11hexname(c); + } else if (color == "page_backgroundcolor" && space == "rgb") { + RGBColor c(RGBColorFromLaTeX(value)); + h_backgroundcolor = X11hexname(c); + } else if (color == "shadecolor" && space == "rgb") { + RGBColor c(RGBColorFromLaTeX(value)); + h_boxbgcolor = X11hexname(c); } else { h_preamble << "\\definecolor{" << color << "}{" << space << "}{" << value diff --git a/src/tex2lyx/test/box-color-size-space-align.tex b/src/tex2lyx/test/box-color-size-space-align.tex index 8c83d58768..33d76cd008 100644 --- a/src/tex2lyx/test/box-color-size-space-align.tex +++ b/src/tex2lyx/test/box-color-size-space-align.tex @@ -10,6 +10,10 @@ \usepackage{amsmath} \usepackage{color} +\definecolor{page_backgroundcolor}{rgb}{1, 0.3359375, 0} +\pagecolor{page_backgroundcolor} +\definecolor{document_fontcolor}{rgb}{0.66796875, 1, 0} +\color{document_fontcolor} \definecolor{note_fontcolor}{rgb}{0, 0, 1} \definecolor{shadecolor}{rgb}{1, 0, 0} \usepackage{framed} @@ -140,6 +144,11 @@ $\boxed{\int A=B}$ \begin{shaded}% Shaded background box\end{shaded} +\begin{minipage}[c]{1\columnwidth}% +\begin{shaded}% +Shaded background box, with inner minipage\end{shaded}% +\end{minipage} + \section{Colors} \subsection{Predefined Colors} -- 2.39.5