2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2018/09/10 v1.2i-ltj-9 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}
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 \fork@array@option<#1>[#2]\@begin@alignbox
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 \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@layoutcaption\endcsname\relax \else
200 \@latex@info{Redeclaring capiton layout setting of '#1'}%
203 \gdef\csname #1@layoutcaption\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\ifmmode\vcenter \else\@pboxswtrue $\vcenter \fi\fi\fi
246 {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi
248 \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}%
249 \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi
250 \if@pboxsw \m@th$\fi \if r\float@pos\else\hss\fi}}%
251 \par\vskip.25\baselineskip
253 \def\make@pcaptionbox#1{%
255 \ifx\csname\@captype @layoutcaption\endcsname\relax
256 \@latex@warning{Default caption layout of `\@captype' unknown.}%
257 \def\caption@dir{Z}\captionwidth\z@
258 \def\caption@posa{Z}\def\caption@posb{Z}%
260 \csname \@captype @layoutcaption\endcsname
263 % \@tempswa: 基本組の組方向とキャプションの組方向が直交するか?
264 \if y\caption@dir \let\captiondir\yoko
265 \ifodd\ltjgetparameter{direction}\relax\@tempswatrue\fi
266 \else\if z\caption@dir \let\captiondir\relax
267 \ifnum\ltjgetparameter{direction}=3\relax\let\captiondir\utod\fi
268 \else\if d\caption@dir \let\captiondir\dtou
269 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
270 \else\if u\caption@dir \let\captiondir\utod
271 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
272 \else\if t\caption@dir \let\captiondir\tate
273 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
275 \setbox0\hbox{\hbox{\captiondir
276 \captionfontsetup\parindent\z@\inhibitglue
277 \csname fnum@\@captype\endcsname #1}}%"
278 \if@tempswa\@tempdima\ltjgetht0\relax\else\@tempdima\ltjgetwd0\relax\fi
279 \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi
282 \if u\caption@posb\vbox
283 \else\if d\caption@posb\vbox
284 \else\if t\caption@posa\vtop
285 \else\if b\caption@posa\vbox
286 \else\ifmmode\vcenter\else\@pboxswtrue $\vcenter\fi
288 {\hsize\@tempdima\kern\z@
289 \vbox{\captiondir\hsize\@tempdima
290 \captionfontsetup\parindent\z@\inhibitglue
291 \csname fnum@\@captype\endcsname #1}\kern\z@
292 }\if@pboxsw \m@th$\fi}%
293 \let\to@captionboxwidth\relax
294 \if l\caption@posb \else\if r\caption@posb\else
295 \def\to@captionboxwidth{to\floatwidth}\fi\fi
296 \setbox\@captionbox\hbox\to@captionboxwidth{%
297 \if t\caption@posa\else\hss\fi
299 \if b\caption@posa\else\hss\fi}}
301 %%% minipage and parbox
302 \def\minipage{\@ifnextchar<%>
303 {\X@minipage}{\X@minipage<Z>}}
304 \def\X@minipage<#1>{\@ifnextchar[%]
305 {\@iminipage<#1>}{\@iiiminipage<#1>{c}\relax[s]}}
306 \def\@iminipage<#1>[#2]{\@ifnextchar[%]
307 {\@iiminipage<#1>{#2}}{\@iiiminipage<#1>{#2}\relax[s]}}
308 \def\@iiminipage<#1>#2[#3]{\@ifnextchar[%]
309 {\@iiiminipage<#1>{#2}{#3}}{\@iiiminipage<#1>{#2}{#3}[#2]}}
310 \def\@iiiminipage<#1>#2#3[#4]#5{%
312 \setlength\@tempdima{#5}%
313 \def\@mpargs{<#1>{#2}{#3}[#4]{#5}}%
316 \ifnum\ltjgetparameter{direction}=3\relax
320 \if #1y\relax \let\box@dir\yoko
321 \else\if #1t\relax\let\box@dir\tate
322 \else\if #1d\relax\let\box@dir\dtou
323 \else\if #1u\relax\let\box@dir\utod
327 \ifcase\ltjgetparameter{direction}\relax
328 \or \let\box@dir\dtou
329 \or\or\let\box@dir\tate
330 \or \let\box@dir\yoko
331 \else \let\box@dir\utod
334 \setbox\@tempboxa\vbox\bgroup\box@dir
338 \textwidth\hsize \columnwidth\hsize
340 \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}%
342 \let\@footnotetext\@mpfootnotetext
343 \let\@listdepth\@mplistdepth \@mplistdepth\z@
349 \ifvoid\@mpfootins\else
350 \vskip\skip\@mpfootins
355 \@minipagefalse %% added 24 May 89
358 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup}
359 \DeclareRobustCommand\parbox{\@ifnextchar<%>
360 {\X@parbox}{\X@parbox<Z>}}
361 \def\X@parbox<#1>{\@ifnextchar[%]
362 {\@iparbox<#1>}{\@iiiparbox<#1>{c}\relax[s]}}
363 \def\@iparbox<#1>[#2]{\@ifnextchar[%]
364 {\@iiparbox<#1>{#2}}{\@iiiparbox<#1>{#2}\relax[s]}}
365 \def\@iiparbox<#1>#2[#3]{\@ifnextchar[%]%
366 {\@iiiparbox<#1>{#2}{#3}}{\@iiiparbox<#1>{#2}{#3}[#2]}}
367 \long\def\@iiiparbox<#1>#2#3[#4]#5#6{%
369 \setlength\@tempdima{#5}%
370 \fork@parbox@option<#1>[#2]%
371 \@begin@tempboxa\vbox{\box@dir
372 \hsize\@tempdima\@parboxrestore\adjustbaseline#6\@@par}%
374 \setlength\@tempdimb{#3}%
375 \edef\@parboxto{to\the\@tempdimb}%
377 \@begin@parbox\@parboxto{\box@dir\adjustbaseline
378 \let\hss\vss\let\unhbox\unvbox
379 \csname bm@#4\endcsname}\@end@parbox
383 % ↓中身\周囲→ yoko tate utod dtou
388 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
389 % B: 周囲と中身が90度ずれ.上端が和文の高さ or 下端が和文の深さに揃うように
390 % C: 周囲と中身が180度ずれ.(コードは B のものを流用)
391 % D: 上端が和文の高さ or 下端が和文の深さに揃うように(コードは B のものを流用)
393 \def\fork@parbox@option@@A#1{%
394 \let\@end@parbox\relax
395 \if #1t\relax \let\@begin@parbox\vtop
396 \else\if #1b\relax\let\@begin@parbox\vbox
399 \let\@begin@parbox\vcenter\let\@end@parbox\relax
401 \def\@begin@parbox{\null$\vcenter}%
402 \def\@end@parbox{\m@th$\null}%
405 \def\lltjext@getjablshift{%
406 \ifnum\ltj@ext@dir=3 \ltjgetparameter{tjabaselineshift}\else
407 \ltjgetparameter{yjabaselineshift}\fi}
408 \def\fork@parbox@option@@B#1{%
410 \def\@begin@parbox{\raise\dimexpr\cht-\lltjext@getjablshift\vtop\bgroup\kern\z@\vbox}%
411 \let\@end@parbox\egroup
413 \def\@begin@parbox{\lower\dimexpr\cdp+\lltjext@getjablshift\vbox\bgroup\vbox}%
414 \def\@end@parbox{\kern\z@\egroup}%
417 \let\@begin@parbox\vcenter\let\@end@parbox\relax
419 \def\@begin@parbox{\null$\vcenter}%
420 \def\@end@parbox{\m@th$\null}%
423 \let\fork@parbox@option@@C=\fork@parbox@option@@B
424 \def\fork@parbox@option<#1>[#2]{%
425 \let\box@dir\relax \ltj@ext@dir=\ltjgetparameter{direction}\relax
427 \ifnum\ltj@ext@dir=3\relax
431 \if #1y\relax \let\box@dir\yoko
432 \else\if #1t\relax\let\box@dir\tate
433 \else\if #1d\relax\let\box@dir\dtou
434 \else\if #1u\relax\let\box@dir\utod
439 \or \let\box@dir\dtou
440 \or\or\let\box@dir\tate
441 \or \let\box@dir\yoko
442 \else \let\box@dir\utod
445 \ifnum\ltj@ext@dir=4 % yoko
446 \ifx\box@dir\yoko \fork@parbox@option@@A{#2}%
447 \else \fork@parbox@option@@B{#2}%
449 \else\ifnum\ltj@ext@dir=1 % dtou
450 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
451 \else\ifx\box@dir\dtou \fork@parbox@option@@A{#2}%
452 \else \fork@parbox@option@@C{#2}%
454 \else\ifnum\ltj@ext@dir=3 % tate
455 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
456 \else\ifx\box@dir\tate \fork@parbox@option@@A{#2}%
457 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
458 \else \fork@parbox@option@@B{#2}% D
461 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
462 \else\ifx\box@dir\utod \fork@parbox@option@@A{#2}%
463 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
464 \else \fork@parbox@option@@B{#2}% D
469 \DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
470 \def\X@makePbox<#1>{%
471 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
472 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
473 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
474 \def\@iimakePbox<#1>#2[#3]#4{%
475 \bgroup\let\box@dir\relax
477 \ifnum\ltjgetparameter{direction}=3 \relax
481 \if #1y\relax \let\box@dir\yoko
482 \else\if #1t\relax\let\box@dir\tate
483 \else\if #1d\relax\let\box@dir\dtou
484 \else\if #1u\relax\let\box@dir\utod
488 \ifcase\ltjgetparameter{direction}
489 \or \let\box@dir\dtou
490 \or\or\let\box@dir\tate
491 \or \let\box@dir\yoko
492 \else \let\box@dir\utod
495 \setlength{\@tempdima}{#2}%
496 \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else
497 \hb@xt@\@tempdima{\box@dir
498 \if #3l\relax\else\hss\fi
500 \if #3r\relax\else\hss\fi}\fi\egroup}
503 \def\picture{\@ifnextchar<%>
504 {\X@picture}{\X@picture<Z>}}
505 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
506 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
508 \def\ltj@@pic@reset@blshift{%
509 \ltj@yablshift\z@\ltj@ykblshift\z@
510 \ltj@tablshift\z@\ltj@tkblshift\z@
512 \def\@@picture<#1>(#2,#3)(#4,#5){%
513 \edef\ltj@@pic@save@blshift{%
514 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
515 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
516 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
517 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
519 \bgroup\let\box@dir\relax
521 \ifnum\ltjgetparameter{direction}=3 \relax
525 \if #1y\relax \let\box@dir\yoko
526 \else\if #1t\relax\let\box@dir\tate
527 \else\if #1d\relax\let\box@dir\dtou
528 \else\if #1u\relax\let\box@dir\utod
532 \ifcase\ltjgetparameter{direction}
533 \or \let\box@dir\dtou
534 \or\or\let\box@dir\tate
535 \or \let\box@dir\yoko
536 \else \let\box@dir\utod
539 \@picwd=#2\unitlength \@picht=#3\unitlength
540 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
541 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
542 \ltj@@pic@reset@blshift
546 \setbox0=\hbox{\box@dir%
547 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
550 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
551 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
553 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
554 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
559 \egroup\ltj@@pic@save@blshift}
561 \def\put{\ltj@@pic@reset@blshift\org@put}
563 \def\line{\ltj@@pic@reset@blshift\org@line}
564 \let\org@vector\vector
565 \def\vector{\ltj@@pic@reset@blshift\org@vector}
566 \let\org@dashbox\dashbox
567 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
569 \def\oval{\ltj@@pic@reset@blshift\org@oval}
570 \let\org@circle\circle
571 \def\circle{\ltj@@pic@reset@blshift\org@circle}
574 \newif\ifnot@advanceline
576 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
577 \DeclareRobustCommand\rensuji{%
578 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
579 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
580 \def\@@rensuji[#1]#2{%
581 \ifvmode\leavevmode\fi
582 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
584 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
585 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
586 \ifnot@advanceline\not@advancelinefalse\else
587 \setbox\z@\hbox{\yoko#2}%
588 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
589 \ifnum\ltjgetparameter{direction}=1\relax
590 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
591 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
592 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
593 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
594 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
597 % 周囲が tate, utod の場合も同じ
598 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
599 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
600 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
601 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
605 \ifnum\ltjgetparameter{direction}=1\relax
606 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
607 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
608 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
611 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
612 \hbox to\@tempdimb{\yoko \hss#2\hss}%
613 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
614 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
615 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
616 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
622 \let\prensuji\rensuji
625 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
626 \def\@Kanji#1{\kansuji #1}
627 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
631 \def\boutenchar{\char\euc"A1A2}%"
632 \def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end}
634 \ifx#1\end \let\ltj@@next=\relax
636 \ifnum\ltjgetparameter{direction}=3\relax
637 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
638 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
639 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
641 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
642 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
643 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
650 \ifnum\ltjgetparameter{direction}=3\relax
651 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
652 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
654 \else\underline{#1}\fi}
657 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
658 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
659 \else (\theequation)\fi}}
660 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
661 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
663 %% Compatibility with array package
665 \def\ltj@lltjext@patch@array{%
666 \patchcmd{\@tabular}{\hbox\bgroup}{%
667 \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{\typeout{SUCC}}{}
669 {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
670 \def\@startpbox##1{\bgroup
671 \box@dir\adjustbaseline%%% これを追加
672 \setlength\hsize{##1}\@arrayparboxrestore
674 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
677 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
678 \def\p@array<##1>[##2]##3{%
681 \ifnum\ltj@ext@dir=3\relax
682 \let\box@dir\utod\@tempcnta=\zstrutbox
686 \let\box@dir\yoko\@tempcnta=\ystrutbox
688 \let\box@dir\tate\@tempcnta=\tstrutbox
690 \let\box@dir\dtou\@tempcnta=\dstrutbox
692 \let\box@dir\utod\@tempcnta=\zstrutbox
697 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
698 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
699 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
700 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
703 \setbox \@arstrutbox \hbox{\box@dir\vrule
704 \@height \arraystretch
705 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
706 \@depth \arraystretch \ltjgetdp \@tempcnta
708 \fork@array@option<##1>[##2]%
711 \xdef\@preamble{\ialign \noexpand \@halignto
712 \bgroup \tabskip \z@skip \@arstrut \@preamble
716 \@begin@alignbox\bgroup\box@dir\adjustbaseline
718 \let\@sharp####\let\protect\relax
719 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
720 \lineskip\z@skip\baselineskip\z@skip\@preamble}
721 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
724 \@ifpackageloaded{array}{%
725 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
726 \let\tabular=\ltj@lltjext@orig@tabular
727 \let\array=\ltj@lltjext@orig@array
728 \ltj@lltjext@patch@array
730 \let\ltj@lltjext@orig@tabularS\relax
731 \let\ltj@lltjext@orig@tabular\relax
732 \let\ltj@lltjext@orig@array\relax
733 \RequirePackage{filehook,etoolbox}
734 \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
737 %%%%%%%%%%%%%%%% LuaTeX-ja original
739 %%\define@key[ltj]{japaram}{autouprightnum}{% %COUNT
740 %% \ltj@@set@stack{AURN}{0}{10000}\z@#1 }