OSDN Git Service

Added lltjp-everyshi.sty
[luatex-ja/luatexja.git] / src / ltj-latex.sty
index d43eab7..ca774fe 100644 (file)
@@ -8,32 +8,16 @@
 \edef\ltj@latex@AtEnd{%
 \endlinechar=\the\endlinechar
 \relax}
-\endlinechar=-1 %
+\endlinechar\m@ne%
 \def\luatexjalatexLoaded{\endinput}
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{ltj-latex}[2013/05/14 LaTeX support of LuaTeX-ja]
+\ProvidesPackage{ltj-latex}[2020-05-17 LaTeX support of LuaTeX-ja]
 
-% I (HK) don't know why the code below is not necessary.
+% cleanup at end of the document
 %\let\ltj@@orig@end=\@@end
-%\outer\protected\def\@@end{%
-%  \directlua{luatexja.direction.remove_end_whatsit()}\ltj@@orig@end}
-
-% Globally add to the head of a macro (cf. LaTeX2e's \g@addto@macro)
-\long\def\ltj@g@addto@macro#1#2{
-  \begingroup
-    \def\ltj@tmpa{#2}
-    \toks@\expandafter\expandafter\expandafter{\expandafter\ltj@tmpa#1}
-    \xdef#1{\the\toks@}
-  \endgroup}
-
-\def\ltj@AtBeginDocument{\ltj@g@addto@macro\@begindocumenthook}
-
-\def\ltj@pkgpatch#1{\ltj@AtBeginDocument{\@ifpackageloaded{#1}{\usepackage{lltjp-#1}}{}}}
-
-% similar to \ltj@pkgpatch, but this is used .sty which
-% can be reloaded inside the document by \input.
-\def\ltj@pkgpatchA#1{\ltj@AtBeginDocument{\@ifpackageloaded{#1}{\input{lltjp-#1.sty}}{}}}
+%\protected\def\@@end{%
+%  \directlua{luatexja.ext_cleanup()}\ltj@@orig@end}
 
 \endlinechar=13
 
 \usepackage{lltjdefs}
 \usepackage{lltjcore}
 
+%%% patching commands
+\RequirePackage{filehook}
+
+\def\ltj@pkgpatch@im#1{%
+ \@ifnextchar[{\ltj@pkgpatch@im@{#1}}{\ltj@pkgpatch@im@{#1}[lltjp-#1]}}%]
+\def\ltj@pkgpatch@im@#1[#2]{%
+  \AtEndOfPackageFile*{#1}{%
+    \@ifpackageloaded{#2}{}{%
+         \@namedef{ver@#2.\@pkgextension}{0000/00/00}%dummy
+         \if\catcode`@=11\let\ltj@temp\relax\else
+           \edef\ltj@temp{\noexpand\catcode`@=\the\catcode`@\relax}\makeatletter
+         \fi
+         \@@input{#2.\@pkgextension}\ltj@temp
+       }%
+  }%
+}
+
+\def\ltj@pkgpatch#1{%
+  \@ifnextchar[{\ltj@pkgpatch@@{#1}}{\ltj@pkgpatch@@{#1}[lltjp-#1]}}%]
+\def\ltj@pkgpatch@@#1[#2]{%
+  \gpreto\@begindocumenthook{%
+    \@ifpackageloaded{#1}{%
+         \@ifpackageloaded{#2}{}{\RequirePackage{#2}}%
+       }{}%
+  }%
+}
+
 %%% default parameters
 \directlua{
   local s = kpse.find_file('ltj-kinsoku.lua', 'tex')
   luatexja.stack.charprop_stack_table[0] = s and dofile(s) or {}
 }
 
-\ltjsetparameter{kanjiskip=0pt plus 0.4pt minus 0.4pt,
+\ltjsetparameter{kanjiskip=\z@ plus .4pt minus .5pt,
   xkanjiskip=.25\zw plus 1pt minus 1pt,
   autospacing, autoxspacing, jacharrange={-1},
-  yalbaselineshift=0pt, yjabaselineshift=0pt,
+  yalbaselineshift=\z@, yjabaselineshift=\z@,
   jcharwidowpenalty=500, differentjfm=paverage
 }
 
 \expandafter\let\csname JY3/mc/m/n/10\endcsname\relax
 
 %%% patch for packages
-\ltj@pkgpatch{listings}
-\ltj@pkgpatch{unicode-math}
-\ltj@pkgpatch{xunicode}
-\ltj@pkgpatch{fontspec}
-\ltj@pkgpatch{stfloats}
-\ltj@pkgpatch{footmisc}
+\ltj@pkgpatch@im{listings}
+\ltj@pkgpatch{xunicode}  %% at \begin{document}
+\ltj@pkgpatch@im{fontspec}
+\ltj@pkgpatch{footmisc}  %% at \begin{document}
 \ltj@pkgpatch{tascmac}
-\ltj@AtBeginDocument{\@ifpackageloaded{ascmac}{\input{lltjp-tascmac.sty}}{}}% ascmac
+\ltj@pkgpatch{ascmac}[lltjp-tascmac]
+\ltj@pkgpatch@im{stfloats}
+\ltj@pkgpatch{preview}  %% at \begin{document}
+  % (preview package has delayed option)
+\ltj@pkgpatch{array}    %% at \begin{document}
+\ltj@pkgpatch{collcell} %% at \begin{document}
+\ltj@pkgpatch@im{unicode-math}
+\ltj@pkgpatch@im{siunitx}
+\ltj@pkgpatch@im{microtype}
+\ltj@pkgpatch@im{everyshi}
 
 \RequirePackage{lltjp-geometry}
 
-
 %%------------------ all done
 \ltj@latex@AtEnd
 \endinput