blob: a9ca6a2c14040bcf4ee89679dbed734e74850f55 (
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
|
%
% lltjp-atbegshi.sty
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{lltjp-atbegshi}[2020-09-30 Patching \string\shipout\space hooks for LuaTeX-ja]
% concept: execute all hooks inside yoko direction \vbox
\ifltj@ltfilehook@avail
%<*ltshipout>-----------------------------------
%
\RequirePackage{expl3}
\ExplSyntaxOn\makeatletter
\box_new:N \l__platex_shipout_dummy_box
\cs_new_eq:NN \__platex_original_shipout_execute_cont: \__shipout_execute_cont:
\cs_set:Npn \__shipout_execute_cont:
{
% if \l_shipout_box is not a \yoko-box (= horizontal writing),
% then make it a \yoko-box behorehand.
\platex_if_box_yoko:NF \l_shipout_box {
\vbox_set:Nn \l_shipout_box { \platex_direction_yoko: \box_use:N \l_shipout_box }
}
% if the current direction is not \yoko,
% then enclose \__shipout_execute_cont: with
% a dummy \yoko-box named \l__platex_shipout_dummy_box.
\platex_if_direction_yoko:TF {
\__platex_original_shipout_execute_cont:
}{
\vbox_set:Nn \l__platex_shipout_dummy_box {
\platex_direction_yoko: \__platex_original_shipout_execute_cont:
}
% [Limitation] the code above may discard some contents,
% so we'd like to put it back by \box\l__platex_shipout_dummy_box.
% however, an infinite loop occurs if we uncomment the line below
% so we can't.
%\box_use:N \l__platex_shipout_dummy_box
}
}
%</ltshipout>-----------------------------------
\ExplSyntaxOff
\expandafter\endinput
\fi
\RequirePackage{atbegshi}
%<*atbegshi>-------------------------------------
% patching atbegshi.sty
%%% following codes are almost copied from
%%% pxatbegshi.sty 2019/09/07 v0.5 (in platex-tools bundle, by H. Yamashita).
\ifdefined\AtBeginShipoutOriginalShipout
\let\AtBeginShipoutOriginalShipout\ltj@shipout
\fi
\AtBeginShipoutInit
\DeclareRobustCommand \AtBeginDvi [1]{%
\global \setbox \@begindvibox
\vbox{\yoko\unvbox \@begindvibox #1}%
}
%% internal macros are locally effective
\begingroup
% helpers
%% unique tokens
\def\pxabgs@mark{\pxabgs@mark@}
\def\pxabgs@fin{\pxabgs@fin@}
%% \pxabgs@patch@cmd\CMD{<orig>}{<new>}
\def\pxabgs@patch@cmd#1#2#3{%
\ifx#1\relax\else
\def\pxabgs@next##1#2##2\pxabgs@mark##3\pxabgs@fin{%
\ifx\pxabgs@mark##3\pxabgs@mark\let#1\relax
\else
\def\pxabgs@fragment{##2}\def#1{##1#3##2}%
\fi}%
\expandafter\pxabgs@next#1\pxabgs@mark#2\pxabgs@mark\pxabgs@fin
\fi
}
% prepare
\ifdefined\AtBegShi@Output
\let\pxabgs@AtBegShi@Output\AtBegShi@Output
\else\let\pxabgs@AtBegShi@Output\relax\fi
% try first patch
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
{\let\AtBegShi@OrgProtect\protect}%
{\setbox8\vbox\bgroup\yoko\let\AtBegShi@OrgProtect\protect}
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
{\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox}%
{\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox\egroup}
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
{%
\begingroup
\setbox\AtBeginShipoutBox\box\AtBeginShipoutBox
\endgroup
\let\protect\AtBegShi@OrgProtect
}{%
\begingroup
\setbox\AtBeginShipoutBox\box\AtBeginShipoutBox
\endgroup
\let\protect\AtBegShi@OrgProtect
\egroup
}
% commit the change only when successful
\ifx\pxabgs@AtBegShi@Output\relax
\@PackageWarningNoLine{lltjp-atbegshi}{%
Failed in patching \string\AtBegShi@Output.\MessageBreak
This may cause error in tate direction%
}
\else
\global\let\AtBegShi@Output\pxabgs@AtBegShi@Output
\fi
\endgroup
%% internal macros are no longer effective
%</atbegshi>-------------------------------------
\endinput
|