Now also for branch:

- tex2lyx/preamble.cpp, text.cpp: add support for \textcolor fixes http://bugzilla.lyx.org/show_bug.cgi?id=2457

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@24422 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2008-04-21 22:17:49 +00:00
parent aec651ca55
commit 8d01107a96
3 changed files with 43 additions and 8 deletions

View File

@ -246,6 +246,7 @@ void handle_package(string const & name, string const & opts)
// 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
@ -254,8 +255,10 @@ void handle_package(string const & name, string const & opts)
}
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;
@ -278,6 +281,7 @@ void handle_package(string const & name, string const & opts)
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
@ -308,6 +312,7 @@ void handle_package(string const & name, string const & opts)
}
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
@ -320,12 +325,21 @@ void handle_package(string const & name, string const & opts)
else
h_inputencoding = opts;
options.clear();
} else if (name == "makeidx")
}
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 << "\\@ifundefined{definecolor}\n {\\usepackage{color}}{}\n";
else if (name == "graphicx")
; // ignore this
else if (is_known(name, known_languages)) {
if (is_known(name, known_french_languages))
h_language = "french";
@ -340,8 +354,8 @@ void handle_package(string const & name, string const & opts)
else
h_language = name;
h_quotes_language = h_language;
} else if (name == "natbib") {
}
else if (name == "natbib") {
h_cite_engine = "natbib_authoryear";
vector<string>::iterator it =
find(options.begin(), options.end(), "authoryear");
@ -354,15 +368,16 @@ void handle_package(string const & name, string const & opts)
options.erase(it);
}
}
} else if (name == "jurabib") {
}
else if (name == "jurabib")
h_cite_engine = "jurabib";
} else if (options.empty())
else if (options.empty())
h_preamble << "\\usepackage{" << name << "}\n";
else {
h_preamble << "\\usepackage[" << opts << "]{" << name << "}\n";
options.clear();
}
// We need to do something with the options...
if (!options.empty())
cerr << "Ignoring options '" << join(options, ",")

View File

@ -1857,6 +1857,23 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
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.,

View File

@ -54,8 +54,11 @@ What's new
- Add support for the HTML-to-LaTeX converters gnuhtml2latex and
htmltolatex (bug 4615).
- The \makeatletter and \makeatother commands are now added to the LaTeX
preamble only when actually needed.
- The commands \makeatletter and \makeatother are now only added to the
preamble when actually needed.
- The command \textcolor is now converted when importing LaTeX files
(bug 2457).
* BUILD/INSTALLATION: