summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty')
-rw-r--r--macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty176
1 files changed, 68 insertions, 108 deletions
diff --git a/macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty b/macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty
index 77b4fdd6d6..21f389d0e2 100644
--- a/macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty
+++ b/macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty
@@ -2,7 +2,7 @@
%% This is file `bidi-atbegshi.sty'.
%%
%% ___________________________________________
-%% Copyright © 2014 Vafa Khalighi <vafak@me.com>
+%% Copyright © 2014--2022 Vafa Khalighi <tex-persian@vafa.ac>
%%
%% It may be distributed and/or modified under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
@@ -13,122 +13,82 @@
%%
%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bidi-atbegshi}[2014/09/11 v0.1 bidi-aware shipout macros]
-\RequirePackage{atbegshi}
-\newcommand*\LengthToUnit[1]{#1\@gobble}
-\newcommand*{\AtBegShi@bidi@horigin@left}{%
- \if@RTL%
- \dimexpr-\textwidth-\AtBegShi@horigin\relax
- \else%
- -\AtBegShi@horigin%
- \fi%
+\ProvidesPackage{bidi-atbegshi}[2022/02/14 v0.2 bidi-aware shipout macros]
+\RequirePackage{atbegshi-ltx}
+\ExplSyntaxOn
+\cs_new:Npn \__shipout_picture_overlay_lower_left:n #1 {
+ \__shipout_init_page_origins:
+ \kern -\c__shipout_horigin_tl \scan_stop:
+ \vbox_to_zero:n {
+ \kern \__dim_eval:w \paperheight - \c__shipout_vorigin_tl \scan_stop:
+ \unitlength 1pt \scan_stop:
+ \hbox_set_to_wd:Nnn \l__shipout_tmp_box \c_zero_dim
+ { \ignorespaces #1 \hss }
+ \box_set_ht:Nn \l__shipout_tmp_box \c_zero_dim
+ \box_set_dp:Nn \l__shipout_tmp_box \c_zero_dim
+ \box_use:N \l__shipout_tmp_box
+ \tex_vss:D
+ }
}
-\newcommand*{\AtBegShi@bidi@horigin@right}{%
- \if@RTL%
- \dimexpr\paperwidth-\textwidth-\AtBegShi@horigin\relax
- \else%
- \dimexpr\paperwidth-\AtBegShi@horigin\relax
- \fi%
+\cs_new:Npn \__shipout_picture_overlay_upper_right:n #1 {
+ \__shipout_init_page_origins:
+ \kern \__dim_eval:w \c__shipout_horigin_tl + \oddsidemargin + \evensidemargin + \textwidth \scan_stop:
+ \vbox_to_zero:n {
+ \kern -\c__shipout_vorigin_tl \scan_stop:
+ \unitlength 1pt \scan_stop:
+ \hbox_set_to_wd:Nnn \l__shipout_tmp_box \c_zero_dim
+ { \ignorespaces #1 \hss }
+ \box_set_ht:Nn \l__shipout_tmp_box \c_zero_dim
+ \box_set_dp:Nn \l__shipout_tmp_box \c_zero_dim
+ \box_use:N \l__shipout_tmp_box
+ \tex_vss:D
+ }
}
-\newcommand*{\AtBegShi@bidi@vorigin@bottom}[1]{%
- \dimexpr\paperheight-\AtBegShi@vorigin\relax
+\cs_new:Npn \__shipout_picture_overlay_lower_right:n #1 {
+ \__shipout_init_page_origins:
+ \kern \__dim_eval:w \c__shipout_horigin_tl + \oddsidemargin + \evensidemargin + \textwidth \scan_stop:
+ \vbox_to_zero:n {
+ \kern \__dim_eval:w \paperheight - \c__shipout_vorigin_tl \scan_stop:
+ \unitlength 1pt \scan_stop:
+ \hbox_set_to_wd:Nnn \l__shipout_tmp_box \c_zero_dim
+ { \ignorespaces #1 \hss }
+ \box_set_ht:Nn \l__shipout_tmp_box \c_zero_dim
+ \box_set_dp:Nn \l__shipout_tmp_box \c_zero_dim
+ \box_use:N \l__shipout_tmp_box
+ \tex_vss:D
+ }
}
-\renewcommand*{\AtBeginShipoutUpperLeft}[1]{%
- \AtBeginShipoutAddToBox{%
- \kern\AtBegShi@bidi@horigin@left\relax
- \vbox to 0pt{%
- \kern-\AtBegShi@vorigin\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
+\cs_new:Npn \__shipout_add_background_picture_lower_left:n #1 {
+ \__shipout_add_background_box:n { \__shipout_picture_overlay_lower_left:n {#1} }
}
-\renewcommand*{\AtBeginShipoutUpperLeftForeground}[1]{%
- \AtBeginShipoutAddToBoxForeground{%
- \kern\AtBegShi@bidi@horigin@left\relax
- \vbox to 0pt{%
- \kern-\AtBegShi@vorigin\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
+\cs_new:Npn \__shipout_add_foreground_picture_lower_left:n #1 {
+ \__shipout_add_foreground_box:n { \__shipout_picture_overlay_lower_left:n {#1} }
}
-\newcommand*{\AtBeginShipoutUpperRight}[1]{%
- \AtBeginShipoutAddToBox{%
- \kern\AtBegShi@bidi@horigin@right\relax
- \vbox to 0pt{%
- \kern-\AtBegShi@vorigin\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
+\cs_new:Npn \__shipout_add_background_picture_upper_right:n #1 {
+ \__shipout_add_background_box:n { \__shipout_picture_overlay_upper_right:n {#1} }
}
-\newcommand*{\AtBeginShipoutUpperRightForeground}[1]{%
- \AtBeginShipoutAddToBoxForeground{%
- \kern\AtBegShi@bidi@horigin@right\relax
- \vbox to 0pt{%
- \kern-\AtBegShi@vorigin\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
+\cs_new:Npn \__shipout_add_foreground_picture_upper_right:n #1 {
+ \__shipout_add_foreground_box:n { \__shipout_picture_overlay_upper_right:n {#1} }
}
-\newcommand*{\AtBeginShipoutLowerLeft}[1]{%
- \AtBeginShipoutAddToBox{%
- \kern\AtBegShi@bidi@horigin@left\relax
- \vbox to 0pt{%
- \kern\AtBegShi@bidi@vorigin@bottom\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
+\cs_new:Npn \__shipout_add_background_picture_lower_right:n #1 {
+ \__shipout_add_background_box:n { \__shipout_picture_overlay_lower_right:n {#1} }
}
-\newcommand*{\AtBeginShipoutLowerLeftForeground}[1]{%
- \AtBeginShipoutAddToBoxForeground{%
- \kern\AtBegShi@bidi@horigin@left\relax
- \vbox to 0pt{%
- \kern\AtBegShi@bidi@vorigin@bottom\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
-}
-\newcommand*{\AtBeginShipoutLowerRight}[1]{%
- \AtBeginShipoutAddToBox{%
- \kern\AtBegShi@bidi@horigin@right\relax
- \vbox to 0pt{%
- \kern\AtBegShi@bidi@vorigin@bottom\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
-}
-\newcommand*{\AtBeginShipoutLowerRightForeground}[1]{%
- \AtBeginShipoutAddToBoxForeground{%
- \kern\AtBegShi@bidi@horigin@right\relax
- \vbox to 0pt{%
- \kern\AtBegShi@bidi@vorigin@bottom\relax
- \AtBegShi@BeginPicture
- #1%
- \AtBegShi@EndPicture
- \vss
- }%
- }%
+\cs_new:Npn \__shipout_add_foreground_picture_lower_right:n #1 {
+ \__shipout_add_foreground_box:n { \__shipout_picture_overlay_lower_right:n {#1} }
}
+\cs_set_eq:NN \AtBeginShipoutLowerLeft
+ \__shipout_add_background_picture_lower_left:n
+\cs_set_eq:NN \AtBeginShipoutLowerLeftForeground
+ \__shipout_add_foreground_picture_lower_left:n
+\cs_set_eq:NN \AtBeginShipoutUpperRight
+ \__shipout_add_background_picture_upper_right:n
+\cs_set_eq:NN \AtBeginShipoutUpperRightForeground
+ \__shipout_add_foreground_picture_upper_right:n
+\cs_set_eq:NN \AtBeginShipoutLowerRight
+ \__shipout_add_background_picture_lower_right:n
+\cs_set_eq:NN \AtBeginShipoutLowerRightForeground
+ \__shipout_add_foreground_picture_lower_right:n
+\ExplSyntaxOff
\endinput
%%
%% End of file `bidi-atbegshi.sty'. \ No newline at end of file