summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/bidi-atbegshi/bidi-atbegshi.sty
blob: 77b4fdd6d698661c0fa772caf7295cdc31b590cb (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
%%
%% This is file `bidi-atbegshi.sty'.
%% 
%%   ___________________________________________
%%   Copyright © 2014  Vafa Khalighi <vafak@me.com>
%% 
%%   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}[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%
}
\newcommand*{\AtBegShi@bidi@horigin@right}{%
  \if@RTL%
    \dimexpr\paperwidth-\textwidth-\AtBegShi@horigin\relax
  \else%
    \dimexpr\paperwidth-\AtBegShi@horigin\relax
  \fi%
}
\newcommand*{\AtBegShi@bidi@vorigin@bottom}[1]{%
  \dimexpr\paperheight-\AtBegShi@vorigin\relax
}
\renewcommand*{\AtBeginShipoutUpperLeft}[1]{%
  \AtBeginShipoutAddToBox{%
    \kern\AtBegShi@bidi@horigin@left\relax
    \vbox to 0pt{%
      \kern-\AtBegShi@vorigin\relax
      \AtBegShi@BeginPicture
      #1%
      \AtBegShi@EndPicture
      \vss
    }%
  }%
}
\renewcommand*{\AtBeginShipoutUpperLeftForeground}[1]{%
  \AtBeginShipoutAddToBoxForeground{%
    \kern\AtBegShi@bidi@horigin@left\relax
    \vbox to 0pt{%
      \kern-\AtBegShi@vorigin\relax
      \AtBegShi@BeginPicture
      #1%
      \AtBegShi@EndPicture
      \vss
    }%
  }%
}
\newcommand*{\AtBeginShipoutUpperRight}[1]{%
  \AtBeginShipoutAddToBox{%
    \kern\AtBegShi@bidi@horigin@right\relax
    \vbox to 0pt{%
      \kern-\AtBegShi@vorigin\relax
      \AtBegShi@BeginPicture
      #1%
      \AtBegShi@EndPicture
      \vss
    }%
  }%
}
\newcommand*{\AtBeginShipoutUpperRightForeground}[1]{%
  \AtBeginShipoutAddToBoxForeground{%
    \kern\AtBegShi@bidi@horigin@right\relax
    \vbox to 0pt{%
      \kern-\AtBegShi@vorigin\relax
      \AtBegShi@BeginPicture
      #1%
      \AtBegShi@EndPicture
      \vss
    }%
  }%
}
\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
    }%
  }%
}
\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
    }%
  }%
}
\endinput
%%
%% End of file `bidi-atbegshi.sty'.