OSDN Git Service

tabbing
[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/03/25 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 width13mm 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 height13mm 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 width13mm height\@tombowwidth depth\z@\hss}%
53   \setbox\@Tr\hbox to\z@{\yoko
54       \vrule height13mm width\@tombowwidth depth\z@
55       \vrule width10mm height\@tombowwidth depth\z@\hss}%
56   \setbox\@BL\hbox to\z@{\yoko\hss
57       \vrule width13mm 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 depth13mm 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 width13mm depth\@tombowwidth height\z@\hss}%
69   \setbox\@Br\hbox to\z@{\yoko
70       \vrule depth13mm 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-13mm\relax
82     \boxmaxdepth\maxdimen
83     \moveleft3mm\vbox to\@@paperheight{%
84       \hbox to\@@paperwidth{\hskip3mm\relax
85          \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip3mm}%
86       \kern-10mm
87       \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
88       \vfill
89       \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
90       \vfill
91       \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
92       \kern-10mm
93       \hbox to\@@paperwidth{\hskip3mm\relax
94          \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip3mm}%
95     }\vss
96   }%
97   \fi
98 }
99 \newdimen\@@paperheight
100 \newdimen\@@paperwidth
101 \newdimen\@@topmargin
102 \def\@outputpage{%
103 \begingroup % the \endgroup is put in by \aftergroup
104   \ifnum\ltjgetparameter{direction}=4\else
105     \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
106   \fi
107   \let \protect \noexpand
108   \language\document@default@language %LaTeX2e 2017/05/01
109   \@resetactivechars
110   \global\let\@@if@newlist\if@newlist
111   \global\@newlistfalse
112   \@parboxrestore
113   \shipout\vbox{\yoko
114     \set@typeset@protect
115     \aftergroup\endgroup
116     \aftergroup\set@typeset@protect
117      \if@specialpage
118        \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
119      \fi
120      \if@twoside
121        \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
122           \ifnum\ltjgetparameter{direction}=3 \let\@themargin\evensidemargin
123           \else\let\@themargin\oddsidemargin\fi
124        \else \let\@thehead\@evenhead
125           \let\@thefoot\@evenfoot
126            \ifnum\ltjgetparameter{direction}=3 \let\@themargin\oddsidemargin
127            \else\let\@themargin\evensidemargin\fi
128      \fi\fi
129      \@@topmargin\topmargin
130      \iftombow
131        \@@paperwidth\paperwidth \advance\@@paperwidth 6mm\relax
132        \@@paperheight\paperheight \advance\@@paperheight 16mm\relax
133        \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
134      \fi
135      \reset@font
136      \normalsize
137      \normalsfcodes
138      \let\label\@gobble
139      \let\index\@gobble
140      \let\glossary\@gobble
141      \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
142     \@begindvi
143     \@outputtombow
144     \vskip \@@topmargin
145     \moveright\@themargin\vbox{%
146       \setbox\@tempboxa \vbox to\headheight{%
147         \vfil
148         \color@hbox
149           \normalcolor
150           \hb@xt@\textwidth{\@thehead}%
151         \color@endbox
152       }%                        %% 22 Feb 87
153       \dp\@tempboxa \z@
154       \box\@tempboxa
155       \vskip \headsep
156       \box\@outputbox
157       \baselineskip \footskip
158       \color@hbox
159         \normalcolor
160         \hb@xt@\textwidth{\@thefoot}%
161       \color@endbox
162     }%
163   }%
164   \global\let\if@newlist\@@if@newlist
165   \global \@colht \textheight
166   \stepcounter{page}%
167   \let\firstmark\botmark
168 }
169
170 %%% Remove extra xkanjiskip
171 \renewcommand\@makefnmark{%
172   \unless\ifnum\ltjgetparameter{direction}=3
173     \hbox{}\hbox{\@textsuperscript{\normalfont\@thefnmark}}\hbox{}%
174   \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}
175 \begingroup
176 \@ifpackageloaded{hyperref}
177   {\def\ltj@setrefprefix{real}}
178   {\def\ltj@setrefprefix{}}
179 \expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
180   \ifx#1\relax
181     \protect\G@refundefinedtrue
182     \nfss@text{\reset@font\bfseries ??}%
183     \@latex@warning{Reference `#3' on page \thepage \space
184               undefined}%
185   \else
186     \expandafter#2#1\protect\@setref@{}% change \null to \protect\@setref@{}
187   \fi}
188 \gdef\@setref@{\ifhmode\spacefactor\@m\fi}
189 \endgroup
190 \if@compatibility\else
191 \def\verb{\relax\ifmmode\hbox\else\leavevmode\vadjust{}\fi
192   \bgroup
193     \verb@eol@error \let\do\@makeother \dospecials
194     \verbatim@font\@noligs
195     \language\l@nohyphenation
196     \@ifstar\@sverb\@verb}
197 \fi
198 \gdef\@stopfield{%
199   \inhibitglue\@tempskipa\lastskip\unskip
200   \hskip\@tempskipa\color@endgroup\egroup}
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 \let\@parboxto\@empty
208 \long\def\@iiiparbox#1#2[#3]#4#5{%
209   \leavevmode
210   \@pboxswfalse
211   \setlength\@tempdima{#4}%
212   \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
213     \ifx\relax#2\else
214       \setlength\@tempdimb{#2}%
215       \edef\@parboxto{to\the\@tempdimb}%
216     \fi
217     \if#1b\vbox
218     \else\if #1t\vtop
219     \else\ifmmode\vcenter
220     \else\@pboxswtrue\null$\vcenter% !!!
221     \fi\fi\fi
222     \@parboxto{\let\hss\vss\let\unhbox\unvbox
223        \csname bm@#3\endcsname}%
224     \if@pboxsw \m@th$\null\fi% !!!
225   \@end@tempboxa}
226 \def\underline#1{%
227   \relax
228   \ifmmode\@@underline{#1}%
229   \else \leavevmode\null$\@@underline{\hbox{#1}}\m@th$\null\relax\fi}
230
231 %%% AtBeginDvi
232 \def \AtBeginDvi #1{%
233   \global \setbox \@begindvibox
234     \vbox{\yoko\unvbox \@begindvibox #1}%
235 }
236
237 \newif\iffnfixbottom
238 \newif\ifltj@ftn@unvboxed
239 %%% @makecol
240 \gdef \@makecol {%
241    \ifvoid\footins
242      \ltj@ftn@unvboxedfalse
243      \setbox\@outputbox \box\@cclv
244    \else
245      \ltj@ftn@unvboxedtrue
246      \setbox\@outputbox \vbox {%
247        \boxmaxdepth \@maxdepth
248        \unvbox \@cclv
249        \iffnfixbottom\vskip\z@ \@plus.0001fil\fi
250        \vskip \skip\footins
251        \color@begingroup
252          \normalcolor
253          \footnoterule
254          \unvbox \footins
255        \color@endgroup
256        }%
257    \fi
258    \let\@elt\relax
259    \xdef\@freelist{\@freelist\@midlist}%
260    \global \let \@midlist \@empty
261    \@combinefloats
262    \ifvbox\@kludgeins
263      \@makespecialcolbox
264    \else
265      \setbox\@outputbox \vbox to\@colht {%
266        \@texttop
267        \dimen@ \dp\@outputbox
268        \unvbox \@outputbox
269        \ifnum\ltjgetparameter{direction}=4\else\vbox{\hskip\z@}\fi %%% LuaTeX-ja
270        \vskip -\dimen@
271        \ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi
272        }%
273    \fi
274    \global \maxdepth \@maxdepth
275 }
276 \let\ltj@orig@makecol=\@makecol
277
278 \patchcmd\@makespecialcolbox{\@textbottom}{\ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi}{}{}
279
280 \def\@gnewline #1{%
281   \ifvmode
282     \@nolnerr
283   \else
284     \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break \null
285     % \null は \break の効果が行頭禁則文字で打ち消されないために必要
286   \ignorespaces
287 \fi}
288
289
290 %%%%%% tabular (platex/#43) \@tabclassz
291 \def\ltj@sharp{\relax\pltx@next@inhibitglue\ltjfakeboxbdd\ignorespaces\@sharp\unskip\ltjfakeboxbdd}
292 \def\@tabclassz{%
293   \ifcase\@lastchclass
294     \@acolampacol
295   \or
296     \@ampacol
297   \or
298   \or
299   \or
300     \@addamp
301   \or
302     \@acolampacol
303   \or
304     \@firstampfalse\@acol
305   \fi
306   \edef\@preamble{%
307     \@preamble{%
308       \ifcase\@chnum
309         \hfil\ltj@sharp\hfil
310       \or
311         \hskip1sp\ltj@sharp\hfil
312       \or
313         \hfil\hskip1sp\ltj@sharp
314       \fi}}}
315 \patchcmd\@classv{%
316    \ignorespaces\@sharp
317 }{%
318    \everypar\expandafter{\the\everypar\ltjfakeboxbdd}\ignorespaces\@sharp\unskip
319 }{}{}
320 \patchcmd{\@tabular}{\leavevmode}{\leavevmode\null}{}{}
321 \apptocmd{\endtabular}{\null}{}{}
322 \expandafter \let \csname endtabular*\endcsname = \endtabular
323
324 %%%%%% tabbing (platex/#53)
325 \patchcmd\@startline{\strut}{\strut\inhibitglue}{}{}
326 \def\ltj@unhbox@curfield{\ltjfakeboxbdd\unhbox\@curfield\ltjfakeboxbdd}
327 %\patchcmd\@contfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}
328 \patchcmd\@addfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}
329 \endinput