X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-latex.sty;h=6b8fa81b904995c02e74e0cf576d80a6d74b5ba5;hb=3fae82d64b193c794fdf2f1262d80bddc98ce5a8;hp=051463600be8bd698cd5ec58c2dab1adbb854501;hpb=d37ee7b0224c81972482cd04c029d4c60e29bfa5;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-latex.sty b/src/ltj-latex.sty index 0514636..6b8fa81 100644 --- a/src/ltj-latex.sty +++ b/src/ltj-latex.sty @@ -12,29 +12,13 @@ \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}}{}}} - -% 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}}{}}} - \endlinechar=13 %%% patch for LaTeX @@ -42,6 +26,33 @@ \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') @@ -58,36 +69,20 @@ \expandafter\let\csname JY3/mc/m/n/10\endcsname\relax %%% patch for packages -\ltj@pkgpatch{listings} -\ltj@pkgpatch{xunicode} -\ltj@pkgpatch{fontspec} -\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}{% - \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{stfloats} -\ltj@pkgpatch{preview} -\ltj@pkgpatch{array} +\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} \RequirePackage{lltjp-geometry} -\RequirePackage{filehook} -\AtEndOfPackageFile*{fontspec}{% - \input{lltjp-fontspec-immediate.sty} - % \RequirePackage だと fontspec にオプション指定したときにエラー出る -} -\AtEndOfPackageFile*{unicode-math}{% - \input{lltjp-unicode-math-immediate.sty} -} - -\@ifpackageloaded{siunitx}{% - \chardef\ltj@patch@siunitx@execute\z@\input{lltjp-siunitx.sty}% -}{% - \AtBeginOfPackageFile*{siunitx}{\input{lltjp-siunitx.sty}}% -} -\AtEndOfPackageFile*{siunitx}{\csname __ltj_siunitx_patch:\endcsname} %%------------------ all done \ltj@latex@AtEnd