2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2016/12/16 v1.2c-ltj-5 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\X@tabarray}
19 \def\tabular{\let\@halignto\@empty\X@tabular}
20 \@namedef{tabular*}{\@ifnextchar<%>
21 {\@stabular}{\@stabular<Z>}}
22 \def\X@tabarray{\@ifnextchar<%>
23 {\p@tabarray}{\p@tabarray<Z>}}
24 \def\X@tabular{\@ifnextchar<%>
25 {\p@tabular}{\p@tabular<Z>}}
26 \def\@stabular<#1>#2{%
27 \setlength\dimen@{#2}%
28 \edef\@halignto{to\the\dimen@}\p@tabular<#1>}
29 \def\p@tabular<#1>{\leavevmode \hbox \bgroup
30 \count@=\ltjgetparameter{direction}$\let\@acol\@tabacol
31 \let\@classz\@tabclassz
32 \let\@classiv\@tabclassiv \let\\\@tabularcr\p@tabarray<#1>}
33 \def\p@tabarray<#1>{\m@th\@ifnextchar[%]
34 {\p@array<#1>}{\p@array<#1>[c]}}
36 \def\p@array<#1>[#2]#3{%
40 \let\box@dir\utod\@tempcnta=\zstrutbox
44 \let\box@dir\yoko\@tempcnta=\ystrutbox
46 \let\box@dir\tate\@tempcnta=\tstrutbox
48 \let\box@dir\dtou\@tempcnta=\dstrutbox
50 \let\box@dir\utod\@tempcnta=\zstrutbox
55 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
56 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
57 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
58 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
61 \setbox\@arstrutbox\hbox{%
63 \vrule\@height\arraystretch\ltjgetht\@tempcnta
64 \@depth\arraystretch\ltjgetdp\@tempcnta \@width\z@}%
65 \fork@array@option<#1>[#2]%
66 \@mkpream{#3}\edef\@preamble{\ialign \noexpand\@halignto
67 \bgroup\@arstrut \@preamble \tabskip\z@skip \cr}%
68 \let\tabularnewline\\%
69 \@begin@alignbox\bgroup\box@dir\adjustbaseline
71 \let\@sharp##\let\protect\relax
72 \lineskip\z@skip\baselineskip\z@skip\@preamble}
73 \def\endarray{\crcr\egroup\egroup\@end@alignbox}
74 \def\endtabular{\endarray$\egroup}
75 \expandafter \let \csname endtabular*\endcsname = \endtabular
76 \def\fork@array@option<#1>[#2]{%
77 \ifnum\ltjgetparameter{direction}=4 % yoko
80 \let\@begin@alignbox\vtop
81 \let\@end@alignbox\relax
83 \let\@begin@alignbox\vbox
84 \let\@end@alignbox\relax
86 \let\@begin@alignbox\vcenter
87 \let\@end@alignbox\relax
91 \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}%
92 \def\@end@alignbox{\egroup}%
94 \let\@begin@alignbox\vbox
95 \let\@end@alignbox\relax
97 \let\@begin@alignbox\vcenter
98 \let\@end@alignbox\relax
101 \else\ifnum\ltjgetparameter{direction}=1 % dtou
104 \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}%
105 \def\@end@alignbox{\egroup}%
107 \let\@begin@alignbox\vbox
108 \let\@end@alignbox\relax
110 \let\@begin@alignbox\vcenter
111 \let\@end@alignbox\relax
113 \else\ifx\box@dir\dtou
115 \let\@begin@alignbox\vtop
116 \let\@end@alignbox\relax
118 \let\@begin@alignbox\vbox
119 \let\@end@alignbox\relax
121 \let\@begin@alignbox\vcenter
122 \let\@end@alignbox\relax
124 \else % 180 度回転→vtop, vbox を入れ替える
126 \let\@begin@alignbox\vbox %%% !!!
127 \let\@end@alignbox\relax
129 \let\@begin@alignbox\vtop %%% !!!
130 \let\@end@alignbox\relax
132 \let\@begin@alignbox\vcenter
133 \let\@end@alignbox\relax
139 \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}%
140 \def\@end@alignbox{\egroup}%
142 \def\@begin@alignbox{\vbox\bgroup\vbox}%
143 \def\@end@alignbox{\kern\z@\egroup}%
145 \let\@begin@alignbox\vcenter
146 \let\@end@alignbox\relax
148 \else\ifx\box@dir\dtou % 180 度回転→vtop, vbox を入れ替える
150 \let\@begin@alignbox\vbox %%% !!!
151 \let\@end@alignbox\relax
153 \let\@begin@alignbox\vtop %%% !!!
154 \let\@end@alignbox\relax
156 \let\@begin@alignbox\vcenter
157 \let\@end@alignbox\relax
161 \let\@begin@alignbox\vtop
162 \let\@end@alignbox\relax
164 \let\@begin@alignbox\vbox
165 \let\@end@alignbox\relax
167 \let\@begin@alignbox\vcenter
168 \let\@end@alignbox\relax
177 \newdimen\floatheight
178 \newdimen\floatruletick \floatruletick=0.4pt
179 \newdimen\captionfloatsep \captionfloatsep=10pt
181 \let\captiondir\relax
182 \newdimen\captionwidth \captionwidth\z@
186 \def\captionfontsetup{\normalfont\normalsize}
187 \def\layoutfloat{\@ifnextchar(%)
188 {\X@layoutfloat}{\X@layoutfloat(-5\p@,-5\p@)}}
189 \def\X@layoutfloat(#1,#2){\@ifnextchar[%]
190 {\@layoutfloat(#1,#2)}{\@layoutfloat(#1,#2)[c]}}
191 \long\def\@layoutfloat(#1,#2)[#3]#4{%
193 \floatwidth=#1 \floatheight=#2 \edef\float@pos{#3}%
194 \ifdim\floatwidth<\z@
195 \floatwidth\ltjgetwd\z@\floatruletick\z@
197 \ifdim\floatheight<\z@
198 \floatheight\ltjgetht\z@\advance\floatheight\ltjgetdp\z@\relax
201 \setbox\@floatbox\vbox to\floatheight{\offinterlineskip
202 \hrule width\floatwidth height\floatruletick depth\z@
203 \vss\hbox to\floatwidth{%
204 \vrule width\floatruletick height\floatheight depth\z@
205 \hss\vbox to\floatheight{\hsize\floatwidth\vss#4\vss}\hss
206 \vrule width\floatruletick height\floatheight depth\z@
207 }\hrule width\floatwidth height\floatruletick depth\z@}}
208 \def\DeclareLayoutCaption#1<#2>(#3)[#4#5]{%
210 \ifx\csname #1@layoutcaption\endcsname\relax \else
211 \@latex@info{Redeclaring capiton layout setting of '#1'}%
214 \gdef\csname #1@layoutcaption\endcsname{%
215 \if Z\caption@dir\def\caption@dir{#2}\fi
216 \ifdim\captionwidth=\z@ \captionwidth=#3\relax\fi
217 \if Z\caption@posa\def\caption@posa{#4}\fi
218 \if Z\caption@posb\def\caption@posb{#5}\fi}}
219 \@onlypreamble\DeclareLayoutCaption
220 \DeclareLayoutCaption{figure}<y>(.8\linewidth)[cd]
221 \DeclareLayoutCaption{table}<y>(.8\linewidth)[cu]
222 \def\layoutcaption{\def\caption@dir{Z}\captionwidth\z@
223 \def\caption@posa{Z}\def\caption@posb{Z}%
224 \@ifnextchar<\X@layoutcaption{%
225 \@ifnextchar(\@ilayoutcaption{%
226 \@ifnextchar[\@iilayoutcaption\relax}}}
227 \def\X@layoutcaption<#1>{\def\caption@dir{#1}%
228 \@ifnextchar(\@ilayoutcaption{%
229 \@ifnextchar[\@iilayoutcaption\relax}}
230 \def\@ilayoutcaption(#1){\setlength\captionwidth{#1}%
231 \@ifnextchar[{\@iilayoutcaption}{\relax}}
232 \def\@iilayoutcaption[#1#2]{%
233 \def\caption@posa{#1}\def\caption@posb{#2}}
234 \def\pcaption{\refstepcounter\@captype \@dblarg{\@pcaption\@captype}}
235 \long\def\@pcaption#1[#2]#3{%
236 \addcontentsline{\csname ext@#1\endcsname}{#1}{%
237 \protect\numberline{\csname the#1\endcsname}{\ignorespaces#2}}%
239 \latex@error{Use with `\protect\layoutfloat'.}\@eha
241 \make@pcaptionbox{#3}%
243 \setbox\@tempboxa\vbox{\hbox to\hsize{\if l\float@pos\else\hss\fi
244 \if l\caption@posb\box\@captionbox\kern\captionfloatsep\fi
245 \if t\caption@posa\vtop
246 \else\if b\caption@posa\vbox
247 \else\ifmmode\vcenter \else\@pboxswtrue $\vcenter \fi\fi\fi
248 {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi
250 \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}%
251 \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi
252 \if@pboxsw \m@th$\fi \if r\float@pos\else\hss\fi}}%
253 \par\vskip.25\baselineskip
255 \def\make@pcaptionbox#1{%
257 \ifx\csname\@captype @layoutcaption\endcsname\relax
258 \@latex@warning{Default caption layout of `\@captype' unknown.}%
259 \def\caption@dir{Z}\captionwidth\z@
260 \def\caption@posa{Z}\def\caption@posb{Z}%
262 \csname \@captype @layoutcaption\endcsname
265 % tempswa\hline 基本組の組方向とキャプションの組方向が直交するか?
266 \if y\caption@dir \let\captiondir\yoko
267 \ifodd\ltjgetparameter{direction}\relax\@tempswatrue\fi
268 \else\if z\caption@dir \let\captiondir\relax
269 \ifnum\ltjgetparameter{direction}=3\relax\let\captiondir\utod\fi
270 \else\if d\caption@dir \let\captiondir\dtou
271 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
272 \else\if u\caption@dir \let\captiondir\utod
273 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
274 \else\if t\caption@dir \let\captiondir\tate
275 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
277 \setbox0\hbox{\hbox{\captiondir
278 \captionfontsetup\parindent\z@\inhibitglue
279 \csname fnum@\@captype\endcsname #1}}%"
280 \if@tempswa\@tempdima\ltjgetht0\relax\else\@tempdima\ltjgetwd0\relax\fi
281 \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi
284 \if u\caption@posb\vbox
285 \else\if d\caption@posb\vbox
286 \else\if t\caption@posa\vtop
287 \else\if b\caption@posa\vbox
288 \else\ifmmode\vcenter\else\@pboxswtrue $\vcenter\fi
290 {\hsize\@tempdima\kern\z@
291 \vbox{\captiondir\hsize\@tempdima
292 \captionfontsetup\parindent\z@\inhibitglue
293 \csname fnum@\@captype\endcsname #1}\kern\z@
294 }\if@pboxsw \m@th$\fi}%
295 \let\to@captionboxwidth\relax
296 \if l\caption@posb \else\if r\caption@posb\else
297 \def\to@captionboxwidth{to\floatwidth}\fi\fi
298 \setbox\@captionbox\hbox\to@captionboxwidth{%
299 \if t\caption@posa\else\hss\fi
301 \if b\caption@posa\else\hss\fi}}
303 %%% minipage and parbox
304 \def\minipage{\@ifnextchar<%>
305 {\X@minipage}{\X@minipage<Z>}}
306 \def\X@minipage<#1>{\@ifnextchar[%]
307 {\@iminipage<#1>}{\@iiiminipage<#1>{c}\relax[s]}}
308 \def\@iminipage<#1>[#2]{\@ifnextchar[%]
309 {\@iiminipage<#1>{#2}}{\@iiiminipage<#1>{#2}\relax[s]}}
310 \def\@iiminipage<#1>#2[#3]{\@ifnextchar[%]
311 {\@iiiminipage<#1>{#2}{#3}}{\@iiiminipage<#1>{#2}{#3}[#2]}}
312 \def\@iiiminipage<#1>#2#3[#4]#5{%
314 \setlength\@tempdima{#5}%
315 \def\@mpargs{<#1>{#2}{#3}[#4]{#5}}%
318 \ifnum\ltjgetparameter{direction}=3\relax
322 \if #1y\relax \let\box@dir\yoko
323 \else\if #1t\relax\let\box@dir\tate
324 \else\if #1d\relax\let\box@dir\dtou
325 \else\if #1u\relax\let\box@dir\utod
329 \ifcase\ltjgetparameter{direction}\relax
330 \or \let\box@dir\dtou
331 \or\or\let\box@dir\tate
332 \or \let\box@dir\yoko
333 \else \let\box@dir\utod
336 \setbox\@tempboxa\vbox\bgroup\box@dir
340 \textwidth\hsize \columnwidth\hsize
342 \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}%
344 \let\@footnotetext\@mpfootnotetext
345 \let\@listdepth\@mplistdepth \@mplistdepth\z@
351 \ifvoid\@mpfootins\else
352 \vskip\skip\@mpfootins
357 \@minipagefalse %% added 24 May 89
360 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup}
361 \DeclareRobustCommand\parbox{\@ifnextchar<%>
362 {\X@parbox}{\X@parbox<Z>}}
363 \def\X@parbox<#1>{\@ifnextchar[%]
364 {\@iparbox<#1>}{\@iiiparbox<#1>{c}\relax[s]}}
365 \def\@iparbox<#1>[#2]{\@ifnextchar[%]
366 {\@iiparbox<#1>{#2}}{\@iiiparbox<#1>{#2}\relax[s]}}
367 \def\@iiparbox<#1>#2[#3]{\@ifnextchar[%]%
368 {\@iiiparbox<#1>{#2}{#3}}{\@iiiparbox<#1>{#2}{#3}[#2]}}
369 \long\def\@iiiparbox<#1>#2#3[#4]#5#6{%
371 \setlength\@tempdima{#5}%
372 \fork@parbox@option<#1>[#2]%
373 \@begin@tempboxa\vbox{\box@dir
374 \hsize\@tempdima\@parboxrestore\adjustbaseline#6\@@par}%
376 \setlength\@tempdimb{#3}%
377 \edef\@parboxto{to\the\@tempdimb}%
379 \@begin@parbox\@parboxto{\box@dir\adjustbaseline
380 \let\hss\vss\let\unhbox\unvbox
381 \csname bm@#4\endcsname}\@end@parbox
383 \def\fork@parbox@option<#1>[#2]{%
386 \ifnum\ltjgetparameter{direction}=3\relax
390 \if #1y\relax \let\box@dir\yoko
391 \else\if #1t\relax\let\box@dir\tate
392 \else\if #1d\relax\let\box@dir\dtou
393 \else\if #1u\relax\let\box@dir\utod
397 \ifcase\ltjgetparameter{direction}\relax
398 \or \let\box@dir\dtou
399 \or\or\let\box@dir\tate
400 \or \let\box@dir\yoko
401 \else \let\box@dir\utod
404 %%% now almost same as \fork@array@option
405 \ifnum\ltjgetparameter{direction}=4 % yoko
408 \let\@begin@parbox\vtop
409 \let\@end@parbox\relax
411 \let\@begin@parbox\vbox
412 \let\@end@parbox\relax
415 \let\@begin@parbox\vcenter\let\@end@parbox\relax
417 \def\@begin@parbox{\null$\vcenter}%
418 \def\@end@parbox{\m@th$\null}%
423 \def\@begin@parbox{\vtop\bgroup\kern\z@\vbox}%
424 \def\@end@parbox{\egroup}%
426 \let\@begin@parbox\vbox
427 \let\@end@parbox\relax
430 \let\@begin@parbox\vcenter\let\@end@parbox\relax
432 \def\@begin@parbox{\null$\vcenter}%
433 \def\@end@parbox{\m@th$\null}%
437 \else\ifnum\ltjgetparameter{direction}=1 % dtou
440 \def\@begin@parbox{\vtop\bgroup\kern\z@\vbox}
441 \def\@end@parbox{\egroup}
443 \let\@begin@parbox\vbox
444 \let\@end@parbox\relax
447 \let\@begin@parbox\vcenter\let\@end@parbox\relax
449 \def\@begin@parbox{\null$\vcenter}%
450 \def\@end@parbox{\m@th$\null}%
453 \else\ifx\box@dir\dtou
455 \let\@begin@parbox\vtop
456 \let\@end@parbox\relax
458 \let\@begin@parbox\vbox
459 \let\@end@parbox\relax
462 \let\@begin@parbox\vcenter\let\@end@parbox\relax
464 \def\@begin@parbox{\null$\vcenter}%
465 \def\@end@parbox{\m@th$\null}%
468 \else % 180 度回転→vtop, vbox を入れ替える
470 \let\@begin@parbox\vbox %%% !!!
471 \let\@end@parbox\relax
473 \let\@begin@parbox\vtop %%% !!!
474 \let\@end@parbox\relax
477 \let\@begin@parbox\vcenter\let\@end@parbox\relax
479 \def\@begin@parbox{\null$\vcenter}%
480 \def\@end@parbox{\m@th$\null}%
487 \def\@begin@parbox{\vtop\bgroup\kern\z@\vbox}%
488 \def\@end@parbox{\egroup}%
490 \def\@begin@parbox{\vbox\bgroup\vbox}%
491 \def\@end@parbox{\kern\z@\egroup}%
494 \let\@begin@parbox\vcenter\let\@end@parbox\relax
496 \def\@begin@parbox{\null$\vcenter}%
497 \def\@end@parbox{\m@th$\null}%
500 \else\ifx\box@dir\dtou % 180 度回転→vtop, vbox を入れ替える
502 \let\@begin@parbox\vbox %%% !!!
503 \let\@end@parbox\relax
505 \let\@begin@parbox\vtop %%% !!!
506 \let\@end@parbox\relax
509 \let\@begin@parbox\vcenter\let\@end@parbox\relax
511 \def\@begin@parbox{\null$\vcenter}%
512 \def\@end@parbox{\m@th$\null}%
517 \let\@begin@parbox\vtop
518 \let\@end@parbox\relax
520 \let\@begin@parbox\vbox
521 \let\@end@parbox\relax
524 \let\@begin@parbox\vcenter\let\@end@parbox\relax
526 \def\@begin@parbox{\null$\vcenter}%
527 \def\@end@parbox{\m@th$\null}%
535 \def\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
536 \def\X@makePbox<#1>{%
537 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
538 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
539 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
540 \def\@iimakePbox<#1>#2[#3]#4{%
541 \bgroup\let\box@dir\relax
543 \ifnum\ltjgetparameter{direction}=3 \relax
547 \if #1y\relax \let\box@dir\yoko
548 \else\if #1t\relax\let\box@dir\tate
549 \else\if #1d\relax\let\box@dir\dtou
550 \else\if #1u\relax\let\box@dir\utod
554 \ifcase\ltjgetparameter{direction}
555 \or \let\box@dir\dtou
556 \or\or\let\box@dir\tate
557 \or \let\box@dir\yoko
558 \else \let\box@dir\utod
561 \ifdim #2 <\z@ \hbox{\box@dir#4}\else
563 \if #3l\relax\else\hss\fi
565 \if #3r\relax\else\hss\fi}\fi\egroup}
568 \def\picture{\@ifnextchar<%>
569 {\X@picture}{\X@picture<Z>}}
570 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
571 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
573 \def\ltj@@pic@reset@blshift{%
574 \ltj@yablshift\z@\ltj@ykblshift\z@
575 \ltj@tablshift\z@\ltj@tkblshift\z@
577 \def\@@picture<#1>(#2,#3)(#4,#5){%
578 \edef\ltj@@pic@save@blshift{%
579 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
580 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
581 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
582 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
584 \bgroup\let\box@dir\relax
586 \ifnum\ltjgetparameter{direction}=3 \relax
590 \if #1y\relax \let\box@dir\yoko
591 \else\if #1t\relax\let\box@dir\tate
592 \else\if #1d\relax\let\box@dir\dtou
593 \else\if #1u\relax\let\box@dir\utod
597 \ifcase\ltjgetparameter{direction}
598 \or \let\box@dir\dtou
599 \or\or\let\box@dir\tate
600 \or \let\box@dir\yoko
601 \else \let\box@dir\utod
604 \@picwd=#2\unitlength \@picht=#3\unitlength
605 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
606 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
607 \ltj@@pic@reset@blshift
611 \setbox0=\hbox{\box@dir%
612 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
615 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
616 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
618 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
619 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
624 \egroup\ltj@@pic@save@blshift}
626 \def\put{\ltj@@pic@reset@blshift\org@put}
628 \def\line{\ltj@@pic@reset@blshift\org@line}
629 \let\org@vector\vector
630 \def\vector{\ltj@@pic@reset@blshift\org@vector}
631 \let\org@dashbox\dashbox
632 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
634 \def\oval{\ltj@@pic@reset@blshift\org@oval}
635 \let\org@circle\circle
636 \def\circle{\ltj@@pic@reset@blshift\org@circle}
639 \newif\ifnot@advanceline
641 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
642 \DeclareRobustCommand\rensuji{%
643 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
644 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
645 \def\@@rensuji[#1]#2{%
646 \ifvmode\leavevmode\fi
647 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
649 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
650 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
651 \ifnot@advanceline\not@advancelinefalse\else
652 \setbox\z@\hbox{\yoko#2}%
653 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
654 \ifnum\ltjgetparameter{direction}=1\relax
655 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
656 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
657 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
658 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
659 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
662 % 周囲が tate, utod の場合も同じ
663 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
664 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
665 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
666 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
670 \ifnum\ltjgetparameter{direction}=1\relax
671 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
672 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
673 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
676 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
677 \hbox to\@tempdimb{\yoko \hss#2\hss}%
678 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
679 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
680 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
681 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
687 \let\prensuji\rensuji
690 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
691 \def\@Kanji#1{\kansuji #1}
692 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
696 \def\boutenchar{\char\euc"A1A2}%"
697 \def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end}
699 \ifx#1\end \let\next=\relax
701 \ifnum\ltjgetparameter{direction}=3\relax
702 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
703 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
704 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
706 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
707 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
708 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
715 \ifnum\ltjgetparameter{direction}=3\relax
716 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
717 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
719 \else\underline{#1}\fi}
722 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
723 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
724 \else (\theequation)\fi}}
725 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
726 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
728 %% Compatibility with array package
730 \def\ltj@lltjext@patch@array{%
731 \patchcmd{\@tabular}{\hbox\bgroup}{%
732 \hbox\bgroup\count@=\ltjgetparameter{direction}}{}{}
733 \def\@startpbox##1{\bgroup
734 \box@dir\adjustbaseline%%% これを追加
735 \hsize=##1\@arrayparboxrestore
737 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
740 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<Z>}}
741 \def\p@array<##1>[##2]##3{%
744 \ifnum\count@=3\relax
745 \let\box@dir\utod\@tempcnta=\zstrutbox
749 \let\box@dir\yoko\@tempcnta=\ystrutbox
751 \let\box@dir\tate\@tempcnta=\tstrutbox
753 \let\box@dir\dtou\@tempcnta=\dstrutbox
755 \let\box@dir\utod\@tempcnta=\zstrutbox
760 \or \let\box@dir\dtou\@tempcnta=\tabskip \z@\tabskip \z@\dstrutbox% dtou
761 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
762 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
763 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
766 \setbox \@arstrutbox \hbox{\box@dir\vrule
767 \@height \arraystretch
768 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
769 \@depth \arraystretch \ltjgetdp \@tempcnta
771 \fork@array@option<##1>[##2]%
774 \xdef\@preamble{\ialign \noexpand \@halignto
775 \bgroup \tabskip \z@skip \@arstrut \@preamble
779 \@begin@alignbox\bgroup\box@dir\adjustbaseline
781 \let\@sharp####\let\protect\relax
782 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
783 \lineskip\z@skip\baselineskip\z@skip\@preamble}
784 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
787 \@ifpackageloaded{array}{%
788 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
789 \let\tabular=\ltj@lltjext@orig@tabular
790 \let\array=\ltj@lltjext@orig@array
791 \ltj@lltjext@patch@array
793 \let\ltj@lltjext@orig@tabularS\relax
794 \let\ltj@lltjext@orig@tabular\relax
795 \let\ltj@lltjext@orig@array\relax
796 \RequirePackage{filehook,etoolbox}
797 \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
800 %%%%%%%%%%%%%%%% LuaTeX-ja original
802 \define@key[ltj]{japaram}{autouprightnum}{% %COUNT
803 \ltj@@set@stack{AURN}{0}{10000}\z@#1 }