2 % lltjcore.sty: derived from plcore.dtx in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjcore}[2018/06/15 Patch to LaTeX2e Kernel for LuaTeX-ja]
7 \RequirePackage{etoolbox}
9 \def\cleardoublepage{\clearpage\if@twoside
11 \ifnum\ltjgetparameter{direction}=3
12 \hbox{}\thispagestyle{empty}\newpage
13 \if@twocolumn\hbox{}\newpage\fi
16 \ifnum\ltjgetparameter{direction}=4
17 \hbox{}\thispagestyle{empty}\newpage
18 \if@twocolumn\hbox{}\newpage\fi
21 \newif\iftombow \tombowfalse
22 \newif\iftombowdate \tombowdatetrue
23 \newdimen\@tombowwidth
24 \setlength{\@tombowwidth}{.1\p@}
25 \newbox\@TL\newbox\@Tl
27 \newbox\@TR\newbox\@Tr
28 \newbox\@BL\newbox\@Bl
30 \newbox\@BR\newbox\@Br
33 \font\@bannerfont=cmtt9
37 \setbox\@TL\hbox to\z@{\yoko\hss
38 \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@
39 \vrule height10mm width\@tombowwidth depth\z@
41 \raise4pt\hbox to\z@{\hskip5mm\@bannerfont\the\@bannertoken\hss}%
43 \setbox\@Tl\hbox to\z@{\yoko\hss
44 \vrule width10mm height\@tombowwidth depth\z@
45 \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@}%
46 \setbox\@TC\hbox{\yoko
47 \vrule width10mm height\@tombowwidth depth\z@
48 \vrule height10mm width\@tombowwidth depth\z@
49 \vrule width10mm height\@tombowwidth depth\z@}%
50 \setbox\@TR\hbox to\z@{\yoko
51 \vrule height10mm width\@tombowwidth depth\z@
52 \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@\hss}%
53 \setbox\@Tr\hbox to\z@{\yoko
54 \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@
55 \vrule width10mm height\@tombowwidth depth\z@\hss}%
56 \setbox\@BL\hbox to\z@{\yoko\hss
57 \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@
58 \vrule depth10mm width\@tombowwidth height\z@}%
59 \setbox\@Bl\hbox to\z@{\yoko\hss
60 \vrule width10mm depth\@tombowwidth height\z@
61 \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@}%
62 \setbox\@BC\hbox{\yoko
63 \vrule width10mm depth\@tombowwidth height\z@
64 \vrule depth10mm width\@tombowwidth height\z@
65 \vrule width10mm depth\@tombowwidth height\z@}%
66 \setbox\@BR\hbox to\z@{\yoko
67 \vrule depth10mm width\@tombowwidth height\z@
68 \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@\hss}%
69 \setbox\@Br\hbox to\z@{\yoko
70 \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@
71 \vrule width10mm depth\@tombowwidth height\z@\hss}%
72 \setbox\@CL\hbox to\z@{\yoko\hss
73 \vrule width10mm height.5\@tombowwidth depth.5\@tombowwidth
74 \vrule height10mm depth10mm width\@tombowwidth}%
75 \setbox\@CR\hbox to\z@{\yoko
76 \vrule height10mm depth10mm width\@tombowwidth
77 \vrule height.5\@tombowwidth depth.5\@tombowwidth width10mm\hss}%
81 \vbox to\z@{\kern-\dimexpr 10mm+\@tombowbleed\relax
83 \moveleft\@tombowbleed\vbox to\@@paperheight{%
86 \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
87 \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip\@tombowbleed}%
89 \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
91 \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
93 \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
95 \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
96 \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip\@tombowbleed}%
102 \def\@tombowcolor{\normalcolor}
103 \def\@tombowbleed{3mm}
104 \def\@tombowreset@@paper{%
105 \@@topmargin\topmargin
107 \@@paperwidth\paperwidth
108 \advance\@@paperwidth 2\dimexpr\@tombowbleed\relax
109 \@@paperheight\paperheight\advance\@@paperheight 10mm\relax
110 \advance\@@paperheight 2\dimexpr\@tombowbleed\relax
111 \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
114 \newdimen\@@paperheight
115 \newdimen\@@paperwidth
116 \newdimen\@@topmargin
118 \begingroup % the \endgroup is put in by \aftergroup
119 \ifnum\ltjgetparameter{direction}=4\else
120 \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
122 \let \protect \noexpand
123 \language\document@default@language %LaTeX2e 2017/05/01
125 \global\let\@@if@newlist\if@newlist
126 \global\@newlistfalse
131 \aftergroup\set@typeset@protect
133 \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
136 \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
137 \ifnum\ltjgetparameter{direction}=3 \let\@themargin\evensidemargin
138 \else\let\@themargin\oddsidemargin\fi
139 \else \let\@thehead\@evenhead
140 \let\@thefoot\@evenfoot
141 \ifnum\ltjgetparameter{direction}=3 \let\@themargin\oddsidemargin
142 \else\let\@themargin\evensidemargin\fi
150 \let\glossary\@gobble
151 \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
155 \moveright\@themargin\vbox{%
156 \setbox\@tempboxa \vbox to\headheight{%
160 \hb@xt@\textwidth{\@thehead}%
167 \baselineskip \footskip
170 \hb@xt@\textwidth{\@thefoot}%
174 \global\let\if@newlist\@@if@newlist
175 \global \@colht \textheight
177 \let\firstmark\botmark
180 %%% Remove extra xkanjiskip
181 \renewcommand\@makefnmark{%
182 \unless\ifnum\ltjgetparameter{direction}=3
183 \hbox{}\hbox{\@textsuperscript{\normalfont\@thefnmark}}\hbox{}%
184 \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}
186 \@ifpackageloaded{hyperref}
187 {\def\ltj@setrefprefix{real}}
188 {\def\ltj@setrefprefix{}}
189 \expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
191 \protect\G@refundefinedtrue
192 \nfss@text{\reset@font\bfseries ??}%
193 \@latex@warning{Reference `#3' on page \thepage \space
196 \expandafter#2#1\protect\@setref@{}% change \null to \protect\@setref@{}
198 \gdef\@setref@{\ifhmode\spacefactor\@m\fi}
200 \if@compatibility\else
201 \def\verb{\relax\ifmmode\hbox\else\leavevmode\vadjust{}\fi
203 \verb@eol@error \let\do\@makeother \dospecials
204 \verbatim@font\@noligs
205 \language\l@nohyphenation
206 \@ifstar\@sverb\@verb}
209 \inhibitglue\@tempskipa\lastskip\unskip
210 \hskip\@tempskipa\color@endgroup\egroup}
211 \pretocmd{\footnote}{\inhibitglue}{}{}
212 \pretocmd{\footnotemark}{\inhibitglue}{}{}
213 \patchcmd{\@footnotemark}{\@makefnmark}{%
214 \unless\ifnum\ltjgetparameter{direction}=3 \@makefnmark%
215 \else\hbox to\z@{\hskip-.25\zw\raise.9\zh\@makefnmark\hss}\fi%
217 \let\@parboxto\@empty
218 \long\def\@iiiparbox#1#2[#3]#4#5{%
221 \setlength\@tempdima{#4}%
222 \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
224 \setlength\@tempdimb{#2}%
225 \edef\@parboxto{to\the\@tempdimb}%
229 \else\ifmmode\vcenter
230 \else\@pboxswtrue\null$\vcenter% !!!
232 \@parboxto{\let\hss\vss\let\unhbox\unvbox
233 \csname bm@#3\endcsname}%
234 \if@pboxsw \m@th$\null\fi% !!!
238 \ifmmode\@@underline{#1}%
239 \else \leavevmode\null$\@@underline{\hbox{#1}}\m@th$\null\relax\fi}
242 \def \AtBeginDvi #1{%
243 \global \setbox \@begindvibox
244 \vbox{\yoko\unvbox \@begindvibox #1}%
248 \newif\ifltj@ftn@unvboxed
252 \ltj@ftn@unvboxedfalse
253 \setbox\@outputbox \box\@cclv
255 \ltj@ftn@unvboxedtrue
256 \setbox\@outputbox \vbox {%
257 \boxmaxdepth \@maxdepth
259 \iffnfixbottom\vskip\z@ \@plus.0001fil\fi
269 \xdef\@freelist{\@freelist\@midlist}%
270 \global \let \@midlist \@empty
275 \setbox\@outputbox \vbox to\@colht {%
277 \dimen@ \dp\@outputbox
279 \ifnum\ltjgetparameter{direction}=4\else\vbox{\hskip\z@}\fi %%% LuaTeX-ja
281 \ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi
284 \global \maxdepth \@maxdepth
286 \let\ltj@orig@makecol=\@makecol
288 \patchcmd\@makespecialcolbox{\@textbottom}{\ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi}{}{}
294 \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break \null
295 % \null は \break の効果が行頭禁則文字で打ち消されないために必要
300 %%%%%% tabular (platex/#43) \@tabclassz
301 \def\ltj@sharp{\relax\pltx@next@inhibitglue\ltjfakeboxbdd\ignorespaces\@sharp\unskip\ltjfakeboxbdd}
314 \@firstampfalse\@acol
321 \hskip1sp\ltj@sharp\hfil
323 \hfil\hskip1sp\ltj@sharp
328 \everypar\expandafter{\the\everypar\ltjfakeboxbdd}\ignorespaces\@sharp\unskip
330 \patchcmd{\@tabular}{\leavevmode}{\leavevmode\null}{}{}
331 \apptocmd{\endtabular}{\null}{}{}
332 \expandafter \let \csname endtabular*\endcsname = \endtabular
334 %%%%%% tabbing (platex/#53)
335 \patchcmd\@startline{\strut}{\strut\inhibitglue}{}{}
336 \def\ltj@unhbox@curfield{\ltjfakeboxbdd\unhbox\@curfield\ltjfakeboxbdd}
337 %\patchcmd\@contfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}
338 \patchcmd\@addfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}