OSDN Git Service

Revert "lltjcore.sty: \null in \@gnewline breaks JFM glue at the beginning of a line"
[luatex-ja/luatexja.git] / src / patches / lltjcore.sty
index 63ba233..a6b71f3 100644 (file)
@@ -1,10 +1,10 @@
 %
 % lltjcore.sty: derived from plcore.dtx in pLaTeX.
-% This file does not include the code relating to "tategaki".
-% 
+%
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjcore}[2015/01/01 Patch to LaTeX2e Kernel for LuaTeX-ja]
+\ProvidesPackage{lltjcore}[2019/09/26 Patch to LaTeX2e Kernel for LuaTeX-ja]
+\RequirePackage{etoolbox}
 
 \def\cleardoublepage{\clearpage\if@twoside
   \ifodd\c@page
 \@bannertoken{}
 \def\maketombowbox{%
   \setbox\@TL\hbox to\z@{\yoko\hss
-      \vrule width13mm height\@tombowwidth depth\z@
+      \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@
       \vrule height10mm width\@tombowwidth depth\z@
       \iftombowdate
         \raise4pt\hbox to\z@{\hskip5mm\@bannerfont\the\@bannertoken\hss}%
       \fi}%
   \setbox\@Tl\hbox to\z@{\yoko\hss
       \vrule width10mm height\@tombowwidth depth\z@
-      \vrule height13mm width\@tombowwidth depth\z@}%
+      \vrule height\dimexpr 10mm+\@tombowbleed\relax  width\@tombowwidth depth\z@}%
   \setbox\@TC\hbox{\yoko
       \vrule width10mm height\@tombowwidth depth\z@
       \vrule height10mm width\@tombowwidth depth\z@
       \vrule width10mm height\@tombowwidth depth\z@}%
   \setbox\@TR\hbox to\z@{\yoko
       \vrule height10mm width\@tombowwidth depth\z@
-      \vrule width13mm height\@tombowwidth depth\z@\hss}%
+      \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@\hss}%
   \setbox\@Tr\hbox to\z@{\yoko
-      \vrule height13mm width\@tombowwidth depth\z@
+      \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@
       \vrule width10mm height\@tombowwidth depth\z@\hss}%
   \setbox\@BL\hbox to\z@{\yoko\hss
-      \vrule width13mm depth\@tombowwidth height\z@
+      \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@
       \vrule depth10mm width\@tombowwidth height\z@}%
   \setbox\@Bl\hbox to\z@{\yoko\hss
       \vrule width10mm depth\@tombowwidth height\z@
-      \vrule depth13mm width\@tombowwidth height\z@}%
+      \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@}%
   \setbox\@BC\hbox{\yoko
       \vrule width10mm depth\@tombowwidth height\z@
       \vrule depth10mm width\@tombowwidth height\z@
       \vrule width10mm depth\@tombowwidth height\z@}%
   \setbox\@BR\hbox to\z@{\yoko
       \vrule depth10mm width\@tombowwidth height\z@
-      \vrule width13mm depth\@tombowwidth height\z@\hss}%
+      \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@\hss}%
   \setbox\@Br\hbox to\z@{\yoko
-      \vrule depth13mm width\@tombowwidth height\z@
+      \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@
       \vrule width10mm depth\@tombowwidth height\z@\hss}%
   \setbox\@CL\hbox to\z@{\yoko\hss
       \vrule width10mm height.5\@tombowwidth depth.5\@tombowwidth
 }
 \def\@outputtombow{%
   \iftombow
-  \vbox to\z@{\kern-13mm\relax
-    \moveleft3mm\vbox to\@@paperheight{%
-      \hbox to\@@paperwidth{\hskip3mm\relax
-         \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip3mm}%
+  \vbox to\z@{\kern-\dimexpr 10mm+\@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}%
       \vfill
       \vfill
       \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
       \kern-10mm
-      \hbox to\@@paperwidth{\hskip3mm\relax
-         \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip3mm}%
+      \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
+         \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip\@tombowbleed}%
+       \color@endgroup
     }\vss
   }%
   \fi
 }
+\def\@tombowcolor{\normalcolor}
+\def\@tombowbleed{3mm}
+\def\@tombowreset@@paper{%
+     \@@topmargin\topmargin
+     \iftombow
+       \@@paperwidth\paperwidth
+          \advance\@@paperwidth 2\dimexpr\@tombowbleed\relax
+       \@@paperheight\paperheight\advance\@@paperheight 10mm\relax
+          \advance\@@paperheight 2\dimexpr\@tombowbleed\relax
+       \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
+     \fi
+}
 \newdimen\@@paperheight
 \newdimen\@@paperwidth
 \newdimen\@@topmargin
     \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
   \fi
   \let \protect \noexpand
+  \language\document@default@language %LaTeX2e 2017/05/01
   \@resetactivechars
   \global\let\@@if@newlist\if@newlist
   \global\@newlistfalse
            \ifnum\ltjgetparameter{direction}=3 \let\@themargin\oddsidemargin
            \else\let\@themargin\evensidemargin\fi
      \fi\fi
-     \@@topmargin\topmargin
-     \iftombow
-       \@@paperwidth\paperwidth \advance\@@paperwidth 6mm\relax
-       \@@paperheight\paperheight \advance\@@paperheight 16mm\relax
-       \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
-     \fi
+     \@tombowreset@@paper
      \reset@font
      \normalsize
      \normalsfcodes
   \stepcounter{page}%
   \let\firstmark\botmark
 }
-\renewcommand\@makefnmark{\hbox{%
+
+%%% Remove extra xkanjiskip
+\renewcommand\@makefnmark{%
   \unless\ifnum\ltjgetparameter{direction}=3
-    \@textsuperscript{\normalfont\@thefnmark}%
-  \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}}
-\long\def\@footnotetext#1{%
-  \ifcase\ltjgetparameter{direction}%
-    \or   \let\@tempa\dtou
-    \or\or\let\@tempa\tate
-    \or   \let\@tempa\yoko
-    \else \let\@tempa\utod
-  \fi
-  \insert\footins{\@tempa%
-    \reset@font\footnotesize
-    \interlinepenalty\interfootnotelinepenalty
-    \splittopskip\footnotesep
-    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-       \csname p@footnote\endcsname\@thefnmark
-    }%
-    \color@begingroup
-      \@makefntext{%
-        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
-    \color@endgroup}}
-\def\@footnotemark{\leavevmode
-  \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
-  \unless\ifnum\ltjgetparameter{direction}=3 \@makefnmark
-  \else\hbox to\z@{\hskip-.25\zw\raise.9\zh\@makefnmark\hss}\fi
-  \ifhmode\spacefactor\@x@sf\fi\relax}
-\def\@setref#1#2#3{%
+    \hbox{}\hbox{\@textsuperscript{\normalfont\@thefnmark}}\hbox{}%
+  \else\hbox{\yoko \@textsuperscript{\normalfont\@thefnmark}}\fi}
+\begingroup
+\@ifpackageloaded{hyperref}
+  {\def\ltj@setrefprefix{real}}
+  {\def\ltj@setrefprefix{}}
+\expandafter\gdef\csname \ltj@setrefprefix @setref\endcsname#1#2#3{%
   \ifx#1\relax
     \protect\G@refundefinedtrue
     \nfss@text{\reset@font\bfseries ??}%
     \@latex@warning{Reference `#3' on page \thepage \space
               undefined}%
   \else
-    \expandafter#2#1\relax% change \null to \relax
+    \expandafter#2#1\protect\@setref@{}% change \null to \protect\@setref@{}
   \fi}
+\gdef\@setref@{\ifhmode\spacefactor\@m\fi}
+\endgroup
 \if@compatibility\else
-\def\verb{\relax\ifmmode\hbox\else\leavevmode\fi
+\def\verb{\relax\ifmmode\hbox\else\leavevmode\vadjust{}\fi
   \bgroup
     \verb@eol@error \let\do\@makeother \dospecials
     \verbatim@font\@noligs
+    \language\l@nohyphenation
     \@ifstar\@sverb\@verb}
 \fi
-\gdef\@stopfield{\null\color@endgroup\egroup}
-\newcount\hour
-\newcount\minute
+\patchcmd{\do@noligs}{\kern\z@}{\vadjust{}}{}{} % reported by p_typo
+\gdef\@stopfield{%
+  \inhibitglue\@tempskipa\lastskip\unskip
+  \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
+\long\def\@iiiparbox#1#2[#3]#4#5{%
+  \leavevmode
+  \@pboxswfalse
+  \setlength\@tempdima{#4}%
+  \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
+    \ifx\relax#2\else
+      \setlength\@tempdimb{#2}%
+      \edef\@parboxto{to\the\@tempdimb}%
+    \fi
+    \if#1b\vbox
+    \else\if #1t\vtop
+    \else\ifmmode\vcenter
+    \else\@pboxswtrue\null$\vcenter% !!!
+    \fi\fi\fi
+    \@parboxto{\let\hss\vss\let\unhbox\unvbox
+       \csname bm@#3\endcsname}%
+    \if@pboxsw \m@th$\null\fi% !!!
+  \@end@tempboxa}
+\DeclareRobustCommand\underline[1]{%
+  \relax
+  \ifmmode\@@underline{#1}%
+  \else \leavevmode\null$\@@underline{\hbox{#1}}\m@th$\null\relax\fi}
 
 %%% AtBeginDvi
-\def \AtBeginDvi #1{%
+\DeclareRobustCommand \AtBeginDvi [1]{%
   \global \setbox \@begindvibox
     \vbox{\yoko\unvbox \@begindvibox #1}%
 }
 
+\newif\iffnfixbottom
+\newif\ifltj@ftn@unvboxed
 %%% @makecol
 \gdef \@makecol {%
    \ifvoid\footins
+     \ltj@ftn@unvboxedfalse
      \setbox\@outputbox \box\@cclv
    \else
+     \ltj@ftn@unvboxedtrue
      \setbox\@outputbox \vbox {%
        \boxmaxdepth \@maxdepth
        \unvbox \@cclv
+       \iffnfixbottom\vskip\z@ \@plus.0001fil\fi
        \vskip \skip\footins
        \color@begingroup
          \normalcolor
        \@texttop
        \dimen@ \dp\@outputbox
        \unvbox \@outputbox
-       \ifnum\ltjgetparameter{direction}=4\else\hskip\z@\fi %%% LuaTeX-ja
+       \ifnum\ltjgetparameter{direction}=4\else\vbox{\hskip\z@}\fi %%% LuaTeX-ja
        \vskip -\dimen@
-       \@textbottom
+       \ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi
        }%
    \fi
    \global \maxdepth \@maxdepth
 }
+\let\ltj@orig@makecol=\@makecol
+
+\patchcmd\@makespecialcolbox{\@textbottom}{\ifltj@ftn@unvboxed\iffnfixbottom\else\@textbottom\fi\else\@textbottom\fi}{}{}
+
+\def\@gnewline #1{%
+  \ifvmode
+    \@nolnerr
+  \else
+    \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break \null
+    % \null は \break の効果が行頭禁則文字で打ち消されないために必要
+  \ignorespaces
+\fi}
+
+
+%%%%%% tabular (platex/#43) \@tabclassz
+\def\ltj@sharp{\relax\pltx@next@inhibitglue\ltjfakeboxbdd\ignorespaces\@sharp\unskip\ltjfakeboxbdd}
+\def\@tabclassz{%
+  \ifcase\@lastchclass
+    \@acolampacol
+  \or
+    \@ampacol
+  \or
+  \or
+  \or
+    \@addamp
+  \or
+    \@acolampacol
+  \or
+    \@firstampfalse\@acol
+  \fi
+  \edef\@preamble{%
+    \@preamble{%
+      \ifcase\@chnum
+        \hfil\hskip1sp\ltj@sharp\hfil
+      \or
+        \hskip1sp\ltj@sharp\hfil
+      \or
+        \hfil\hskip1sp\ltj@sharp
+      \fi}}}
+\patchcmd\@classv{%
+   \ignorespaces\@sharp
+}{%
+   \everypar\expandafter{\the\everypar\ltjfakeboxbdd}\ignorespaces\@sharp\unskip
+}{}{}
+\patchcmd{\@tabular}{\leavevmode}{\leavevmode\null}{}{}
+\apptocmd{\endtabular}{\null}{}{}
+\expandafter \let \csname endtabular*\endcsname = \endtabular
 
+%%%%%% tabbing (platex/#53)
+\patchcmd\@startline{\strut}{\strut\inhibitglue}{}{}
+\def\ltj@unhbox@curfield{\ltjfakeboxbdd\unhbox\@curfield\ltjfakeboxbdd}
+%\patchcmd\@contfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}
+\patchcmd\@addfield{\unhbox\@curfield}{\ltj@unhbox@curfield}{}{}
 \endinput