2 % lltjcore.sty: derived from plcore.dtx in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjcore}[2021-03-14 Patch to LaTeX2e Kernel for LuaTeX-ja]
7 \RequirePackage{etoolbox}
10 \RequirePackage{expl3}
12 \cs_set_eq:NN \platex_direction_yoko: \yoko
13 \cs_set_eq:NN \platex_direction_tate: \tate
14 \cs_set_eq:NN \platex_direction_dtou: \dtou
15 \cs_set_eq:NN \platex_direction_utod: \utod % LuaTeX-ja specific
16 \prg_new_conditional:Npnn \platex_if_box_yoko:N #1 { p, T, F, TF }
17 { \if_int_compare:w \ltjgetparameter{boxdir}{#1} = 4 \scan_stop:
18 \prg_return_true: \else: \prg_return_false: \fi: }
19 \prg_new_conditional:Npnn \platex_if_box_utod:N #1 { p, T, F, TF }
20 { \if_int_compare:w \ltjgetparameter{boxdir}{#1} = 11 \scan_stop:
21 \prg_return_true: \else: \prg_return_false: \fi: }
22 \prg_new_eq_conditional:NNn \platex_if_box_tate_math:N \platex_if_box_utod:N { p, T, F, TF }
23 \prg_new_conditional:Npnn \platex_if_box_tate_nomath:N #1 { p, T, F, TF }
24 { \if_int_compare:w \ltjgetparameter{boxdir}{#1} = 3 \scan_stop:
25 \prg_return_true: \else: \prg_return_false: \fi: }
26 \prg_new_conditional:Npnn \platex_if_box_tate:N #1 { p, T, F, TF }
27 { \if_int_compare:w \ltjgetparameter{boxdir}{#1} = 3 \scan_stop:
29 \else: \if_int_compare:w \ltjgetparameter{boxdir}{#1} = 11 \scan_stop: % utod
34 \prg_new_conditional:Npnn \platex_if_box_dtou:N #1 { p, T, F, TF }
35 { \if_int_compare:w \ltjgetparameter{boxdir}{#1} = 1 \scan_stop:
36 \prg_return_true: \else: \prg_return_false: \fi: }
37 \prg_new_conditional:Npnn \platex_if_direction_yoko: { p, T, F, TF }
38 { \if_int_compare:w \ltjgetparameter{direction} = 4 \scan_stop:
39 \prg_return_true: \else: \prg_return_false: \fi: }
40 \prg_new_conditional:Npnn \platex_if_direction_utod: { p, T, F, TF }
41 { \if_int_compare:w \ltjgetparameter{direction} = 11 \scan_stop:
42 \prg_return_true: \else: \prg_return_false: \fi: }
43 \prg_new_eq_conditional:NNn
44 \platex_if_direction_tate_math: \platex_if_direction_utod: { p, T, F, TF }
45 \prg_new_conditional:Npnn \platex_if_direction_tate_nomath: { p, T, F, TF }
46 { \if_int_compare:w \ltjgetparameter{direction} = 3 \scan_stop:
47 \prg_return_true: \else: \prg_return_false: \fi: }
48 \prg_new_conditional:Npnn \platex_if_direction_tate: { p, T, F, TF }
49 { \if_int_compare:w \ltjgetparameter{direction} = 3 \scan_stop:
51 \else: \if_int_compare:w \ltjgetparameter{direction} = 11 \scan_stop: % utod
56 \prg_new_conditional:Npnn \platex_if_direction_dtou: { p, T, F, TF }
57 { \if_int_compare:w \ltjgetparameter{direction} = 1 \scan_stop:
58 \prg_return_true: \else: \prg_return_false: \fi: }
61 \def\cleardoublepage{\clearpage\if@twoside
63 \ifnum\ltjgetparameter{direction}=3
64 \hbox{}\thispagestyle{empty}\newpage
65 \if@twocolumn\hbox{}\newpage\fi
68 \ifnum\ltjgetparameter{direction}=4
69 \hbox{}\thispagestyle{empty}\newpage
70 \if@twocolumn\hbox{}\newpage\fi
74 \patchcmd\@vtryfc{\global\setbox\@outputbox\vbox{}}
75 {\global\setbox\@outputbox\vbox{\unless\ifnum\ltjgetparameter{direction}=4\hskip\z@\fi}}{}{}
77 \newif\iftombow \tombowfalse
78 \newif\iftombowdate \tombowdatetrue
79 \newdimen\@tombowwidth
80 \setlength{\@tombowwidth}{.1\p@}
81 \newbox\@TL\newbox\@Tl
83 \newbox\@TR\newbox\@Tr
84 \newbox\@BL\newbox\@Bl
86 \newbox\@BR\newbox\@Br
89 \font\@bannerfont=cmtt9
93 \setbox\@TL\hbox to\z@{\yoko\hss
94 \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@
95 \vrule height10mm width\@tombowwidth depth\z@
97 \raise4pt\hbox to\z@{\hskip5mm\@bannerfont\the\@bannertoken\hss}%
99 \setbox\@Tl\hbox to\z@{\yoko\hss
100 \vrule width10mm height\@tombowwidth depth\z@
101 \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@}%
102 \setbox\@TC\hbox{\yoko
103 \vrule width10mm height\@tombowwidth depth\z@
104 \vrule height10mm width\@tombowwidth depth\z@
105 \vrule width10mm height\@tombowwidth depth\z@}%
106 \setbox\@TR\hbox to\z@{\yoko
107 \vrule height10mm width\@tombowwidth depth\z@
108 \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@\hss}%
109 \setbox\@Tr\hbox to\z@{\yoko
110 \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@
111 \vrule width10mm height\@tombowwidth depth\z@\hss}%
112 \setbox\@BL\hbox to\z@{\yoko\hss
113 \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@
114 \vrule depth10mm width\@tombowwidth height\z@}%
115 \setbox\@Bl\hbox to\z@{\yoko\hss
116 \vrule width10mm depth\@tombowwidth height\z@
117 \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@}%
118 \setbox\@BC\hbox{\yoko
119 \vrule width10mm depth\@tombowwidth height\z@
120 \vrule depth10mm width\@tombowwidth height\z@
121 \vrule width10mm depth\@tombowwidth height\z@}%
122 \setbox\@BR\hbox to\z@{\yoko
123 \vrule depth10mm width\@tombowwidth height\z@
124 \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@\hss}%
125 \setbox\@Br\hbox to\z@{\yoko
126 \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@
127 \vrule width10mm depth\@tombowwidth height\z@\hss}%
128 \setbox\@CL\hbox to\z@{\yoko\hss
129 \vrule width10mm height.5\@tombowwidth depth.5\@tombowwidth
130 \vrule height10mm depth10mm width\@tombowwidth}%
131 \setbox\@CR\hbox to\z@{\yoko
132 \vrule height10mm depth10mm width\@tombowwidth
133 \vrule height.5\@tombowwidth depth.5\@tombowwidth width10mm\hss}%
135 \def\@outputtombow#1#2{%
137 \vbox to\z@{\kern\dimexpr#1-10mm-\@tombowbleed\relax
138 \boxmaxdepth\maxdimen
139 \moveleft\dimexpr#2+\@tombowbleed\vbox to\@@paperheight{%
142 \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
143 \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip\@tombowbleed}%
145 \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
147 \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
149 \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
151 \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
152 \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip\@tombowbleed}%
158 \def\@tombowcolor{\normalcolor}
159 \def\@tombowbleed{3mm}
160 \def\@tombowreset@@paper{%
162 \@@paperwidth\dimexpr\paperwidth+2\dimexpr\@tombowbleed\relax
163 \@@paperheight\dimexpr\paperheight+10mm+2\dimexpr\@tombowbleed\relax
164 \advance\@themargin 1in\relax
167 \newdimen\@@paperheight
168 \newdimen\@@paperwidth
170 \patchcmd\@outputpage{\begingroup\let\protect\noexpand}{% tate direction
172 \ifnum\ltjgetparameter{direction}=4\else
173 \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
175 \let \protect \noexpand
177 \patchcmd\@outputpage{% supply \yoko
179 \aftergroup \endgroup
181 \yoko \set@typeset@protect
182 \aftergroup \endgroup
184 \patchcmd\@outputpage{\let\@thefoot\@oddfoot\let\@themargin\oddsidemargin}{% tate direction
185 \let\@thefoot\@oddfoot
186 \ifnum\ltjgetparameter{direction}=3 \let\@themargin\evensidemargin
187 \else\let\@themargin\oddsidemargin\fi
189 \patchcmd\@outputpage{\let\@thefoot\@evenfoot\let\@themargin\evensidemargin}{% tate direction
190 \let\@thefoot\@evenfoot
191 \ifnum\ltjgetparameter{direction}=3 \let\@themargin\oddsidemargin
192 \else\let\@themargin\evensidemargin\fi
194 \ifltj@ltfilehook@avail
195 \AddToHook{shipout/before}{%
196 \iftombow\setbox\ShipoutBox\vbox{\vskip1in\moveright1in\box\ShipoutBox}\fi
198 \AddToHook{shipout/background}{\@tombowreset@@paper\@outputtombow{1in}{-1in}}
200 \patchcmd\@outputpage{\vskip\topmargin}{\vskip\topmargin\iftombow\vskip1in\fi}{}{}
201 \patchcmd\@outputpage{\reset@font}{\@tombowreset@@paper\reset@font}{}{}
202 \patchcmd\@outputpage{\@begindvi}{\@begindvi\@outputtombow{0pt}{0pt}}{}{}
206 %%% Remove extra xkanjiskip
207 \renewcommand\@makefnmark{%
208 \unless\ifnum\ltjgetparameter{direction}=3
209 \hbox{}\hbox{\@textsuperscript{\normalfont\@thefnmark}}\hbox{}%
210 \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}
212 \@ifpackageloaded{hyperref}
213 {\def\ltj@setrefprefix{real}}
214 {\def\ltj@setrefprefix{}}
215 \expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
217 \protect\G@refundefinedtrue
218 \nfss@text{\reset@font\bfseries ??}%
219 \@latex@warning{Reference `#3' on page \thepage \space
222 \expandafter#2#1\protect\@setref@{}% change \null to \protect\@setref@{}
224 \gdef\@setref@{\ifhmode\spacefactor\@m\fi}
226 \if@compatibility\else
227 \def\verb{\relax\ifmmode\hbox\else\leavevmode\vadjust{}\fi
229 \verb@eol@error \let\do\@makeother \dospecials
230 \verbatim@font\@noligs
231 \language\l@nohyphenation
232 \@ifstar\@sverb\@verb}
234 \patchcmd{\do@noligs}{\kern\z@}{\vadjust{}}{}{} % reported by p_typo
236 \inhibitglue\@tempskipa\lastskip\unskip
237 \hskip\@tempskipa\color@endgroup\egroup}
238 \pretocmd{\footnote}{\inhibitglue}{}{}
239 \pretocmd{\footnotemark}{\inhibitglue}{}{}
240 \patchcmd{\@footnotemark}{\@makefnmark}{%
241 \unless\ifnum\ltjgetparameter{direction}=3 \@makefnmark%
242 \else\hbox to\z@{\hskip-.25\zw\raise.9\zh\@makefnmark\hss}\fi%
244 \let\@parboxto\@empty
245 \long\def\@iiiparbox#1#2[#3]#4#5{%
248 \setlength\@tempdima{#4}%
249 \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
251 \setlength\@tempdimb{#2}%
252 \edef\@parboxto{to\the\@tempdimb}%
256 \else\ifmmode\vcenter
257 \else\@pboxswtrue\null$\vcenter% !!!
259 \@parboxto{\let\hss\vss\let\unhbox\unvbox
260 \csname bm@#3\endcsname}%
261 \if@pboxsw \m@th$\null\fi% !!!
263 \DeclareRobustCommand\underline[1]{%
265 \ifmmode\@@underline{#1}%
266 \else \leavevmode\null$\@@underline{\hbox{#1}}\m@th$\null\relax\fi}
269 \newif\ifltj@ftn@unvboxed
273 \ltj@ftn@unvboxedfalse
274 \setbox\@outputbox \box\@cclv
276 \ltj@ftn@unvboxedtrue
277 \setbox\@outputbox \vbox {%
278 \boxmaxdepth \@maxdepth
280 \iffnfixbottom\vskip\z@ \@plus.0001fil\fi
290 \xdef\@freelist{\@freelist\@midlist}%
291 \global \let \@midlist \@empty
296 \setbox\@outputbox \vbox to\@colht {%
298 \dimen@ \dp\@outputbox
300 \unless\ifnum\ltjgetparameter{direction}=4\vbox{\hskip\z@}\fi %%% LuaTeX-ja
302 \ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi
305 \global \maxdepth \@maxdepth
307 \let\ltj@orig@makecol=\@makecol
309 \patchcmd\@makespecialcolbox{\@textbottom}{\ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi}{}{}
315 \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break \null
316 % \null は \break の効果が行頭禁則文字で打ち消されないために必要
321 %%%%%% tabular (platex/#43) \@tabclassz
322 \def\ltj@sharp{\relax\pltx@next@inhibitglue\ltjfakeboxbdd\ignorespaces\@sharp\unskip\ltjfakeboxbdd}
335 \@firstampfalse\@acol
340 \hfil\hskip1sp\ltj@sharp\hfil
342 \hskip1sp\ltj@sharp\hfil
344 \hfil\hskip1sp\ltj@sharp
349 \everypar\expandafter{\the\everypar\ltjfakeboxbdd}\ignorespaces\@sharp\unskip
351 \patchcmd{\@tabular}{\leavevmode}{\leavevmode\null}{}{}
352 \apptocmd{\endtabular}{\null}{}{}
353 \expandafter \let \csname endtabular*\endcsname = \endtabular
355 %%%%%% tabbing (platex/#53)
356 \patchcmd\@startline{\strut}{\strut\inhibitglue}{}{}
357 \def\ltj@unhbox@curfield{\ltjfakeboxbdd\unhbox\@curfield\ltjfakeboxbdd}
358 %\patchcmd\@contfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}
359 \patchcmd\@addfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}