3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
18 #include "LayoutFile.h"
21 #include "TextClass.h"
23 #include "support/convert.h"
24 #include "support/FileName.h"
25 #include "support/filetools.h"
26 #include "support/lstrings.h"
28 #include <boost/regex.hpp>
38 using namespace lyx::support;
44 // special columntypes
45 extern map<char, int> special_columns;
47 map<string, vector<string> > used_packages;
49 // needed to handle encodings with babel
50 bool one_language = true;
54 const char * const known_languages[] = { "afrikaans", "american", "arabic",
55 "austrian", "bahasa", "basque", "belarusian", "brazil", "brazilian", "breton",
56 "british", "bulgarian", "canadian", "canadien", "catalan", "croatian", "czech",
57 "danish", "dutch", "english", "esperanto", "estonian", "finnish", "francais",
58 "french", "frenchb", "frenchle", "frenchpro", "galician", "german", "germanb",
59 "greek", "hebrew", "icelandic", "irish", "italian", "lsorbian", "magyar",
60 "naustrian", "ngerman", "ngermanb", "norsk", "nynorsk", "polish", "portuges",
61 "portuguese", "romanian", "russian", "russianb", "scottish", "serbian", "slovak",
62 "slovene", "spanish", "swedish", "thai", "turkish", "ukraineb", "ukrainian",
63 "usorbian", "welsh", 0};
65 //note this when updating to lyxformat 305:
66 //bahasai, indonesian, and indon = equal to bahasa
67 //malay and meyalu = equal to bahasam
69 const char * const known_brazilian_languages[] = {"brazil", "brazilian", 0};
70 const char * const known_french_languages[] = {"french", "frenchb", "francais",
71 "frenchle", "frenchpro", 0};
72 const char * const known_german_languages[] = {"german", "germanb", 0};
73 const char * const known_ngerman_languages[] = {"ngerman", "ngermanb", 0};
74 const char * const known_portuguese_languages[] = {"portuges", "portuguese", 0};
75 const char * const known_russian_languages[] = {"russian", "russianb", 0};
76 const char * const known_ukrainian_languages[] = {"ukrainian", "ukraineb", 0};
78 char const * const known_fontsizes[] = { "10pt", "11pt", "12pt", 0 };
80 const char * const known_roman_fonts[] = { "ae", "bookman", "charter",
81 "cmr", "fourier", "lmodern", "mathpazo", "mathptmx", "newcent", 0};
83 const char * const known_sans_fonts[] = { "avant", "berasans", "cmbr", "cmss",
86 const char * const known_typewriter_fonts[] = { "beramono", "cmtl", "cmtt",
87 "courier", "lmtt", "luximono", "fourier", "lmodern", "mathpazo", "mathptmx",
90 const char * const known_paper_sizes[] = { "a3paper", "b3paper", "a4paper",
91 "b4paper", "a5paper", "b5paper", "executivepaper", "legalpaper",
94 const char * const known_class_paper_sizes[] = { "a4paper", "a5paper",
95 "executivepaper", "legalpaper", "letterpaper", 0};
97 const char * const known_paper_margins[] = { "lmargin", "tmargin", "rmargin",
98 "bmargin", "headheight", "headsep", "footskip", "columnsep", 0};
100 const char * const known_coded_paper_margins[] = { "leftmargin", "topmargin",
101 "rightmargin", "bottommargin", "headheight", "headsep", "footskip",
105 ostringstream h_preamble;
106 string h_textclass = "article";
107 string h_options = string();
108 string h_language = "english";
109 string h_inputencoding = "auto";
110 string h_font_roman = "default";
111 string h_font_sans = "default";
112 string h_font_typewriter = "default";
113 string h_font_default_family = "default";
114 string h_font_sc = "false";
115 string h_font_osf = "false";
116 string h_font_sf_scale = "100";
117 string h_font_tt_scale = "100";
118 string h_graphics = "default";
119 string h_paperfontsize = "default";
120 string h_spacing = "single";
121 string h_papersize = "default";
122 string h_use_geometry = "false";
123 string h_use_amsmath = "1";
124 string h_use_esint = "1";
125 string h_cite_engine = "basic";
126 string h_use_bibtopic = "false";
127 string h_paperorientation = "portrait";
128 string h_secnumdepth = "3";
129 string h_tocdepth = "3";
130 string h_paragraph_separation = "indent";
131 string h_defskip = "medskip";
132 string h_quotes_language = "english";
133 string h_papercolumns = "1";
134 string h_papersides = string();
135 string h_paperpagestyle = "default";
136 string h_tracking_changes = "false";
137 string h_output_changes = "false";
138 string h_margins = "";
140 // returns true if at least one of the options in what has been found
141 bool handle_opt(vector<string> & opts, char const * const * what, string & target)
147 // the last language option is the document language (for babel and LyX)
148 // the last size option is the document font size
149 vector<string>::iterator it;
150 vector<string>::iterator position = opts.begin();
151 for (; *what; ++what) {
152 it = find(opts.begin(), opts.end(), *what);
153 if (it != opts.end()) {
154 if (it >= position) {
165 void delete_opt(vector<string> & opts, char const * const * what)
170 // remove found options from the list
171 // do this after handle_opt to avoid potential memory leaks
172 vector<string>::iterator it;
173 for (; *what; ++what) {
174 it = find(opts.begin(), opts.end(), *what);
175 if (it != opts.end())
182 * Split a package options string (keyval format) into a vector.
184 * authorformat=smallcaps,
186 * titleformat=colonsep,
187 * bibformat={tabular,ibidem,numbered}
189 vector<string> split_options(string const & input)
191 vector<string> options;
195 Token const & t = p.get_token();
196 if (t.asInput() == ",") {
197 options.push_back(trim(option));
199 } else if (t.asInput() == "=") {
202 if (p.next_token().asInput() == "{")
203 option += '{' + p.getArg('{', '}') + '}';
204 } else if (t.cat() != catSpace)
205 option += t.asInput();
209 options.push_back(trim(option));
216 * Add package \p name with options \p options to used_packages.
217 * Remove options from \p options that we don't want to output.
219 void add_package(string const & name, vector<string> & options)
221 // every package inherits the global options
222 if (used_packages.find(name) == used_packages.end())
223 used_packages[name] = split_options(h_options);
225 vector<string> & v = used_packages[name];
226 v.insert(v.end(), options.begin(), options.end());
227 if (name == "jurabib") {
228 // Don't output the order argument (see the cite command
229 // handling code in text.cpp).
230 vector<string>::iterator end =
231 remove(options.begin(), options.end(), "natbiborder");
232 end = remove(options.begin(), end, "jurabiborder");
233 options.erase(end, options.end());
238 // Given is a string like "scaled=0.9", return 0.9 * 100
239 string const scale_as_percentage(string const & scale)
241 string::size_type pos = scale.find('=');
242 if (pos != string::npos) {
243 string value = scale.substr(pos + 1);
245 return convert<string>(100 * convert<double>(value));
247 // If the input string didn't match our expectations.
248 // return the default value "100"
253 void handle_package(Parser &p, string const & name, string const & opts,
254 bool in_lyx_preamble)
256 vector<string> options = split_options(opts);
257 add_package(name, options);
261 if (is_known(name, known_roman_fonts)) {
266 if (name == "fourier") {
267 h_font_roman = "utopia";
268 // when font uses real small capitals
269 if (opts == "expert")
273 if (name == "mathpazo")
274 h_font_roman = "palatino";
276 if (name == "mathptmx")
277 h_font_roman = "times";
280 if (is_known(name, known_sans_fonts)) {
284 h_font_sf_scale = scale_as_percentage(scale);
289 if (is_known(name, known_typewriter_fonts)) {
290 h_font_typewriter = name;
293 h_font_tt_scale = scale_as_percentage(scale);
297 // font uses old-style figure
301 else if (name == "amsmath" || name == "amssymb")
304 else if (name == "esint")
307 else if (name == "babel" && !opts.empty()) {
308 // check if more than one option was used - used later for inputenc
309 // in case inputenc is parsed before babel, set the encoding to auto
310 if (options.begin() != options.end() - 1) {
311 one_language = false;
312 h_inputencoding = "auto";
314 // babel takes the last language of the option of its \usepackage
315 // call as document language. If there is no such language option, the
316 // last language in the documentclass options is used.
317 handle_opt(options, known_languages, h_language);
318 delete_opt(options, known_languages);
319 if (is_known(h_language, known_brazilian_languages))
320 h_language = "brazilian";
321 else if (is_known(h_language, known_french_languages)) {
322 h_language = "french";
323 h_quotes_language = "french";
324 } else if (is_known(h_language, known_german_languages)) {
325 h_language = "german";
326 h_quotes_language = "german";
327 } else if (is_known(h_language, known_ngerman_languages)) {
328 h_language = "ngerman";
329 h_quotes_language = "german";
330 } else if (is_known(h_language, known_portuguese_languages))
331 h_language = "portuguese";
332 else if (is_known(h_language, known_russian_languages))
333 h_language = "russian";
334 else if (is_known(h_language, known_ukrainian_languages))
335 h_language = "ukrainian";
336 // LyX only knows the following quotes languages:
337 // english, swedish, german, polish, french and danish
338 // french and german are already handled, english is the default
339 if (h_language == "swedish" || h_language == "polish"
340 || h_language == "danish")
341 h_quotes_language = h_language;
344 else if (name == "fontenc")
347 else if (name == "inputenc") {
348 // h_inputencoding is only set when there is not more than one
349 // inputenc option because otherwise h_inputencoding must be
350 // set to "auto" (the default encoding of the document language)
351 // Therefore check for the "," character.
352 // It is also only set when there is not more then one babel
353 // language option but this is handled in the routine for babel.
354 if (opts.find(",") == string::npos && one_language == true) {
356 //change ascii to auto to be in the unicode range, see
357 //http://www.lyx.org/trac/ticket/4719
358 h_inputencoding = "auto";
359 else if (!opts.empty())
360 h_inputencoding = opts;
362 if (!options.empty())
363 p.setEncoding(options.back());
367 else if (name == "makeidx")
370 else if (name == "prettyref")
373 else if (name == "varioref")
376 else if (name == "verbatim")
379 else if (name == "nomencl")
382 else if (name == "textcomp")
385 else if (name == "url")
388 else if (name == "color") {
389 // with the following command this package is only loaded when needed for
390 // undefined colors, since we only support the predefined colors
391 h_preamble << "\\@ifundefined{definecolor}\n {\\usepackage{color}}{}\n";
394 else if (name == "graphicx")
397 else if (name == "setspace")
400 else if (name == "geometry")
401 ; // Ignore this, the geometry settings are made by the \geometry
402 // command. This command is handled below.
404 else if (is_known(name, known_languages)) {
405 if (is_known(name, known_brazilian_languages))
406 h_language = "brazilian";
407 else if (is_known(name, known_french_languages))
408 h_language = "french";
409 h_quotes_language = "french";
410 } else if (is_known(name, known_german_languages)) {
411 h_language = "german";
412 h_quotes_language = "german";
413 } else if (is_known(name, known_ngerman_languages)) {
414 h_language = "ngerman";
415 h_quotes_language = "german";
416 } else if (is_known(name, known_portuguese_languages))
417 h_language = "portuguese";
418 else if (is_known(name, known_russian_languages))
419 h_language = "russian";
420 else if (is_known(name, known_ukrainian_languages))
421 h_language = "ukrainian";
422 // LyX only knows the following quotes languages:
423 // english, swedish, german, polish, french and danish
424 // french and german are already handled, english is the default
425 if (name == "swedish" || name == "polish"
427 h_quotes_language = name;
430 else if (name == "natbib") {
431 h_cite_engine = "natbib_authoryear";
432 vector<string>::iterator it =
433 find(options.begin(), options.end(), "authoryear");
434 if (it != options.end())
437 it = find(options.begin(), options.end(), "numbers");
438 if (it != options.end()) {
439 h_cite_engine = "natbib_numerical";
445 else if (name == "jurabib")
446 h_cite_engine = "jurabib";
448 else if (!in_lyx_preamble) {
450 h_preamble << "\\usepackage{" << name << "}";
452 h_preamble << "\\usepackage[" << opts << "]{"
458 // We need to do something with the options...
459 if (!options.empty())
460 cerr << "Ignoring options '" << join(options, ",")
461 << "' of package " << name << '.' << endl;
463 // remove the whitespace
469 void end_preamble(ostream & os, TextClass const & /*textclass*/)
471 os << "#LyX file created by tex2lyx " << PACKAGE_VERSION << "\n"
472 << "\\lyxformat 264\n"
473 << "\\begin_document\n"
474 << "\\begin_header\n"
475 << "\\textclass " << h_textclass << "\n";
476 if (!h_preamble.str().empty())
477 os << "\\begin_preamble\n" << h_preamble.str() << "\n\\end_preamble\n";
478 if (!h_options.empty())
479 os << "\\options " << h_options << "\n";
480 os << "\\language " << h_language << "\n"
481 << "\\inputencoding " << h_inputencoding << "\n"
482 << "\\font_roman " << h_font_roman << "\n"
483 << "\\font_sans " << h_font_sans << "\n"
484 << "\\font_typewriter " << h_font_typewriter << "\n"
485 << "\\font_default_family " << h_font_default_family << "\n"
486 << "\\font_sc " << h_font_sc << "\n"
487 << "\\font_osf " << h_font_osf << "\n"
488 << "\\font_sf_scale " << h_font_sf_scale << "\n"
489 << "\\font_tt_scale " << h_font_tt_scale << "\n"
490 << "\\graphics " << h_graphics << "\n"
491 << "\\paperfontsize " << h_paperfontsize << "\n"
492 << "\\spacing " << h_spacing << "\n"
493 << "\\papersize " << h_papersize << "\n"
494 << "\\use_geometry " << h_use_geometry << "\n"
495 << "\\use_amsmath " << h_use_amsmath << "\n"
496 << "\\use_esint " << h_use_esint << "\n"
497 << "\\cite_engine " << h_cite_engine << "\n"
498 << "\\use_bibtopic " << h_use_bibtopic << "\n"
499 << "\\paperorientation " << h_paperorientation << "\n"
501 << "\\secnumdepth " << h_secnumdepth << "\n"
502 << "\\tocdepth " << h_tocdepth << "\n"
503 << "\\paragraph_separation " << h_paragraph_separation << "\n"
504 << "\\defskip " << h_defskip << "\n"
505 << "\\quotes_language " << h_quotes_language << "\n"
506 << "\\papercolumns " << h_papercolumns << "\n"
507 << "\\papersides " << h_papersides << "\n"
508 << "\\paperpagestyle " << h_paperpagestyle << "\n"
509 << "\\tracking_changes " << h_tracking_changes << "\n"
510 << "\\output_changes " << h_output_changes << "\n"
511 << "\\end_header\n\n"
513 // clear preamble for subdocuments
517 } // anonymous namespace
519 void parse_preamble(Parser & p, ostream & os,
520 string const & forceclass, TeX2LyXDocClass & tc)
522 // initialize fixed types
523 special_columns['D'] = 3;
524 bool is_full_document = false;
525 bool is_lyx_file = false;
526 bool in_lyx_preamble = false;
528 // determine whether this is a full document or a fragment for inclusion
530 Token const & t = p.get_token();
532 if (t.cat() == catEscape && t.cs() == "documentclass") {
533 is_full_document = true;
539 while (is_full_document && p.good()) {
540 Token const & t = p.get_token();
543 cerr << "t: " << t << "\n";
549 if (!in_lyx_preamble &&
550 (t.cat() == catLetter ||
551 t.cat() == catSuper ||
553 t.cat() == catOther ||
554 t.cat() == catMath ||
555 t.cat() == catActive ||
556 t.cat() == catBegin ||
558 t.cat() == catAlign ||
559 t.cat() == catParameter))
560 h_preamble << t.cs();
562 else if (!in_lyx_preamble &&
563 (t.cat() == catSpace || t.cat() == catNewline))
564 h_preamble << t.asInput();
566 else if (t.cat() == catComment) {
567 // regex to parse comments (currently not used)
568 static regex const islyxfile("%% LyX .* created this file");
569 static regex const usercommands("User specified LaTeX commands");
571 string const comment = t.asInput();
573 // magically switch encoding default if it looks like XeLaTeX
574 static string const magicXeLaTeX =
575 "% This document must be compiled with XeLaTeX ";
576 if (comment.size() > magicXeLaTeX.size()
577 && comment.substr(0, magicXeLaTeX.size()) == magicXeLaTeX
578 && h_inputencoding == "auto") {
579 cerr << "XeLaTeX comment found, switching to UTF8\n";
580 h_inputencoding = "utf8";
583 if (regex_search(comment, sub, islyxfile)) {
585 in_lyx_preamble = true;
586 } else if (is_lyx_file
587 && regex_search(comment, sub, usercommands))
588 in_lyx_preamble = false;
589 else if (!in_lyx_preamble)
590 h_preamble << t.asInput();
593 else if (t.cs() == "pagestyle")
594 h_paperpagestyle = p.verbatim_item();
596 else if (t.cs() == "makeatletter") {
597 // LyX takes care of this
598 p.setCatCode('@', catLetter);
601 else if (t.cs() == "makeatother") {
602 // LyX takes care of this
603 p.setCatCode('@', catOther);
606 else if (t.cs() == "newcommand" || t.cs() == "renewcommand"
607 || t.cs() == "providecommand"
608 || t.cs() == "DeclareRobustCommand"
609 || t.cs() == "ProvideTextCommandDefault"
610 || t.cs() == "DeclareMathAccent") {
612 if (p.next_token().character() == '*') {
616 string const name = p.verbatim_item();
617 string const opt1 = p.getOpt();
618 string const opt2 = p.getFullOpt();
619 string const body = p.verbatim_item();
621 if (name == "\\rmdefault")
622 if (is_known(body, known_roman_fonts))
624 if (name == "\\sfdefault")
625 if (is_known(body, known_sans_fonts))
627 if (name == "\\ttdefault")
628 if (is_known(body, known_typewriter_fonts))
629 h_font_typewriter = body;
630 if (name == "\\familydefault") {
631 string family = body;
632 // remove leading "\"
633 h_font_default_family = family.erase(0,1);
635 // only non-lyxspecific stuff
636 if (!in_lyx_preamble) {
638 ss << '\\' << t.cs();
641 ss << '{' << name << '}' << opt1 << opt2
642 << '{' << body << "}";
643 h_preamble << ss.str();
645 // Add the command to the known commands
646 add_known_command(name, opt1, !opt2.empty());
648 ostream & out = in_preamble ? h_preamble : os;
649 out << "\\" << t.cs() << "{" << name << "}"
650 << opts << "{" << body << "}";
655 else if (t.cs() == "documentclass") {
656 vector<string>::iterator it;
657 vector<string> opts = split_options(p.getArg('[', ']'));
658 handle_opt(opts, known_fontsizes, h_paperfontsize);
659 delete_opt(opts, known_fontsizes);
660 // delete "pt" at the end
661 string::size_type i = h_paperfontsize.find("pt");
662 if (i != string::npos)
663 h_paperfontsize.erase(i);
664 // The documentclass options are always parsed before the options
665 // of the babel call so that a language cannot overwrite the babel
667 handle_opt(opts, known_languages, h_language);
668 delete_opt(opts, known_languages);
669 if (is_known(h_language, known_brazilian_languages))
670 h_language = "brazilian";
671 else if (is_known(h_language, known_french_languages)) {
672 h_language = "french";
673 h_quotes_language = "french";
674 } else if (is_known(h_language, known_german_languages)) {
675 h_language = "german";
676 h_quotes_language = "german";
677 } else if (is_known(h_language, known_ngerman_languages)) {
678 h_language = "ngerman";
679 h_quotes_language = "german";
680 } else if (is_known(h_language, known_portuguese_languages))
681 h_language = "portuguese";
682 else if (is_known(h_language, known_russian_languages))
683 h_language = "russian";
684 else if (is_known(h_language, known_ukrainian_languages))
685 h_language = "ukrainian";
686 // LyX only knows the following quotes languages:
687 // english, swedish, german, polish, french and danish
688 // french and german are already handled, english is the default
689 if (h_language == "swedish" || h_language == "polish"
690 || h_language == "danish")
691 h_quotes_language = h_language;
693 if ((it = find(opts.begin(), opts.end(), "landscape")) != opts.end()) {
694 h_paperorientation = "landscape";
698 if ((it = find(opts.begin(), opts.end(), "oneside"))
703 if ((it = find(opts.begin(), opts.end(), "twoside"))
709 if ((it = find(opts.begin(), opts.end(), "onecolumn"))
711 h_papercolumns = "1";
714 if ((it = find(opts.begin(), opts.end(), "twocolumn"))
716 h_papercolumns = "2";
720 // some size options are know to any document classes, other sizes
721 // are handled by the \geometry command of the geometry package
722 handle_opt(opts, known_class_paper_sizes, h_papersize);
723 delete_opt(opts, known_class_paper_sizes);
724 // the remaining options
725 h_options = join(opts, ",");
726 h_textclass = p.getArg('{', '}');
729 else if (t.cs() == "usepackage") {
730 string const options = p.getArg('[', ']');
731 string const name = p.getArg('{', '}');
732 vector<string> vecnames;
733 split(name, vecnames, ',');
734 vector<string>::const_iterator it = vecnames.begin();
735 vector<string>::const_iterator end = vecnames.end();
736 for (; it != end; ++it)
737 handle_package(p, trim(*it), options,
741 else if (t.cs() == "inputencoding") {
742 string const encoding = p.getArg('{','}');
743 h_inputencoding = encoding;
744 p.setEncoding(encoding);
747 else if (t.cs() == "newenvironment") {
748 string const name = p.getArg('{', '}');
750 ss << "\\newenvironment{" << name << "}";
753 ss << '{' << p.verbatim_item() << '}';
754 ss << '{' << p.verbatim_item() << '}';
755 if (!in_lyx_preamble)
756 h_preamble << ss.str();
759 else if (t.cs() == "def") {
760 string name = p.get_token().cs();
761 while (p.next_token().cat() != catBegin)
762 name += p.get_token().cs();
763 if (!in_lyx_preamble)
764 h_preamble << "\\def\\" << name << '{'
765 << p.verbatim_item() << "}";
768 else if (t.cs() == "newcolumntype") {
769 string const name = p.getArg('{', '}');
772 string opts = p.getOpt();
774 istringstream is(string(opts, 1));
777 special_columns[name[0]] = nargs;
778 h_preamble << "\\newcolumntype{" << name << "}";
780 h_preamble << "[" << nargs << "]";
781 h_preamble << "{" << p.verbatim_item() << "}";
784 else if (t.cs() == "setcounter") {
785 string const name = p.getArg('{', '}');
786 string const content = p.getArg('{', '}');
787 if (name == "secnumdepth")
788 h_secnumdepth = content;
789 else if (name == "tocdepth")
790 h_tocdepth = content;
792 h_preamble << "\\setcounter{" << name << "}{" << content << "}";
795 else if (t.cs() == "setlength") {
796 string const name = p.verbatim_item();
797 string const content = p.verbatim_item();
798 // the paragraphs are only not indented when \parindent is set to zero
799 if (name == "\\parindent" && content != "") {
800 if (content[0] == '0')
801 h_paragraph_separation = "skip";
802 } else if (name == "\\parskip") {
803 if (content == "\\smallskipamount")
804 h_defskip = "smallskip";
805 else if (content == "\\medskipamount")
806 h_defskip = "medskip";
807 else if (content == "\\bigskipamount")
808 h_defskip = "bigskip";
812 h_preamble << "\\setlength{" << name << "}{" << content << "}";
815 else if (t.cs() == "onehalfspacing")
816 h_spacing = "onehalf";
818 else if (t.cs() == "doublespacing")
819 h_spacing = "double";
821 else if (t.cs() == "setstretch")
822 h_spacing = "other " + p.verbatim_item();
824 else if (t.cs() == "begin") {
825 string const name = p.getArg('{', '}');
826 if (name == "document")
828 h_preamble << "\\begin{" << name << "}";
831 else if (t.cs() == "geometry") {
832 h_use_geometry = "true";
833 vector<string> opts = split_options(p.getArg('{', '}'));
834 vector<string>::iterator it;
836 if ((it = find(opts.begin(), opts.end(), "landscape")) != opts.end()) {
837 h_paperorientation = "landscape";
841 handle_opt(opts, known_paper_sizes, h_papersize);
842 delete_opt(opts, known_paper_sizes);
844 char const * const * margin = known_paper_margins;
846 for (; *margin; ++margin) {
848 // search for the "=" in e.g. "lmargin=2cm" to get the value
849 for(size_t i = 0; i != opts.size(); i++) {
850 if (opts.at(i).find(*margin) != string::npos) {
851 string::size_type pos = opts.at(i).find("=");
852 string value = opts.at(i).substr(pos + 1);
853 string name = known_coded_paper_margins[k];
854 h_margins += "\\" + name + " " + value + "\n";
860 else if (t.cs() == "jurabibsetup") {
861 vector<string> jurabibsetup =
862 split_options(p.getArg('{', '}'));
863 // add jurabibsetup to the jurabib package options
864 add_package("jurabib", jurabibsetup);
865 if (!jurabibsetup.empty()) {
866 h_preamble << "\\jurabibsetup{"
867 << join(jurabibsetup, ",") << '}';
871 else if (!t.cs().empty() && !in_lyx_preamble)
872 h_preamble << '\\' << t.cs();
874 // remove the whitespace
878 // remove the whitespace
881 // Force textclass if the user wanted it
882 if (!forceclass.empty())
883 h_textclass = forceclass;
884 if (noweb_mode && !prefixIs(h_textclass, "literate-"))
885 h_textclass.insert(0, "literate-");
886 FileName layoutfilename = libFileSearch("layouts", h_textclass, "layout");
887 if (layoutfilename.empty()) {
888 cerr << "Error: Could not find layout file for textclass \"" << h_textclass << "\"." << endl;
891 tc.read(layoutfilename);
892 if (h_papersides.empty()) {
895 h_papersides = ss.str();
897 end_preamble(os, tc);