OSDN Git Service

luatexja-fontspec-*.sty: forgot to update \setmonojfont
[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}[2018/06/15 Patch to LaTeX2e Kernel for LuaTeX-ja]
7 \RequirePackage{etoolbox}
8
9 \def\cleardoublepage{\clearpage\if@twoside
10   \ifodd\c@page
11     \ifnum\ltjgetparameter{direction}=3
12       \hbox{}\thispagestyle{empty}\newpage
13       \if@twocolumn\hbox{}\newpage\fi
14     \fi
15   \else
16     \ifnum\ltjgetparameter{direction}=4
17       \hbox{}\thispagestyle{empty}\newpage
18       \if@twocolumn\hbox{}\newpage\fi
19     \fi
20   \fi\fi}
21 \newif\iftombow \tombowfalse
22 \newif\iftombowdate \tombowdatetrue
23 \newdimen\@tombowwidth
24 \setlength{\@tombowwidth}{.1\p@}
25 \newbox\@TL\newbox\@Tl
26 \newbox\@TC
27 \newbox\@TR\newbox\@Tr
28 \newbox\@BL\newbox\@Bl
29 \newbox\@BC
30 \newbox\@BR\newbox\@Br
31 \newbox\@CL
32 \newbox\@CR
33 \font\@bannerfont=cmtt9
34 \newtoks\@bannertoken
35 \@bannertoken{}
36 \def\maketombowbox{%
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@
40       \iftombowdate
41         \raise4pt\hbox to\z@{\hskip5mm\@bannerfont\the\@bannertoken\hss}%
42       \fi}%
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}%
78 }
79 \def\@outputtombow{%
80   \iftombow
81   \vbox to\z@{\kern-\dimexpr 10mm+\@tombowbleed\relax
82     \boxmaxdepth\maxdimen
83       \moveleft\@tombowbleed\vbox to\@@paperheight{%
84           \color@begingroup
85           \@tombowcolor
86       \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
87          \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip\@tombowbleed}%
88       \kern-10mm
89       \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
90       \vfill
91       \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
92       \vfill
93       \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
94       \kern-10mm
95       \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
96          \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip\@tombowbleed}%
97         \color@endgroup
98     }\vss
99   }%
100   \fi
101 }
102 \def\@tombowcolor{\normalcolor}
103 \def\@tombowbleed{3mm}
104 \def\@tombowreset@@paper{%
105      \@@topmargin\topmargin
106      \iftombow
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
112      \fi
113 }
114 \newdimen\@@paperheight
115 \newdimen\@@paperwidth
116 \newdimen\@@topmargin
117 \def\@outputpage{%
118 \begingroup % the \endgroup is put in by \aftergroup
119   \ifnum\ltjgetparameter{direction}=4\else
120     \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
121   \fi
122   \let \protect \noexpand
123   \language\document@default@language %LaTeX2e 2017/05/01
124   \@resetactivechars
125   \global\let\@@if@newlist\if@newlist
126   \global\@newlistfalse
127   \@parboxrestore
128   \shipout\vbox{\yoko
129     \set@typeset@protect
130     \aftergroup\endgroup
131     \aftergroup\set@typeset@protect
132      \if@specialpage
133        \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
134      \fi
135      \if@twoside
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
143      \fi\fi
144      \@tombowreset@@paper
145      \reset@font
146      \normalsize
147      \normalsfcodes
148      \let\label\@gobble
149      \let\index\@gobble
150      \let\glossary\@gobble
151      \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
152     \@begindvi
153     \@outputtombow
154     \vskip \@@topmargin
155     \moveright\@themargin\vbox{%
156       \setbox\@tempboxa \vbox to\headheight{%
157         \vfil
158         \color@hbox
159           \normalcolor
160           \hb@xt@\textwidth{\@thehead}%
161         \color@endbox
162       }%                        %% 22 Feb 87
163       \dp\@tempboxa \z@
164       \box\@tempboxa
165       \vskip \headsep
166       \box\@outputbox
167       \baselineskip \footskip
168       \color@hbox
169         \normalcolor
170         \hb@xt@\textwidth{\@thefoot}%
171       \color@endbox
172     }%
173   }%
174   \global\let\if@newlist\@@if@newlist
175   \global \@colht \textheight
176   \stepcounter{page}%
177   \let\firstmark\botmark
178 }
179
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}
185 \begingroup
186 \@ifpackageloaded{hyperref}
187   {\def\ltj@setrefprefix{real}}
188   {\def\ltj@setrefprefix{}}
189 \expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
190   \ifx#1\relax
191     \protect\G@refundefinedtrue
192     \nfss@text{\reset@font\bfseries ??}%
193     \@latex@warning{Reference `#3' on page \thepage \space
194               undefined}%
195   \else
196     \expandafter#2#1\protect\@setref@{}% change \null to \protect\@setref@{}
197   \fi}
198 \gdef\@setref@{\ifhmode\spacefactor\@m\fi}
199 \endgroup
200 \if@compatibility\else
201 \def\verb{\relax\ifmmode\hbox\else\leavevmode\vadjust{}\fi
202   \bgroup
203     \verb@eol@error \let\do\@makeother \dospecials
204     \verbatim@font\@noligs
205     \language\l@nohyphenation
206     \@ifstar\@sverb\@verb}
207 \fi
208 \gdef\@stopfield{%
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%
216 }{}{}
217 \let\@parboxto\@empty
218 \long\def\@iiiparbox#1#2[#3]#4#5{%
219   \leavevmode
220   \@pboxswfalse
221   \setlength\@tempdima{#4}%
222   \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
223     \ifx\relax#2\else
224       \setlength\@tempdimb{#2}%
225       \edef\@parboxto{to\the\@tempdimb}%
226     \fi
227     \if#1b\vbox
228     \else\if #1t\vtop
229     \else\ifmmode\vcenter
230     \else\@pboxswtrue\null$\vcenter% !!!
231     \fi\fi\fi
232     \@parboxto{\let\hss\vss\let\unhbox\unvbox
233        \csname bm@#3\endcsname}%
234     \if@pboxsw \m@th$\null\fi% !!!
235   \@end@tempboxa}
236 \def\underline#1{%
237   \relax
238   \ifmmode\@@underline{#1}%
239   \else \leavevmode\null$\@@underline{\hbox{#1}}\m@th$\null\relax\fi}
240
241 %%% AtBeginDvi
242 \def \AtBeginDvi #1{%
243   \global \setbox \@begindvibox
244     \vbox{\yoko\unvbox \@begindvibox #1}%
245 }
246
247 \newif\iffnfixbottom
248 \newif\ifltj@ftn@unvboxed
249 %%% @makecol
250 \gdef \@makecol {%
251    \ifvoid\footins
252      \ltj@ftn@unvboxedfalse
253      \setbox\@outputbox \box\@cclv
254    \else
255      \ltj@ftn@unvboxedtrue
256      \setbox\@outputbox \vbox {%
257        \boxmaxdepth \@maxdepth
258        \unvbox \@cclv
259        \iffnfixbottom\vskip\z@ \@plus.0001fil\fi
260        \vskip \skip\footins
261        \color@begingroup
262          \normalcolor
263          \footnoterule
264          \unvbox \footins
265        \color@endgroup
266        }%
267    \fi
268    \let\@elt\relax
269    \xdef\@freelist{\@freelist\@midlist}%
270    \global \let \@midlist \@empty
271    \@combinefloats
272    \ifvbox\@kludgeins
273      \@makespecialcolbox
274    \else
275      \setbox\@outputbox \vbox to\@colht {%
276        \@texttop
277        \dimen@ \dp\@outputbox
278        \unvbox \@outputbox
279        \ifnum\ltjgetparameter{direction}=4\else\vbox{\hskip\z@}\fi %%% LuaTeX-ja
280        \vskip -\dimen@
281        \ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi
282        }%
283    \fi
284    \global \maxdepth \@maxdepth
285 }
286 \let\ltj@orig@makecol=\@makecol
287
288 \patchcmd\@makespecialcolbox{\@textbottom}{\ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi}{}{}
289
290 \def\@gnewline #1{%
291   \ifvmode
292     \@nolnerr
293   \else
294     \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break \null
295     % \null は \break の効果が行頭禁則文字で打ち消されないために必要
296   \ignorespaces
297 \fi}
298
299
300 %%%%%% tabular (platex/#43) \@tabclassz
301 \def\ltj@sharp{\relax\pltx@next@inhibitglue\ltjfakeboxbdd\ignorespaces\@sharp\unskip\ltjfakeboxbdd}
302 \def\@tabclassz{%
303   \ifcase\@lastchclass
304     \@acolampacol
305   \or
306     \@ampacol
307   \or
308   \or
309   \or
310     \@addamp
311   \or
312     \@acolampacol
313   \or
314     \@firstampfalse\@acol
315   \fi
316   \edef\@preamble{%
317     \@preamble{%
318       \ifcase\@chnum
319         \hfil\hskip1sp\ltj@sharp\hfil
320       \or
321         \hskip1sp\ltj@sharp\hfil
322       \or
323         \hfil\hskip1sp\ltj@sharp
324       \fi}}}
325 \patchcmd\@classv{%
326    \ignorespaces\@sharp
327 }{%
328    \everypar\expandafter{\the\everypar\ltjfakeboxbdd}\ignorespaces\@sharp\unskip
329 }{}{}
330 \patchcmd{\@tabular}{\leavevmode}{\leavevmode\null}{}{}
331 \apptocmd{\endtabular}{\null}{}{}
332 \expandafter \let \csname endtabular*\endcsname = \endtabular
333
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}{}{}
339 \endinput