use_amsmath = package_auto;
use_esint = package_auto;
use_mhchem = package_auto;
+ use_mathdots = package_auto;
cite_engine_ = ENGINE_BASIC;
use_bibtopic = false;
use_indices = false;
html_math_img_scale = 1.0;
output_sync = false;
+ use_refstyle = true;
}
void BufferParams::setDefSkip(VSpace const & vs)
{
+ // DEFSKIP will cause an infinite loop
+ LASSERT(vs.kind() != VSpace::DEFSKIP, return);
pimpl_->defskip = vs;
}
lex.next();
string const classname = lex.getString();
// if there exists a local layout file, ignore the system one
- // NOTE: in this case, the textclass (.cls file) is assumed to be available.
+ // NOTE: in this case, the textclass (.cls file) is assumed to
+ // be available.
string tcp;
LayoutFileList & bcl = LayoutFileList::get();
if (tcp.empty() && !filepath.empty())
setBaseClass(tcp);
else
setBaseClass(classname);
- // We assume that a tex class exists for local or unknown layouts so this warning
- // will only be given for system layouts.
+ // We assume that a tex class exists for local or unknown
+ // layouts so this warning, will only be given for system layouts.
if (!baseClass()->isTeXClassAvailable()) {
- docstring desc =
+ docstring const desc =
translateIfPossible(from_utf8(baseClass()->description()));
+ docstring const prereqs =
+ from_utf8(baseClass()->prerequisites());
docstring const msg =
bformat(_("The selected document class\n"
"\t%1$s\n"
"requires external files that are not available.\n"
- "The document class can still be used, but LyX\n"
- "will not be able to produce output until the\n"
- "following prerequisites are installed:\n"
+ "The document class can still be used, but the\n"
+ "document cannot be compiled until the following\n"
+ "prerequisites are installed:\n"
"\t%2$s\n"
"See section 3.1.2.2 of the User's Guide for\n"
- "more information."),
- desc, from_utf8(baseClass()->prerequisites()));
+ "more information."), desc, prereqs);
frontend::Alert::warning(_("Document class not available"),
msg);
}
pimpl_->indentation = HSpace(indentation);
} else if (token == "\\defskip") {
lex.next();
- string defskip = lex.getString();
- if (defskip == "defskip")
- // this is invalid
- defskip = "medskip";
+ string const defskip = lex.getString();
pimpl_->defskip = VSpace(defskip);
+ if (pimpl_->defskip.kind() == VSpace::DEFSKIP)
+ // that is invalid
+ pimpl_->defskip = VSpace(VSpace::MEDSKIP);
} else if (token == "\\quotes_language") {
string quotes_lang;
lex >> quotes_lang;
int usemhchem;
lex >> usemhchem;
use_mhchem = packagetranslator().find(usemhchem);
+ } else if (token == "\\use_mathdots") {
+ int usemathdots;
+ lex >> usemathdots;
+ use_mathdots = packagetranslator().find(usemathdots);
} else if (token == "\\cite_engine") {
string engine;
lex >> engine;
istringstream ss(lex.getString());
Author a;
ss >> a;
- author_map[a.buffer_id()] = pimpl_->authorlist.record(a);
+ author_map[a.bufferId()] = pimpl_->authorlist.record(a);
} else if (token == "\\paperorientation") {
string orient;
lex >> orient;
lex >> output_sync;
} else if (token == "\\output_sync_macro") {
lex >> output_sync_macro;
+ } else if (token == "\\use_refstyle") {
+ lex >> use_refstyle;
} else {
lyxerr << "BufferParams::readToken(): Unknown token: " <<
token << endl;
<< "\n\\use_amsmath " << use_amsmath
<< "\n\\use_esint " << use_esint
<< "\n\\use_mhchem " << use_mhchem
+ << "\n\\use_mathdots " << use_mathdots
<< "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic)
<< "\n\\use_indices " << convert<string>(use_indices)
<< "\n\\paperorientation " << string_orientation[orientation]
<< "\n\\suppress_date " << convert<string>(suppress_date)
+ << "\n\\use_refstyle " << use_refstyle
<< '\n';
if (isbackgroundcolor == true)
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
features.require("esint");
if (use_mhchem == package_on)
features.require("mhchem");
+ if (use_mathdots == package_on)
+ features.require("mathdots");
// Document-level line spacing
if (spacing().getSpace() != Spacing::Single && !spacing().isDefault())
features.useLanguage(default_language);
ostringstream language_options;
- bool const use_babel = features.useBabel();
+ bool const use_babel = features.useBabel() && !tclass.provides("babel");
if (use_babel) {
language_options << features.getLanguages();
if (!language->babel().empty()) {
language_options << ',';
language_options << language->babel();
}
- // if Vietnamese is used, babel must directly be loaded
- // with language options, not in the class options, see
- // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
- size_t viet = language_options.str().find("vietnam");
- // viet = string::npos when not found
- // the same is for all other languages that are not directly supported by
- // babel, but where LaTeX-packages add babel support.
- // this is currently the case for Latvian, Lithuanian, Mongolian
- // and Turkmen
- size_t latvian = language_options.str().find("latvian");
- size_t lithu = language_options.str().find("lithuanian");
- size_t mongo = language_options.str().find("mongolian");
- size_t turkmen = language_options.str().find("turkmen");
- // if Japanese is used, babel must directly be loaded
- // with language options, not in the class options, see
- // http://www.lyx.org/trac/ticket/4597#c4
- size_t japan = language_options.str().find("japanese");
- if (lyxrc.language_global_options && !language_options.str().empty()
- && viet == string::npos && japan == string::npos
- && latvian == string::npos && lithu == string::npos
- && mongo == string::npos && turkmen == string::npos)
+ if (lyxrc.language_global_options
+ && !features.needBabelLangOptions())
clsoptions << language_options.str() << ',';
}
|| features.isRequired("vietnamese")
|| features.isRequired("japanese") ) ) {
// FIXME UNICODE
- lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
- lyxpreamble += from_utf8(features.getBabelOptions()) + '\n';
+ lyxpreamble += from_utf8(features.getBabelPresettings());
+ lyxpreamble += from_utf8(babelCall(language_options.str(),
+ features.needBabelLangOptions())) + '\n';
+ lyxpreamble += from_utf8(features.getBabelPostsettings());
}
// The optional packages;
texrow.newlines(lines);
// set back for the rest
lyxpreamble.clear();
- }
+ } else if (features.isRequired("nameref"))
+ // hyperref loads this automatically
+ lyxpreamble += "\\usepackage{nameref}\n";
// Will be surrounded by \makeatletter and \makeatother when not empty
docstring atlyxpreamble;
&& !features.isRequired("vietnamese")
&& !features.isRequired("japanese")) {
// FIXME UNICODE
- lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
- lyxpreamble += from_utf8(features.getBabelOptions()) + '\n';
+ lyxpreamble += from_utf8(features.getBabelPresettings());
+ lyxpreamble += from_utf8(babelCall(language_options.str(),
+ features.needBabelLangOptions())) + '\n';
+ lyxpreamble += from_utf8(features.getBabelPostsettings());
}
docstring const i18npreamble = features.getTClassI18nPreamble(use_babel);
}
-DocumentClass const * BufferParams::documentClassPtr() const {
+DocumentClass const * BufferParams::documentClassPtr() const
+{
return doc_class_;
}
-void BufferParams::setDocumentClass(DocumentClass const * const tc) {
+void BufferParams::setDocumentClass(DocumentClass const * const tc)
+{
// evil, but this function is evil
doc_class_ = const_cast<DocumentClass *>(tc);
}
}
-string BufferParams::babelCall(string const & lang_opts) const
+string BufferParams::babelCall(string const & lang_opts, bool const langoptions) const
{
string lang_pack = lyxrc.language_package;
if (lang_pack != "\\usepackage{babel}")
return lang_pack;
- // suppress the babel call when there is no babel language defined
+ // suppress the babel call if there is no BabelName defined
// for the document language in the lib/languages file and if no
// other languages are used (lang_opts is then empty)
if (lang_opts.empty())
return string();
- // If Vietnamese is used, babel must directly be loaded with the
- // language options, see
- // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
- size_t viet = lang_opts.find("vietnam");
- // viet = string::npos when not found
- // the same is for all other languages that are not directly supported by
- // babel, but where LaTeX-packages add babel support.
- // this is currently the case for Latvian, Lithuanian, Mongolian
- // and Turkmen
- size_t latvian = lang_opts.find("latvian");
- size_t lithu = lang_opts.find("lithuanian");
- size_t mongo = lang_opts.find("mongolian");
- size_t turkmen = lang_opts.find("turkmen");
- // If Japanese is used, babel must directly be loaded with the
- // language options, see
- // http://www.lyx.org/trac/ticket/4597#c4
- size_t japan = lang_opts.find("japanese");
- if (!lyxrc.language_global_options || viet != string::npos
- || japan != string::npos || latvian != string::npos
- || lithu != string::npos || mongo != string::npos
- || turkmen != string::npos)
+ // either a specific language (AsBabelOptions setting in
+ // lib/languages) or the prefs require the languages to
+ // be submitted to babel itself (not the class).
+ if (langoptions)
return "\\usepackage[" + lang_opts + "]{babel}";
return lang_pack;
}