#include "LaTeXFeatures.h"
#include "Buffer.h"
-#include "Color.h"
#include "BufferParams.h"
+#include "ColorSet.h"
#include "Encoding.h"
#include "Floating.h"
#include "FloatList.h"
"%% A simple dot to overcome graphicx limitations\n"
"\\newcommand{\\lyxdot}{.}\n";
+static string const boxcite_def =
+ "\\let\\cite@rig\\cite\n"
+ "\\newcommand{\\b@xcite}[2][\\%]{\\def\\def@pt{\\%}\\def\\pas@pt{#1}\n"
+ " \\mbox{\\ifx\\def@pt\\pas@pt\\cite@rig{#2}\\else\\cite@rig[#1]{#2}\\fi}}\n";
+
+static string const lyxuline_def =
+ "\\newcommand{\\lyxuline}[1]{{\\let\\cite\\b@xcite\\uline{#1}}}\n";
+
+static string const lyxuuline_def =
+ "\\newcommand{\\lyxuuline}[1]{{\\let\\cite\\b@xcite\\uuline{#1}}}\n";
+
+static string const lyxuwave_def =
+ "\\newcommand{\\lyxuwave}[1]{{\\let\\cite\\b@xcite\\uwave{#1}}}\n";
+
+static string const lyxsout_def =
+ "\\newcommand{\\lyxsout}[1]{{\\let\\cite\\b@xcite\\sout{#1}}}\n";
+
static string const changetracking_dvipost_def =
"%% Change tracking with dvipost\n"
"\\dvipostlayout\n"
"\\AtBeginDocument{\\DeclareFontEncoding{T2A}{}{}}\n";
static string const lyxmathsym_def =
- "\\DeclareRobustCommand{\\lyxmathsym}[1]{\\ifmmode\\begingroup\\def\\b@ld{bold}\n"
- " \\def\\rmorbf##1{\\ifx\\math@version\\b@ld\\textbf{##1}\\else\\textrm{##1}\\fi}\n"
- " \\mathchoice{\\hbox{\\rmorbf{#1}}}{\\hbox{\\rmorbf{#1}}}\n"
- " {\\hbox{\\smaller[2]\\rmorbf{#1}}}{\\hbox{\\smaller[3]\\rmorbf{#1}}}\n"
- " \\endgroup\\else#1\\fi}\n";
+ "\\newcommand{\\lyxmathsym}[1]{\\ifmmode\\begingroup\\def\\b@ld{bold}\n"
+ " \\text{\\ifx\\math@version\\b@ld\\bfseries\\fi#1}\\endgroup\\else#1\\fi}\n";
static string const papersizedvi_def =
"\\special{papersize=\\the\\paperwidth,\\the\\paperheight}\n";
// listings is handled in BufferParams.cpp
"bm",
"pdfpages",
- "relsize",
"amscd",
"slashed"
};
if (mustProvide("pdfcolmk"))
colors << "\\usepackage{pdfcolmk}\n";
+ if (mustProvide("pagecolor")) {
+ // the \pagecolor command must be set after color is loaded and
+ // before pdfpages, therefore add the command here
+ // define the set color
+ colors << "\\definecolor{page_backgroundcolor}{rgb}{";
+ colors << outputLaTeXColor(params_.backgroundcolor) << "}\n";
+ // set the page color
+ colors << "\\pagecolor{page_backgroundcolor}\n";
+ }
+
return colors.str();
}
&& params_.use_esint == BufferParams::package_off
&& params_.use_amsmath != BufferParams::package_off)) {
packages << "\\usepackage{amsmath}\n";
- } else if (mustProvide("amsbsy")) {
- // amsbsy is already provided by amsmath
- packages << "\\usepackage{amsbsy}\n";
+ } else {
+ // amsbsy and amstext are already provided by amsmath
+ if (mustProvide("amsbsy"))
+ packages << "\\usepackage{amsbsy}\n";
+ if (mustProvide("amstext"))
+ packages << "\\usepackage{amstext}\n";
}
// wasysym is a simple feature, but it must be after amsmath if both
// [x]color and pdfcolmk are handled in getColorOptions() above
// makeidx.sty
- if (isRequired("makeidx")) {
- if (!tclass.provides("makeidx"))
+ if (isRequired("makeidx") || isRequired("splitidx")) {
+ if (!tclass.provides("makeidx") && !isRequired("splitidx"))
packages << "\\usepackage{makeidx}\n";
+ if (!tclass.provides("splitidx") && isRequired("splitidx"))
+ packages << "\\usepackage{splitidx}\n";
packages << "\\makeindex\n";
}
if (mustProvide("lyxline"))
macros << lyxline_def << '\n';
+ if (mustProvide("boxcite"))
+ macros << boxcite_def << '\n';
+
+ if (mustProvide("lyxuline"))
+ macros << lyxuline_def << '\n';
+
+ if (mustProvide("lyxuuline"))
+ macros << lyxuuline_def << '\n';
+
+ if (mustProvide("lyxuwave"))
+ macros << lyxuwave_def << '\n';
+
+ if (mustProvide("lyxsout"))
+ macros << lyxsout_def << '\n';
+
if (mustProvide("noun"))
macros << noun_def << '\n';
tcpreamble << tclass.preamble();
+ list<docstring>::const_iterator cit = usedLayouts_.begin();
+ list<docstring>::const_iterator end = usedLayouts_.end();
+ for (; cit != end; ++cit)
+ tcpreamble << tclass[*cit].preamble();
+
+ return tcpreamble.str();
+}
+
+
+docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel) const
+{
+ DocumentClass const & tclass = params_.documentClass();
+ // collect preamble snippets in a set to prevent multiple identical
+ // commands (would happen if e.g. both theorem and theorem* are used)
+ set<docstring> snippets;
typedef LanguageList::const_iterator lang_it;
lang_it const lbeg = UsedLanguages_.begin();
lang_it const lend = UsedLanguages_.end();
list<docstring>::const_iterator cit = usedLayouts_.begin();
list<docstring>::const_iterator end = usedLayouts_.end();
for (; cit != end; ++cit) {
- tcpreamble << tclass[*cit].preamble();
- tcpreamble << tclass[*cit].i18npreamble(buffer().language());
- for (lang_it lit = lbeg; lit != lend; ++lit)
- tcpreamble << tclass[*cit].i18npreamble(*lit);
+ // language dependent commands (once per document)
+ snippets.insert(tclass[*cit].langpreamble(buffer().language()));
+ // commands for language changing (for multilanguage documents)
+ if (use_babel && !UsedLanguages_.empty()) {
+ snippets.insert(tclass[*cit].babelpreamble(buffer().language()));
+ for (lang_it lit = lbeg; lit != lend; ++lit)
+ snippets.insert(tclass[*cit].babelpreamble(*lit));
+ }
}
+ odocstringstream tcpreamble;
+ set<docstring>::const_iterator const send = snippets.end();
+ set<docstring>::const_iterator it = snippets.begin();
+ for (; it != send; ++it)
+ tcpreamble << *it;
return tcpreamble.str();
}