2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2017/07/17 v1.2g-ltj-6 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\fork@parbox@option@@B#1{%
394 \def\@begin@parbox{\raise\cht\vtop\bgroup\kern\z@\vbox}%
395 \let\@end@parbox\egroup
397 \def\@begin@parbox{\lower\cdp\vbox\bgroup\vbox}%
398 \def\@end@parbox{\kern\z@\egroup}%
401 \let\@begin@parbox\vcenter\let\@end@parbox\relax
403 \def\@begin@parbox{\null$\vcenter}%
404 \def\@end@parbox{\m@th$\null}%
407 \let\fork@parbox@option@@C=\fork@parbox@option@@B
408 \def\fork@parbox@option<#1>[#2]{%
409 \let\box@dir\relax \ltj@ext@dir=\ltjgetparameter{direction}\relax
411 \ifnum\ltj@ext@dir=3\relax
415 \if #1y\relax \let\box@dir\yoko
416 \else\if #1t\relax\let\box@dir\tate
417 \else\if #1d\relax\let\box@dir\dtou
418 \else\if #1u\relax\let\box@dir\utod
423 \or \let\box@dir\dtou
424 \or\or\let\box@dir\tate
425 \or \let\box@dir\yoko
426 \else \let\box@dir\utod
429 \ifnum\ltj@ext@dir=4 % yoko
430 \ifx\box@dir\yoko \fork@parbox@option@@A{#2}%
431 \else \fork@parbox@option@@B{#2}%
433 \else\ifnum\ltj@ext@dir=1 % dtou
434 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
435 \else\ifx\box@dir\dtou \fork@parbox@option@@A{#2}%
436 \else \fork@parbox@option@@C{#2}%
438 \else\ifnum\ltj@ext@dir=3 % tate
439 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
440 \else\ifx\box@dir\tate \fork@parbox@option@@A{#2}%
441 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
442 \else \fork@parbox@option@@B{#2}% D
445 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
446 \else\ifx\box@dir\utod \fork@parbox@option@@A{#2}%
447 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
448 \else \fork@parbox@option@@B{#2}% D
453 \DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
454 \def\X@makePbox<#1>{%
455 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
456 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
457 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
458 \def\@iimakePbox<#1>#2[#3]#4{%
459 \bgroup\let\box@dir\relax
461 \ifnum\ltjgetparameter{direction}=3 \relax
465 \if #1y\relax \let\box@dir\yoko
466 \else\if #1t\relax\let\box@dir\tate
467 \else\if #1d\relax\let\box@dir\dtou
468 \else\if #1u\relax\let\box@dir\utod
472 \ifcase\ltjgetparameter{direction}
473 \or \let\box@dir\dtou
474 \or\or\let\box@dir\tate
475 \or \let\box@dir\yoko
476 \else \let\box@dir\utod
479 \setlength{\@tempdima}{#2}%
480 \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else
481 \hb@xt@\@tempdima{\box@dir
482 \if #3l\relax\else\hss\fi
484 \if #3r\relax\else\hss\fi}\fi\egroup}
487 \def\picture{\@ifnextchar<%>
488 {\X@picture}{\X@picture<Z>}}
489 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
490 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
492 \def\ltj@@pic@reset@blshift{%
493 \ltj@yablshift\z@\ltj@ykblshift\z@
494 \ltj@tablshift\z@\ltj@tkblshift\z@
496 \def\@@picture<#1>(#2,#3)(#4,#5){%
497 \edef\ltj@@pic@save@blshift{%
498 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
499 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
500 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
501 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
503 \bgroup\let\box@dir\relax
505 \ifnum\ltjgetparameter{direction}=3 \relax
509 \if #1y\relax \let\box@dir\yoko
510 \else\if #1t\relax\let\box@dir\tate
511 \else\if #1d\relax\let\box@dir\dtou
512 \else\if #1u\relax\let\box@dir\utod
516 \ifcase\ltjgetparameter{direction}
517 \or \let\box@dir\dtou
518 \or\or\let\box@dir\tate
519 \or \let\box@dir\yoko
520 \else \let\box@dir\utod
523 \@picwd=#2\unitlength \@picht=#3\unitlength
524 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
525 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
526 \ltj@@pic@reset@blshift
530 \setbox0=\hbox{\box@dir%
531 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
534 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
535 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
537 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
538 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
543 \egroup\ltj@@pic@save@blshift}
545 \def\put{\ltj@@pic@reset@blshift\org@put}
547 \def\line{\ltj@@pic@reset@blshift\org@line}
548 \let\org@vector\vector
549 \def\vector{\ltj@@pic@reset@blshift\org@vector}
550 \let\org@dashbox\dashbox
551 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
553 \def\oval{\ltj@@pic@reset@blshift\org@oval}
554 \let\org@circle\circle
555 \def\circle{\ltj@@pic@reset@blshift\org@circle}
558 \newif\ifnot@advanceline
560 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
561 \DeclareRobustCommand\rensuji{%
562 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
563 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
564 \def\@@rensuji[#1]#2{%
565 \ifvmode\leavevmode\fi
566 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
568 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
569 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
570 \ifnot@advanceline\not@advancelinefalse\else
571 \setbox\z@\hbox{\yoko#2}%
572 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
573 \ifnum\ltjgetparameter{direction}=1\relax
574 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
575 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
576 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
577 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
578 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
581 % 周囲が tate, utod の場合も同じ
582 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
583 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
584 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
585 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
589 \ifnum\ltjgetparameter{direction}=1\relax
590 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
591 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
592 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
595 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
596 \hbox to\@tempdimb{\yoko \hss#2\hss}%
597 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
598 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
599 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
600 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
606 \let\prensuji\rensuji
609 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
610 \def\@Kanji#1{\kansuji #1}
611 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
615 \def\boutenchar{\char\euc"A1A2}%"
616 \def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end}
618 \ifx#1\end \let\next=\relax
620 \ifnum\ltjgetparameter{direction}=3\relax
621 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
622 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
623 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
625 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
626 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
627 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
634 \ifnum\ltjgetparameter{direction}=3\relax
635 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
636 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
638 \else\underline{#1}\fi}
641 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
642 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
643 \else (\theequation)\fi}}
644 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
645 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
647 %% Compatibility with array package
649 \def\ltj@lltjext@patch@array{%
650 \patchcmd{\@tabular}{\hbox\bgroup}{%
651 \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{}{}
653 {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
654 \def\@startpbox##1{\bgroup
655 \box@dir\adjustbaseline%%% これを追加
656 \setlength\hsize{##1}\@arrayparboxrestore
658 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
661 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
662 \def\p@array<##1>[##2]##3{%
665 \ifnum\ltj@ext@dir=3\relax
666 \let\box@dir\utod\@tempcnta=\zstrutbox
670 \let\box@dir\yoko\@tempcnta=\ystrutbox
672 \let\box@dir\tate\@tempcnta=\tstrutbox
674 \let\box@dir\dtou\@tempcnta=\dstrutbox
676 \let\box@dir\utod\@tempcnta=\zstrutbox
681 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
682 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
683 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
684 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
687 \setbox \@arstrutbox \hbox{\box@dir\vrule
688 \@height \arraystretch
689 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
690 \@depth \arraystretch \ltjgetdp \@tempcnta
692 \fork@array@option<##1>[##2]%
695 \xdef\@preamble{\ialign \noexpand \@halignto
696 \bgroup \tabskip \z@skip \@arstrut \@preamble
700 \@begin@alignbox\bgroup\box@dir\adjustbaseline
702 \let\@sharp####\let\protect\relax
703 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
704 \lineskip\z@skip\baselineskip\z@skip\@preamble}
705 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
708 \@ifpackageloaded{array}{%
709 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
710 \let\tabular=\ltj@lltjext@orig@tabular
711 \let\array=\ltj@lltjext@orig@array
712 \ltj@lltjext@patch@array
714 \let\ltj@lltjext@orig@tabularS\relax
715 \let\ltj@lltjext@orig@tabular\relax
716 \let\ltj@lltjext@orig@array\relax
717 \RequirePackage{filehook,etoolbox}
718 \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
721 %%%%%%%%%%%%%%%% LuaTeX-ja original
723 \define@key[ltj]{japaram}{autouprightnum}{% %COUNT
724 \ltj@@set@stack{AURN}{0}{10000}\z@#1 }