2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2018/09/22 v1.2j-ltj-9 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}<y>(.8\linewidth)[cd]
210 \DeclareLayoutCaption{table}<y>(.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\relax\else\@tempdima\ltjgetwd0\relax\fi
280 \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi
283 \if u\caption@posb\vbox
284 \else\if d\caption@posb\vbox
285 \else\if t\caption@posa\vtop
286 \else\if b\caption@posa\vbox
287 \else\ifmmode\vcenter\else\@pboxswtrue $\vcenter\fi
289 {\hsize\@tempdima\kern\z@
290 \vbox{\captiondir\hsize\@tempdima
291 \captionfontsetup\parindent\z@\inhibitglue
292 \csname fnum@\@captype\endcsname #1}\kern\z@
293 }\if@pboxsw \m@th$\fi}%
294 \let\to@captionboxwidth\relax
295 \if l\caption@posb \else\if r\caption@posb\else
296 \def\to@captionboxwidth{to\floatwidth}\fi\fi
297 \setbox\@captionbox\hbox\to@captionboxwidth{%
298 \if t\caption@posa\else\hss\fi
300 \if b\caption@posa\else\hss\fi}}
302 %%% minipage and parbox
303 \def\minipage{\@ifnextchar<%>
304 {\X@minipage}{\X@minipage<Z>}}
305 \def\X@minipage<#1>{\@ifnextchar[%]
306 {\@iminipage<#1>}{\@iiiminipage<#1>{c}\relax[s]}}
307 \def\@iminipage<#1>[#2]{\@ifnextchar[%]
308 {\@iiminipage<#1>{#2}}{\@iiiminipage<#1>{#2}\relax[s]}}
309 \def\@iiminipage<#1>#2[#3]{\@ifnextchar[%]
310 {\@iiiminipage<#1>{#2}{#3}}{\@iiiminipage<#1>{#2}{#3}[#2]}}
311 \def\@iiiminipage<#1>#2#3[#4]#5{%
313 \setlength\@tempdima{#5}%
314 \def\@mpargs{<#1>{#2}{#3}[#4]{#5}}%
317 \ifnum\ltjgetparameter{direction}=3\relax
321 \if #1y\relax \let\box@dir\yoko
322 \else\if #1t\relax\let\box@dir\tate
323 \else\if #1d\relax\let\box@dir\dtou
324 \else\if #1u\relax\let\box@dir\utod
328 \ifcase\ltjgetparameter{direction}\relax
329 \or \let\box@dir\dtou
330 \or\or\let\box@dir\tate
331 \or \let\box@dir\yoko
332 \else \let\box@dir\utod
335 \setbox\@tempboxa\vbox\bgroup\box@dir
339 \textwidth\hsize \columnwidth\hsize
341 \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}%
343 \let\@footnotetext\@mpfootnotetext
344 \let\@listdepth\@mplistdepth \@mplistdepth\z@
350 \ifvoid\@mpfootins\else
351 \vskip\skip\@mpfootins
356 \@minipagefalse %% added 24 May 89
359 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup}
360 \DeclareRobustCommand\parbox{\@ifnextchar<%>
361 {\X@parbox}{\X@parbox<Z>}}
362 \def\X@parbox<#1>{\@ifnextchar[%]
363 {\@iparbox<#1>}{\@iiiparbox<#1>{c}\relax[s]}}
364 \def\@iparbox<#1>[#2]{\@ifnextchar[%]
365 {\@iiparbox<#1>{#2}}{\@iiiparbox<#1>{#2}\relax[s]}}
366 \def\@iiparbox<#1>#2[#3]{\@ifnextchar[%]%
367 {\@iiiparbox<#1>{#2}{#3}}{\@iiiparbox<#1>{#2}{#3}[#2]}}
368 \long\def\@iiiparbox<#1>#2#3[#4]#5#6{%
370 \setlength\@tempdima{#5}%
371 \fork@parbox@option<#1>[#2]%
372 \@begin@tempboxa\vbox{\box@dir
373 \hsize\@tempdima\@parboxrestore\adjustbaseline#6\@@par}%
375 \setlength\@tempdimb{#3}%
376 \edef\@parboxto{to\the\@tempdimb}%
378 \@begin@parbox\@parboxto{\box@dir\adjustbaseline
379 \let\hss\vss\let\unhbox\unvbox
380 \csname bm@#4\endcsname}\@end@parbox
384 % ↓中身\周囲→ yoko tate utod dtou
389 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
390 % B: 周囲と中身が90度ずれ.上端が和文の高さ or 下端が和文の深さに揃うように
391 % C: 周囲と中身が180度ずれ.(コードは B のものを流用)
392 % D: 上端が和文の高さ or 下端が和文の深さに揃うように(コードは B のものを流用)
394 \def\fork@parbox@option@@A#1{%
395 \let\@end@parbox\relax
396 \if #1t\relax \let\@begin@parbox\vtop
397 \else\if #1b\relax\let\@begin@parbox\vbox
400 \let\@begin@parbox\vcenter\let\@end@parbox\relax
402 \def\@begin@parbox{\null$\vcenter}%
403 \def\@end@parbox{\m@th$\null}%
406 \def\lltjext@getjablshift{%
407 \ifnum\ltj@ext@dir=3 \ltjgetparameter{tjabaselineshift}\else
408 \ltjgetparameter{yjabaselineshift}\fi}
409 \def\fork@parbox@option@@B#1{%
411 \def\@begin@parbox{\raise\dimexpr\cht-\lltjext@getjablshift\vtop\bgroup\kern\z@\vbox}%
412 \let\@end@parbox\egroup
414 \def\@begin@parbox{\lower\dimexpr\cdp+\lltjext@getjablshift\vbox\bgroup\vbox}%
415 \def\@end@parbox{\kern\z@\egroup}%
418 \let\@begin@parbox\vcenter\let\@end@parbox\relax
420 \def\@begin@parbox{\null$\vcenter}%
421 \def\@end@parbox{\m@th$\null}%
424 \let\fork@parbox@option@@C=\fork@parbox@option@@B
425 \def\fork@parbox@option<#1>[#2]{%
426 \let\box@dir\relax \ltj@ext@dir=\ltjgetparameter{direction}\relax
428 \ifnum\ltj@ext@dir=3\relax
432 \if #1y\relax \let\box@dir\yoko
433 \else\if #1t\relax\let\box@dir\tate
434 \else\if #1d\relax\let\box@dir\dtou
435 \else\if #1u\relax\let\box@dir\utod
440 \or \let\box@dir\dtou
441 \or\or\let\box@dir\tate
442 \or \let\box@dir\yoko
443 \else \let\box@dir\utod
446 \ifnum\ltj@ext@dir=4 % yoko
447 \ifx\box@dir\yoko \fork@parbox@option@@A{#2}%
448 \else \fork@parbox@option@@B{#2}%
450 \else\ifnum\ltj@ext@dir=1 % dtou
451 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
452 \else\ifx\box@dir\dtou \fork@parbox@option@@A{#2}%
453 \else \fork@parbox@option@@C{#2}%
455 \else\ifnum\ltj@ext@dir=3 % tate
456 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
457 \else\ifx\box@dir\tate \fork@parbox@option@@A{#2}%
458 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
459 \else \fork@parbox@option@@B{#2}% D
462 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
463 \else\ifx\box@dir\utod \fork@parbox@option@@A{#2}%
464 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
465 \else \fork@parbox@option@@B{#2}% D
470 \DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
471 \def\X@makePbox<#1>{%
472 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
473 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
474 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
475 \def\@iimakePbox<#1>#2[#3]#4{%
476 \bgroup\let\box@dir\relax
478 \ifnum\ltjgetparameter{direction}=3 \relax
482 \if #1y\relax \let\box@dir\yoko
483 \else\if #1t\relax\let\box@dir\tate
484 \else\if #1d\relax\let\box@dir\dtou
485 \else\if #1u\relax\let\box@dir\utod
489 \ifcase\ltjgetparameter{direction}
490 \or \let\box@dir\dtou
491 \or\or\let\box@dir\tate
492 \or \let\box@dir\yoko
493 \else \let\box@dir\utod
496 \setlength{\@tempdima}{#2}%
497 \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else
498 \hb@xt@\@tempdima{\box@dir
499 \if #3l\relax\else\hss\fi
501 \if #3r\relax\else\hss\fi}\fi\egroup}
504 \def\picture{\@ifnextchar<%>
505 {\X@picture}{\X@picture<Z>}}
506 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
507 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
509 \def\ltj@@pic@reset@blshift{%
510 \ltj@yablshift\z@\ltj@ykblshift\z@
511 \ltj@tablshift\z@\ltj@tkblshift\z@
513 \def\@@picture<#1>(#2,#3)(#4,#5){%
514 \edef\ltj@@pic@save@blshift{%
515 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
516 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
517 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
518 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
520 \bgroup\let\box@dir\relax
522 \ifnum\ltjgetparameter{direction}=3 \relax
526 \if #1y\relax \let\box@dir\yoko
527 \else\if #1t\relax\let\box@dir\tate
528 \else\if #1d\relax\let\box@dir\dtou
529 \else\if #1u\relax\let\box@dir\utod
533 \ifcase\ltjgetparameter{direction}
534 \or \let\box@dir\dtou
535 \or\or\let\box@dir\tate
536 \or \let\box@dir\yoko
537 \else \let\box@dir\utod
540 \@picwd=#2\unitlength \@picht=#3\unitlength
541 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
542 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
543 \ltj@@pic@reset@blshift
547 \setbox0=\hbox{\box@dir%
548 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
551 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
552 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
554 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
555 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
560 \egroup\ltj@@pic@save@blshift}
562 \def\put{\ltj@@pic@reset@blshift\org@put}
564 \def\line{\ltj@@pic@reset@blshift\org@line}
565 \let\org@vector\vector
566 \def\vector{\ltj@@pic@reset@blshift\org@vector}
567 \let\org@dashbox\dashbox
568 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
570 \def\oval{\ltj@@pic@reset@blshift\org@oval}
571 \let\org@circle\circle
572 \def\circle{\ltj@@pic@reset@blshift\org@circle}
575 \newif\ifnot@advanceline
577 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
578 \DeclareRobustCommand\rensuji{%
579 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
580 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
581 \def\@@rensuji[#1]#2{%
582 \ifvmode\leavevmode\fi
583 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
585 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
586 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
587 \ifnot@advanceline\not@advancelinefalse\else
588 \setbox\z@\hbox{\yoko#2}%
589 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
590 \ifnum\ltjgetparameter{direction}=1\relax
591 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
592 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
593 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
594 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
595 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
598 % 周囲が tate, utod の場合も同じ
599 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
600 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
601 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
602 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
606 \ifnum\ltjgetparameter{direction}=1\relax
607 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
608 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
609 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
612 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
613 \hbox to\@tempdimb{\yoko \hss#2\hss}%
614 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
615 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
616 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
617 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
623 \let\prensuji\rensuji
626 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
627 \def\@Kanji#1{\kansuji #1}
628 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
632 \def\boutenchar{\char\euc"A1A2}%"
633 \def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end}
635 \ifx#1\end \let\ltj@@next=\relax
637 \ifnum\ltjgetparameter{direction}=3\relax
638 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
639 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
640 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
642 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
643 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
644 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
651 \ifnum\ltjgetparameter{direction}=3\relax
652 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
653 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
655 \else\underline{#1}\fi}
658 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
659 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
660 \else (\theequation)\fi}}
661 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
662 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
664 %% Compatibility with array package
666 \def\ltj@lltjext@patch@array{%
667 \patchcmd{\@tabular}{\hbox\bgroup}{%
668 \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{}{}
670 {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
671 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
672 \patchcmd{\p@stabular}{\p@tabular}{\@tabular}{}{}
673 \def\@startpbox##1{\bgroup
674 \box@dir\adjustbaseline%%% これを追加
675 \setlength\hsize{##1}\@arrayparboxrestore
677 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
680 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
681 \def\p@array<##1>[##2]##3{%
684 \ifnum\ltj@ext@dir=3\relax
685 \let\box@dir\utod\@tempcnta=\zstrutbox
689 \let\box@dir\yoko\@tempcnta=\ystrutbox
691 \let\box@dir\tate\@tempcnta=\tstrutbox
693 \let\box@dir\dtou\@tempcnta=\dstrutbox
695 \let\box@dir\utod\@tempcnta=\zstrutbox
700 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
701 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
702 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
703 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
706 \setbox \@arstrutbox \hbox{\box@dir\vrule
707 \@height \arraystretch
708 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
709 \@depth \arraystretch \ltjgetdp \@tempcnta
711 \fork@array@option<##1>[##2]%
714 \xdef\@preamble{\ialign \noexpand \@halignto
715 \bgroup \tabskip \z@skip \@arstrut \@preamble
719 \@begin@alignbox\bgroup\box@dir\adjustbaseline
721 \let\@sharp####\let\protect\relax
722 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
723 \lineskip\z@skip\baselineskip\z@skip\@preamble}
724 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
727 \@ifpackageloaded{array}{%
728 \let\tabular=\ltj@lltjext@orig@tabular
729 \let\array=\ltj@lltjext@orig@array
730 \ltj@lltjext@patch@array
732 \let\ltj@lltjext@orig@tabular\relax
733 \let\ltj@lltjext@orig@array\relax
734 \RequirePackage{filehook,etoolbox}
735 \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
738 %%%%%%%%%%%%%%%% LuaTeX-ja original
740 %%\define@key[ltj]{japaram}{autouprightnum}{% %COUNT
741 %% \ltj@@set@stack{AURN}{0}{10000}\z@#1 }