string h_spacing = "single";
string h_papersize = "default";
string h_use_geometry = "false";
-string h_use_amsmath = "0";
+string h_use_amsmath = "1";
+string h_use_esint = "1";
string h_cite_engine = "basic";
string h_use_bibtopic = "false";
string h_paperorientation = "portrait";
}
-void handle_package(string const & name, string const & opts,
+void handle_package(Parser &p, string const & name, string const & opts,
bool in_lyx_preamble)
{
vector<string> options = split_options(opts);
string scale;
// roman fonts
- if (is_known(name, known_roman_fonts))
+ if (is_known(name, known_roman_fonts)) {
h_font_roman = name;
+ p.skip_spaces();
+ }
if (name == "fourier") {
h_font_roman = "utopia";
// when font uses real small capitals
if (opts == "expert")
h_font_sc = "true";
+ p.skip_spaces();
}
- if (name == "mathpazo")
+
+ if (name == "mathpazo") {
h_font_roman = "palatino";
+ p.skip_spaces();
+ }
- if (name == "mathptmx")
+ if (name == "mathptmx") {
h_font_roman = "times";
+ p.skip_spaces();
+ }
// sansserif fonts
if (is_known(name, known_sans_fonts)) {
scale = opts;
h_font_sf_scale = scale_as_percentage(scale);
}
+ p.skip_spaces();
}
+
// typewriter fonts
if (is_known(name, known_typewriter_fonts)) {
h_font_typewriter = name;
scale = opts;
h_font_tt_scale = scale_as_percentage(scale);
}
+ p.skip_spaces();
}
+
// font uses old-style figure
- if (name == "eco")
+ if (name == "eco") {
h_font_osf = "true";
+ p.skip_spaces();
+ }
- else if (name == "amsmath" || name == "amssymb")
- h_use_amsmath = "1";
+ else if (name == "amsmath" || name == "amssymb") {
+ h_use_amsmath = "2";
+ p.skip_spaces();
+ }
+
+ else if (name == "esint") {
+ h_use_esint = "2";
+ p.skip_spaces();
+ }
else if (name == "babel" && !opts.empty()) {
// check if more than one option was used - used later for inputenc
h_language = "ukrainian";
h_quotes_language = h_language;
}
+ p.skip_spaces();
}
else if (name == "fontenc")
- ; // ignore this
+ p.skip_spaces(); // ignore this
else if (name == "inputenc") {
- // only set when there is not more than one inputenc option
- // therefore check for the "," character
- // also only set when there is not more then one babel language option
+ // only set when there is not more than one inputenc
+ // option therefore check for the "," character also
+ // only set when there is not more then one babel
+ // language option
if (opts.find(",") == string::npos && one_language == true) {
if (opts == "ascii")
//change ascii to auto to be in the unicode range, see
else if (!opts.empty())
h_inputencoding = opts;
}
+ if (!options.empty())
+ p.setEncoding(options.back());
options.clear();
+ p.skip_spaces();
}
else if (name == "makeidx")
- ; // ignore this
+ p.skip_spaces(); // ignore this
+
+ else if (name == "prettyref")
+ p.skip_spaces(); // ignore this
+
+ else if (name == "varioref")
+ p.skip_spaces(); // ignore this
else if (name == "verbatim")
- ; // ignore this
+ p.skip_spaces(); // ignore this
+
+ else if (name == "url")
+ p.skip_spaces(); // ignore this
- else if (name == "color")
+ 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";
+ p.skip_spaces();
+ }
else if (name == "graphicx")
- ; // ignore this
+ p.skip_spaces(); // ignore this
else if (name == "setspace")
- ; // ignore this
+ p.skip_spaces(); // ignore this
else if (name == "geometry")
- ; // Ignore this, the geometry settings are made by the \geometry
+ p.skip_spaces(); // Ignore this, the geometry settings are made by the \geometry
// command. This command is handled below.
else if (is_known(name, known_languages)) {
else
h_language = name;
h_quotes_language = h_language;
+ p.skip_spaces();
}
+
else if (name == "natbib") {
h_cite_engine = "natbib_authoryear";
vector<string>::iterator it =
options.erase(it);
}
}
+ p.skip_spaces();
}
- else if (name == "jurabib")
+
+ else if (name == "jurabib") {
h_cite_engine = "jurabib";
+ p.skip_spaces();
+ }
+
else if (!in_lyx_preamble) {
if (options.empty())
- h_preamble << "\\usepackage{" << name << "}\n";
+ h_preamble << "\\usepackage{" << name << "}";
else {
h_preamble << "\\usepackage[" << opts << "]{"
- << name << "}\n";
+ << name << "}";
options.clear();
}
}
void end_preamble(ostream & os, TextClass const & /*textclass*/)
{
os << "#LyX file created by tex2lyx " << PACKAGE_VERSION << "\n"
- << "\\lyxformat 249\n"
+ << "\\lyxformat 256\n"
<< "\\begin_document\n"
<< "\\begin_header\n"
<< "\\textclass " << h_textclass << "\n";
<< "\\papersize " << h_papersize << "\n"
<< "\\use_geometry " << h_use_geometry << "\n"
<< "\\use_amsmath " << h_use_amsmath << "\n"
+ << "\\use_esint " << h_use_esint << "\n"
<< "\\cite_engine " << h_cite_engine << "\n"
<< "\\use_bibtopic " << h_use_bibtopic << "\n"
<< "\\paperorientation " << h_paperorientation << "\n"
special_columns['D'] = 3;
bool is_full_document = false;
bool is_lyx_file = false;
- bool in_lyx_preamble = true;
+ bool in_lyx_preamble = false;
// determine whether this is a full document or a fragment for inclusion
while (p.good()) {
}
smatch sub;
- if (regex_search(comment, sub, islyxfile))
+ if (regex_search(comment, sub, islyxfile)) {
is_lyx_file = true;
- else if (is_lyx_file
- && regex_search(comment, sub, usercommands))
+ in_lyx_preamble = true;
+ } else if (is_lyx_file
+ && regex_search(comment, sub, usercommands))
in_lyx_preamble = false;
else if (!in_lyx_preamble)
h_preamble << t.asInput();
else if (t.cs() == "usepackage") {
string const options = p.getArg('[', ']');
string const name = p.getArg('{', '}');
- if (options.empty() && name.find(',')) {
- vector<string> vecnames;
- split(name, vecnames, ',');
- vector<string>::const_iterator it = vecnames.begin();
- vector<string>::const_iterator end = vecnames.end();
- for (; it != end; ++it)
- handle_package(trim(*it), string(),
- in_lyx_preamble);
- } else {
- handle_package(name, options, in_lyx_preamble);
- }
+ vector<string> vecnames;
+ split(name, vecnames, ',');
+ vector<string>::const_iterator it = vecnames.begin();
+ vector<string>::const_iterator end = vecnames.end();
+ for (; it != end; ++it)
+ handle_package(p, trim(*it), options,
+ in_lyx_preamble);
}
else if (t.cs() == "inputencoding") {
- h_inputencoding = p.getArg('{','}');
+ string const encoding = p.getArg('{','}');
+ h_inputencoding = encoding;
+ p.setEncoding(encoding);
}
else if (t.cs() == "newenvironment") {