2 % lltjext.sty: derived from plext.sty in pLaTeX.
5 \NeedsTeXFormat{LaTeX2e}
6 \ProvidesPackage{lltjext}[2018/03/29 v1.2g-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{%
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 \setbox\@arstrutbox\hbox{%
65 \vrule\@height\arraystretch\ltjgetht\@tempcnta
66 \@depth\arraystretch\ltjgetdp\@tempcnta \@width\z@}%
67 \fork@array@option<#1>[#2]%
68 \@mkpream{#3}\edef\@preamble{\ialign \noexpand\@halignto
69 \bgroup\@arstrut \@preamble \tabskip\z@skip \cr}%
70 \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
71 \let\tabularnewline\\%
72 \@begin@alignbox\bgroup\box@dir\adjustbaseline
74 \let\@sharp##\let\protect\relax
75 \lineskip\z@skip\baselineskip\z@skip\@preamble}
76 \def\endarray{\crcr\egroup\egroup\@end@alignbox}
77 \def\endtabular{\endarray$\egroup}
78 \expandafter \let \csname endtabular*\endcsname = \endtabular
79 % ↓中身\周囲→ yoko tate utod dtou
84 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
85 % B: 周囲と中身が90度ずれ.上端/下端がベースラインに揃うように
86 % C: 周囲と中身が180度ずれ.\vtop, \vbox 入れ替え
87 % D: 欧文ベースライン同士を揃えるようにする
89 \def\fork@array@option@@A#1{%
90 \let\@end@alignbox\relax
91 \if #1t\relax \let\@begin@alignbox\vtop
92 \else\if #1b\relax\let\@begin@alignbox\vbox
93 \else \let\@begin@alignbox\vcenter
95 \def\fork@array@option@@B#1{%
97 \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}%
98 \let\@end@alignbox\egroup
100 \def\@begin@alignbox{\vbox\bgroup\vbox}%
101 \def\@end@alignbox{\kern\z@\egroup}%
103 \let\@begin@alignbox\vcenter
104 \let\@end@alignbox\relax
106 \def\fork@array@option@@C#1{%
107 \let\@end@alignbox\relax
108 \if #1t\relax \let\@begin@alignbox\vbox
109 \else\if #1b\relax\let\@begin@alignbox\vtop
110 \else \let\@begin@alignbox\vcenter
112 \def\fork@array@option<#1>[#2]{%
113 \ifnum\ltj@ext@dir=4 % yoko
114 \ifx\box@dir\yoko \fork@array@option@@A{#2}%
115 \else \fork@array@option@@B{#2}%
117 \else\ifnum\ltj@ext@dir=1 % dtou
118 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
119 \else\ifx\box@dir\dtou \fork@array@option@@A{#2}%
120 \else \fork@array@option@@C{#2}%
122 \else\ifnum\ltj@ext@dir=3 % tate
123 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
124 \else\ifx\box@dir\tate \fork@array@option@@A{#2}%
125 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
128 \def\@begin@alignbox{\lower\dimexpr
129 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vtop}
130 \let\@end@alignbox\relax
132 \def\@begin@alignbox{\lower\dimexpr
133 \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vbox}
134 \let\@end@alignbox\relax
136 \let\@begin@alignbox\vcenter
137 \let\@end@alignbox\relax
141 \ifx\box@dir\yoko \fork@array@option@@B{#2}%
142 \else\ifx\box@dir\utod \fork@array@option@@A{#2}%
143 \else\ifx\box@dir\dtou \fork@array@option@@C{#2}%
146 \def\@begin@alignbox{\lower\dimexpr
147 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vtop}
148 \let\@end@alignbox\relax
150 \def\@begin@alignbox{\lower\dimexpr
151 \ltjgetparameter{yalbaselineshift}-\ltjgetparameter{talbaselineshift}\vbox}
152 \let\@end@alignbox\relax
154 \let\@begin@alignbox\vcenter
155 \let\@end@alignbox\relax
163 \newdimen\floatheight
164 \newdimen\floatruletick \floatruletick=0.4pt
165 \newdimen\captionfloatsep \captionfloatsep=10pt
167 \let\captiondir\relax
168 \newdimen\captionwidth \captionwidth\z@
172 \def\captionfontsetup{\normalfont\normalsize}
173 \def\layoutfloat{\@ifnextchar(%)
174 {\X@layoutfloat}{\X@layoutfloat(-5\p@,-5\p@)}}
175 \def\X@layoutfloat(#1,#2){\@ifnextchar[%]
176 {\@layoutfloat(#1,#2)}{\@layoutfloat(#1,#2)[c]}}
177 \long\def\@layoutfloat(#1,#2)[#3]#4{%
179 \floatwidth=#1 \floatheight=#2 \edef\float@pos{#3}%
180 \ifdim\floatwidth<\z@
181 \floatwidth\ltjgetwd\z@\floatruletick\z@
183 \ifdim\floatheight<\z@
184 \floatheight\ltjgetht\z@\advance\floatheight\ltjgetdp\z@\relax
187 \setbox\@floatbox\vbox to\floatheight{\offinterlineskip
188 \hrule width\floatwidth height\floatruletick depth\z@
189 \vss\hbox to\floatwidth{%
190 \vrule width\floatruletick height\floatheight depth\z@
191 \hss\vbox to\floatheight{\hsize\floatwidth\vss#4\vss}\hss
192 \vrule width\floatruletick height\floatheight depth\z@
193 }\hrule width\floatwidth height\floatruletick depth\z@}}
194 \def\DeclareLayoutCaption#1<#2>(#3)[#4#5]{%
196 \ifx\csname #1@layoutcaption\endcsname\relax \else
197 \@latex@info{Redeclaring capiton layout setting of '#1'}%
200 \gdef\csname #1@layoutcaption\endcsname{%
201 \if Z\caption@dir\def\caption@dir{#2}\fi
202 \ifdim\captionwidth=\z@ \captionwidth=#3\relax\fi
203 \if Z\caption@posa\def\caption@posa{#4}\fi
204 \if Z\caption@posb\def\caption@posb{#5}\fi}}
205 \@onlypreamble\DeclareLayoutCaption
206 \DeclareLayoutCaption{figure}<y>(.8\linewidth)[cd]
207 \DeclareLayoutCaption{table}<y>(.8\linewidth)[cu]
208 \def\layoutcaption{\def\caption@dir{Z}\captionwidth\z@
209 \def\caption@posa{Z}\def\caption@posb{Z}%
210 \@ifnextchar<\X@layoutcaption{%
211 \@ifnextchar(\@ilayoutcaption{%
212 \@ifnextchar[\@iilayoutcaption\relax}}}
213 \def\X@layoutcaption<#1>{\def\caption@dir{#1}%
214 \@ifnextchar(\@ilayoutcaption{%
215 \@ifnextchar[\@iilayoutcaption\relax}}
216 \def\@ilayoutcaption(#1){\setlength\captionwidth{#1}%
217 \@ifnextchar[{\@iilayoutcaption}{\relax}}
218 \def\@iilayoutcaption[#1#2]{%
219 \def\caption@posa{#1}\def\caption@posb{#2}}
220 \def\pcaption{\refstepcounter\@captype \@dblarg{\@pcaption\@captype}}
221 \long\def\@pcaption#1[#2]#3{%
222 \addcontentsline{\csname ext@#1\endcsname}{#1}{%
223 \protect\numberline{\csname the#1\endcsname}{\ignorespaces#2}}%
225 \latex@error{Use with `\protect\layoutfloat'.}\@eha
227 \make@pcaptionbox{#3}%
229 \setbox\@tempboxa\vbox{\hbox to\hsize{\if l\float@pos\else\hss\fi
230 \if l\caption@posb\box\@captionbox\kern\captionfloatsep\fi
231 \if t\caption@posa\vtop
232 \else\if b\caption@posa\vbox
233 \else\ifmmode\vcenter \else\@pboxswtrue $\vcenter \fi\fi\fi
234 {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi
236 \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}%
237 \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi
238 \if@pboxsw \m@th$\fi \if r\float@pos\else\hss\fi}}%
239 \par\vskip.25\baselineskip
241 \def\make@pcaptionbox#1{%
243 \ifx\csname\@captype @layoutcaption\endcsname\relax
244 \@latex@warning{Default caption layout of `\@captype' unknown.}%
245 \def\caption@dir{Z}\captionwidth\z@
246 \def\caption@posa{Z}\def\caption@posb{Z}%
248 \csname \@captype @layoutcaption\endcsname
251 % \@tempswa: 基本組の組方向とキャプションの組方向が直交するか?
252 \if y\caption@dir \let\captiondir\yoko
253 \ifodd\ltjgetparameter{direction}\relax\@tempswatrue\fi
254 \else\if z\caption@dir \let\captiondir\relax
255 \ifnum\ltjgetparameter{direction}=3\relax\let\captiondir\utod\fi
256 \else\if d\caption@dir \let\captiondir\dtou
257 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
258 \else\if u\caption@dir \let\captiondir\utod
259 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
260 \else\if t\caption@dir \let\captiondir\tate
261 \ifodd\ltjgetparameter{direction}\else\@tempswatrue\fi
263 \setbox0\hbox{\hbox{\captiondir
264 \captionfontsetup\parindent\z@\inhibitglue
265 \csname fnum@\@captype\endcsname #1}}%"
266 \if@tempswa\@tempdima\ltjgetht0\relax\else\@tempdima\ltjgetwd0\relax\fi
267 \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi
270 \if u\caption@posb\vbox
271 \else\if d\caption@posb\vbox
272 \else\if t\caption@posa\vtop
273 \else\if b\caption@posa\vbox
274 \else\ifmmode\vcenter\else\@pboxswtrue $\vcenter\fi
276 {\hsize\@tempdima\kern\z@
277 \vbox{\captiondir\hsize\@tempdima
278 \captionfontsetup\parindent\z@\inhibitglue
279 \csname fnum@\@captype\endcsname #1}\kern\z@
280 }\if@pboxsw \m@th$\fi}%
281 \let\to@captionboxwidth\relax
282 \if l\caption@posb \else\if r\caption@posb\else
283 \def\to@captionboxwidth{to\floatwidth}\fi\fi
284 \setbox\@captionbox\hbox\to@captionboxwidth{%
285 \if t\caption@posa\else\hss\fi
287 \if b\caption@posa\else\hss\fi}}
289 %%% minipage and parbox
290 \def\minipage{\@ifnextchar<%>
291 {\X@minipage}{\X@minipage<Z>}}
292 \def\X@minipage<#1>{\@ifnextchar[%]
293 {\@iminipage<#1>}{\@iiiminipage<#1>{c}\relax[s]}}
294 \def\@iminipage<#1>[#2]{\@ifnextchar[%]
295 {\@iiminipage<#1>{#2}}{\@iiiminipage<#1>{#2}\relax[s]}}
296 \def\@iiminipage<#1>#2[#3]{\@ifnextchar[%]
297 {\@iiiminipage<#1>{#2}{#3}}{\@iiiminipage<#1>{#2}{#3}[#2]}}
298 \def\@iiiminipage<#1>#2#3[#4]#5{%
300 \setlength\@tempdima{#5}%
301 \def\@mpargs{<#1>{#2}{#3}[#4]{#5}}%
304 \ifnum\ltjgetparameter{direction}=3\relax
308 \if #1y\relax \let\box@dir\yoko
309 \else\if #1t\relax\let\box@dir\tate
310 \else\if #1d\relax\let\box@dir\dtou
311 \else\if #1u\relax\let\box@dir\utod
315 \ifcase\ltjgetparameter{direction}\relax
316 \or \let\box@dir\dtou
317 \or\or\let\box@dir\tate
318 \or \let\box@dir\yoko
319 \else \let\box@dir\utod
322 \setbox\@tempboxa\vbox\bgroup\box@dir
326 \textwidth\hsize \columnwidth\hsize
328 \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}%
330 \let\@footnotetext\@mpfootnotetext
331 \let\@listdepth\@mplistdepth \@mplistdepth\z@
337 \ifvoid\@mpfootins\else
338 \vskip\skip\@mpfootins
343 \@minipagefalse %% added 24 May 89
346 \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup}
347 \DeclareRobustCommand\parbox{\@ifnextchar<%>
348 {\X@parbox}{\X@parbox<Z>}}
349 \def\X@parbox<#1>{\@ifnextchar[%]
350 {\@iparbox<#1>}{\@iiiparbox<#1>{c}\relax[s]}}
351 \def\@iparbox<#1>[#2]{\@ifnextchar[%]
352 {\@iiparbox<#1>{#2}}{\@iiiparbox<#1>{#2}\relax[s]}}
353 \def\@iiparbox<#1>#2[#3]{\@ifnextchar[%]%
354 {\@iiiparbox<#1>{#2}{#3}}{\@iiiparbox<#1>{#2}{#3}[#2]}}
355 \long\def\@iiiparbox<#1>#2#3[#4]#5#6{%
357 \setlength\@tempdima{#5}%
358 \fork@parbox@option<#1>[#2]%
359 \@begin@tempboxa\vbox{\box@dir
360 \hsize\@tempdima\@parboxrestore\adjustbaseline#6\@@par}%
362 \setlength\@tempdimb{#3}%
363 \edef\@parboxto{to\the\@tempdimb}%
365 \@begin@parbox\@parboxto{\box@dir\adjustbaseline
366 \let\hss\vss\let\unhbox\unvbox
367 \csname bm@#4\endcsname}\@end@parbox
371 % ↓中身\周囲→ yoko tate utod dtou
376 % A: 周囲と中身の組方向が一致.そのまま \vtop/\vcenter/\vbox
377 % B: 周囲と中身が90度ずれ.上端が和文の高さ or 下端が和文の深さに揃うように
378 % C: 周囲と中身が180度ずれ.(コードは B のものを流用)
379 % D: 上端が和文の高さ or 下端が和文の深さに揃うように(コードは B のものを流用)
381 \def\fork@parbox@option@@A#1{%
382 \let\@end@parbox\relax
383 \if #1t\relax \let\@begin@parbox\vtop
384 \else\if #1b\relax\let\@begin@parbox\vbox
387 \let\@begin@parbox\vcenter\let\@end@parbox\relax
389 \def\@begin@parbox{\null$\vcenter}%
390 \def\@end@parbox{\m@th$\null}%
393 \def\lltjext@getjablshift{%
394 \ifnum\ltj@ext@dir=3 \ltjgetparameter{tjabaselineshift}\else
395 \ltjgetparameter{yjabaselineshift}\fi}
396 \def\fork@parbox@option@@B#1{%
398 \def\@begin@parbox{\raise\dimexpr\cht-\lltjext@getjablshift\vtop\bgroup\kern\z@\vbox}%
399 \let\@end@parbox\egroup
401 \def\@begin@parbox{\lower\dimexpr\cdp+\lltjext@getjablshift\vbox\bgroup\vbox}%
402 \def\@end@parbox{\kern\z@\egroup}%
405 \let\@begin@parbox\vcenter\let\@end@parbox\relax
407 \def\@begin@parbox{\null$\vcenter}%
408 \def\@end@parbox{\m@th$\null}%
411 \let\fork@parbox@option@@C=\fork@parbox@option@@B
412 \def\fork@parbox@option<#1>[#2]{%
413 \let\box@dir\relax \ltj@ext@dir=\ltjgetparameter{direction}\relax
415 \ifnum\ltj@ext@dir=3\relax
419 \if #1y\relax \let\box@dir\yoko
420 \else\if #1t\relax\let\box@dir\tate
421 \else\if #1d\relax\let\box@dir\dtou
422 \else\if #1u\relax\let\box@dir\utod
427 \or \let\box@dir\dtou
428 \or\or\let\box@dir\tate
429 \or \let\box@dir\yoko
430 \else \let\box@dir\utod
433 \ifnum\ltj@ext@dir=4 % yoko
434 \ifx\box@dir\yoko \fork@parbox@option@@A{#2}%
435 \else \fork@parbox@option@@B{#2}%
437 \else\ifnum\ltj@ext@dir=1 % dtou
438 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
439 \else\ifx\box@dir\dtou \fork@parbox@option@@A{#2}%
440 \else \fork@parbox@option@@C{#2}%
442 \else\ifnum\ltj@ext@dir=3 % tate
443 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
444 \else\ifx\box@dir\tate \fork@parbox@option@@A{#2}%
445 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
446 \else \fork@parbox@option@@B{#2}% D
449 \ifx\box@dir\yoko \fork@parbox@option@@B{#2}%
450 \else\ifx\box@dir\utod \fork@parbox@option@@A{#2}%
451 \else\ifx\box@dir\dtou \fork@parbox@option@@C{#2}%
452 \else \fork@parbox@option@@B{#2}% D
457 \DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox<Z>}}
458 \def\X@makePbox<#1>{%
459 \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}}
460 \def\@imakePbox<#1>[#2]{\@ifnextchar[%]
461 {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}}
462 \def\@iimakePbox<#1>#2[#3]#4{%
463 \bgroup\let\box@dir\relax
465 \ifnum\ltjgetparameter{direction}=3 \relax
469 \if #1y\relax \let\box@dir\yoko
470 \else\if #1t\relax\let\box@dir\tate
471 \else\if #1d\relax\let\box@dir\dtou
472 \else\if #1u\relax\let\box@dir\utod
476 \ifcase\ltjgetparameter{direction}
477 \or \let\box@dir\dtou
478 \or\or\let\box@dir\tate
479 \or \let\box@dir\yoko
480 \else \let\box@dir\utod
483 \setlength{\@tempdima}{#2}%
484 \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else
485 \hb@xt@\@tempdima{\box@dir
486 \if #3l\relax\else\hss\fi
488 \if #3r\relax\else\hss\fi}\fi\egroup}
491 \def\picture{\@ifnextchar<%>
492 {\X@picture}{\X@picture<Z>}}
493 \def\X@picture<#1>(#2,#3){\@ifnextchar(%)
494 {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}}
496 \def\ltj@@pic@reset@blshift{%
497 \ltj@yablshift\z@\ltj@ykblshift\z@
498 \ltj@tablshift\z@\ltj@tkblshift\z@
500 \def\@@picture<#1>(#2,#3)(#4,#5){%
501 \edef\ltj@@pic@save@blshift{%
502 \noexpand\ltj@yablshift\the\ltj@yablshift\noexpand\relax
503 \noexpand\ltj@ykblshift\the\ltj@ykblshift\noexpand\relax
504 \noexpand\ltj@tablshift\the\ltj@tablshift\noexpand\relax
505 \noexpand\ltj@tkblshift\the\ltj@tkblshift\noexpand\relax
507 \bgroup\let\box@dir\relax
509 \ifnum\ltjgetparameter{direction}=3 \relax
513 \if #1y\relax \let\box@dir\yoko
514 \else\if #1t\relax\let\box@dir\tate
515 \else\if #1d\relax\let\box@dir\dtou
516 \else\if #1u\relax\let\box@dir\utod
520 \ifcase\ltjgetparameter{direction}
521 \or \let\box@dir\dtou
522 \or\or\let\box@dir\tate
523 \or \let\box@dir\yoko
524 \else \let\box@dir\utod
527 \@picwd=#2\unitlength \@picht=#3\unitlength
528 \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
529 \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
530 \ltj@@pic@reset@blshift
534 \setbox0=\hbox{\box@dir%
535 \ltjsetht\@picbox\@picht \ltjsetdp\@picbox\z@
538 \ifnum\ltjgetparameter{direction}=3 \@tempswatrue\fi
539 \ifnum\ltjgetparameter{direction}=11 \@tempswatrue\fi
541 \ifx\box@dir\yoko % この場合だけ垂直位置補正が必要
542 \ltjsetht\@picbox\dimexpr\ltjgetht\@picbox+\ltjgetdp\@picbox\relax
547 \egroup\ltj@@pic@save@blshift}
549 \def\put{\ltj@@pic@reset@blshift\org@put}
551 \def\line{\ltj@@pic@reset@blshift\org@line}
552 \let\org@vector\vector
553 \def\vector{\ltj@@pic@reset@blshift\org@vector}
554 \let\org@dashbox\dashbox
555 \def\dashbox{\ltj@@pic@reset@blshift\org@dashbox}
557 \def\oval{\ltj@@pic@reset@blshift\org@oval}
558 \let\org@circle\circle
559 \def\circle{\ltj@@pic@reset@blshift\org@circle}
562 \newif\ifnot@advanceline
564 \rensujiskip=0.25\chs plus.25\zw minus.25\zw
565 \DeclareRobustCommand\rensuji{%
566 \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}}
567 \def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}}
568 \def\@@rensuji[#1]#2{%
569 \ifvmode\leavevmode\fi
570 \ifnum\ltjgetparameter{direction}=4\relax\hbox{#2}\else
572 \setbox\tw@\hbox{漢}% 「あ」では仮名書体使用時がまずそう
573 \@tempdimb\ltjgetht\tw@ \advance\@tempdimb\ltjgetdp\tw@
574 \ifnot@advanceline\not@advancelinefalse\else
575 \setbox\z@\hbox{\yoko#2}%
576 \@tempdima\ltjgetht\z@ \advance\@tempdima\ltjgetdp\z@
577 \ifnum\ltjgetparameter{direction}=1\relax
578 % 周囲が dtou の場合には,高さ \ltjgetht\tw@, 深さ \ltjgetdp\tw@ のボックスを基準としている.
579 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
580 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
581 \else\if #1l\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
582 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
585 % 周囲が tate, utod の場合も同じ
586 \if #1c\relax\vrule \@width \z@ \@height\dimexpr.5\@tempdima+.5\ltjgetht\tw@-.5\ltjgetdp\tw@
587 \@depth\dimexpr.5\@tempdima-.5\ltjgetht\tw@+.5\ltjgetdp\tw@
588 \else\if #1r\relax\vrule\@width \z@\@height\ltjgetht\tw@ \@depth\dimexpr\@tempdima-\ltjgetht\tw@
589 \else\vrule\@width \z@ \@height\dimexpr\@tempdima-\ltjgetdp\tw@ \@depth\ltjgetdp\tw@
593 \ifnum\ltjgetparameter{direction}=1\relax
594 \if #1c\relax\hbox to\@tempdimb{\yoko\hss#2\hss\kern-\ltjgetdp\tw@}%
595 \else\if #1r\relax\vbox{\hbox to\@tempdimb{\yoko\hss#2\kern-\ltjgetdp\tw@}}%
596 \else\lower\ltjgetdp\tw@\vtop{\hbox to\@tempdimb{\yoko#2\hss}}%
599 \if #1c\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
600 \hbox to\@tempdimb{\yoko \hss#2\hss}%
601 \else\if #1r\relax\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
602 \vbox{\hbox to\@tempdimb{\yoko\hss#2}}%
603 \else\raise\dimexpr.5\@tempdimb-\ltjgetdp\tw@
604 \vtop{\hbox to\@tempdimb{\yoko #2\hss}}%
610 \let\prensuji\rensuji
613 \def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname}
614 \def\@Kanji#1{\kansuji #1}
615 \def\kanji{\ifnum\ltjgetparameter{direction}=3 \expandafter\kansuji\fi}
619 \def\boutenchar{\char\euc"A1A2}%"
620 \def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end}
622 \ifx#1\end \let\ltj@@next=\relax
624 \ifnum\ltjgetparameter{direction}=3\relax
625 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
626 \vss\moveleft0.2\zw\hbox{\yoko\boutenchar}\nointerlineskip
627 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
629 \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen
630 \vss\moveleft-0.2\zw\hbox{\boutenchar}\nointerlineskip
631 \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax
638 \ifnum\ltjgetparameter{direction}=3\relax
639 \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
640 \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
642 \else\underline{#1}\fi}
645 \def\@eqnnum{{\reset@font\rmfamily \normalcolor
646 \ifnum\ltjgetparameter{direction}=11\raise.25\zh\hbox{\yoko(\theequation)}%
647 \else (\theequation)\fi}}
648 \def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
649 \def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}}
651 %% Compatibility with array package
653 \def\ltj@lltjext@patch@array{%
654 \patchcmd{\@tabular}{\hbox\bgroup}{%
655 \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{\typeout{SUCC}}{}
657 {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
658 \def\@startpbox##1{\bgroup
659 \box@dir\adjustbaseline%%% これを追加
660 \setlength\hsize{##1}\@arrayparboxrestore
662 \vrule \@height \ltjgetht\@arstrutbox \@width \z@
665 \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
666 \def\p@array<##1>[##2]##3{%
669 \ifnum\ltj@ext@dir=3\relax
670 \let\box@dir\utod\@tempcnta=\zstrutbox
674 \let\box@dir\yoko\@tempcnta=\ystrutbox
676 \let\box@dir\tate\@tempcnta=\tstrutbox
678 \let\box@dir\dtou\@tempcnta=\dstrutbox
680 \let\box@dir\utod\@tempcnta=\zstrutbox
685 \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou
686 \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate
687 \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko
688 \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
691 \setbox \@arstrutbox \hbox{\box@dir\vrule
692 \@height \arraystretch
693 \dimexpr \ltjgetht\@tempcnta+\extrarowheight\relax
694 \@depth \arraystretch \ltjgetdp \@tempcnta
696 \fork@array@option<##1>[##2]%
699 \xdef\@preamble{\ialign \noexpand \@halignto
700 \bgroup \tabskip \z@skip \@arstrut \@preamble
704 \@begin@alignbox\bgroup\box@dir\adjustbaseline
706 \let\@sharp####\let\protect\relax
707 \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
708 \lineskip\z@skip\baselineskip\z@skip\@preamble}
709 \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
712 \@ifpackageloaded{array}{%
713 \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
714 \let\tabular=\ltj@lltjext@orig@tabular
715 \let\array=\ltj@lltjext@orig@array
716 \ltj@lltjext@patch@array
718 \let\ltj@lltjext@orig@tabularS\relax
719 \let\ltj@lltjext@orig@tabular\relax
720 \let\ltj@lltjext@orig@array\relax
721 \RequirePackage{filehook,etoolbox}
722 \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
725 %%%%%%%%%%%%%%%% LuaTeX-ja original
727 %%\define@key[ltj]{japaram}{autouprightnum}{% %COUNT
728 %% \ltj@@set@stack{AURN}{0}{10000}\z@#1 }