OSDN Git Service

small fix
[luatex-ja/luatexja.git] / src / lltjext.sty
index b0796ac..9fe18f4 100644 (file)
@@ -3,12 +3,9 @@
 %
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjext}[2018/09/21 v1.2j-ltj-9 Macros for vertical writing]
+\ProvidesPackage{lltjext}[2020-09-30 v1.2k-ltj-12 Macros for vertical writing]
 \RequirePackage{luatexja}
 \newcount\ltj@ext@dir
-{\catcode`\*=11
-\global\let\ltj@lltjext@orig@tabularS=\tabular*
-}%
 \let\ltj@lltjext@orig@tabular=\tabular
 \let\ltj@lltjext@orig@array=\array
 
@@ -20,6 +17,9 @@
 \def\tabular{\let\@halignto\@empty\X@tabular}
 \@namedef{tabular*}{\@ifnextchar<%>
    {\p@stabular}{\p@stabular<Z>}}
+{\catcode`\*=11
+\global\let\ltj@lltjext@orig@tabularS=\tabular*
+}%
 \def\X@tabarray{\@ifnextchar<%>
    {\p@tabarray}{\p@tabarray<Z>}}
 \def\X@tabular{\@ifnextchar<%>
@@ -36,7 +36,6 @@
    {\p@array<#1>}{\p@array<#1>[c]}}
 
 \def\p@array<#1>[#2]#3{%
-  \fork@array@option<#1>[#2]\@begin@alignbox
   \let\box@dir\relax
   \if #1z\relax
     \ifnum\ltj@ext@dir=3\relax
@@ -61,6 +60,7 @@
        \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod
     \fi
   \fi
+  \fork@array@option<#1>[#2]\@begin@alignbox
   \bgroup\box@dir\adjustbaseline
   \setbox\@arstrutbox\hbox{%
     \box@dir
     }\hrule width\floatwidth height\floatruletick depth\z@}}
 \def\DeclareLayoutCaption#1<#2>(#3)[#4#5]{%
   \expandafter
-  \ifx\csname #1@layoutcaption\endcsname\relax \else
+  \ifx\csname #1@layoutc@ption\endcsname\relax \else
     \@latex@info{Redeclaring capiton layout setting of '#1'}%
   \fi
   \expandafter
-  \gdef\csname #1@layoutcaption\endcsname{%
+  \gdef\csname #1@layoutc@ption\endcsname{%
      \if Z\caption@dir\def\caption@dir{#2}\fi
      \ifdim\captionwidth=\z@ \captionwidth=#3\relax\fi
      \if Z\caption@posa\def\caption@posa{#4}\fi
      \if Z\caption@posb\def\caption@posb{#5}\fi}}
 \@onlypreamble\DeclareLayoutCaption
-\DeclareLayoutCaption{figure}<y>(.8\linewidth)[cd]
-\DeclareLayoutCaption{table}<y>(.8\linewidth)[cu]
+\DeclareLayoutCaption{figure}<n>(.8\linewidth)[cd]
+\DeclareLayoutCaption{table}<n>(.8\linewidth)[cu]
 \def\layoutcaption{\def\caption@dir{Z}\captionwidth\z@
   \def\caption@posa{Z}\def\caption@posb{Z}%
   \@ifnextchar<\X@layoutcaption{%
     \if l\caption@posb\box\@captionbox\kern\captionfloatsep\fi
     \if t\caption@posa\vtop
     \else\if b\caption@posa\vbox
-    \else\ifmmode\vcenter \else\@pboxswtrue $\vcenter \fi\fi\fi
+    \else\@pboxswtrue $\vcenter \fi\fi
     {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi
      \unvbox\@floatbox
      \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}%
+    \if@pboxsw \m@th$\fi
     \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi
-    \if@pboxsw \m@th$\fi \if r\float@pos\else\hss\fi}}%
+    \if r\float@pos\else\hss\fi}}%
   \par\vskip.25\baselineskip
   \box\@tempboxa}
 \def\make@pcaptionbox#1{%
   \expandafter
-  \ifx\csname\@captype @layoutcaption\endcsname\relax
+  \ifx\csname\@captype @layoutc@ption\endcsname\relax
      \@latex@warning{Default caption layout of `\@captype' unknown.}%
        \def\caption@dir{Z}\captionwidth\z@
        \def\caption@posa{Z}\def\caption@posb{Z}%
   \else
-     \csname \@captype @layoutcaption\endcsname
+     \csname \@captype @layoutc@ption\endcsname
   \fi
   \@tempswafalse
   % \@tempswa: 基本組の組方向とキャプションの組方向が直交するか?
   \setbox0\hbox{\hbox{\captiondir
      \captionfontsetup\parindent\z@\inhibitglue
      \csname fnum@\@captype\endcsname  #1}}%"
-  \if@tempswa\@tempdima\ltjgetht0\relax\else\@tempdima\ltjgetwd0\relax\fi
+  \if@tempswa\@tempdima\ltjgetht0 \advance\@tempdima\ltjgetdp0
+  \else\@tempdima\ltjgetwd0 \fi
   \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi
   \@pboxswfalse
   \setbox0\hbox{%
        \else \let\box@dir\utod
     \fi
   \fi
+\ifltj@ltfilehook@avail % LaTeX2e >= 2020-10-01
+  \@defaultunitsset\@picht{#3}\unitlength
+  \@defaultunitsset\@picwd{#2}\unitlength
+  \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
+    \@defaultunitsset\@tempdimc{#4}\unitlength\hskip-\@tempdimc
+    \@defaultunitsset\@tempdimc{#5}\unitlength\lower\@tempdimc\hbox\bgroup
+\else % <= 2020-02-02
   \@picwd=#2\unitlength \@picht=#3\unitlength
   \setbox\@picbox\hbox to\@picwd\bgroup\box@dir
   \hskip-#4\unitlength\lower#5\unitlength\hbox\bgroup
+\fi
   \ltj@@pic@reset@blshift
   \ignorespaces}
 \def\endpicture{%
 %%% bou
 %%%
 \def\boutenchar{\char\euc"A1A2}%"
-\def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end}
+\DeclareRobustCommand\bou[1]{\ifvmode\leavevmode\fi\@bou#1\end}
 \def\@bou#1{%
   \ifx#1\end \let\ltj@@next=\relax
   \else
   \fi\ltj@@next}
 
 %%% kasen
-\def\kasen#1{%
+\DeclareRobustCommand\kasen[1]{%
   \ifnum\ltjgetparameter{direction}=3\relax
     \setbox\z@\hbox{#1}\leavevmode\raise.7\zw
     \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
        \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{}{}
   \pretocmd{\array}%
        {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{}
+  \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
+  \patchcmd{\p@stabular}{\p@tabular}{\@tabular}{}{}
+  \@ifpackagelater{array}{2018/09/13}
+    {\expandafter\@firstoftwo}
+    {\expandafter\@secondoftwo}
+  {% = for 2018/09/13 v2.4i or newer
+  \def\@startpbox##1{\bgroup
+    \color@begingroup
+    \box@dir\adjustbaseline%%% これを追加
+    \setlength\hsize{##1}\@arrayparboxrestore
+      \everypar{%
+         \vrule \@height \ltjgetht\@arstrutbox \@width \z@
+         \everypar{}}%
+      }%
+  }{ % = for 2018/04/30 v2.4h or older
   \def\@startpbox##1{\bgroup
-   \box@dir\adjustbaseline%%% これを追加
-   \setlength\hsize{##1}\@arrayparboxrestore
-     \everypar{%
-        \vrule \@height \ltjgetht\@arstrutbox \@width \z@
-        \everypar{}}%
-     }
-  \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
+    \box@dir\adjustbaseline%%% これを追加
+    \setlength\hsize{##1}\@arrayparboxrestore
+      \everypar{%
+         \vrule \@height \ltjgetht\@arstrutbox \@width \z@
+         \everypar{}}%
+      }%
+  }%
+  \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<Z>}}
   \def\p@array<##1>[##2]##3{%
     \let\box@dir\relax
     \if ##1z\relax
       \let\\\@arraycr\let\tabularnewline\\\let\par\@empty
      \lineskip\z@skip\baselineskip\z@skip\@preamble}
   \def\endarray{\crcr\egroup\egroup\@end@alignbox\@arrayright}
-  \@namedef{tabular*}{\@ifnextchar<{\p@stabular}{\p@stabular<Z>}}%>
-  \def\p@stabular<##1>##2{%
-    \setlength\dimen@{##2}%
-    \edef\@halignto{to\the\dimen@}\@tabular<##1>}
 }
-
 \@ifpackageloaded{array}{%
-  \expandafter\let\csname tabular*\endcsname=\ltj@lltjext@orig@tabularS
   \let\tabular=\ltj@lltjext@orig@tabular
   \let\array=\ltj@lltjext@orig@array
   \ltj@lltjext@patch@array
 }{%
-  \let\ltj@lltjext@orig@tabularS\relax
   \let\ltj@lltjext@orig@tabular\relax
   \let\ltj@lltjext@orig@array\relax
-  \RequirePackage{filehook,etoolbox}
-  \AtEndOfPackageFile{array}{\ltj@lltjext@patch@array}
+  \ltj@ExecuteAfterPackage{array}{\ltj@lltjext@patch@array}
 }
 
 %%%%%%%%%%%%%%%% LuaTeX-ja original