summaryrefslogtreecommitdiff
path: root/macros/optex/base/margins.opm
diff options
context:
space:
mode:
Diffstat (limited to 'macros/optex/base/margins.opm')
-rw-r--r--macros/optex/base/margins.opm42
1 files changed, 40 insertions, 2 deletions
diff --git a/macros/optex/base/margins.opm b/macros/optex/base/margins.opm
index d88cc04237..0f544fc5dd 100644
--- a/macros/optex/base/margins.opm
+++ b/macros/optex/base/margins.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \margins {Macros for margins setting <2021-03-15>} % preloaded in format
+\_codedecl \margins {Macros for margins setting <2023-05-01>} % preloaded in format
\_doc ----------------------------
\`\margins``/<pg> <fmt> (<left>,<right>,<top>,<bot>)<unit>`
@@ -36,9 +36,11 @@
\_fi\_fi
\_if 1#1\_shiftoffset=0pt \_def\_prepoffsets{}\_else \_if 2#1% double-page layout
\_shiftoffset = \_dimexpr \_pgwidth -\_hsize -2\_hoffset \_relax
- \_def\_prepoffsets{\_ifodd\_pageno \_else \_advance\_hoffset \_shiftoffset \_fi}%
+ \_def\_prepoffsets{\_ifodd\_pageno \_else \_advance\_hoffset \_shiftoffset \_fi
+ \_setpagerightoffset}%
\_else \_opwarning{use \_string\_margins/1 or \_string\_margins/2}%
\_fi\_fi\_fi
+ \_setpagerightoffset
}
\_def\_setpagedimens{\_isnextchar({\_setpagedimensB}{\_setpagedimensA}}
\_def\_setpagedimensA#1 {\_ifcsname _pgs:#1\_endcsname
@@ -74,7 +76,43 @@
\_public \magscale ;
+ \_doc -----------------------------
+ When left-to-right direction of typesetting is selected (default) then
+ \"main vertical line" of the page has `\hoffset` distance from the left
+ paper border and all lines at the page start here and run to the right side
+ (exceptions can be done by `\moveleft` or `\moveright`, of course). When we
+ have set right-to-left direction (using `\textdir TRT`, for example), then
+ the \"main vertical line" cannot be at the same position because lines run to the left,
+ i.e.\ they would be off paper. This is reason why the setting `\pagedir TRT` shifts the
+ \"main vertical line" to an alternative position: it has `\pagerightoffset+1in` distance from the
+ {\em right} paper border and thus right-to-left lines are visible on the
+ paper. We have to set `\pagerightoffset` properly for such cases. This is
+ done in the macro \`\_setpagerightoffset`.
+ It must be called whenever `\hoffset` is changed.
+ \_cod -----------------------------
+
+\_def\_setpagerightoffset{%
+ \_pagerightoffset=\_dimexpr\_pdfpagewidth-\_xhsize-\_hoffset-1in\_relax
+}
+\_setpagerightoffset % setting default value from default values
+
+ \_doc -----------------------------
+ Page numbers and numbers of (sub)sections have to be printed in
+ left-to-right mode even though the document mode is right-to-left.
+ We print these numbers via \`\_numprint``{<number>}` in \OpTeX/ macros.
+ The `\_numprint` is `\_useit` by default (i.e.\ do nothing special)
+ because we have left-to-right mode as default. But a user can define
+ \begtt
+ \_def\_numprint#1{{\textdir TLT #1}}
+ \endtt
+ if the document is set to right-to-left mode.
+ \_cod -----------------------------
+
+\_let\_numprint=\_useit
+
\_endcode % -----------------------------------------
+2023-05-01 \_numprint for page numbers, section numbers introduced
+2023-04-29 \_setpagerightoffset for TRT typesetting introduced again
2021-03-15 \_setxhsize added
2020-03-14 released