#include "LaTeXFeatures.h"
#include "LaTeXFonts.h"
#include "Font.h"
-#include "Lexer.h"
#include "LyXRC.h"
#include "OutputParams.h"
#include "Spacing.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/Length.h"
+#include "support/Lexer.h"
#include "support/Messages.h"
#include "support/mutex.h"
#include "support/Package.h"
static char const * const string_quotes_style[] = {
"english", "swedish", "german", "polish", "swiss", "danish", "plain",
"british", "swedishg", "french", "frenchin", "russian", "cjk", "cjkangle",
- "hungarian", ""
+ "hungarian", "hebrew", ""
};
translator.addPair(string_quotes_style[12], QuoteStyle::CJK);
translator.addPair(string_quotes_style[13], QuoteStyle::CJKAngle);
translator.addPair(string_quotes_style[14], QuoteStyle::Hungarian);
+ translator.addPair(string_quotes_style[15], QuoteStyle::Hebrew);
return translator;
}
shell_escape = false;
output_sync = false;
use_refstyle = true;
+ use_formatted_ref = false;
use_minted = false;
use_lineno = false;
lex >> output_sync_macro;
} else if (token == "\\use_refstyle") {
lex >> use_refstyle;
+ } else if (token == "\\use_formatted_ref") {
+ lex >> use_formatted_ref;
} else if (token == "\\use_minted") {
lex >> use_minted;
} else if (token == "\\use_lineno") {
<< "\n\\suppress_date " << convert<string>(suppress_date)
<< "\n\\justification " << convert<string>(justification)
<< "\n\\use_refstyle " << use_refstyle
+ << "\n\\use_formatted_ref " << use_formatted_ref
<< "\n\\use_minted " << use_minted
<< "\n\\use_lineno " << use_lineno
<< '\n';
{
features.require(documentClass().required());
- if (columns > 1 && language->rightToLeft())
+ if (columns > 1 && language->rightToLeft()
+ && !features.runparams().isFullUnicode()
+ && language->babel() != "hebrew")
features.require("rtloutputdblcol");
if (output_changes) {
features.require("ulem");
features.require("xcolor");
// improves color handling in PDF output
- features.require("pdfcolmk");
} else {
features.require("ct-none");
}
"\n\nPlease select an appropriate "
"document encoding\n"
"(such as utf8) or change the "
- "preamble code accordingly."),
+ "metadata accordingly."),
uncodable_glyphs));
}
if (!doc_metadata.str().empty()) {
break;
}
+ if (paragraph_separation) {
+ if (!tclass.halfparskip().empty() && getDefSkip().kind() == VSpace::HALFLINE)
+ clsoptions << tclass.halfparskip() << ",";
+ if (!tclass.fullparskip().empty() && getDefSkip().kind() == VSpace::FULLLINE)
+ clsoptions << tclass.fullparskip() << ",";
+ }
+
// language should be a parameter to \documentclass
if (language->babel() == "hebrew"
&& default_language->babel() != "hebrew")
if (useNonTeXFonts) {
// Babel (as of 2017/11/03) loads fontspec itself
+ // However, it does so only if a non-default font is requested via \babelfont
+ // Thus load fontspec if this is not the case and we need fontspec features
+ bool const babel_needfontspec =
+ !features.isAvailableAtLeastFrom("babel", 2017, 11, 3)
+ || (fontsRoman() == "default"
+ && fontsSans() == "default"
+ && fontsTypewriter() == "default"
+ // these need fontspec features
+ && (features.isRequired("textquotesinglep")
+ || features.isRequired("textquotedblp")));
if (!features.isProvided("fontspec")
- && !(features.useBabel() && features.isAvailableAtLeastFrom("babel", 2017, 11, 3)))
+ && (!features.useBabel() || babel_needfontspec))
os << "\\usepackage{fontspec}\n";
if (features.mustProvide("unicode-math")
&& features.isAvailable("unicode-math"))
if (paragraph_separation) {
// when skip separation
string psopt;
+ bool default_skip = false;
+ bool by_class_option = false;
switch (getDefSkip().kind()) {
case VSpace::SMALLSKIP:
psopt = "\\smallskipamount";
break;
case VSpace::HALFLINE:
// default (no option)
+ default_skip = true;
+ by_class_option = !tclass.halfparskip().empty();
break;
case VSpace::FULLLINE:
psopt = "\\baselineskip";
+ by_class_option = !tclass.fullparskip().empty();
break;
case VSpace::LENGTH:
psopt = getDefSkip().length().asLatexString();
default:
break;
}
- if (!features.isProvided("parskip")) {
+ if (features.isProvided("parskip")) {
+ // package already loaded (with arbitrary options)
+ // change parskip value only
if (!psopt.empty())
- psopt = "[skip=" + psopt + "]";
- os << "\\usepackage" + psopt + "{parskip}\n";
- } else {
- os << "\\setlength{\\parskip}{" + psopt + "}\n";
+ os << "\\setlength{\\parskip}{" + psopt + "}\n";
+ else if (default_skip)
+ // explicitly reset default (might have been changed
+ // in a class or package)
+ os << "\\parskip=.5\\baselineskip plus 2pt\\relax\n";
+ } else if (!by_class_option) {
+ // load parskip package with required options
+ string psopts;
+ if (!psopt.empty()) {
+ if (contains(psopt, ' '))
+ // glue length has spaces: embrace
+ psopts = "skip={" + psopt + "}";
+ else
+ psopts = "skip=" + psopt;
+ }
+ string const xpsopts = getPackageOptions("parskip");
+ if (!xpsopts.empty()) {
+ if (!psopts.empty())
+ psopts += ",";
+ psopts += xpsopts;
+ }
+ os << "\\usepackage";
+ if (!psopts.empty())
+ os << "[" << psopts << "]";
+ os << "{parskip}\n";
}
} else {
// when separation by indentation
}
+bool BufferParams::hasPackageOption(string const package, string const opt) const
+{
+ for (auto const & p : documentClass().packageOptions())
+ if (package == p.first && opt == p.second)
+ return true;
+ return false;
+}
+
+
+string BufferParams::getPackageOptions(string const package) const
+{
+ for (auto const & p : documentClass().packageOptions())
+ if (package == p.first)
+ return p.second;
+ return string();
+}
+
+
+bool BufferParams::useBidiPackage(OutputParams const & rp) const
+{
+ return (rp.use_polyglossia
+ // as of babel 3.29, bidi=bidi-* is supported by babel
+ // So we check whether we use a respective version and
+ // whethert bidi-r or bidi-l have been requested either via class
+ // or package options
+ || (rp.use_babel
+ && LaTeXFeatures::isAvailableAtLeastFrom("babel", 2019, 4, 3)
+ && (hasPackageOption("babel", "bidi-r")
+ || hasPackageOption("babel", "bidi-l")
+ || contains(options, "bidi-r")
+ || contains(options, "bidi-l")))
+ )
+ && rp.flavor == Flavor::XeTeX;
+}
+
+
void BufferParams::readPreamble(Lexer & lex)
{
if (lex.getString() != "\\begin_preamble")
os << "\\babelfont{rm}[";
else
os << "\\setmainfont[";
- if (!font_roman_opts.empty())
- os << font_roman_opts << ',';
os << texmapping;
if (fonts_roman_osf)
os << ",Numbers=OldStyle";
+ if (!font_roman_opts.empty())
+ os << ',' << font_roman_opts;
os << "]{" << parseFontName(fontsRoman()) << "}\n";
}
if (fontsSans() != "default") {
<< float(fontsSansScale()) / 100 << ',';
if (fonts_sans_osf)
os << "Numbers=OldStyle,";
+ os << texmapping;
if (!font_sans_opts.empty())
- os << font_sans_opts << ',';
- os << texmapping << "]{"
- << sans << "}\n";
+ os << ',' << font_sans_opts;
+ os << "]{" << sans << "}\n";
} else {
if (babelfonts)
os << "\\babelfont{sf}[";
os << "\\setsansfont[";
if (fonts_sans_osf)
os << "Numbers=OldStyle,";
+ os << texmapping;
if (!font_sans_opts.empty())
- os << font_sans_opts << ',';
- os << texmapping << "]{"
- << sans << "}\n";
+ os << ',' << font_sans_opts;
+ os << "]{" << sans << "}\n";
}
}
if (fontsTypewriter() != "default") {