2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2019/09/25 v1.2k-ltj-11 Macros for vertical writing]
7 \RequirePackage{luatexja}
9 \let\ltj@lltjext@orig@tabular=\tabular
10 \let\ltj@lltjext@orig@array=\array
13 \def\array{\let\@acol\@arrayacol \let\@classz\@arrayclassz
14 \let\@classiv\@arrayclassiv
15 \let\\\@arraycr\let\@halignto\@empty
16 \ltj@ext@dir=\ltjgetparameter{direction}\relax\X@tabarray}
17 \def\tabular{\let\@halignto\@empty\X@tabular}
18 \@namedef{tabular*}{\@ifnextchar<%>
19 {\p@stabular}{\p@stabular<Z>}}
21 \global\let\ltj@lltjext@orig@tabularS=\tabular*
23 \def\X@tabarray{\@ifnextchar<%>
24 {\p@tabarray}{\p@tabarray<Z>}}
25 \def\X@tabular{\@ifnextchar<%>
26 {\p@tabular}{\p@tabular<Z>}}
27 \def\p@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}
33 \let\@classz\@tabclassz
34 \let\@classiv\@tabclassiv \let\\\@tabularcr\p@tabarray<#1>}
35 \def\p@tabarray<#1>{\m@th\@ifnextchar[%]
36 {\p@array<#1>}{\p@array<#1>[c]}}
38 \def\p@array<#1>[#2]#3{%
41 \ifnum\ltj@ext@dir=3\relax
42 \let\box@dir\utod\@tempcnta=\zstrutbox
46 \let\box@dir\yoko\@tempcnta=\ystrutbox
48 \let\box@dir\tate\@tempcnta=\tstrutbox
50 \let\box@dir\dtou\@tempcnta=\dstrutbox
52 \let\box@dir\utod\@tempcnta=\zstrutbox
57 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
58 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
59 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
60 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
63 \fork@array@option<#1>[#2]\@begin@alignbox
64 \bgroup\box@dir\adjustbaseline
65 \setbox\@arstrutbox\hbox{%
67 \vrule\@height\arraystretch\ltjgetht\@tempcnta
68 \@depth\arraystretch\ltjgetdp\@tempcnta \@width\z@}%
69 \@mkpream{#3}\edef\@preamble{\ialign \noexpand\@halignto
70 \bgroup\@arstrut \@preamble \tabskip\z@skip \cr}%
71 \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
72 \let\tabularnewline\\%
76 \lineskip\z@skip\baselineskip\z@skip
77 \ifhmode \@preamerr\z@ \@@par\fi
79 \def\endarray{\crcr\egroup\egroup\@end@alignbox}
80 \def\endtabular{\endarray$\egroup}
81 \expandafter \let \csname endtabular*\endcsname = \endtabular
82 % ↓中身\周囲→ yoko tate utod dtou
87 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
88 % B: 周囲と中身が90度ずれ.上端/下端がベースラインに揃うように
89 % C: 周囲と中身が180度ずれ.\vtop, \vbox 入れ替え
90 % D: 欧文ベースライン同士を揃えるようにする
92 \def\fork@array@option@@A#1{%
93 \let\@end@alignbox\relax
94 \if #1t\relax \let\@begin@alignbox\vtop
95 \else\if #1b\relax\let\@begin@alignbox\vbox
96 \else \let\@begin@alignbox\vcenter
98 \def\fork@array@option@@B#1{%
100 \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}%
101 \let\@end@alignbox\egroup
103 \def\@begin@alignbox{\vbox\bgroup\vbox}%
104 \def\@end@alignbox{\kern\z@\egroup}%
106 \let\@begin@alignbox\vcenter
107 \let\@end@alignbox\relax
109 \def\fork@array@option@@C#1{%
110 \let\@end@alignbox\relax
111 \if #1t\relax \let\@begin@alignbox\vbox
112 \else\if #1b\relax\let\@begin@alignbox\vtop
113 \else \let\@begin@alignbox\vcenter
115 \def\fork@array@option<#1>[#2]{%
116 \ifnum\ltj@ext@dir=4 % yoko
117 \ifx\box@dir\yoko \fork@array@option@@A{#2}%
118 \else \fork@array@option@@B{#2}%
120 \else\ifnum\ltj@ext@dir=1 % dtou
121 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
122 \else\ifx\box@dir\dtou \fork@array@option@@A{#2}%
123 \else \fork@array@option@@C{#2}%
125 \else\ifnum\ltj@ext@dir=3 % tate
126 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
127 \else\ifx\box@dir\tate \fork@array@option@@A{#2}%
128 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
131 \def\@begin@alignbox{\lower\dimexpr
132 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vtop}
133 \let\@end@alignbox\relax
135 \def\@begin@alignbox{\lower\dimexpr
136 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vbox}
137 \let\@end@alignbox\relax
139 \let\@begin@alignbox\vcenter
140 \let\@end@alignbox\relax
144 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
145 \else\ifx\box@dir\utod \fork@array@option@@A{#2}%
146 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
149 \def\@begin@alignbox{\lower\dimexpr
150 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vtop}
151 \let\@end@alignbox\relax
153 \def\@begin@alignbox{\lower\dimexpr
154 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vbox}
155 \let\@end@alignbox\relax
157 \let\@begin@alignbox\vcenter
158 \let\@end@alignbox\relax
166 \newdimen\floatheight
167 \newdimen\floatruletick \floatruletick=0.4pt
168 \newdimen\captionfloatsep \captionfloatsep=10pt
170 \let\captiondir\relax
171 \newdimen\captionwidth \captionwidth\z@
175 \def\captionfontsetup{\normalfont\normalsize}
176 \def\layoutfloat{\@ifnextchar(%)
177 {\X@layoutfloat}{\X@layoutfloat(-5\p@,-5\p@)}}
178 \def\X@layoutfloat(#1,#2){\@ifnextchar[%]
179 {\@layoutfloat(#1,#2)}{\@layoutfloat(#1,#2)[c]}}
180 \long\def\@layoutfloat(#1,#2)[#3]#4{%
182 \floatwidth=#1 \floatheight=#2 \edef\float@pos{#3}%
183 \ifdim\floatwidth<\z@
184 \floatwidth\ltjgetwd\z@\floatruletick\z@
186 \ifdim\floatheight<\z@
187 \floatheight\ltjgetht\z@\advance\floatheight\ltjgetdp\z@\relax
190 \setbox\@floatbox\vbox to\floatheight{\offinterlineskip
191 \hrule width\floatwidth height\floatruletick depth\z@
192 \vss\hbox to\floatwidth{%
193 \vrule width\floatruletick height\floatheight depth\z@
194 \hss\vbox to\floatheight{\hsize\floatwidth\vss#4\vss}\hss
195 \vrule width\floatruletick height\floatheight depth\z@
196 }\hrule width\floatwidth height\floatruletick depth\z@}}
197 \def\DeclareLayoutCaption#1<#2>(#3)[#4#5]{%
199 \ifx\csname #1@layoutc@ption\endcsname\relax \else
200 \@latex@info{Redeclaring capiton layout setting of '#1'}%
203 \gdef\csname #1@layoutc@ption\endcsname{%
204 \if Z\caption@dir\def\caption@dir{#2}\fi
205 \ifdim\captionwidth=\z@ \captionwidth=#3\relax\fi
206 \if Z\caption@posa\def\caption@posa{#4}\fi
207 \if Z\caption@posb\def\caption@posb{#5}\fi}}
208 \@onlypreamble\DeclareLayoutCaption
209 \DeclareLayoutCaption{figure}<n>(.8\linewidth)[cd]
210 \DeclareLayoutCaption{table}<n>(.8\linewidth)[cu]
211 \def\layoutcaption{\def\caption@dir{Z}\captionwidth\z@
212 \def\caption@posa{Z}\def\caption@posb{Z}%
213 \@ifnextchar<\X@layoutcaption{%
214 \@ifnextchar(\@ilayoutcaption{%
215 \@ifnextchar[\@iilayoutcaption\relax}}}
216 \def\X@layoutcaption<#1>{\def\caption@dir{#1}%
217 \@ifnextchar(\@ilayoutcaption{%
218 \@ifnextchar[\@iilayoutcaption\relax}}
219 \def\@ilayoutcaption(#1){\setlength\captionwidth{#1}%
220 \@ifnextchar[{\@iilayoutcaption}{\relax}}
221 \def\@iilayoutcaption[#1#2]{%
222 \def\caption@posa{#1}\def\caption@posb{#2}}
224 \ifx\@captype\@undefined
225 \@latex@error{\noexpand\pcaption outside float}\@ehd
228 \refstepcounter\@captype
229 \expandafter\@firstofone
231 {\@dblarg{\@pcaption\@captype}}%
233 \long\def\@pcaption#1[#2]#3{%
234 \addcontentsline{\csname ext@#1\endcsname}{#1}{%
235 \protect\numberline{\csname the#1\endcsname}{\ignorespaces#2}}%
237 \@latex@error{Use \noexpand\pcaption with `\protect\layoutfloat'}\@eha
239 \make@pcaptionbox{#3}%
241 \setbox\@tempboxa\vbox{\hbox to\hsize{\if l\float@pos\else\hss\fi
242 \if l\caption@posb\box\@captionbox\kern\captionfloatsep\fi
243 \if t\caption@posa\vtop
244 \else\if b\caption@posa\vbox
245 \else\@pboxswtrue $\vcenter \fi\fi
246 {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi
248 \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}%
250 \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi
251 \if r\float@pos\else\hss\fi}}%
252 \par\vskip.25\baselineskip
254 \def\make@pcaptionbox#1{%
256 \ifx\csname\@captype @layoutc@ption\endcsname\relax
257 \@latex@warning{Default caption layout of `\@captype' unknown.}%
258 \def\caption@dir{Z}\captionwidth\z@
259 \def\caption@posa{Z}\def\caption@posb{Z}%
261 \csname \@captype @layoutc@ption\endcsname
264 % \@tempswa: 基本組の組方向とキャプションの組方向が直交するか?
265 \if y\caption@dir \let\captiondir\yoko
266 \ifodd\ltjgetparameter{direction}\relax\@tempswatrue\fi
267 \else\if z\caption@dir \let\captiondir\relax
268 \ifnum\ltjgetparameter{direction}=3\relax\let\captiondir\utod\fi
269 \else\if d\caption@dir \let\captiondir\dtou
270 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
271 \else\if u\caption@dir \let\captiondir\utod
272 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
273 \else\if t\caption@dir \let\captiondir\tate
274 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
276 \setbox0\hbox{\hbox{\captiondir
277 \captionfontsetup\parindent\z@\inhibitglue
278 \csname fnum@\@captype\endcsname #1}}%"
279 \if@tempswa\@tempdima\ltjgetht0 \advance\@tempdima\ltjgetdp0
280 \else\@tempdima\ltjgetwd0 \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
385 % ↓中身\周囲→ yoko tate utod dtou
390 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
391 % B: 周囲と中身が90度ずれ.上端が和文の高さ or 下端が和文の深さに揃うように
392 % C: 周囲と中身が180度ずれ.(コードは B のものを流用)
393 % D: 上端が和文の高さ or 下端が和文の深さに揃うように(コードは B のものを流用)
395 \def\fork@parbox@option@@A#1{%
396 \let\@end@parbox\relax
397 \if #1t\relax \let\@begin@parbox\vtop
398 \else\if #1b\relax\let\@begin@parbox\vbox
401 \let\@begin@parbox\vcenter\let\@end@parbox\relax
403 \def\@begin@parbox{\null$\vcenter}%
404 \def\@end@parbox{\m@th$\null}%
407 \def\lltjext@getjablshift{%
408 \ifnum\ltj@ext@dir=3 \ltjgetparameter{tjabaselineshift}\else
409 \ltjgetparameter{yjabaselineshift}\fi}
410 \def\fork@parbox@option@@B#1{%
412 \def\@begin@parbox{\raise\dimexpr\cht-\lltjext@getjablshift\vtop\bgroup\kern\z@\vbox}%
413 \let\@end@parbox\egroup
415 \def\@begin@parbox{\lower\dimexpr\cdp+\lltjext@getjablshift\vbox\bgroup\vbox}%
416 \def\@end@parbox{\kern\z@\egroup}%
419 \let\@begin@parbox\vcenter\let\@end@parbox\relax
421 \def\@begin@parbox{\null$\vcenter}%
422 \def\@end@parbox{\m@th$\null}%
425 \let\fork@parbox@option@@C=\fork@parbox@option@@B
426 \def\fork@parbox@option<#1>[#2]{%
427 \let\box@dir\relax \ltj@ext@dir=\ltjgetparameter{direction}\relax
429 \ifnum\ltj@ext@dir=3\relax
433 \if #1y\relax \let\box@dir\yoko
434 \else\if #1t\relax\let\box@dir\tate
435 \else\if #1d\relax\let\box@dir\dtou
436 \else\if #1u\relax\let\box@dir\utod
441 \or \let\box@dir\dtou
442 \or\or\let\box@dir\tate
443 \or \let\box@dir\yoko
444 \else \let\box@dir\utod
447 \ifnum\ltj@ext@dir=4 % yoko
448 \ifx\box@dir\yoko \fork@parbox@option@@A{#2}%
449 \else \fork@parbox@option@@B{#2}%
451 \else\ifnum\ltj@ext@dir=1 % dtou
452 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
453 \else\ifx\box@dir\dtou \fork@parbox@option@@A{#2}%
454 \else \fork@parbox@option@@C{#2}%
456 \else\ifnum\ltj@ext@dir=3 % tate
457 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
458 \else\ifx\box@dir\tate \fork@parbox@option@@A{#2}%
459 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
460 \else \fork@parbox@option@@B{#2}% D
463 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
464 \else\ifx\box@dir\utod \fork@parbox@option@@A{#2}%
465 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
466 \else \fork@parbox@option@@B{#2}% D
471 \DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
472 \def\X@makePbox<#1>{%
473 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
474 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
475 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
476 \def\@iimakePbox<#1>#2[#3]#4{%
477 \bgroup\let\box@dir\relax
479 \ifnum\ltjgetparameter{direction}=3 \relax
483 \if #1y\relax \let\box@dir\yoko
484 \else\if #1t\relax\let\box@dir\tate
485 \else\if #1d\relax\let\box@dir\dtou
486 \else\if #1u\relax\let\box@dir\utod
490 \ifcase\ltjgetparameter{direction}
491 \or \let\box@dir\dtou
492 \or\or\let\box@dir\tate
493 \or \let\box@dir\yoko
494 \else \let\box@dir\utod
497 \setlength{\@tempdima}{#2}%
498 \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else
499 \hb@xt@\@tempdima{\box@dir
500 \if #3l\relax\else\hss\fi
502 \if #3r\relax\else\hss\fi}\fi\egroup}
505 \def\picture{\@ifnextchar<%>
506 {\X@picture}{\X@picture<Z>}}
507 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
508 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
510 \def\ltj@@pic@reset@blshift{%
511 \ltj@yablshift\z@\ltj@ykblshift\z@
512 \ltj@tablshift\z@\ltj@tkblshift\z@
514 \def\@@picture<#1>(#2,#3)(#4,#5){%
515 \edef\ltj@@pic@save@blshift{%
516 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
517 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
518 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
519 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
521 \bgroup\let\box@dir\relax
523 \ifnum\ltjgetparameter{direction}=3 \relax
527 \if #1y\relax \let\box@dir\yoko
528 \else\if #1t\relax\let\box@dir\tate
529 \else\if #1d\relax\let\box@dir\dtou
530 \else\if #1u\relax\let\box@dir\utod
534 \ifcase\ltjgetparameter{direction}
535 \or \let\box@dir\dtou
536 \or\or\let\box@dir\tate
537 \or \let\box@dir\yoko
538 \else \let\box@dir\utod
541 \@picwd=#2\unitlength \@picht=#3\unitlength
542 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
543 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
544 \ltj@@pic@reset@blshift
548 \setbox0=\hbox{\box@dir%
549 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
552 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
553 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
555 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
556 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
561 \egroup\ltj@@pic@save@blshift}
563 \def\put{\ltj@@pic@reset@blshift\org@put}
565 \def\line{\ltj@@pic@reset@blshift\org@line}
566 \let\org@vector\vector
567 \def\vector{\ltj@@pic@reset@blshift\org@vector}
568 \let\org@dashbox\dashbox
569 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
571 \def\oval{\ltj@@pic@reset@blshift\org@oval}
572 \let\org@circle\circle
573 \def\circle{\ltj@@pic@reset@blshift\org@circle}
576 \newif\ifnot@advanceline
578 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
579 \DeclareRobustCommand\rensuji{%
580 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
581 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
582 \def\@@rensuji[#1]#2{%
583 \ifvmode\leavevmode\fi
584 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
586 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
587 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
588 \ifnot@advanceline\not@advancelinefalse\else
589 \setbox\z@\hbox{\yoko#2}%
590 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
591 \ifnum\ltjgetparameter{direction}=1\relax
592 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
593 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
594 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
595 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
596 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
599 % 周囲が tate, utod の場合も同じ
600 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
601 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
602 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
603 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
607 \ifnum\ltjgetparameter{direction}=1\relax
608 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
609 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
610 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
613 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
614 \hbox to\@tempdimb{\yoko \hss#2\hss}%
615 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
616 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
617 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
618 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
624 \let\prensuji\rensuji
627 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
628 \def\@Kanji#1{\kansuji #1}
629 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
633 \def\boutenchar{\char\euc"A1A2}%"
634 \DeclareRobustCommand\bou[1]{\ifvmode\leavevmode\fi\@bou#1\end}
636 \ifx#1\end \let\ltj@@next=\relax
638 \ifnum\ltjgetparameter{direction}=3\relax
639 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
640 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
641 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
643 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
644 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
645 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
651 \DeclareRobustCommand\kasen[1]{%
652 \ifnum\ltjgetparameter{direction}=3\relax
653 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
654 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
656 \else\underline{#1}\fi}
659 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
660 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
661 \else (\theequation)\fi}}
662 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
663 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
665 %% Compatibility with array package
667 \def\ltj@lltjext@patch@array{%
668 \patchcmd{\@tabular}{\hbox\bgroup}{%
669 \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{}{}
671 {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
672 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
673 \patchcmd{\p@stabular}{\p@tabular}{\@tabular}{}{}
674 \@ifpackagelater{array}{2018/09/13}
675 {\expandafter\@firstoftwo}
676 {\expandafter\@secondoftwo}
677 {% = for 2018/09/13 v2.4i or newer
678 \def\@startpbox##1{\bgroup
680 \box@dir\adjustbaseline%%% これを追加
681 \setlength\hsize{##1}\@arrayparboxrestore
683 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
686 }{ % = for 2018/04/30 v2.4h or older
687 \def\@startpbox##1{\bgroup
688 \box@dir\adjustbaseline%%% これを追加
689 \setlength\hsize{##1}\@arrayparboxrestore
691 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
695 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
696 \def\p@array<##1>[##2]##3{%
699 \ifnum\ltj@ext@dir=3\relax
700 \let\box@dir\utod\@tempcnta=\zstrutbox
704 \let\box@dir\yoko\@tempcnta=\ystrutbox
706 \let\box@dir\tate\@tempcnta=\tstrutbox
708 \let\box@dir\dtou\@tempcnta=\dstrutbox
710 \let\box@dir\utod\@tempcnta=\zstrutbox
715 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
716 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
717 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
718 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
721 \setbox \@arstrutbox \hbox{\box@dir\vrule
722 \@height \arraystretch
723 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
724 \@depth \arraystretch \ltjgetdp \@tempcnta
726 \fork@array@option<##1>[##2]%
729 \xdef\@preamble{\ialign \noexpand \@halignto
730 \bgroup \tabskip \z@skip \@arstrut \@preamble
734 \@begin@alignbox\bgroup\box@dir\adjustbaseline
736 \let\@sharp####\let\protect\relax
737 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
738 \lineskip\z@skip\baselineskip\z@skip\@preamble}
739 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
742 \@ifpackageloaded{array}{%
743 \let\tabular=\ltj@lltjext@orig@tabular
744 \let\array=\ltj@lltjext@orig@array
745 \ltj@lltjext@patch@array
747 \let\ltj@lltjext@orig@tabular\relax
748 \let\ltj@lltjext@orig@array\relax
749 \RequirePackage{filehook,etoolbox}
750 \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
753 %%%%%%%%%%%%%%%% LuaTeX-ja original
755 %%\define@key[ltj]{japaram}{autouprightnum}{% %COUNT
756 %% \ltj@@set@stack{AURN}{0}{10000}\z@#1 }