2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2017/08/27 v1.2g-ltj-8 Macros for vertical writing]
7 \RequirePackage{luatexja}
10 \global\let\ltj@lltjext@orig@tabularS=\tabular*
12 \let\ltj@lltjext@orig@tabular=\tabular
13 \let\ltj@lltjext@orig@array=\array
16 \def\array{\let\@acol\@arrayacol \let\@classz\@arrayclassz
17 \let\@classiv\@arrayclassiv
18 \let\\\@arraycr\let\@halignto\@empty
19 \ltj@ext@dir=\ltjgetparameter{direction}\relax\X@tabarray}
20 \def\tabular{\let\@halignto\@empty\X@tabular}
21 \@namedef{tabular*}{\@ifnextchar<%>
22 {\@stabular}{\@stabular<Z>}}
23 \def\X@tabarray{\@ifnextchar<%>
24 {\p@tabarray}{\p@tabarray<Z>}}
25 \def\X@tabular{\@ifnextchar<%>
26 {\p@tabular}{\p@tabular<Z>}}
27 \def\@stabular<#1>#2{%
28 \setlength\dimen@{#2}%
29 \edef\@halignto{to\the\dimen@}\p@tabular<#1>}
30 \def\p@tabular<#1>{\leavevmode \hbox \bgroup
31 \ltj@ext@dir=\ltjgetparameter{direction}$\let\@acol\@tabacol
32 \let\@classz\@tabclassz
33 \let\@classiv\@tabclassiv \let\\\@tabularcr\p@tabarray<#1>}
34 \def\p@tabarray<#1>{\m@th\@ifnextchar[%]
35 {\p@array<#1>}{\p@array<#1>[c]}}
37 \def\p@array<#1>[#2]#3{%
40 \ifnum\ltj@ext@dir=3\relax
41 \let\box@dir\utod\@tempcnta=\zstrutbox
45 \let\box@dir\yoko\@tempcnta=\ystrutbox
47 \let\box@dir\tate\@tempcnta=\tstrutbox
49 \let\box@dir\dtou\@tempcnta=\dstrutbox
51 \let\box@dir\utod\@tempcnta=\zstrutbox
56 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
57 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
58 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
59 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
62 \setbox\@arstrutbox\hbox{%
64 \vrule\@height\arraystretch\ltjgetht\@tempcnta
65 \@depth\arraystretch\ltjgetdp\@tempcnta \@width\z@}%
66 \fork@array@option<#1>[#2]%
67 \@mkpream{#3}\edef\@preamble{\ialign \noexpand\@halignto
68 \bgroup\@arstrut \@preamble \tabskip\z@skip \cr}%
69 \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
70 \let\tabularnewline\\%
71 \@begin@alignbox\bgroup\box@dir\adjustbaseline
73 \let\@sharp##\let\protect\relax
74 \lineskip\z@skip\baselineskip\z@skip\@preamble}
75 \def\endarray{\crcr\egroup\egroup\@end@alignbox}
76 \def\endtabular{\endarray$\egroup}
77 \expandafter \let \csname endtabular*\endcsname = \endtabular
78 % ↓中身\周囲→ yoko tate utod dtou
83 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
84 % B: 周囲と中身が90度ずれ.上端/下端がベースラインに揃うように
85 % C: 周囲と中身が180度ずれ.\vtop, \vbox 入れ替え
86 % D: 欧文ベースライン同士を揃えるようにする
88 \def\fork@array@option@@A#1{%
89 \let\@end@alignbox\relax
90 \if #1t\relax \let\@begin@alignbox\vtop
91 \else\if #1b\relax\let\@begin@alignbox\vbox
92 \else \let\@begin@alignbox\vcenter
94 \def\fork@array@option@@B#1{%
96 \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}%
97 \let\@end@alignbox\egroup
99 \def\@begin@alignbox{\vbox\bgroup\vbox}%
100 \def\@end@alignbox{\kern\z@\egroup}%
102 \let\@begin@alignbox\vcenter
103 \let\@end@alignbox\relax
105 \def\fork@array@option@@C#1{%
106 \let\@end@alignbox\relax
107 \if #1t\relax \let\@begin@alignbox\vbox
108 \else\if #1b\relax\let\@begin@alignbox\vtop
109 \else \let\@begin@alignbox\vcenter
111 \def\fork@array@option<#1>[#2]{%
112 \ifnum\ltj@ext@dir=4 % yoko
113 \ifx\box@dir\yoko \fork@array@option@@A{#2}%
114 \else \fork@array@option@@B{#2}%
116 \else\ifnum\ltj@ext@dir=1 % dtou
117 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
118 \else\ifx\box@dir\dtou \fork@array@option@@A{#2}%
119 \else \fork@array@option@@C{#2}%
121 \else\ifnum\ltj@ext@dir=3 % tate
122 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
123 \else\ifx\box@dir\tate \fork@array@option@@A{#2}%
124 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
127 \def\@begin@alignbox{\lower\dimexpr
128 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vtop}
129 \let\@end@alignbox\relax
131 \def\@begin@alignbox{\lower\dimexpr
132 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vbox}
133 \let\@end@alignbox\relax
135 \let\@begin@alignbox\vcenter
136 \let\@end@alignbox\relax
140 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
141 \else\ifx\box@dir\utod \fork@array@option@@A{#2}%
142 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
145 \def\@begin@alignbox{\lower\dimexpr
146 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vtop}
147 \let\@end@alignbox\relax
149 \def\@begin@alignbox{\lower\dimexpr
150 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vbox}
151 \let\@end@alignbox\relax
153 \let\@begin@alignbox\vcenter
154 \let\@end@alignbox\relax
162 \newdimen\floatheight
163 \newdimen\floatruletick \floatruletick=0.4pt
164 \newdimen\captionfloatsep \captionfloatsep=10pt
166 \let\captiondir\relax
167 \newdimen\captionwidth \captionwidth\z@
171 \def\captionfontsetup{\normalfont\normalsize}
172 \def\layoutfloat{\@ifnextchar(%)
173 {\X@layoutfloat}{\X@layoutfloat(-5\p@,-5\p@)}}
174 \def\X@layoutfloat(#1,#2){\@ifnextchar[%]
175 {\@layoutfloat(#1,#2)}{\@layoutfloat(#1,#2)[c]}}
176 \long\def\@layoutfloat(#1,#2)[#3]#4{%
178 \floatwidth=#1 \floatheight=#2 \edef\float@pos{#3}%
179 \ifdim\floatwidth<\z@
180 \floatwidth\ltjgetwd\z@\floatruletick\z@
182 \ifdim\floatheight<\z@
183 \floatheight\ltjgetht\z@\advance\floatheight\ltjgetdp\z@\relax
186 \setbox\@floatbox\vbox to\floatheight{\offinterlineskip
187 \hrule width\floatwidth height\floatruletick depth\z@
188 \vss\hbox to\floatwidth{%
189 \vrule width\floatruletick height\floatheight depth\z@
190 \hss\vbox to\floatheight{\hsize\floatwidth\vss#4\vss}\hss
191 \vrule width\floatruletick height\floatheight depth\z@
192 }\hrule width\floatwidth height\floatruletick depth\z@}}
193 \def\DeclareLayoutCaption#1<#2>(#3)[#4#5]{%
195 \ifx\csname #1@layoutcaption\endcsname\relax \else
196 \@latex@info{Redeclaring capiton layout setting of '#1'}%
199 \gdef\csname #1@layoutcaption\endcsname{%
200 \if Z\caption@dir\def\caption@dir{#2}\fi
201 \ifdim\captionwidth=\z@ \captionwidth=#3\relax\fi
202 \if Z\caption@posa\def\caption@posa{#4}\fi
203 \if Z\caption@posb\def\caption@posb{#5}\fi}}
204 \@onlypreamble\DeclareLayoutCaption
205 \DeclareLayoutCaption{figure}<y>(.8\linewidth)[cd]
206 \DeclareLayoutCaption{table}<y>(.8\linewidth)[cu]
207 \def\layoutcaption{\def\caption@dir{Z}\captionwidth\z@
208 \def\caption@posa{Z}\def\caption@posb{Z}%
209 \@ifnextchar<\X@layoutcaption{%
210 \@ifnextchar(\@ilayoutcaption{%
211 \@ifnextchar[\@iilayoutcaption\relax}}}
212 \def\X@layoutcaption<#1>{\def\caption@dir{#1}%
213 \@ifnextchar(\@ilayoutcaption{%
214 \@ifnextchar[\@iilayoutcaption\relax}}
215 \def\@ilayoutcaption(#1){\setlength\captionwidth{#1}%
216 \@ifnextchar[{\@iilayoutcaption}{\relax}}
217 \def\@iilayoutcaption[#1#2]{%
218 \def\caption@posa{#1}\def\caption@posb{#2}}
219 \def\pcaption{\refstepcounter\@captype \@dblarg{\@pcaption\@captype}}
220 \long\def\@pcaption#1[#2]#3{%
221 \addcontentsline{\csname ext@#1\endcsname}{#1}{%
222 \protect\numberline{\csname the#1\endcsname}{\ignorespaces#2}}%
224 \latex@error{Use with `\protect\layoutfloat'.}\@eha
226 \make@pcaptionbox{#3}%
228 \setbox\@tempboxa\vbox{\hbox to\hsize{\if l\float@pos\else\hss\fi
229 \if l\caption@posb\box\@captionbox\kern\captionfloatsep\fi
230 \if t\caption@posa\vtop
231 \else\if b\caption@posa\vbox
232 \else\ifmmode\vcenter \else\@pboxswtrue $\vcenter \fi\fi\fi
233 {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi
235 \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}%
236 \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi
237 \if@pboxsw \m@th$\fi \if r\float@pos\else\hss\fi}}%
238 \par\vskip.25\baselineskip
240 \def\make@pcaptionbox#1{%
242 \ifx\csname\@captype @layoutcaption\endcsname\relax
243 \@latex@warning{Default caption layout of `\@captype' unknown.}%
244 \def\caption@dir{Z}\captionwidth\z@
245 \def\caption@posa{Z}\def\caption@posb{Z}%
247 \csname \@captype @layoutcaption\endcsname
250 % \@tempswa: 基本組の組方向とキャプションの組方向が直交するか?
251 \if y\caption@dir \let\captiondir\yoko
252 \ifodd\ltjgetparameter{direction}\relax\@tempswatrue\fi
253 \else\if z\caption@dir \let\captiondir\relax
254 \ifnum\ltjgetparameter{direction}=3\relax\let\captiondir\utod\fi
255 \else\if d\caption@dir \let\captiondir\dtou
256 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
257 \else\if u\caption@dir \let\captiondir\utod
258 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
259 \else\if t\caption@dir \let\captiondir\tate
260 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
262 \setbox0\hbox{\hbox{\captiondir
263 \captionfontsetup\parindent\z@\inhibitglue
264 \csname fnum@\@captype\endcsname #1}}%"
265 \if@tempswa\@tempdima\ltjgetht0\relax\else\@tempdima\ltjgetwd0\relax\fi
266 \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi
269 \if u\caption@posb\vbox
270 \else\if d\caption@posb\vbox
271 \else\if t\caption@posa\vtop
272 \else\if b\caption@posa\vbox
273 \else\ifmmode\vcenter\else\@pboxswtrue $\vcenter\fi
275 {\hsize\@tempdima\kern\z@
276 \vbox{\captiondir\hsize\@tempdima
277 \captionfontsetup\parindent\z@\inhibitglue
278 \csname fnum@\@captype\endcsname #1}\kern\z@
279 }\if@pboxsw \m@th$\fi}%
280 \let\to@captionboxwidth\relax
281 \if l\caption@posb \else\if r\caption@posb\else
282 \def\to@captionboxwidth{to\floatwidth}\fi\fi
283 \setbox\@captionbox\hbox\to@captionboxwidth{%
284 \if t\caption@posa\else\hss\fi
286 \if b\caption@posa\else\hss\fi}}
288 %%% minipage and parbox
289 \def\minipage{\@ifnextchar<%>
290 {\X@minipage}{\X@minipage<Z>}}
291 \def\X@minipage<#1>{\@ifnextchar[%]
292 {\@iminipage<#1>}{\@iiiminipage<#1>{c}\relax[s]}}
293 \def\@iminipage<#1>[#2]{\@ifnextchar[%]
294 {\@iiminipage<#1>{#2}}{\@iiiminipage<#1>{#2}\relax[s]}}
295 \def\@iiminipage<#1>#2[#3]{\@ifnextchar[%]
296 {\@iiiminipage<#1>{#2}{#3}}{\@iiiminipage<#1>{#2}{#3}[#2]}}
297 \def\@iiiminipage<#1>#2#3[#4]#5{%
299 \setlength\@tempdima{#5}%
300 \def\@mpargs{<#1>{#2}{#3}[#4]{#5}}%
303 \ifnum\ltjgetparameter{direction}=3\relax
307 \if #1y\relax \let\box@dir\yoko
308 \else\if #1t\relax\let\box@dir\tate
309 \else\if #1d\relax\let\box@dir\dtou
310 \else\if #1u\relax\let\box@dir\utod
314 \ifcase\ltjgetparameter{direction}\relax
315 \or \let\box@dir\dtou
316 \or\or\let\box@dir\tate
317 \or \let\box@dir\yoko
318 \else \let\box@dir\utod
321 \setbox\@tempboxa\vbox\bgroup\box@dir
325 \textwidth\hsize \columnwidth\hsize
327 \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}%
329 \let\@footnotetext\@mpfootnotetext
330 \let\@listdepth\@mplistdepth \@mplistdepth\z@
336 \ifvoid\@mpfootins\else
337 \vskip\skip\@mpfootins
342 \@minipagefalse %% added 24 May 89
345 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup}
346 \DeclareRobustCommand\parbox{\@ifnextchar<%>
347 {\X@parbox}{\X@parbox<Z>}}
348 \def\X@parbox<#1>{\@ifnextchar[%]
349 {\@iparbox<#1>}{\@iiiparbox<#1>{c}\relax[s]}}
350 \def\@iparbox<#1>[#2]{\@ifnextchar[%]
351 {\@iiparbox<#1>{#2}}{\@iiiparbox<#1>{#2}\relax[s]}}
352 \def\@iiparbox<#1>#2[#3]{\@ifnextchar[%]%
353 {\@iiiparbox<#1>{#2}{#3}}{\@iiiparbox<#1>{#2}{#3}[#2]}}
354 \long\def\@iiiparbox<#1>#2#3[#4]#5#6{%
356 \setlength\@tempdima{#5}%
357 \fork@parbox@option<#1>[#2]%
358 \@begin@tempboxa\vbox{\box@dir
359 \hsize\@tempdima\@parboxrestore\adjustbaseline#6\@@par}%
361 \setlength\@tempdimb{#3}%
362 \edef\@parboxto{to\the\@tempdimb}%
364 \@begin@parbox\@parboxto{\box@dir\adjustbaseline
365 \let\hss\vss\let\unhbox\unvbox
366 \csname bm@#4\endcsname}\@end@parbox
370 % ↓中身\周囲→ yoko tate utod dtou
375 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
376 % B: 周囲と中身が90度ずれ.上端が和文の高さ or 下端が和文の深さに揃うように
377 % C: 周囲と中身が180度ずれ.(コードは B のものを流用)
378 % D: 上端が和文の高さ or 下端が和文の深さに揃うように(コードは B のものを流用)
380 \def\fork@parbox@option@@A#1{%
381 \let\@end@parbox\relax
382 \if #1t\relax \let\@begin@parbox\vtop
383 \else\if #1b\relax\let\@begin@parbox\vbox
386 \let\@begin@parbox\vcenter\let\@end@parbox\relax
388 \def\@begin@parbox{\null$\vcenter}%
389 \def\@end@parbox{\m@th$\null}%
392 \def\lltjext@getjablshift{%
393 \ifnum\ltj@ext@dir=3 \ltjgetparameter{tjabaselineshift}\else
394 \ltjgetparameter{yjabaselineshift}\fi}
395 \def\fork@parbox@option@@B#1{%
397 \def\@begin@parbox{\raise\dimexpr\cht-\lltjext@getjablshift\vtop\bgroup\kern\z@\vbox}%
398 \let\@end@parbox\egroup
400 \def\@begin@parbox{\lower\dimexpr\cdp+\lltjext@getjablshift\vbox\bgroup\vbox}%
401 \def\@end@parbox{\kern\z@\egroup}%
404 \let\@begin@parbox\vcenter\let\@end@parbox\relax
406 \def\@begin@parbox{\null$\vcenter}%
407 \def\@end@parbox{\m@th$\null}%
410 \let\fork@parbox@option@@C=\fork@parbox@option@@B
411 \def\fork@parbox@option<#1>[#2]{%
412 \let\box@dir\relax \ltj@ext@dir=\ltjgetparameter{direction}\relax
414 \ifnum\ltj@ext@dir=3\relax
418 \if #1y\relax \let\box@dir\yoko
419 \else\if #1t\relax\let\box@dir\tate
420 \else\if #1d\relax\let\box@dir\dtou
421 \else\if #1u\relax\let\box@dir\utod
426 \or \let\box@dir\dtou
427 \or\or\let\box@dir\tate
428 \or \let\box@dir\yoko
429 \else \let\box@dir\utod
432 \ifnum\ltj@ext@dir=4 % yoko
433 \ifx\box@dir\yoko \fork@parbox@option@@A{#2}%
434 \else \fork@parbox@option@@B{#2}%
436 \else\ifnum\ltj@ext@dir=1 % dtou
437 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
438 \else\ifx\box@dir\dtou \fork@parbox@option@@A{#2}%
439 \else \fork@parbox@option@@C{#2}%
441 \else\ifnum\ltj@ext@dir=3 % tate
442 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
443 \else\ifx\box@dir\tate \fork@parbox@option@@A{#2}%
444 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
445 \else \fork@parbox@option@@B{#2}% D
448 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
449 \else\ifx\box@dir\utod \fork@parbox@option@@A{#2}%
450 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
451 \else \fork@parbox@option@@B{#2}% D
456 \DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
457 \def\X@makePbox<#1>{%
458 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
459 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
460 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
461 \def\@iimakePbox<#1>#2[#3]#4{%
462 \bgroup\let\box@dir\relax
464 \ifnum\ltjgetparameter{direction}=3 \relax
468 \if #1y\relax \let\box@dir\yoko
469 \else\if #1t\relax\let\box@dir\tate
470 \else\if #1d\relax\let\box@dir\dtou
471 \else\if #1u\relax\let\box@dir\utod
475 \ifcase\ltjgetparameter{direction}
476 \or \let\box@dir\dtou
477 \or\or\let\box@dir\tate
478 \or \let\box@dir\yoko
479 \else \let\box@dir\utod
482 \setlength{\@tempdima}{#2}%
483 \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else
484 \hb@xt@\@tempdima{\box@dir
485 \if #3l\relax\else\hss\fi
487 \if #3r\relax\else\hss\fi}\fi\egroup}
490 \def\picture{\@ifnextchar<%>
491 {\X@picture}{\X@picture<Z>}}
492 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
493 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
495 \def\ltj@@pic@reset@blshift{%
496 \ltj@yablshift\z@\ltj@ykblshift\z@
497 \ltj@tablshift\z@\ltj@tkblshift\z@
499 \def\@@picture<#1>(#2,#3)(#4,#5){%
500 \edef\ltj@@pic@save@blshift{%
501 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
502 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
503 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
504 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
506 \bgroup\let\box@dir\relax
508 \ifnum\ltjgetparameter{direction}=3 \relax
512 \if #1y\relax \let\box@dir\yoko
513 \else\if #1t\relax\let\box@dir\tate
514 \else\if #1d\relax\let\box@dir\dtou
515 \else\if #1u\relax\let\box@dir\utod
519 \ifcase\ltjgetparameter{direction}
520 \or \let\box@dir\dtou
521 \or\or\let\box@dir\tate
522 \or \let\box@dir\yoko
523 \else \let\box@dir\utod
526 \@picwd=#2\unitlength \@picht=#3\unitlength
527 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
528 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
529 \ltj@@pic@reset@blshift
533 \setbox0=\hbox{\box@dir%
534 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
537 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
538 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
540 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
541 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
546 \egroup\ltj@@pic@save@blshift}
548 \def\put{\ltj@@pic@reset@blshift\org@put}
550 \def\line{\ltj@@pic@reset@blshift\org@line}
551 \let\org@vector\vector
552 \def\vector{\ltj@@pic@reset@blshift\org@vector}
553 \let\org@dashbox\dashbox
554 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
556 \def\oval{\ltj@@pic@reset@blshift\org@oval}
557 \let\org@circle\circle
558 \def\circle{\ltj@@pic@reset@blshift\org@circle}
561 \newif\ifnot@advanceline
563 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
564 \DeclareRobustCommand\rensuji{%
565 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
566 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
567 \def\@@rensuji[#1]#2{%
568 \ifvmode\leavevmode\fi
569 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
571 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
572 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
573 \ifnot@advanceline\not@advancelinefalse\else
574 \setbox\z@\hbox{\yoko#2}%
575 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
576 \ifnum\ltjgetparameter{direction}=1\relax
577 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
578 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
579 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
580 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
581 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
584 % 周囲が tate, utod の場合も同じ
585 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
586 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
587 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
588 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
592 \ifnum\ltjgetparameter{direction}=1\relax
593 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
594 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
595 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
598 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
599 \hbox to\@tempdimb{\yoko \hss#2\hss}%
600 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
601 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
602 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
603 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
609 \let\prensuji\rensuji
612 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
613 \def\@Kanji#1{\kansuji #1}
614 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
618 \def\boutenchar{\char\euc"A1A2}%"
619 \def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end}
621 \ifx#1\end \let\ltj@@next=\relax
623 \ifnum\ltjgetparameter{direction}=3\relax
624 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
625 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
626 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
628 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
629 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
630 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
637 \ifnum\ltjgetparameter{direction}=3\relax
638 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
639 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
641 \else\underline{#1}\fi}
644 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
645 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
646 \else (\theequation)\fi}}
647 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
648 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
650 %% Compatibility with array package
652 \def\ltj@lltjext@patch@array{%
653 \patchcmd{\@tabular}{\hbox\bgroup}{%
654 \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{}{}
656 {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
657 \def\@startpbox##1{\bgroup
658 \box@dir\adjustbaseline%%% これを追加
659 \setlength\hsize{##1}\@arrayparboxrestore
661 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
664 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
665 \def\p@array<##1>[##2]##3{%
668 \ifnum\ltj@ext@dir=3\relax
669 \let\box@dir\utod\@tempcnta=\zstrutbox
673 \let\box@dir\yoko\@tempcnta=\ystrutbox
675 \let\box@dir\tate\@tempcnta=\tstrutbox
677 \let\box@dir\dtou\@tempcnta=\dstrutbox
679 \let\box@dir\utod\@tempcnta=\zstrutbox
684 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
685 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
686 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
687 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
690 \setbox \@arstrutbox \hbox{\box@dir\vrule
691 \@height \arraystretch
692 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
693 \@depth \arraystretch \ltjgetdp \@tempcnta
695 \fork@array@option<##1>[##2]%
698 \xdef\@preamble{\ialign \noexpand \@halignto
699 \bgroup \tabskip \z@skip \@arstrut \@preamble
703 \@begin@alignbox\bgroup\box@dir\adjustbaseline
705 \let\@sharp####\let\protect\relax
706 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
707 \lineskip\z@skip\baselineskip\z@skip\@preamble}
708 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
711 \@ifpackageloaded{array}{%
712 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
713 \let\tabular=\ltj@lltjext@orig@tabular
714 \let\array=\ltj@lltjext@orig@array
715 \ltj@lltjext@patch@array
717 \let\ltj@lltjext@orig@tabularS\relax
718 \let\ltj@lltjext@orig@tabular\relax
719 \let\ltj@lltjext@orig@array\relax
720 \RequirePackage{filehook,etoolbox}
721 \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
724 %%%%%%%%%%%%%%%% LuaTeX-ja original
726 %%\define@key[ltj]{japaram}{autouprightnum}{% %COUNT
727 %% \ltj@@set@stack{AURN}{0}{10000}\z@#1 }