|| language()->lang() == "arabic_arabi")) {
if (runparams.use_polyglossia) {
// LuaTeX/luabidi
- os << "\\LR{";
- count += 5;
+ // \LR needs extra grouping
+ // (possibly a LuaTeX bug)
+ os << "{\\LR{";
+ count += 6;
} else {
os << "{\\beginL ";
count += 9;
|| language()->lang() == "arabic_arabi")) {
if (runparams.use_polyglossia) {
// LuaTeX/luabidi
- os << "}";
- count += 1;
+ // luabidi's \LR needs extra grouping
+ // (possibly a LuaTeX bug)
+ os << "}}";
+ count += 2;
} else {
os << "\\endL}";
count += 6;
running_change = Change(Change::UNCHANGED);
}
- bool close_brace = false;
+ unsigned int close_brace = 0;
bool const disp_env = (inset->isEnvironment() && inset->getLayout().isDisplay())
|| runparams.inDisplayMath;
string close_env;
os << "\\begin{LTR}";
close_env = "LTR";
} else {
+ if (runparams.flavor == Flavor::LuaTeX) {
+ // luabidi's \LRE needs extra grouping
+ // (possibly a LuaTeX bug)
+ os << '{';
+ close_brace = 1;
+ }
os << "\\LRE{";
- close_brace = true;
+ close_brace += 1;
}
} else if (running_font.language()->lang() == "farsi"
|| running_font.language()->lang() == "arabic_arabi") {
os << "\\textLR{" << termcmd;
- close_brace = true;
+ close_brace = 1;
} else {
// babel classic
os << "\\L{";
if (disp_env)
os << safebreakln;
- close_brace = true;
+ close_brace = 1;
}
}
if (!close_env.empty())
os << "\\end{" << close_env << "}";
- if (close_brace) {
- os << '}';
+ if (close_brace > 0) {
+ for (unsigned i = 0; i < close_brace; ++i)
+ os << '}';
if (disp_env)
os << safebreakln;
}