2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2022-08-24 v1.2k-ltj-14 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}\relax
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{%
39 \ifnum\ltj@ext@dir=0 \ltj@ext@dir=\ltjgetparameter{direction}\relax\fi
42 \ifnum\ltj@ext@dir=3\relax
43 \let\box@dir\utod\@tempcnta=\zstrutbox
47 \let\box@dir\yoko\@tempcnta=\ystrutbox
49 \let\box@dir\tate\@tempcnta=\tstrutbox
51 \let\box@dir\dtou\@tempcnta=\dstrutbox
53 \let\box@dir\utod\@tempcnta=\zstrutbox
58 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
59 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
60 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
61 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
64 \fork@array@option<#1>[#2]\@begin@alignbox
65 \bgroup\box@dir\adjustbaseline
66 \setbox\@arstrutbox\hbox{%
68 \vrule\@height\arraystretch\ltjgetht\@tempcnta
69 \@depth\arraystretch\ltjgetdp\@tempcnta \@width\z@}%
70 \@mkpream{#3}\edef\@preamble{\ialign \noexpand\@halignto
71 \bgroup\@arstrut \@preamble \tabskip\z@skip \cr}%
72 \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
73 \let\tabularnewline\\%
77 \lineskip\z@skip\baselineskip\z@skip
78 \ifhmode \@preamerr\z@ \@@par\fi
80 \def\endarray{\crcr\egroup\egroup\@end@alignbox}
81 \def\endtabular{\endarray$\egroup}
82 \expandafter \let \csname endtabular*\endcsname = \endtabular
83 % ↓中身\周囲→ yoko tate utod dtou
88 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
89 % B: 周囲と中身が90度ずれ.上端/下端がベースラインに揃うように
90 % C: 周囲と中身が180度ずれ.\vtop, \vbox 入れ替え
91 % D: 欧文ベースライン同士を揃えるようにする
93 \def\fork@array@option@@A#1{%
94 \let\@end@alignbox\relax
95 \if #1t\relax \let\@begin@alignbox\vtop
96 \else\if #1b\relax\let\@begin@alignbox\vbox
97 \else \let\@begin@alignbox\vcenter
99 \def\fork@array@option@@B#1{%
101 \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}%
102 \let\@end@alignbox\egroup
104 \def\@begin@alignbox{\vbox\bgroup\vbox}%
105 \def\@end@alignbox{\kern\z@\egroup}%
107 \let\@begin@alignbox\vcenter
108 \let\@end@alignbox\relax
110 \def\fork@array@option@@C#1{%
111 \let\@end@alignbox\relax
112 \if #1t\relax \let\@begin@alignbox\vbox
113 \else\if #1b\relax\let\@begin@alignbox\vtop
114 \else \let\@begin@alignbox\vcenter
116 \def\fork@array@option<#1>[#2]{%
117 \ifnum\ltj@ext@dir=4 % yoko
118 \ifx\box@dir\yoko \fork@array@option@@A{#2}%
119 \else \fork@array@option@@B{#2}%
121 \else\ifnum\ltj@ext@dir=1 % dtou
122 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
123 \else\ifx\box@dir\dtou \fork@array@option@@A{#2}%
124 \else \fork@array@option@@C{#2}%
126 \else\ifnum\ltj@ext@dir=3 % tate
127 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
128 \else\ifx\box@dir\tate \fork@array@option@@A{#2}%
129 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
132 \def\@begin@alignbox{\lower\dimexpr
133 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vtop}
134 \let\@end@alignbox\relax
136 \def\@begin@alignbox{\lower\dimexpr
137 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vbox}
138 \let\@end@alignbox\relax
140 \let\@begin@alignbox\vcenter
141 \let\@end@alignbox\relax
145 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
146 \else\ifx\box@dir\utod \fork@array@option@@A{#2}%
147 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
150 \def\@begin@alignbox{\lower\dimexpr
151 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vtop}
152 \let\@end@alignbox\relax
154 \def\@begin@alignbox{\lower\dimexpr
155 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vbox}
156 \let\@end@alignbox\relax
158 \let\@begin@alignbox\vcenter
159 \let\@end@alignbox\relax
167 \newdimen\floatheight
168 \newdimen\floatruletick \floatruletick=0.4pt
169 \newdimen\captionfloatsep \captionfloatsep=10pt
171 \let\captiondir\relax
172 \newdimen\captionwidth \captionwidth\z@
176 \def\captionfontsetup{\normalfont\normalsize}
177 \def\layoutfloat{\@ifnextchar(%)
178 {\X@layoutfloat}{\X@layoutfloat(-5\p@,-5\p@)}}
179 \def\X@layoutfloat(#1,#2){\@ifnextchar[%]
180 {\@layoutfloat(#1,#2)}{\@layoutfloat(#1,#2)[c]}}
181 \long\def\@layoutfloat(#1,#2)[#3]#4{%
183 \floatwidth=#1 \floatheight=#2 \edef\float@pos{#3}%
184 \ifdim\floatwidth<\z@
185 \floatwidth\ltjgetwd\z@\floatruletick\z@
187 \ifdim\floatheight<\z@
188 \floatheight\ltjgetht\z@\advance\floatheight\ltjgetdp\z@\relax
191 \setbox\@floatbox\vbox to\floatheight{\offinterlineskip
192 \hrule width\floatwidth height\floatruletick depth\z@
193 \vss\hbox to\floatwidth{%
194 \vrule width\floatruletick height\floatheight depth\z@
195 \hss\vbox to\floatheight{\hsize\floatwidth\vss#4\vss}\hss
196 \vrule width\floatruletick height\floatheight depth\z@
197 }\hrule width\floatwidth height\floatruletick depth\z@}}
198 \def\DeclareLayoutCaption#1<#2>(#3)[#4#5]{%
200 \ifx\csname #1@layoutc@ption\endcsname\relax \else
201 \@latex@info{Redeclaring capiton layout setting of '#1'}%
204 \gdef\csname #1@layoutc@ption\endcsname{%
205 \if Z\caption@dir\def\caption@dir{#2}\fi
206 \ifdim\captionwidth=\z@ \captionwidth=#3\relax\fi
207 \if Z\caption@posa\def\caption@posa{#4}\fi
208 \if Z\caption@posb\def\caption@posb{#5}\fi}}
209 \@onlypreamble\DeclareLayoutCaption
210 \DeclareLayoutCaption{figure}<n>(.8\linewidth)[cd]
211 \DeclareLayoutCaption{table}<n>(.8\linewidth)[cu]
212 \def\layoutcaption{\def\caption@dir{Z}\captionwidth\z@
213 \def\caption@posa{Z}\def\caption@posb{Z}%
214 \@ifnextchar<\X@layoutcaption{%
215 \@ifnextchar(\@ilayoutcaption{%
216 \@ifnextchar[\@iilayoutcaption\relax}}}
217 \def\X@layoutcaption<#1>{\def\caption@dir{#1}%
218 \@ifnextchar(\@ilayoutcaption{%
219 \@ifnextchar[\@iilayoutcaption\relax}}
220 \def\@ilayoutcaption(#1){\setlength\captionwidth{#1}%
221 \@ifnextchar[{\@iilayoutcaption}{\relax}}
222 \def\@iilayoutcaption[#1#2]{%
223 \def\caption@posa{#1}\def\caption@posb{#2}}
225 \ifx\@captype\@undefined
226 \@latex@error{\noexpand\pcaption outside float}\@ehd
229 \refstepcounter\@captype
230 \expandafter\@firstofone
232 {\@dblarg{\@pcaption\@captype}}%
234 \long\def\@pcaption#1[#2]#3{%
235 \addcontentsline{\csname ext@#1\endcsname}{#1}{%
236 \protect\numberline{\csname the#1\endcsname}{\ignorespaces#2}}%
238 \@latex@error{Use \noexpand\pcaption with `\protect\layoutfloat'}\@eha
240 \make@pcaptionbox{#3}%
242 \setbox\@tempboxa\vbox{\hbox to\hsize{\if l\float@pos\else\hss\fi
243 \if l\caption@posb\box\@captionbox\kern\captionfloatsep\fi
244 \if t\caption@posa\vtop
245 \else\if b\caption@posa\vbox
246 \else\@pboxswtrue $\vcenter \fi\fi
247 {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi
249 \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}%
251 \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi
252 \if r\float@pos\else\hss\fi}}%
253 \par\vskip.25\baselineskip
255 \def\make@pcaptionbox#1{%
257 \ifx\csname\@captype @layoutc@ption\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 @layoutc@ption\endcsname
265 % \@tempswa: 基本組の組方向とキャプションの組方向が直交するか?
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 \advance\@tempdima\ltjgetdp0
281 \else\@tempdima\ltjgetwd0 \fi
282 \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi
285 \if u\caption@posb\vbox
286 \else\if d\caption@posb\vbox
287 \else\if t\caption@posa\vtop
288 \else\if b\caption@posa\vbox
289 \else\ifmmode\vcenter\else\@pboxswtrue $\vcenter\fi
291 {\hsize\@tempdima\kern\z@
292 \vbox{\captiondir\hsize\@tempdima
293 \captionfontsetup\parindent\z@\inhibitglue
294 \csname fnum@\@captype\endcsname #1}\kern\z@
295 }\if@pboxsw \m@th$\fi}%
296 \let\to@captionboxwidth\relax
297 \if l\caption@posb \else\if r\caption@posb\else
298 \def\to@captionboxwidth{to\floatwidth}\fi\fi
299 \setbox\@captionbox\hbox\to@captionboxwidth{%
300 \if t\caption@posa\else\hss\fi
302 \if b\caption@posa\else\hss\fi}}
304 %%% minipage and parbox
305 \def\minipage{\@ifnextchar<%>
306 {\X@minipage}{\X@minipage<Z>}}
307 \def\X@minipage<#1>{\@ifnextchar[%]
308 {\@iminipage<#1>}{\@iiiminipage<#1>{c}\relax[s]}}
309 \def\@iminipage<#1>[#2]{\@ifnextchar[%]
310 {\@iiminipage<#1>{#2}}{\@iiiminipage<#1>{#2}\relax[s]}}
311 \def\@iiminipage<#1>#2[#3]{\@ifnextchar[%]
312 {\@iiiminipage<#1>{#2}{#3}}{\@iiiminipage<#1>{#2}{#3}[#2]}}
313 \def\@iiiminipage<#1>#2#3[#4]#5{%
315 \setlength\@tempdima{#5}%
316 \def\@mpargs{<#1>{#2}{#3}[#4]{#5}}%
319 \ifnum\ltjgetparameter{direction}=3\relax
323 \if #1y\relax \let\box@dir\yoko
324 \else\if #1t\relax\let\box@dir\tate
325 \else\if #1d\relax\let\box@dir\dtou
326 \else\if #1u\relax\let\box@dir\utod
330 \ifcase\ltjgetparameter{direction}\relax
331 \or \let\box@dir\dtou
332 \or\or\let\box@dir\tate
333 \or \let\box@dir\yoko
334 \else \let\box@dir\utod
337 \setbox\@tempboxa\vbox\bgroup\box@dir
341 \textwidth\hsize \columnwidth\hsize
343 \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}%
345 \let\@footnotetext\@mpfootnotetext
346 \let\@listdepth\@mplistdepth \@mplistdepth\z@
352 \ifvoid\@mpfootins\else
353 \vskip\skip\@mpfootins
358 \@minipagefalse %% added 24 May 89
361 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup}
362 \DeclareRobustCommand\parbox{\@ifnextchar<%>
363 {\X@parbox}{\X@parbox<Z>}}
364 \def\X@parbox<#1>{\@ifnextchar[%]
365 {\@iparbox<#1>}{\@iiiparbox<#1>{c}\relax[s]}}
366 \def\@iparbox<#1>[#2]{\@ifnextchar[%]
367 {\@iiparbox<#1>{#2}}{\@iiiparbox<#1>{#2}\relax[s]}}
368 \def\@iiparbox<#1>#2[#3]{\@ifnextchar[%]%
369 {\@iiiparbox<#1>{#2}{#3}}{\@iiiparbox<#1>{#2}{#3}[#2]}}
370 \long\def\@iiiparbox<#1>#2#3[#4]#5#6{%
372 \setlength\@tempdima{#5}%
373 \fork@parbox@option<#1>[#2]%
374 \@begin@tempboxa\vbox{\box@dir
375 \hsize\@tempdima\@parboxrestore\adjustbaseline#6\@@par}%
377 \setlength\@tempdimb{#3}%
378 \edef\@parboxto{to\the\@tempdimb}%
380 \@begin@parbox\@parboxto{\box@dir\adjustbaseline
381 \let\hss\vss\let\unhbox\unvbox
382 \csname bm@#4\endcsname}\@end@parbox
386 % ↓中身\周囲→ yoko tate utod dtou
391 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
392 % B: 周囲と中身が90度ずれ.上端が和文の高さ or 下端が和文の深さに揃うように
393 % C: 周囲と中身が180度ずれ.(コードは B のものを流用)
394 % D: 上端が和文の高さ or 下端が和文の深さに揃うように(コードは B のものを流用)
396 \def\fork@parbox@option@@A#1{%
397 \let\@end@parbox\relax
398 \if #1t\relax \let\@begin@parbox\vtop
399 \else\if #1b\relax\let\@begin@parbox\vbox
402 \let\@begin@parbox\vcenter\let\@end@parbox\relax
404 \def\@begin@parbox{\null$\vcenter}%
405 \def\@end@parbox{\m@th$\null}%
408 \def\lltjext@getjablshift{%
409 \ifnum\ltj@ext@dir=3 \ltjgetparameter{tjabaselineshift}\else
410 \ltjgetparameter{yjabaselineshift}\fi}
411 \def\fork@parbox@option@@B#1{%
413 \def\@begin@parbox{\raise\dimexpr\cht-\lltjext@getjablshift\vtop\bgroup\kern\z@\vbox}%
414 \let\@end@parbox\egroup
416 \def\@begin@parbox{\lower\dimexpr\cdp+\lltjext@getjablshift\vbox\bgroup\vbox}%
417 \def\@end@parbox{\kern\z@\egroup}%
420 \let\@begin@parbox\vcenter\let\@end@parbox\relax
422 \def\@begin@parbox{\null$\vcenter}%
423 \def\@end@parbox{\m@th$\null}%
426 \let\fork@parbox@option@@C=\fork@parbox@option@@B
427 \def\fork@parbox@option<#1>[#2]{%
428 \let\box@dir\relax \ltj@ext@dir=\ltjgetparameter{direction}\relax
430 \ifnum\ltj@ext@dir=3\relax
434 \if #1y\relax \let\box@dir\yoko
435 \else\if #1t\relax\let\box@dir\tate
436 \else\if #1d\relax\let\box@dir\dtou
437 \else\if #1u\relax\let\box@dir\utod
442 \or \let\box@dir\dtou
443 \or\or\let\box@dir\tate
444 \or \let\box@dir\yoko
445 \else \let\box@dir\utod
448 \ifnum\ltj@ext@dir=4 % yoko
449 \ifx\box@dir\yoko \fork@parbox@option@@A{#2}%
450 \else \fork@parbox@option@@B{#2}%
452 \else\ifnum\ltj@ext@dir=1 % dtou
453 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
454 \else\ifx\box@dir\dtou \fork@parbox@option@@A{#2}%
455 \else \fork@parbox@option@@C{#2}%
457 \else\ifnum\ltj@ext@dir=3 % tate
458 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
459 \else\ifx\box@dir\tate \fork@parbox@option@@A{#2}%
460 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
461 \else \fork@parbox@option@@B{#2}% D
464 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
465 \else\ifx\box@dir\utod \fork@parbox@option@@A{#2}%
466 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
467 \else \fork@parbox@option@@B{#2}% D
472 \DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
473 \def\X@makePbox<#1>{%
474 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
475 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
476 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
477 \def\@iimakePbox<#1>#2[#3]#4{%
478 \bgroup\let\box@dir\relax
480 \ifnum\ltjgetparameter{direction}=3 \relax
484 \if #1y\relax \let\box@dir\yoko
485 \else\if #1t\relax\let\box@dir\tate
486 \else\if #1d\relax\let\box@dir\dtou
487 \else\if #1u\relax\let\box@dir\utod
491 \ifcase\ltjgetparameter{direction}
492 \or \let\box@dir\dtou
493 \or\or\let\box@dir\tate
494 \or \let\box@dir\yoko
495 \else \let\box@dir\utod
498 \setlength{\@tempdima}{#2}%
499 \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else
500 \hb@xt@\@tempdima{\box@dir
501 \if #3l\relax\else\hss\fi
503 \if #3r\relax\else\hss\fi}\fi\egroup}
506 \def\picture{\@ifnextchar<%>
507 {\X@picture}{\X@picture<Z>}}
508 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
509 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
511 \def\ltj@@pic@reset@blshift{%
512 \ltj@yablshift\z@\ltj@ykblshift\z@
513 \ltj@tablshift\z@\ltj@tkblshift\z@
514 %\unsetattribute\ltj@yablshift\unsetattribute\ltj@ykblshift
515 %\unsetattribute\ltj@tablshift\unsetattribute\ltj@tkblshift
517 \def\@@picture<#1>(#2,#3)(#4,#5){%
518 \edef\ltj@@pic@save@blshift{%
519 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
520 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
521 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
522 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
524 \bgroup\let\box@dir\relax
526 \ifnum\ltjgetparameter{direction}=3 \relax
530 \if #1y\relax \let\box@dir\yoko
531 \else\if #1t\relax\let\box@dir\tate
532 \else\if #1d\relax\let\box@dir\dtou
533 \else\if #1u\relax\let\box@dir\utod
537 \ifcase\ltjgetparameter{direction}
538 \or \let\box@dir\dtou
539 \or\or\let\box@dir\tate
540 \or \let\box@dir\yoko
541 \else \let\box@dir\utod
544 \ifltj@ltfilehook@avail % LaTeX2e >= 2020-10-01
545 \@defaultunitsset\@picht{#3}\unitlength
546 \@defaultunitsset\@picwd{#2}\unitlength
547 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
548 \@defaultunitsset\@tempdimc{#4}\unitlength\hskip-\@tempdimc
549 \@defaultunitsset\@tempdimc{#5}\unitlength\lower\@tempdimc\hbox\bgroup
550 \else % <= 2020-02-02
551 \@picwd=#2\unitlength \@picht=#3\unitlength
552 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
553 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
555 \ltj@@pic@reset@blshift
559 \setbox0=\hbox{\box@dir%
560 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
563 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
564 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
566 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
567 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
572 \egroup\ltj@@pic@save@blshift}
574 \def\put{\ltj@@pic@reset@blshift\org@put}
576 \def\line{\ltj@@pic@reset@blshift\org@line}
577 \let\org@vector\vector
578 \def\vector{\ltj@@pic@reset@blshift\org@vector}
579 \let\org@dashbox\dashbox
580 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
582 \def\oval{\ltj@@pic@reset@blshift\org@oval}
583 \let\org@circle\circle
584 \def\circle{\ltj@@pic@reset@blshift\org@circle}
587 \newif\ifnot@advanceline
589 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
590 \DeclareRobustCommand\rensuji{%
591 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
592 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
593 \def\@@rensuji[#1]#2{%
594 \ifvmode\leavevmode\fi
595 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
597 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
598 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
599 \ifnot@advanceline\not@advancelinefalse\else
600 \setbox\z@\hbox{\yoko#2}%
601 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
602 \ifnum\ltjgetparameter{direction}=1\relax
603 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
604 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
605 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
606 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
607 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
610 % 周囲が tate, utod の場合も同じ
611 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
612 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
613 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
614 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
618 \ifnum\ltjgetparameter{direction}=1\relax
619 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
620 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
621 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
624 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
625 \hbox to\@tempdimb{\yoko \hss#2\hss}%
626 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
627 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
628 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
629 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
635 \let\prensuji\rensuji
638 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
639 \def\@Kanji#1{\kansuji #1}
640 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
644 \def\boutenchar{\char\euc"A1A2}%"
645 \DeclareRobustCommand\bou[1]{\ifvmode\leavevmode\fi\@bou#1\end}
647 \ifx#1\end \let\ltj@@next=\relax
649 \ifnum\ltjgetparameter{direction}=3\relax
650 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
651 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
652 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
654 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
655 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
656 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
662 \DeclareRobustCommand\kasen[1]{%
663 \ifnum\ltjgetparameter{direction}=3\relax
664 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
665 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
667 \else\underline{#1}\fi}
670 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
671 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
672 \else (\theequation)\fi}}
673 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
674 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
676 %% Compatibility with array package
678 \def\ltj@lltjext@patch@array{%
679 \patchcmd{\@tabular}{\hbox\bgroup}{%
680 \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
682 {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
683 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
684 \patchcmd{\p@stabular}{\p@tabular}{\@tabular}{}{}
685 \@ifpackagelater{array}{2018/09/13}
686 {\expandafter\@firstoftwo}
687 {\expandafter\@secondoftwo}
688 {% = for 2018/09/13 v2.4i or newer
689 \def\@startpbox##1{\bgroup
691 \box@dir\adjustbaseline%%% これを追加
692 \setlength\hsize{##1}\@arrayparboxrestore
694 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
697 }{ % = for 2018/04/30 v2.4h or older
698 \def\@startpbox##1{\bgroup
699 \box@dir\adjustbaseline%%% これを追加
700 \setlength\hsize{##1}\@arrayparboxrestore
702 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
706 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<Z>}}
707 \def\p@array<##1>[##2]##3{%
708 \ifnum\ltj@ext@dir=0 \ltj@ext@dir=\ltjgetparameter{direction}\relax\fi
711 \ifnum\ltj@ext@dir=3\relax
712 \let\box@dir\utod\@tempcnta=\zstrutbox
716 \let\box@dir\yoko\@tempcnta=\ystrutbox
718 \let\box@dir\tate\@tempcnta=\tstrutbox
720 \let\box@dir\dtou\@tempcnta=\dstrutbox
722 \let\box@dir\utod\@tempcnta=\zstrutbox
727 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
728 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
729 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
730 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
733 \setbox \@arstrutbox \hbox{\box@dir\vrule
734 \@height \arraystretch
735 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
736 \@depth \arraystretch \ltjgetdp \@tempcnta
738 \fork@array@option<##1>[##2]%
741 \xdef\@preamble{\noexpand\ialign \noexpand \@halignto
742 \bgroup \tabskip \z@skip \@arstrut \@preamble
746 \@begin@alignbox\bgroup\box@dir\adjustbaseline
748 \let\@sharp####\let\protect\relax
749 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
750 \lineskip\z@skip\baselineskip\z@skip\@preamble}
751 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
753 \@ifpackageloaded{array}{%
754 \let\tabular=\ltj@lltjext@orig@tabular
755 \let\array=\ltj@lltjext@orig@array
756 \ltj@lltjext@patch@array
758 \let\ltj@lltjext@orig@tabular\relax
759 \let\ltj@lltjext@orig@array\relax
760 \ltj@ExecuteAfterPackage{array}{\ltj@lltjext@patch@array}
763 %%%%%%%%%%%%%%%% LuaTeX-ja original
765 %%\define@key[ltj]{japaram}{autouprightnum}{% %COUNT
766 %% \ltj@@set@stack{AURN}{0}{10000}\z@#1 }