[LyX/master] mirror left and right margins in LuaTeX with main RTL
Udi Fogiel
ufogiel at lyx.org
Mon Jul 6 00:26:58 UTC 2026
commit df939f252a92a70565951462a6aeb90b082a7563
Author: Udi Fogiel <ufogiel at lyx.org>
Date: Sun Jul 5 22:18:37 2026 +0300
mirror left and right margins in LuaTeX with main RTL
see https://github.com/LaTeX-Package-Repositories/geometry/issues/20
for further details
---
src/BufferParams.cpp | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 6e8abdf2ac..923e557e81 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -2527,14 +2527,26 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
gs << "," << g_options;
// output this only if use_geometry is true
if (use_geometry) {
+ // In LuaTeX with RTL main language, lmargin/rmargin are
+ // reversed relative to the user's visual intent. This
+ // only matters for one-sided documents: with two-sided
+ // documents lmargin/rmargin already mean inner/outer
+ // margin, which alternates by page side regardless.
+ OutputParams const & rp = features.runparams();
+ bool const luatex_rtl = (rp.flavor == Flavor::LuaTeX
+ || rp.flavor == Flavor::DviLuaTeX)
+ && language->rightToLeft()
+ && sides == OneSide;
if (!topmargin.empty())
gs << ",tmargin=" << Length(topmargin).asLatexString();
if (!bottommargin.empty())
gs << ",bmargin=" << Length(bottommargin).asLatexString();
if (!leftmargin.empty())
- gs << ",lmargin=" << Length(leftmargin).asLatexString();
+ gs << "," << (luatex_rtl ? "rmargin" : "lmargin")
+ << "=" << Length(leftmargin).asLatexString();
if (!rightmargin.empty())
- gs << ",rmargin=" << Length(rightmargin).asLatexString();
+ gs << "," << (luatex_rtl ? "lmargin" : "rmargin")
+ << "=" << Length(rightmargin).asLatexString();
if (!headheight.empty())
gs << ",headheight=" << Length(headheight).asLatexString();
if (!headsep.empty())
More information about the lyx-cvs
mailing list