#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"
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");
}
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 (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")