OSDN Git Service

Fix #39431: support notdef=... (introduced in luaotfload v2.98)
[luatex-ja/luatexja.git] / src / ltj-latex.sty
index e892d8f..446707b 100644 (file)
 \def\luatexjalatexLoaded{\endinput}
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{ltj-latex}[2018/08/23 LaTeX support of LuaTeX-ja]
+\ProvidesPackage{ltj-latex}[2018/08/24 LaTeX support of LuaTeX-ja]
 
 % cleanup at end of the document
 %\let\ltj@@orig@end=\@@end
 %\protected\def\@@end{%
 %  \directlua{luatexja.ext_cleanup()}\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}}{}}}
-
 \endlinechar=13
 
 %%% patch for LaTeX
 \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}{\input{#2.sty}}}
+\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{
 %%% patch for packages
 \ltj@pkgpatch@im{listings}
 \ltj@pkgpatch{xunicode}  %% at \begin{document}
-\ltj@pkgpatch{fontspec}  %% at \begin{document}
-\ltj@pkgpatch@im{fontspec}[lltjp-fontspec-immediate]
+\ltj@pkgpatch@im{fontspec}
 \ltj@pkgpatch{footmisc}  %% at \begin{document}
 \ltj@pkgpatch{tascmac}
-\ltj@AtBeginDocument{\@ifpackageloaded{ascmac}{%
-  \edef\ltj@asc@temp{\noexpand\catcode`\noexpand\@=\the\catcode`\@}%
-  \makeatletter\input{lltjp-tascmac.sty}%
-  \ltj@asc@temp\let\ltj@asc@temp=\relax
-}{}}% 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@im{unicode-math}
 \ltj@pkgpatch@im{siunitx}
+\ltj@pkgpatch@im{microtype}
 
 \RequirePackage{lltjp-geometry}