OSDN Git Service

37d43f67c3394ca435160a9feb8318c63e79fd41
[luatex-ja/luatexja.git] / src / patches / lltjcore.sty
1 %
2 % lltjcore.sty: derived from plcore.dtx in pLaTeX.
3 %
4
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjcore}[2017/06/18 Patch to LaTeX2e Kernel for LuaTeX-ja]
7
8 \def\cleardoublepage{\clearpage\if@twoside
9   \ifodd\c@page
10     \ifnum\ltjgetparameter{direction}=3
11       \hbox{}\thispagestyle{empty}\newpage
12       \if@twocolumn\hbox{}\newpage\fi
13     \fi
14   \else
15     \ifnum\ltjgetparameter{direction}=4
16       \hbox{}\thispagestyle{empty}\newpage
17       \if@twocolumn\hbox{}\newpage\fi
18     \fi
19   \fi\fi}
20 \newif\iftombow \tombowfalse
21 \newif\iftombowdate \tombowdatetrue
22 \newdimen\@tombowwidth
23 \setlength{\@tombowwidth}{.1\p@}
24 \newbox\@TL\newbox\@Tl
25 \newbox\@TC
26 \newbox\@TR\newbox\@Tr
27 \newbox\@BL\newbox\@Bl
28 \newbox\@BC
29 \newbox\@BR\newbox\@Br
30 \newbox\@CL
31 \newbox\@CR
32 \font\@bannerfont=cmtt9
33 \newtoks\@bannertoken
34 \@bannertoken{}
35 \def\maketombowbox{%
36   \setbox\@TL\hbox to\z@{\yoko\hss
37       \vrule width13mm height\@tombowwidth depth\z@
38       \vrule height10mm width\@tombowwidth depth\z@
39       \iftombowdate
40         \raise4pt\hbox to\z@{\hskip5mm\@bannerfont\the\@bannertoken\hss}%
41       \fi}%
42   \setbox\@Tl\hbox to\z@{\yoko\hss
43       \vrule width10mm height\@tombowwidth depth\z@
44       \vrule height13mm width\@tombowwidth depth\z@}%
45   \setbox\@TC\hbox{\yoko
46       \vrule width10mm height\@tombowwidth depth\z@
47       \vrule height10mm width\@tombowwidth depth\z@
48       \vrule width10mm height\@tombowwidth depth\z@}%
49   \setbox\@TR\hbox to\z@{\yoko
50       \vrule height10mm width\@tombowwidth depth\z@
51       \vrule width13mm height\@tombowwidth depth\z@\hss}%
52   \setbox\@Tr\hbox to\z@{\yoko
53       \vrule height13mm width\@tombowwidth depth\z@
54       \vrule width10mm height\@tombowwidth depth\z@\hss}%
55   \setbox\@BL\hbox to\z@{\yoko\hss
56       \vrule width13mm depth\@tombowwidth height\z@
57       \vrule depth10mm width\@tombowwidth height\z@}%
58   \setbox\@Bl\hbox to\z@{\yoko\hss
59       \vrule width10mm depth\@tombowwidth height\z@
60       \vrule depth13mm width\@tombowwidth height\z@}%
61   \setbox\@BC\hbox{\yoko
62       \vrule width10mm depth\@tombowwidth height\z@
63       \vrule depth10mm width\@tombowwidth height\z@
64       \vrule width10mm depth\@tombowwidth height\z@}%
65   \setbox\@BR\hbox to\z@{\yoko
66       \vrule depth10mm width\@tombowwidth height\z@
67       \vrule width13mm depth\@tombowwidth height\z@\hss}%
68   \setbox\@Br\hbox to\z@{\yoko
69       \vrule depth13mm width\@tombowwidth height\z@
70       \vrule width10mm depth\@tombowwidth height\z@\hss}%
71   \setbox\@CL\hbox to\z@{\yoko\hss
72       \vrule width10mm height.5\@tombowwidth depth.5\@tombowwidth
73       \vrule height10mm depth10mm width\@tombowwidth}%
74   \setbox\@CR\hbox to\z@{\yoko
75       \vrule height10mm depth10mm width\@tombowwidth
76       \vrule height.5\@tombowwidth depth.5\@tombowwidth width10mm\hss}%
77 }
78 \def\@outputtombow{%
79   \iftombow
80   \vbox to\z@{\kern-13mm\relax
81     \boxmaxdepth\maxdimen
82     \moveleft3mm\vbox to\@@paperheight{%
83       \hbox to\@@paperwidth{\hskip3mm\relax
84          \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip3mm}%
85       \kern-10mm
86       \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
87       \vfill
88       \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
89       \vfill
90       \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
91       \kern-10mm
92       \hbox to\@@paperwidth{\hskip3mm\relax
93          \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip3mm}%
94     }\vss
95   }%
96   \fi
97 }
98 \newdimen\@@paperheight
99 \newdimen\@@paperwidth
100 \newdimen\@@topmargin
101 \def\@outputpage{%
102 \begingroup % the \endgroup is put in by \aftergroup
103   \ifnum\ltjgetparameter{direction}=4\else
104     \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
105   \fi
106   \let \protect \noexpand
107   \language\document@default@language %LaTeX2e 2017/05/01
108   \@resetactivechars
109   \global\let\@@if@newlist\if@newlist
110   \global\@newlistfalse
111   \@parboxrestore
112   \shipout\vbox{\yoko
113     \set@typeset@protect
114     \aftergroup\endgroup
115     \aftergroup\set@typeset@protect
116      \if@specialpage
117        \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
118      \fi
119      \if@twoside
120        \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
121           \ifnum\ltjgetparameter{direction}=3 \let\@themargin\evensidemargin
122           \else\let\@themargin\oddsidemargin\fi
123        \else \let\@thehead\@evenhead
124           \let\@thefoot\@evenfoot
125            \ifnum\ltjgetparameter{direction}=3 \let\@themargin\oddsidemargin
126            \else\let\@themargin\evensidemargin\fi
127      \fi\fi
128      \@@topmargin\topmargin
129      \iftombow
130        \@@paperwidth\paperwidth \advance\@@paperwidth 6mm\relax
131        \@@paperheight\paperheight \advance\@@paperheight 16mm\relax
132        \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
133      \fi
134      \reset@font
135      \normalsize
136      \normalsfcodes
137      \let\label\@gobble
138      \let\index\@gobble
139      \let\glossary\@gobble
140      \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
141     \@begindvi
142     \@outputtombow
143     \vskip \@@topmargin
144     \moveright\@themargin\vbox{%
145       \setbox\@tempboxa \vbox to\headheight{%
146         \vfil
147         \color@hbox
148           \normalcolor
149           \hb@xt@\textwidth{\@thehead}%
150         \color@endbox
151       }%                        %% 22 Feb 87
152       \dp\@tempboxa \z@
153       \box\@tempboxa
154       \vskip \headsep
155       \box\@outputbox
156       \baselineskip \footskip
157       \color@hbox
158         \normalcolor
159         \hb@xt@\textwidth{\@thefoot}%
160       \color@endbox
161     }%
162   }%
163   \global\let\if@newlist\@@if@newlist
164   \global \@colht \textheight
165   \stepcounter{page}%
166   \let\firstmark\botmark
167 }
168
169 %%% Remove extra xkanjiskip
170 \renewcommand\@makefnmark{%
171   \unless\ifnum\ltjgetparameter{direction}=3
172     \hbox{}\hbox{\@textsuperscript{\normalfont\@thefnmark}}\hbox{}%
173   \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}
174 \begingroup
175 \@ifpackageloaded{hyperref}
176   {\def\ltj@setrefprefix{real}}
177   {\def\ltj@setrefprefix{}}
178 \expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
179   \ifx#1\relax
180     \protect\G@refundefinedtrue
181     \nfss@text{\reset@font\bfseries ??}%
182     \@latex@warning{Reference `#3' on page \thepage \space
183               undefined}%
184   \else
185     \expandafter#2#1\relax{}% change \null to \relax
186   \fi}
187 \endgroup
188 \if@compatibility\else
189 \def\verb{\relax\ifmmode\hbox\else\leavevmode\fi
190   \bgroup
191     \verb@eol@error \let\do\@makeother \dospecials
192     \verbatim@font\@noligs
193     \language\l@nohyphenation
194     \@ifstar\@sverb\@verb}
195 \fi
196 \gdef\@stopfield{\null\color@endgroup\egroup}
197 \newcount\hour
198 \newcount\minute
199 \RequirePackage{etoolbox}
200 \ifltj@everyhook@avail
201   \pretocmd{\footnote}{\inhibitglue}{}{}
202   \pretocmd{\footnotemark}{\inhibitglue}{}{}
203   \patchcmd{\@footnotemark}{\@makefnmark}{%
204     \unless\ifnum\ltjgetparameter{direction}=3 \@makefnmark%
205     \else\hbox to\z@{\hskip-.25\zw\raise.9\zh\@makefnmark\hss}\fi%
206   }{}{}
207   \patchcmd{\@tabular}{\leavevmode}{\leavevmode\null}{}{}
208   \apptocmd{\endtabular}{\null}{}{}
209   \expandafter \let \csname endtabular*\endcsname = \endtabular
210 \fi
211 \let\@parboxto\@empty
212 \long\def\@iiiparbox#1#2[#3]#4#5{%
213   \leavevmode
214   \@pboxswfalse
215   \setlength\@tempdima{#4}%
216   \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
217     \ifx\relax#2\else
218       \setlength\@tempdimb{#2}%
219       \edef\@parboxto{to\the\@tempdimb}%
220     \fi
221     \if#1b\vbox
222     \else\if #1t\vtop
223     \else\ifmmode\vcenter
224     \else\@pboxswtrue\null$\vcenter% !!!
225     \fi\fi\fi
226     \@parboxto{\let\hss\vss\let\unhbox\unvbox
227        \csname bm@#3\endcsname}%
228     \if@pboxsw \m@th$\null\fi% !!!
229   \@end@tempboxa}
230 \def\underline#1{%
231   \relax
232   \ifmmode\@@underline{#1}%
233   \else \leavevmode\null$\@@underline{\hbox{#1}}\m@th$\null\relax\fi}
234
235 %%% AtBeginDvi
236 \def \AtBeginDvi #1{%
237   \global \setbox \@begindvibox
238     \vbox{\yoko\unvbox \@begindvibox #1}%
239 }
240
241 \newif\iffnfixbottom
242 \newif\ifltj@ftn@unvboxed
243 %%% @makecol
244 \gdef \@makecol {%
245    \ifvoid\footins
246      \ltj@ftn@unvboxedfalse
247      \setbox\@outputbox \box\@cclv
248    \else
249      \ltj@ftn@unvboxedtrue
250      \setbox\@outputbox \vbox {%
251        \boxmaxdepth \@maxdepth
252        \unvbox \@cclv
253        \iffnfixbottom\vskip\z@ \@plus.0001fil\fi
254        \vskip \skip\footins
255        \color@begingroup
256          \normalcolor
257          \footnoterule
258          \unvbox \footins
259        \color@endgroup
260        }%
261    \fi
262    \let\@elt\relax
263    \xdef\@freelist{\@freelist\@midlist}%
264    \global \let \@midlist \@empty
265    \@combinefloats
266    \ifvbox\@kludgeins
267      \@makespecialcolbox
268    \else
269      \setbox\@outputbox \vbox to\@colht {%
270        \@texttop
271        \dimen@ \dp\@outputbox
272        \unvbox \@outputbox
273        \ifnum\ltjgetparameter{direction}=4\else\vbox{\hskip\z@}\fi %%% LuaTeX-ja
274        \vskip -\dimen@
275        \ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi
276        }%
277    \fi
278    \global \maxdepth \@maxdepth
279 }
280 \let\ltj@orig@makecol=\@makecol
281
282 \patchcmd\@makespecialcolbox{\@textbottom}{\ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi}{}{}
283
284 \def\@gnewline #1{%
285   \ifvmode
286     \@nolnerr
287   \else
288     \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break \null
289     % \null は \break の効果が行頭禁則文字で打ち消されないために必要
290   \ignorespaces
291 \fi}
292
293 \def\@no@lnbk #1[#2]{%
294   \ifvmode
295     \@nolnerr
296   \else
297     \@tempskipa\lastskip
298     \unskip
299     \penalty #1\@getpen{#2}%
300     \hskip\z@\relax %% added (2017/05/03)
301     \ifdim\@tempskipa>\z@
302       \hskip\@tempskipa
303       \ignorespaces
304     \fi
305   \fi}
306
307 %%%%%% \@tabclassz
308 \def\ltj@sharp{\ltjfakeboxbdd\@sharp\unskip\ltjfakeboxbdd}
309 \def\@tabclassz{%
310   \ifcase\@lastchclass
311     \@acolampacol
312   \or
313     \@ampacol
314   \or
315   \or
316   \or
317     \@addamp
318   \or
319     \@acolampacol
320   \or
321     \@firstampfalse\@acol
322   \fi
323   \edef\@preamble{%
324     \@preamble{%
325       \ifcase\@chnum
326         \hfil\ignorespaces\ltj@sharp\hfil
327       \or
328         \hskip1sp\ignorespaces\ltj@sharp\hfil
329       \or
330         \hfil\hskip1sp\ignorespaces\ltj@sharp
331       \fi}}}
332
333
334 \endinput