2 % lltjcore.sty: derived from plcore.dtx in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjcore}[2021-03-19 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{%
76 \unless\ifnum\ltjgetparameter{direction}=4
77 \primitive\everypar{}\hskip\z@\fi
80 \newif\iftombow \tombowfalse
81 \newif\iftombowdate \tombowdatetrue
82 \newdimen\@tombowwidth
83 \setlength{\@tombowwidth}{.1\p@}
84 \newbox\@TL\newbox\@Tl
86 \newbox\@TR\newbox\@Tr
87 \newbox\@BL\newbox\@Bl
89 \newbox\@BR\newbox\@Br
92 \font\@bannerfont=file:lmmono9-regular.otf % cmtt9 in pLaTeX
96 \setbox\@TL\hbox to\z@{\yoko\hss
97 \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@
98 \vrule height10mm width\@tombowwidth depth\z@
100 \raise4pt\hbox to\z@{\hskip5mm\@bannerfont\the\@bannertoken\hss}%
102 \setbox\@Tl\hbox to\z@{\yoko\hss
103 \vrule width10mm height\@tombowwidth depth\z@
104 \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@}%
105 \setbox\@TC\hbox{\yoko
106 \vrule width10mm height\@tombowwidth depth\z@
107 \vrule height10mm width\@tombowwidth depth\z@
108 \vrule width10mm height\@tombowwidth depth\z@}%
109 \setbox\@TR\hbox to\z@{\yoko
110 \vrule height10mm width\@tombowwidth depth\z@
111 \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@\hss}%
112 \setbox\@Tr\hbox to\z@{\yoko
113 \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@
114 \vrule width10mm height\@tombowwidth depth\z@\hss}%
115 \setbox\@BL\hbox to\z@{\yoko\hss
116 \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@
117 \vrule depth10mm width\@tombowwidth height\z@}%
118 \setbox\@Bl\hbox to\z@{\yoko\hss
119 \vrule width10mm depth\@tombowwidth height\z@
120 \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@}%
121 \setbox\@BC\hbox{\yoko
122 \vrule width10mm depth\@tombowwidth height\z@
123 \vrule depth10mm width\@tombowwidth height\z@
124 \vrule width10mm depth\@tombowwidth height\z@}%
125 \setbox\@BR\hbox to\z@{\yoko
126 \vrule depth10mm width\@tombowwidth height\z@
127 \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@\hss}%
128 \setbox\@Br\hbox to\z@{\yoko
129 \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@
130 \vrule width10mm depth\@tombowwidth height\z@\hss}%
131 \setbox\@CL\hbox to\z@{\yoko\hss
132 \vrule width10mm height.5\@tombowwidth depth.5\@tombowwidth
133 \vrule height10mm depth10mm width\@tombowwidth}%
134 \setbox\@CR\hbox to\z@{\yoko
135 \vrule height10mm depth10mm width\@tombowwidth
136 \vrule height.5\@tombowwidth depth.5\@tombowwidth width10mm\hss}%
140 \vbox to\z@{\kern\dimexpr-10mm-\@tombowbleed\relax
141 \boxmaxdepth\maxdimen
142 \moveleft\@tombowbleed\vbox to\@@paperheight{%
145 \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
146 \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip\@tombowbleed}%
148 \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
150 \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
152 \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
154 \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
155 \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip\@tombowbleed}%
161 \def\@tombowcolor{\normalcolor}
162 \def\@tombowbleed{3mm}
163 \def\@tombowreset@@paper{%
164 \@@topmargin \topmargin % only for compatibility
166 \@@paperwidth\dimexpr\paperwidth+2\dimexpr\@tombowbleed\relax
167 \@@paperheight\dimexpr\paperheight+10mm+2\dimexpr\@tombowbleed\relax
168 \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
171 \newdimen\@@paperheight
172 \newdimen\@@paperwidth
173 \newdimen\@@topmargin % not used by LuaTeX-ja; only to avoid existing codes
174 \patchcmd\@outputpage{\begingroup\let\protect\noexpand}{% tate direction
176 \ifnum\ltjgetparameter{direction}=4\else
177 \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
179 \let \protect \noexpand
181 \patchcmd\@outputpage{% supply \yoko
183 \aftergroup \endgroup
185 \yoko \set@typeset@protect
186 \aftergroup \endgroup
188 \patchcmd\@outputpage{\let\@thefoot\@oddfoot\let\@themargin\oddsidemargin}{% tate direction
189 \let\@thefoot\@oddfoot
190 \ifnum\ltjgetparameter{direction}=3 \let\@themargin\evensidemargin
191 \else\let\@themargin\oddsidemargin\fi
193 \patchcmd\@outputpage{\let\@thefoot\@evenfoot\let\@themargin\evensidemargin}{% tate direction
194 \let\@thefoot\@evenfoot
195 \ifnum\ltjgetparameter{direction}=3 \let\@themargin\oddsidemargin
196 \else\let\@themargin\evensidemargin\fi
199 % 将来は shipout hook で書き直したい
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}{}{}
204 %%% Remove extra xkanjiskip
205 \renewcommand\@makefnmark{%
206 \unless\ifnum\ltjgetparameter{direction}=3
207 \hbox{}\hbox{\@textsuperscript{\normalfont\@thefnmark}}\hbox{}%
208 \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}
210 \@ifpackageloaded{hyperref}
211 {\def\ltj@setrefprefix{real}}
212 {\def\ltj@setrefprefix{}}
213 \expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
215 \protect\G@refundefinedtrue
216 \nfss@text{\reset@font\bfseries ??}%
217 \@latex@warning{Reference `#3' on page \thepage \space
220 \expandafter#2#1\protect\@setref@{}% change \null to \protect\@setref@{}
222 \gdef\@setref@{\ifhmode\spacefactor\@m\fi}
224 \if@compatibility\else
225 \def\verb{\relax\ifmmode\hbox\else\leavevmode\vadjust{}\fi
227 \verb@eol@error \let\do\@makeother \dospecials
228 \verbatim@font\@noligs
229 \language\l@nohyphenation
230 \@ifstar\@sverb\@verb}
232 \patchcmd{\do@noligs}{\kern\z@}{\vadjust{}}{}{} % reported by p_typo
234 \inhibitglue\@tempskipa\lastskip\unskip
235 \hskip\@tempskipa\color@endgroup\egroup}
236 \pretocmd{\footnote}{\inhibitglue}{}{}
237 \pretocmd{\footnotemark}{\inhibitglue}{}{}
238 \patchcmd{\@footnotemark}{\@makefnmark}{%
239 \unless\ifnum\ltjgetparameter{direction}=3 \@makefnmark%
240 \else\hbox to\z@{\hskip-.25\zw\raise.9\zh\@makefnmark\hss}\fi%
242 \let\@parboxto\@empty
243 \long\def\@iiiparbox#1#2[#3]#4#5{%
246 \setlength\@tempdima{#4}%
247 \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
249 \setlength\@tempdimb{#2}%
250 \edef\@parboxto{to\the\@tempdimb}%
254 \else\ifmmode\vcenter
255 \else\@pboxswtrue\null$\vcenter% !!!
257 \@parboxto{\let\hss\vss\let\unhbox\unvbox
258 \csname bm@#3\endcsname}%
259 \if@pboxsw \m@th$\null\fi% !!!
261 \DeclareRobustCommand\underline[1]{%
263 \ifmmode\@@underline{#1}%
264 \else \leavevmode\null$\@@underline{\hbox{#1}}\m@th$\null\relax\fi}
267 \newif\ifltj@ftn@unvboxed
271 \ltj@ftn@unvboxedfalse
272 \setbox\@outputbox \box\@cclv
274 \ltj@ftn@unvboxedtrue
275 \setbox\@outputbox \vbox {%
276 \boxmaxdepth \@maxdepth
278 \iffnfixbottom\vskip\z@ \@plus.0001fil\fi
288 \xdef\@freelist{\@freelist\@midlist}%
289 \global \let \@midlist \@empty
294 \setbox\@outputbox \vbox to\@colht {%
296 \dimen@ \dp\@outputbox
298 \unless\ifnum\ltjgetparameter{direction}=4
299 \vbox{\primitive\everypar{}\hskip\z@}%
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}{}{}