summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty
blob: 21f389d0e28029ace119e84d8003dfbe42155bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
%%
%% This is file `bidi-atbegshi.sty'.
%% 
%%   ___________________________________________
%%   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
%%   this license is at: http://www.latex-project.org/lppl.txt
%% 
%%   This work is “author-maintained” (as per LPPL maintenance status)
%%   by Vafa Khalighi.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\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
    }
}
\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
    }
}
\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
    }
}
\cs_new:Npn \__shipout_add_background_picture_lower_left:n #1 {
   \__shipout_add_background_box:n { \__shipout_picture_overlay_lower_left:n {#1} }
}
\cs_new:Npn \__shipout_add_foreground_picture_lower_left:n #1 {
   \__shipout_add_foreground_box:n { \__shipout_picture_overlay_lower_left:n {#1} }
}
\cs_new:Npn \__shipout_add_background_picture_upper_right:n #1 {
   \__shipout_add_background_box:n { \__shipout_picture_overlay_upper_right:n {#1} }
}
\cs_new:Npn \__shipout_add_foreground_picture_upper_right:n #1 {
   \__shipout_add_foreground_box:n { \__shipout_picture_overlay_upper_right:n {#1} }
}
\cs_new:Npn \__shipout_add_background_picture_lower_right:n #1 {
   \__shipout_add_background_box:n { \__shipout_picture_overlay_lower_right:n {#1} }
}
\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'.