OSDN Git Service

c66c208a0360eb01f026f6bae2477ce8fc8cdb16
[luatex-ja/luatexja.git] / src / ltj-latex.sty
1 %
2 % ltj-latex.sty
3 %
4
5 %! これは外から読まれない
6 %% Avoid multiple loading.
7 \csname luatexjalatexLoaded\endcsname
8 \edef\ltj@latex@AtEnd{%
9 \endlinechar=\the\endlinechar
10 \relax}
11 \endlinechar\m@ne%
12 \def\luatexjalatexLoaded{\endinput}
13
14 \NeedsTeXFormat{LaTeX2e}
15 \ProvidesPackage{ltj-latex}[2017/03/12 LaTeX support of LuaTeX-ja]
16
17 % LaTeX2e 2017/05/01 で行われる対策
18 \ifx\document@default@language \@undefined
19   \let\document@default@language\m@ne
20 \fi
21 \ifx\l@nohyphenation \@undefined
22   \newlanguage\l@nohyphenation
23 \fi
24
25 % cleanup at end of the document
26 %\let\ltj@@orig@end=\@@end
27 %\protected\def\@@end{%
28 %  \directlua{luatexja.ext_cleanup()}\ltj@@orig@end}
29
30 % Globally add to the head of a macro (cf. LaTeX2e's \g@addto@macro)
31 \long\def\ltj@g@addto@macro#1#2{%
32   \begingroup
33     \def\ltj@tmpa{#2}
34     \toks@\expandafter\expandafter\expandafter{\expandafter\ltj@tmpa#1}
35     \xdef#1{\the\toks@}
36   \endgroup}
37
38 \def\ltj@AtBeginDocument{\ltj@g@addto@macro\@begindocumenthook}
39
40 \def\ltj@pkgpatch#1{\ltj@AtBeginDocument{\@ifpackageloaded{#1}{\usepackage{lltjp-#1}}{}}}
41
42 % similar to \ltj@pkgpatch, but this is used .sty which
43 % can be reloaded inside the document by \input.
44 \def\ltj@pkgpatchA#1{\ltj@AtBeginDocument{\@ifpackageloaded{#1}{\input{lltjp-#1.sty}}{}}}
45
46 \endlinechar=13
47
48 %%% patch for LaTeX
49 \usepackage{lltjfont}
50 \usepackage{lltjdefs}
51 \usepackage{lltjcore}
52
53 %%% default parameters
54 \directlua{
55   local s = kpse.find_file('ltj-kinsoku.lua', 'tex')
56   luatexja.stack.charprop_stack_table[0] = s and dofile(s) or {}
57 }
58
59 \ltjsetparameter{kanjiskip=\z@ plus .4pt minus .5pt,
60   xkanjiskip=.25\zw plus 1pt minus 1pt,
61   autospacing, autoxspacing, jacharrange={-1},
62   yalbaselineshift=\z@, yjabaselineshift=\z@,
63   jcharwidowpenalty=500, differentjfm=paverage
64 }
65
66 \expandafter\let\csname JY3/mc/m/n/10\endcsname\relax
67
68 %%% patch for packages
69 \ltj@pkgpatch{listings}
70 \ltj@pkgpatch{unicode-math}
71 \ltj@pkgpatch{xunicode}
72 \ltj@pkgpatch{fontspec}
73 \ltj@pkgpatch{footmisc}
74 \ltj@pkgpatch{tascmac}
75 \ltj@AtBeginDocument{\@ifpackageloaded{ascmac}{%
76   \edef\ltj@asc@temp{\noexpand\catcode`\noexpand\@=\the\catcode`\@}%
77   \makeatletter\input{lltjp-tascmac.sty}%
78   \ltj@asc@temp\let\ltj@asc@temp=\relax
79 }{}}% ascmac
80 \ltj@pkgpatch{stfloats}
81
82 \RequirePackage{lltjp-geometry}
83 \RequirePackage{filehook}
84 \AtEndOfPackageFile*{fontspec}{%
85   \input{lltjp-fontspec-immediate.sty}
86   % \RequirePackage だと fontspec にオプション指定したときにエラー出る
87 }
88
89
90 %%------------------ all done
91 \ltj@latex@AtEnd
92 \endinput
93 %% EOF