- fprintf(file, "\\paperfontsize %s\n", fontsize.c_str());
-
- spacing.writeFile(file);
-
- fprintf(file, "\\papersize %s\n", string_papersize[papersize2]);
- fprintf(file, "\\paperpackage %s\n",
- string_paperpackages[paperpackage]);
- fprintf(file, "\\use_geometry %d\n",use_geometry);
- fprintf(file, "\\use_amsmath %d\n",use_amsmath);
- fprintf(file, "\\paperorientation %s\n",
- string_orientation[orientation]);
- if (!paperwidth.empty())
- fprintf(file, "\\paperwidth %s\n",
- VSpace(paperwidth).asLyXCommand().c_str());
- if (!paperheight.empty())
- fprintf(file, "\\paperheight %s\n",
- VSpace(paperheight).asLyXCommand().c_str());
- if (!leftmargin.empty())
- fprintf(file, "\\leftmargin %s\n",
- VSpace(leftmargin).asLyXCommand().c_str());
- if (!topmargin.empty())
- fprintf(file, "\\topmargin %s\n",
- VSpace(topmargin).asLyXCommand().c_str());
- if (!rightmargin.empty())
- fprintf(file, "\\rightmargin %s\n",
- VSpace(rightmargin).asLyXCommand().c_str());
- if (!bottommargin.empty())
- fprintf(file, "\\bottommargin %s\n",
- VSpace(bottommargin).asLyXCommand().c_str());
- if (!headheight.empty())
- fprintf(file, "\\headheight %s\n",
- VSpace(headheight).asLyXCommand().c_str());
- if (!headsep.empty())
- fprintf(file, "\\headsep %s\n",
- VSpace(headsep).asLyXCommand().c_str());
- if (!footskip.empty())
- fprintf(file, "\\footskip %s\n",
- VSpace(footskip).asLyXCommand().c_str());
- fprintf(file, "\\secnumdepth %d\n", secnumdepth);
- fprintf(file, "\\tocdepth %d\n", tocdepth);
- fprintf(file, "\\paragraph_separation %s\n",
- string_paragraph_separation[paragraph_separation]);
- fprintf(file, "\\defskip %s\n", defskip.asLyXCommand().c_str());
- fprintf(file, "\\quotes_language %s\n",
- string_quotes_language[quotes_language]);
- switch(quotes_times) {
- case InsetQuotes::SingleQ:
- fprintf(file, "\\quotes_times 1\n"); break;
- case InsetQuotes::DoubleQ:
- fprintf(file, "\\quotes_times 2\n"); break;
- }
- fprintf(file, "\\papercolumns %d\n", columns);
- fprintf(file, "\\papersides %d\n", sides);
- fprintf(file, "\\paperpagestyle %s\n", pagestyle.c_str());
+
+ if (inputenc == "auto") {
+ string const doc_encoding =
+ language->encoding()->LatexName();
+
+ // Create a list with all the input encodings used
+ // in the document
+ std::set<string> encodings =
+ features.getEncodingSet(doc_encoding);
+
+ os << "\\usepackage[";
+ std::copy(encodings.begin(), encodings.end(),
+ std::ostream_iterator<string>(os, ","));
+ os << doc_encoding << "]{inputenc}\n";
+ texrow.newline();
+ } else if (inputenc != "default") {
+ os << "\\usepackage[" << inputenc
+ << "]{inputenc}\n";
+ texrow.newline();
+ }
+
+ // At the very beginning the text parameters.
+ if (paperpackage != PACKAGE_NONE) {
+ switch (paperpackage) {
+ case PACKAGE_A4:
+ os << "\\usepackage{a4}\n";
+ texrow.newline();
+ break;
+ case PACKAGE_A4WIDE:
+ os << "\\usepackage{a4wide}\n";
+ texrow.newline();
+ break;
+ case PACKAGE_WIDEMARGINSA4:
+ os << "\\usepackage[widemargins]{a4}\n";
+ texrow.newline();
+ break;
+ }
+ }
+ if (use_geometry) {
+ os << "\\usepackage{geometry}\n";
+ texrow.newline();
+ os << "\\geometry{verbose";
+ if (orientation == ORIENTATION_LANDSCAPE)
+ os << ",landscape";
+ switch (papersize2) {
+ case VM_PAPER_CUSTOM:
+ if (!paperwidth.empty())
+ os << ",paperwidth="
+ << paperwidth;
+ if (!paperheight.empty())
+ os << ",paperheight="
+ << paperheight;
+ break;
+ case VM_PAPER_USLETTER:
+ os << ",letterpaper";
+ break;
+ case VM_PAPER_USLEGAL:
+ os << ",legalpaper";
+ break;
+ case VM_PAPER_USEXECUTIVE:
+ os << ",executivepaper";
+ break;
+ case VM_PAPER_A3:
+ os << ",a3paper";
+ break;
+ case VM_PAPER_A4:
+ os << ",a4paper";
+ break;
+ case VM_PAPER_A5:
+ os << ",a5paper";
+ break;
+ case VM_PAPER_B3:
+ os << ",b3paper";
+ break;
+ case VM_PAPER_B4:
+ os << ",b4paper";
+ break;
+ case VM_PAPER_B5:
+ os << ",b5paper";
+ break;
+ default:
+ // default papersize ie VM_PAPER_DEFAULT
+ switch (lyxrc.default_papersize) {
+ case PAPER_DEFAULT: // keep compiler happy
+ case PAPER_USLETTER:
+ os << ",letterpaper";
+ break;
+ case PAPER_LEGALPAPER:
+ os << ",legalpaper";
+ break;
+ case PAPER_EXECUTIVEPAPER:
+ os << ",executivepaper";
+ break;
+ case PAPER_A3PAPER:
+ os << ",a3paper";
+ break;
+ case PAPER_A4PAPER:
+ os << ",a4paper";
+ break;
+ case PAPER_A5PAPER:
+ os << ",a5paper";
+ break;
+ case PAPER_B5PAPER:
+ os << ",b5paper";
+ break;
+ }
+ }
+ if (!topmargin.empty())
+ os << ",tmargin=" << topmargin;
+ if (!bottommargin.empty())
+ os << ",bmargin=" << bottommargin;
+ if (!leftmargin.empty())
+ os << ",lmargin=" << leftmargin;
+ if (!rightmargin.empty())
+ os << ",rmargin=" << rightmargin;
+ if (!headheight.empty())
+ os << ",headheight=" << headheight;
+ if (!headsep.empty())
+ os << ",headsep=" << headsep;
+ if (!footskip.empty())
+ os << ",footskip=" << footskip;
+ os << "}\n";
+ texrow.newline();
+ }
+
+ if (tokenPos(tclass.opt_pagestyle(),
+ '|', pagestyle) >= 0) {
+ if (pagestyle == "fancy") {
+ os << "\\usepackage{fancyhdr}\n";
+ texrow.newline();
+ }
+ os << "\\pagestyle{" << pagestyle << "}\n";
+ texrow.newline();
+ }
+
+ if (secnumdepth != tclass.secnumdepth()) {
+ os << "\\setcounter{secnumdepth}{"
+ << secnumdepth
+ << "}\n";
+ texrow.newline();
+ }
+ if (tocdepth != tclass.tocdepth()) {
+ os << "\\setcounter{tocdepth}{"
+ << tocdepth
+ << "}\n";
+ texrow.newline();
+ }
+
+ if (paragraph_separation) {
+ switch (defskip.kind()) {
+ case VSpace::SMALLSKIP:
+ os << "\\setlength\\parskip{\\smallskipamount}\n";
+ break;
+ case VSpace::MEDSKIP:
+ os << "\\setlength\\parskip{\\medskipamount}\n";
+ break;
+ case VSpace::BIGSKIP:
+ os << "\\setlength\\parskip{\\bigskipamount}\n";
+ break;
+ case VSpace::LENGTH:
+ os << "\\setlength\\parskip{"
+ << defskip.length().asLatexString()
+ << "}\n";
+ break;
+ default: // should never happen // Then delete it.
+ os << "\\setlength\\parskip{\\medskipamount}\n";
+ break;
+ }
+ texrow.newline();
+
+ os << "\\setlength\\parindent{0pt}\n";
+ texrow.newline();
+ }
+
+ // Now insert the LyX specific LaTeX commands...
+
+ // The optional packages;
+ string lyxpreamble(features.getPackages());
+
+ // this might be useful...
+ lyxpreamble += "\n\\makeatletter\n";
+
+ // Some macros LyX will need
+ string tmppreamble(features.getMacros());
+
+ if (!tmppreamble.empty()) {
+ lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
+ "LyX specific LaTeX commands.\n"
+ + tmppreamble + '\n';
+ }
+
+ // the text class specific preamble
+ tmppreamble = features.getTClassPreamble();
+ if (!tmppreamble.empty()) {
+ lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
+ "Textclass specific LaTeX commands.\n"
+ + tmppreamble + '\n';
+ }
+
+ /* the user-defined preamble */
+ if (!preamble.empty()) {
+ lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
+ "User specified LaTeX commands.\n"
+ + preamble + '\n';
+ }
+
+ // Itemize bullet settings need to be last in case the user
+ // defines their own bullets that use a package included
+ // in the user-defined preamble -- ARRae
+ // Actually it has to be done much later than that
+ // since some packages like frenchb make modifications
+ // at \begin{document} time -- JMarc
+ string bullets_def;