summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexja/src/ltj-latex.sty
blob: 213f2f71094280a22d3337f7861e817c87e8816f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
%
% ltj-latex.sty
%

%! これは外から読まれない
%% Avoid multiple loading.
\csname luatexjalatexLoaded\endcsname
\edef\ltj@latex@AtEnd{%
\endlinechar=\the\endlinechar
\relax}
\endlinechar\m@ne%
\def\luatexjalatexLoaded{\endinput}

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ltj-latex}[2020-12-29 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}

\endlinechar=13

%%% LaTeX version detection
\ifcsname tex_shipout:D\endcsname
  \expandafter\let\csname tex_shipout:D\endcsname\ltj@shipout
\fi
\newif\ifltj@ltfilehook@avail
\@ifl@t@r\fmtversion{2020-10-01}{%
  \@ifl@t@r\fmtversion{2020-10-02}%
    {\ltj@ltfilehook@availtrue}
    {%
      \ifnum\patch@level<0\relax \ifnum\patch@level<-6 \ltj@ltfilehook@availtrue\fi
      \else\ltj@ltfilehook@availtrue\fi
    }%
}{}

%%% patch for LaTeX
\usepackage{lltjfont}
\usepackage{lltjdefs}
\usepackage{lltjcore}
\RequirePackage{lltjp-atbegshi}

%%% patching commands
\ifltj@ltfilehook@avail
  \def\@@ltj@ExecuteAfterPackage#1{\AddToHook{package/after/#1}}
  \def\@@ltj@ExecuteBeforePackage#1{\AddToHook{package/before/#1}}
  \def\ltj@ExecuteAfterPackage{\@ifstar\@@ltj@ExecuteAfterPackage@star\@@ltj@ExecuteAfterPackage}
  \def\@@ltj@ExecuteAfterPackage@star#1#2{%
    \@ifpackageloaded{#1}{#2}{\@@ltj@ExecuteAfterPackage{#1}{#2}}%
  }
  \def\ltj@ExecuteBeforePackage{\@ifstar\@@ltj@ExecuteBeforePackage@star\@@ltj@ExecuteBeforePackage}
  \def\@@ltj@ExecuteBeforePackage@star#1#2{%
    \@ifpackageloaded{#1}{#2}{\@@ltj@ExecuteBeforePackage{#1}{#2}}%
  }
\else
  \RequirePackage{filehook}
  \let\ltj@ExecuteAfterPackage=\AtEndOfPackageFile
  \let\ltj@ExecuteBeforePackage=\AtBeginOfPackageFile
\fi
\def\ltj@pkgpatch@im#1{\@ifnextchar[{\ltj@pkgpatch@im@{#1}}{\ltj@pkgpatch@im@{#1}[lltjp-#1]}}%]
\def\ltj@pkgpatch@im@#1[#2]{\ltj@ExecuteAfterPackage*{#1}{\ltj@pkgpatch@im@@{#2}}}
\def\ltj@pkgpatch@im@@#1{%
  \@ifpackageloaded{#1}{}{%
    \if\catcode`@=11\let\ltj@temp\relax\else
      \edef\ltj@temp{\noexpand\catcode`@=\the\catcode`@\relax}\makeatletter
    \fi
    \@@input{#1.\@pkgextension}\ltj@temp
  }%
}

\def\ltj@pkgpatch#1{\@ifnextchar[{\ltj@pkgpatch@{#1}}{\ltj@pkgpatch@{#1}[lltjp-#1]}}%]
\ifltj@ltfilehook@avail
  \def\ltj@pkgpatch@@{\AddToHook{begindocument/before}[luatexja.autopatch]}
\else
  \def\ltj@pkgpatch@@{\gpreto\@begindocumenthook}
\fi
\def\ltj@pkgpatch@#1[#2]{%
  \ltj@pkgpatch@@{%
    \@ifpackageloaded{#1}{\@ifpackageloaded{#2}{}{\RequirePackage{#2}}}{}%
  }%
}
\expandafter\let\csname JY3/mc/m/n/10\endcsname\relax

%%% patch for packages
\ltj@pkgpatch@im{listings}
\ltj@pkgpatch{xunicode}  %% at \begin{document}
\ltj@pkgpatch@im{fontspec}
\ltj@pkgpatch{footmisc}  %% at \begin{document}
\ltj@pkgpatch{tascmac}
\ltj@pkgpatch{ascmac}[lltjp-tascmac]
\ltj@pkgpatch@im{stfloats}
\ifltj@ltfilehook@avail\else
  \ltj@pkgpatch{preview}  %% at \begin{document}
  % (preview package has delayed option)
\fi
\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}

\ifltj@ltfilehook@avail\else\ltj@pkgpatch@im{everyshi}\fi

\RequirePackage{lltjp-geometry}

%%------------------ all done
\ltj@latex@AtEnd
\endinput
%% EOF