| 1 |
%% |
| 2 |
%% This is file `bidi-atbegshi.sty'. |
| 3 |
%% |
| 4 |
%% ___________________________________________ |
| 5 |
%% Copyright © 2014--2022 Vafa Khalighi <[email protected]> |
| 6 |
%% |
| 7 |
%% It may be distributed and/or modified under the LaTeX Project Public License, |
| 8 |
%% version 1.3c or higher (your choice). The latest version of |
| 9 |
%% this license is at: http://www.latex-project.org/lppl.txt |
| 10 |
%% |
| 11 |
%% This work is “author-maintained” (as per LPPL maintenance status) |
| 12 |
%% by Vafa Khalighi. |
| 13 |
%% |
| 14 |
%% |
| 15 |
\NeedsTeXFormat{LaTeX2e} |
| 16 |
\ProvidesPackage{bidi-atbegshi}[2022/02/14 v0.2 bidi-aware shipout macros] |
| 17 |
\RequirePackage{atbegshi-ltx} |
| 18 |
\ExplSyntaxOn |
| 19 |
\cs_new:Npn \__shipout_picture_overlay_lower_left:n #1 { |
| 20 |
\__shipout_init_page_origins: |
| 21 |
\kern -\c__shipout_horigin_tl \scan_stop: |
| 22 |
\vbox_to_zero:n { |
| 23 |
\kern \__dim_eval:w \paperheight - \c__shipout_vorigin_tl \scan_stop: |
| 24 |
\unitlength 1pt \scan_stop: |
| 25 |
\hbox_set_to_wd:Nnn \l__shipout_tmp_box \c_zero_dim |
| 26 |
{ \ignorespaces #1 \hss } |
| 27 |
\box_set_ht:Nn \l__shipout_tmp_box \c_zero_dim |
| 28 |
\box_set_dp:Nn \l__shipout_tmp_box \c_zero_dim |
| 29 |
\box_use:N \l__shipout_tmp_box |
| 30 |
\tex_vss:D |
| 31 |
} |
| 32 |
} |
| 33 |
\cs_new:Npn \__shipout_picture_overlay_upper_right:n #1 { |
| 34 |
\__shipout_init_page_origins: |
| 35 |
\kern \__dim_eval:w \c__shipout_horigin_tl + \oddsidemargin + \evensidemargin + \textwidth \scan_stop: |
| 36 |
\vbox_to_zero:n { |
| 37 |
\kern -\c__shipout_vorigin_tl \scan_stop: |
| 38 |
\unitlength 1pt \scan_stop: |
| 39 |
\hbox_set_to_wd:Nnn \l__shipout_tmp_box \c_zero_dim |
| 40 |
{ \ignorespaces #1 \hss } |
| 41 |
\box_set_ht:Nn \l__shipout_tmp_box \c_zero_dim |
| 42 |
\box_set_dp:Nn \l__shipout_tmp_box \c_zero_dim |
| 43 |
\box_use:N \l__shipout_tmp_box |
| 44 |
\tex_vss:D |
| 45 |
} |
| 46 |
} |
| 47 |
\cs_new:Npn \__shipout_picture_overlay_lower_right:n #1 { |
| 48 |
\__shipout_init_page_origins: |
| 49 |
\kern \__dim_eval:w \c__shipout_horigin_tl + \oddsidemargin + \evensidemargin + \textwidth \scan_stop: |
| 50 |
\vbox_to_zero:n { |
| 51 |
\kern \__dim_eval:w \paperheight - \c__shipout_vorigin_tl \scan_stop: |
| 52 |
\unitlength 1pt \scan_stop: |
| 53 |
\hbox_set_to_wd:Nnn \l__shipout_tmp_box \c_zero_dim |
| 54 |
{ \ignorespaces #1 \hss } |
| 55 |
\box_set_ht:Nn \l__shipout_tmp_box \c_zero_dim |
| 56 |
\box_set_dp:Nn \l__shipout_tmp_box \c_zero_dim |
| 57 |
\box_use:N \l__shipout_tmp_box |
| 58 |
\tex_vss:D |
| 59 |
} |
| 60 |
} |
| 61 |
\cs_new:Npn \__shipout_add_background_picture_lower_left:n #1 { |
| 62 |
\__shipout_add_background_box:n { \__shipout_picture_overlay_lower_left:n {#1} } |
| 63 |
} |
| 64 |
\cs_new:Npn \__shipout_add_foreground_picture_lower_left:n #1 { |
| 65 |
\__shipout_add_foreground_box:n { \__shipout_picture_overlay_lower_left:n {#1} } |
| 66 |
} |
| 67 |
\cs_new:Npn \__shipout_add_background_picture_upper_right:n #1 { |
| 68 |
\__shipout_add_background_box:n { \__shipout_picture_overlay_upper_right:n {#1} } |
| 69 |
} |
| 70 |
\cs_new:Npn \__shipout_add_foreground_picture_upper_right:n #1 { |
| 71 |
\__shipout_add_foreground_box:n { \__shipout_picture_overlay_upper_right:n {#1} } |
| 72 |
} |
| 73 |
\cs_new:Npn \__shipout_add_background_picture_lower_right:n #1 { |
| 74 |
\__shipout_add_background_box:n { \__shipout_picture_overlay_lower_right:n {#1} } |
| 75 |
} |
| 76 |
\cs_new:Npn \__shipout_add_foreground_picture_lower_right:n #1 { |
| 77 |
\__shipout_add_foreground_box:n { \__shipout_picture_overlay_lower_right:n {#1} } |
| 78 |
} |
| 79 |
\cs_set_eq:NN \AtBeginShipoutLowerLeft |
| 80 |
\__shipout_add_background_picture_lower_left:n |
| 81 |
\cs_set_eq:NN \AtBeginShipoutLowerLeftForeground |
| 82 |
\__shipout_add_foreground_picture_lower_left:n |
| 83 |
\cs_set_eq:NN \AtBeginShipoutUpperRight |
| 84 |
\__shipout_add_background_picture_upper_right:n |
| 85 |
\cs_set_eq:NN \AtBeginShipoutUpperRightForeground |
| 86 |
\__shipout_add_foreground_picture_upper_right:n |
| 87 |
\cs_set_eq:NN \AtBeginShipoutLowerRight |
| 88 |
\__shipout_add_background_picture_lower_right:n |
| 89 |
\cs_set_eq:NN \AtBeginShipoutLowerRightForeground |
| 90 |
\__shipout_add_foreground_picture_lower_right:n |
| 91 |
\ExplSyntaxOff |
| 92 |
\endinput |
| 93 |
%% |
| 94 |
%% End of file `bidi-atbegshi.sty'. |