OSDN Git Service

gh #3
[luatex-ja/luatexja.git] / src / patches / lltjcore.sty
index 19b365a..111e59b 100644 (file)
@@ -3,7 +3,7 @@
 %
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjcore}[2021-03-25 Patch to LaTeX2e Kernel for LuaTeX-ja]
+\ProvidesPackage{lltjcore}[2023-02-26 Patch to LaTeX2e Kernel for LuaTeX-ja]
 \RequirePackage{etoolbox}
 
 %%% expl3
 }
 \def\@outputtombow{%
   \iftombow
-  \vbox to\z@{\kern\dimexpr-10mm-\@tombowbleed\relax
+  \vbox to\z@{\kern-\@tombowbleed\relax
     \boxmaxdepth\maxdimen
       \moveleft\@tombowbleed\vbox to\@@paperheight{%
          \color@begingroup
          \@tombowcolor
-      \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
-         \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip\@tombowbleed}%
-      \kern-10mm%
-      \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
+      \setbox\z@\hbox to\@@paperwidth{\hskip\@tombowbleed\relax
+         \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip\@tombowbleed}
+      \ht\z@=\z@\dp\z@=\z@\box\z@%
+      \kern\@tombowbleed
+      \setbox\z@\hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
+      \ht\z@=\z@\dp\z@=\z@\box\z@%
       \vfill
-      \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
+      \setbox\z@\hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
+      \ht\z@=\z@\dp\z@=\z@\box\z@%
       \vfill
-      \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
-      \kern-10mm%
-      \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
+      \setbox\z@\hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
+      \ht\z@=\z@\dp\z@=\z@\box\z@
+      \kern\@tombowbleed
+      \setbox\z@\hbox to\@@paperwidth{\hskip\@tombowbleed\relax
          \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip\@tombowbleed}%
+      \ht\z@=\z@\dp\z@=\z@\box\z@%
+      \kern\dimexpr10mm%
       \color@endgroup
     }\vss
   }%
 \patchcmd\@outputpage{\reset@font}{\@tombowreset@@paper\reset@font}{}{}
 \patchcmd\@outputpage{\@begindvi}{\@begindvi\@outputtombow}{}{}
 
+%
+\pretocmd\@floatboxreset{\pltx@save@float@dir}{}{}
+\patchcmd\@endfloatbox{\outer@nobreak}{\outer@nobreak\pltx@check@float@dir}{}{}
+\def\pltx@save@float@dir{%
+  \edef\pltx@float@dir@first{\ltjgetparameter{direction}}}
+\def\pltx@check@float@dir{%
+  \ifx\pltx@float@dir@first\@undefined\else
+    \ifnum\ltjgetparameter{direction}=\pltx@float@dir@first\else
+      \pltx@err@float@dir
+    \fi
+  \fi}
+\def\pltx@err@float@dir{%
+  \@latex@error{Direction change inside float!?\MessageBreak
+    Use \noexpand\layoutcaption provided in \string\usepackage{lltjext}}\@ehc}
 %%% Remove extra xkanjiskip
 \renewcommand\@makefnmark{%
   \unless\ifnum\ltjgetparameter{direction}=3
   \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}
 \begingroup
 \@ifpackageloaded{hyperref}
-  {\def\ltj@setrefprefix{real}}
+  {\ifdefined\real@setref\def\ltj@setrefprefix{real}\else\def\ltj@setrefprefix{}\fi}
   {\def\ltj@setrefprefix{}}
 \expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
   \ifx#1\relax
   \hskip\@tempskipa\color@endgroup\egroup}
 \pretocmd{\footnote}{\inhibitglue}{}{}
 \pretocmd{\footnotemark}{\inhibitglue}{}{}
-\patchcmd{\@footnotemark}{\@makefnmark}{%
-  \unless\ifnum\ltjgetparameter{direction}=3 \@makefnmark%
-  \else\hbox to\z@{\hskip-.25\zw\raise.9\zh\@makefnmark\hss}\fi%
-}{}{}
-\let\@parboxto\@empty
+\def\@ltj@process@makefnmark#1{%
+  \unless\ifnum\ltjgetparameter{direction}=3 #1%
+  \else\hbox to\z@{\hskip-.25\zw\raise.9\zh#1\hss}\fi%
+}%
+\ifdefined\@kernel@process@makefnmark %% 2022-06-01 latex-lab?
+  \let\ltj@orig@kernel@process@makefnmark=\@kernel@process@makefnmark
+  \def\@kernel@process@makefnmark#1{\ltj@orig@kernel@process@makefnmark{\@ltj@process@makefnmark#1}}
+\else
+  \patchcmd{\@footnotemark}{\@makefnmark}{\@ltj@process@makefnmark\@makefnmark}{}{}
+\fi
 \long\def\@iiiparbox#1#2[#3]#4#5{%
   \leavevmode
   \@pboxswfalse