OSDN Git Service

7a524c2b1f93802f9687387e565e497fbf23bee1
[luatex-ja/luatexja.git] / doc / manual.dtx
1 %#! lualatex -shell-escape manual.ins
2
3 %<en>\documentclass[a4paper,titlepage]{article}
4 %<ja>\documentclass[a4paper,titlepage]{ltjsarticle}
5 \usepackage[margin=20mm,footskip=5mm]{geometry}
6
7 \usepackage{amsmath,amssymb,xcolor,pict2e,multienum,amsthm,float}
8 \usepackage{booktabs,listings,lltjlisting,showexpl,multicol}
9 \usepackage{luatexja-otf}
10 \usepackage{luatexja-fontspec}
11 \usepackage[unicode]{hyperref}
12 \usepackage[all]{xy}
13 \SelectTips{cm}{}
14
15 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
16 \DeclareRobustCommand\LuaTeX{Lua\TeX}
17 \DeclareRobustCommand\pdfTeX{pdf\TeX}
18 \DeclareRobustCommand\pTeX{p\kern-.05em\TeX}
19 \DeclareRobustCommand\upTeX{p\kern-.05em\TeX}
20 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
21 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
22 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\kern-.125em\pTeX}
23
24 \ltjsetparameter{jacharrange={-3}}
25 \theoremstyle{definition}
26 %<en>\newtheorem{defn}{Definition}
27 %<ja>\newtheorem{defn}{定義}
28
29 \newenvironment{cslist}{%
30   \leftskip2em\parindent=0pt\def\makelabel##1{{\tt\char92##1}}
31   \def\{{\char`\{}\def\}{\char`\}}
32   \let\origitem=\item
33   \def\item[##1]{\par\smallskip\par\hskip-\leftskip\makelabel{##1}\par}
34 }{}
35
36 \makeatletter
37 \long\def\@makecaption#1#2{%
38   \vskip\abovecaptionskip
39   \sbox\@tempboxa{{\small #1. #2}}%
40   \ifdim \wd\@tempboxa >\hsize
41     {\small #1. #2}\par
42   \else
43     \global \@minipagefalse
44     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
45   \fi
46   \vskip\belowcaptionskip}
47 \makeatother
48
49 %<*en>
50 \title{The \LuaTeX-ja package}
51 \author{The \LuaTeX-ja project team}
52 %</en>
53 %<*ja>
54 \title{\LuaTeX-jaパッケージ}
55 \author{\LuaTeX-jaプロジェクトチーム}
56 %</ja>
57
58 \lstset{
59   basicstyle=\ttfamily\small, pos=o, breaklines=true,
60   numbers=none, rframe={}, basewidth=0.5em
61 }
62
63 \parskip=\smallskipamount
64 \protected\def\Param#1{\textsf{#1}} % parameter name
65 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
66
67 \begin{document}
68 \catcode`\<=13
69 \def<#1>{{\normalfont\rm\itshape$\langle$#1$\rangle$}}
70 \maketitle
71
72 \tableofcontents
73 \bigskip
74
75 %<*en>
76 {\Large\bf This documentation is far from complete. It may have many
77 grammatical (and contextual) errors.}
78 %</en>
79 %<*ja>
80 \textbf{\large 本ドキュメントはまだまだ未完成です.}
81 %</ja>
82
83 \clearpage
84 %<en>\part{User's manual}
85 %<ja>\part{ユーザーズマニュアル}
86
87 %<en>\section{Introduction}
88 %<ja>\section{はじめに}
89
90 %<*en>
91 The \LuaTeX-ja package is a macro package for typesetting high-quality
92 Japanese documents when using \LuaTeX.
93 %</en>
94 %<*ja>
95 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
96 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
97 %</ja>
98
99 %<en>\subsection{Backgrounds}
100 %<ja>\subsection{背景}
101
102 %<*en>
103 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
104 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
105 extension of \TeX: so it can produce high-quality Japanese documents
106 without using very complicated macros. But this point is a mixed
107 blessing: \pTeX\ is left behind from other extensions of \TeX,
108 especially \eTeX\ and pdf\TeX, and from changes about
109 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
110 %</en>
111 %<*ja>
112 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
113 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
114 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
115 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
116 もなってしまった:\pTeX という(組版的に)満足なものがあったため,海外で
117 行われている数々の\TeX の拡張──例えば\eTeX や\pdfTeX ──や,TrueType,
118 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
119 を怠ってしまったのだ.
120 %</ja>
121
122 %<*en>
123 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
124 of \pTeX) and \epTeX\ (merging of \pTeX\ and
125 \eTeX\ extension), have developed to fill those gaps to some
126 extent, but gaps still exist.
127 %</en>
128 %<*ja>
129 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
130 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
131 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
132 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
133 るようになった.だが,\pdfTeX 拡張(pdf直接出力やmicro-typesetting)を
134 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
135 る.
136 %</ja>
137
138 %<*en>
139 However, the appearance of \LuaTeX\ changed the whole situation. With
140 using Lua `callbacks', users can customize the internal processing of
141 \LuaTeX. So there is no need to modify sources of engines to
142 support Japanese typesetting: to do this, we only have to write Lua
143 scripts for appropriate callbacks.
144 %</en>
145 %<*ja>
146 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
147 `callback'を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
148 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
149 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
150 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
151 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
152 が始まったパッケージである.
153 %</ja>
154
155 %<en>\subsection{Major Changes from \pTeX}
156 %<ja>\subsection{\pTeX からの主な変更点}
157
158 %<*en>
159 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
160 target of development was to implement features of \pTeX. However,
161 \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
162 specifications/behaviors of \pTeX\ were not adopted}.
163 %</en>
164 %<*ja>
165 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
166 能をLuaコードにより実装することであった.しかし,開発が進むにつれ,\pTeX
167 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
168 ているような状況も発見された.そのため,\textbf{\LuaTeX-ja は,もはや
169 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
170 れば,そこは積極的に改める.}
171 %</ja>
172
173 %<*en>
174 The followings are major changes from \pTeX:
175 %</en>
176 %<*ja>
177 以下は \pTeX からの主な変更点である.
178 %</ja>
179
180 \begin{itemize}
181 %<*en>
182 \item A Japanese font is a tuple of a `real' font, a Japanese font
183       metric (\textbf{JFM}, for short), and an optional string called
184       `variation'.
185 %</en>
186 %<*ja>
187 \item 和文フォントは「実際の」フォント,和文フォントメトリック(JFM と呼ぶ),そ
188       して `variation' と呼ばれる文字列の組である.
189 %</ja>
190
191 %<*en>
192 \item In \pTeX, a linebreak after Japanese character is ignored (and
193       doesn't yield a space), since linebreaks (in source files) are
194       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
195       doesn't have this function completely, because of a specification
196       of \LuaTeX.
197 %</en>
198 %<*ja>
199 \item 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
200       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
201       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
202 %</ja>
203
204 %<*en>
205 \item The insertion process of glues/kerns between two Japanese
206       characters and between a Japanese character and other characters
207       (we refer these glues/kerns as \textbf{JAglue}) is rewritten from
208       scratch.
209 %</en>
210 %<*ja>
211 \item 2つの和文文字の間,和文文字と欧文文字の間に入るグルー/カーン
212       (\textbf{JAglue} と呼ぶ)の挿入処理が0から書き直されている.
213 %</ja>
214
215 \begin{itemize}
216 %<*en>
217 \item As \LuaTeX's internal character handling is `node-based'
218       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
219       insertion process of \textbf{JAglue} is now `node-based'.
220 %</en>
221 %<*ja>
222 \item \LuaTeX の内部での文字の扱いが「ノードベース」になっているように(例えば,
223       \verb+of{}fice+ で合字は抑制されない),\textbf{JAglue} の挿入処理も
224       「ノードベース」である.
225 %</ja>
226
227 %<*en>
228 \item Furthermore, nodes between two characters which have no effects in
229       linebreak (\textit{e.g.}, \verb+\special+ node) and kerns from
230       italic correction are ignored in the insertion process.
231 %</en>
232 %<*ja>
233 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば
234       \verb+\special+ ノード)や,イタリック補正に伴う挿入されるカーンは
235       挿入処理中では無視される.
236 %</ja>
237
238 %<*en>
239 \item \emph{Caution: due to above two points, many methods which did the
240       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
241       effective anymore.} In concrete terms, the following two methods are not effective anymore:
242 %</en>
243 %<*ja>
244 \item \textbf{注意:上の2つの変更により,従来 \textbf{JAglue} の挿入処理を分断するのに
245       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
246 %</ja>
247 \begin{verbatim}
248   ちょ{}っと  ちょ\/っと
249 \end{verbatim}
250 %<*en>
251       If you want to do so, please put an empty hbox between it instead:
252 %</en>
253 %<*ja>
254       もし同じことをやりたければ,空のhboxを間に挟むようにしてください:
255 %</ja>
256 \begin{verbatim}
257   ちょ\hbox{}っと
258 \end{verbatim}
259
260
261 %<*en>
262 \item In the process, two Japanese fonts which only differ in their `real'
263       fonts are identified.
264 %</en>
265 %<*ja>
266 \item 処理中では,2つの和文フォントは,「実際の」フォントのみが異なる場合に同一視
267       される.
268 %</ja>
269 \end{itemize}
270
271 %<*en>
272 \item At the present, vertical typesetting (\emph{tategaki}), is not
273       supported in \LuaTeX-ja.
274 %</en>
275 %<*ja>
276 \item 現時点では,縦書きは \LuaTeX-ja ではサポートされていない.
277 %</ja>
278
279 \end{itemize} 
280
281 %<*en>
282 For detailed information, see Part~\ref{part-imp}.
283 %</en>
284 %<*ja>
285 詳細については第 \ref{part-imp} 部を見よ.
286 %</ja>
287
288 %<en>\subsection{Notations}
289 %<ja>\subsection{用語と記法}
290
291 %<*en>
292 In this document, the following terms and notations are used:
293 %</en>
294 %<*ja>
295 本ドキュメントでは,以下の用語と記法を用いる:
296 %</ja>
297
298 \begin{itemize}
299 %<*en>
300 \item Characters are divided into two types: 
301 %</en>
302 %<*ja>
303 \item 文字は2種類に分けられる:
304 %</ja>
305 \begin{itemize}
306 %<*en>
307 \item \textbf{JAchar}: standing for Japanese characters such as
308       Hiragana, Katakana, Kanji and other punctuation marks for
309       Japanese.
310 %</en>
311 %<*ja>
312 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった和文文字の
313       ことを指す.
314 %</ja>
315
316 %<*en>
317 \item \textbf{ALchar}: standing for all other characters like alphabets. 
318 %</en>
319 %<*ja>
320 \item \textbf{ALchar}: アルファベットを始めとする,その他全ての文字を指す.
321 %</ja>
322 \end{itemize}
323
324 %<*en>
325 We say `alphabetic fonts' for fonts used in \textbf{ALchar}, and `Japanese fonts' for fonts used in \textbf{JAchar}.
326 %</en>
327 %<*ja>
328 そして,\textbf{ALchar} の出力に用いられるフォントを「欧文フォント」と呼び,
329 \textbf{JAchar} の出力に用いられるフォントを「和文フォント」と呼ぶ.
330 %</ja>
331
332 %<*en>
333 \item A word in a sans-serif font (like \Param{prebreakpenalty})
334       means an internal parameter for Japanese typesetting, and it
335       is used as a key in \verb+\ltjsetparameter+ command.
336 %</en>
337 %<*ja>
338 \item サンセリフ体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
339       パラメータを表し,これらは \verb+\ltjsetparameter+ コマンドのキーとして
340       用いられる.
341 %</ja>
342
343 %<*en>
344 \item A word in typewriter font with underline (like \Pkg{fontspec})
345       means a package or a class of \LaTeX.
346 %</en>
347 %<*ja>
348 \item 下線付きのタイプライタ体で書かれた語(例:\Pkg{fontspec})は \LaTeX の
349       パッケージやクラスを表す.
350 %</ja>
351
352 %<*en>
353 \item The word `primitive' is used not only for primitives in \LuaTeX,
354       but also for control sequences that defined in the core module of
355       \LuaTeX-ja.
356 %</en>
357 %<*ja>
358 \item 「プリミティブ」という語を,\LuaTeX のプリミティブだけではなく \LuaTeX-ja
359       のコアモジュールで定義されたコントロールシーケンスに対しても用いる.
360 %</ja>
361
362 %<*en>
363 \item In this document, natural numbers start from~0.
364 %</en>
365 %<*ja>
366 \item 本ドキュメントでは,自然数は0から始まる.
367 %</ja>
368 \end{itemize}
369
370 %<en>\subsection{About the project}
371 %<ja>\subsection{プロジェクトについて}
372
373 %<*en>
374 \paragraph{Project Wiki} Project Wiki is under construction.
375 %</en>
376 %<*ja>
377 \paragraph{プロジェクト Wiki} プロジェクト Wiki は構築中である.
378 %</ja>
379
380 %<*en>
381 \begin{itemize}
382 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
383 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
384 \end{itemize}
385 %</en>
386 %<*ja>
387 \begin{itemize}
388 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
389 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
390 \end{itemize}
391 %</ja>
392
393 %<*en>
394 This project is hosted by SourceForge.JP.
395 %</en>
396 %<*ja>
397 本プロジェクトは SourceForge.JP のサービスを用いて運営されている.
398 %</ja>
399
400 %<en>\paragraph{Members}\ 
401 %<ja>\paragraph{開発メンバー}\ 
402 %<*en>
403 \begin{multienumerate}
404 \def\labelenumi{$\bullet$}
405 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
406 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
407 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{}
408 \end{multienumerate}
409 %</en>
410 %<*ja>
411 \begin{multienumerate}
412 \def\labelenumi{$\bullet$}
413 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
414 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
415 \mitemxxx{本田 知亮}{齋藤修三郎}{}
416 \end{multienumerate}
417 %</ja>
418
419
420 % \paragraph{Acknowledgments} -- 挿入するならここ
421
422 \clearpage
423 %<en>\section{Getting Started}
424 %<ja>\section{使い方}
425 %<en>\subsection{Installation}
426 %<ja>\subsection{インストール}
427
428 %<*en>
429 To install the \LuaTeX-ja\ package, you will need:
430 %</en>
431 %<*ja>
432 \LuaTeX-ja パッケージのインストールには,次のものが必要である.
433 %</ja>
434 \begin{itemize}
435 %<*en>
436 \item \LuaTeX\ (version 0.65.0-beta or later) and its supporting packages.\\
437 If you are using \TeX~Live~2011 or current W32\TeX, you don't have to worry.
438 %</en>
439 %<*ja>
440 \item \LuaTeX(バージョン 0.65.0-beta 以降)とその支援パッケージ.
441       \TeX~Live~2011 や W32\TeX の最新版ならば問題ない.
442 %</ja>
443 %<*en>
444 \item The source archive of \LuaTeX-ja, of course{\tt:)}
445 %</en>
446 %<*ja>
447 \item \LuaTeX-ja のソースアーカイブ(もちろん {\tt:)}).
448 %</ja>
449 \end{itemize}
450
451 %<*en>
452 The installation methods are as follows:
453 %</en>
454 %<*ja>
455 インストール方法は以下のようになる:
456 %</ja>
457 \begin{enumerate}
458 %<*en>
459 \item Download the source archive.
460
461       At the present, \LuaTeX-ja has no official release, so you have to retrieve
462       the archive from the repository.
463       You can retrieve the Git repository via
464 %</en>
465 %<*ja>
466 \item ソースアーカイブをダウンロードする.
467
468       現時点では,\LuaTeX-ja の公式リリースはないので,レポジトリからアーカイブを
469       取得しなければならない.
470       次のようにすることで,Git レポジトリを取得することができる:
471 %</ja>
472 \begin{verbatim}
473 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
474 \end{verbatim} 
475 %<*en>
476       or download the archive of HEAD in \texttt{master} branch from
477 %</en>
478 %<*ja>
479       もしくは,\texttt{master} ブランチの HEAD アーカイブを以下からダウンロードすることができる:
480 %</ja>
481 \begin{flushleft}
482 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
483 \end{flushleft}
484
485 %<*en>
486 Note that the forefront of development may not be in \texttt{master} branch.
487 %</en>
488 %<*ja>
489 開発中の最新の成果は \texttt{master} ブランチには含まれていないかもしれないことに注意.
490 %</ja>
491
492 %<*en>
493 \item Extract the archive. You will see {\tt src/} and several other sub-directories.
494 %</en>
495 %<*ja>
496 \item アーカイブを展開する.{\tt src/} をはじめとしたいくつかのディレクトリができる.
497 %</ja>
498
499 %<*en>
500 \item Copy all the contents of {\tt src/} into one of your \texttt{TEXMF} tree.
501 %</en>
502 %<*ja>
503 \item {\tt src/} の中身全てを自分の \texttt{TEXMF} ツリーにコピーする.
504 %</ja>
505
506 %<*en>
507 \item If {\tt mktexlsr} is needed to update the filename database, make it so.
508 %</en>
509 %<*ja>
510 \item もし {\tt mktexlsr} を実行する必要があればそうする.
511 %</ja>
512 \end{enumerate}
513
514 %<en>\subsection{Cautions}
515 %<ja>\subsection{注意点}
516
517 \begin{itemize}
518 %<*en>
519 \item The encoding of your source file must be UTF-8. No other
520       encodings, such as EUC-JP or Shift-JIS, are not supported.
521 %</en>
522 %<*ja>
523 \item 原稿のソースファイルの文字コードは UTF-8 でなければならない.
524       EUC-JP や Shift-JIS は使用できない.
525 %</ja>
526
527 %<*en>
528 \item May be conflict with other packages. 
529
530       For example, the default setting of \textbf{JAchar} in the present
531       version does not coexist with the \Pkg{unicode-math}
532       package. Putting the following line in preamble makes that
533       mathematical symbols will be typeset correctly, but several
534       Japanese characters will be treated as an \textbf{ALchar} as
535       side-effect:
536 %</en>
537 %<*ja>
538 \item いくつかのパッケージと衝突する.
539
540       例えば,\textbf{JAchar} の範囲の設定がデフォルトのままだと,現行の
541       バージョンでは \Pkg{unicode-math} パッケージと共存できない.
542       以下の行をプリアンブルに追加することで数学記号が正しく出るように
543       なるが,副作用としていくつかの和文文字が \textbf{ALchar} として
544       扱われるようになってしまう:
545 %</ja>
546 \begin{verbatim}
547 \ltjsetparameter{jacharrange={-3, -8}}
548 \end{verbatim}
549 \end{itemize}
550
551 %<en>\subsection{Using in plain \TeX}
552 %<ja>\subsection{plain \TeX で使う}
553 \label{ssec-plain}
554
555 %<*en>
556 To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
557 \begin{verbatim}
558 \input luatexja.sty
559 \end{verbatim}
560 This does minimal settings (like {\tt ptex.tex}) for typesetting Japanese documents:
561 %</en>
562 %<*ja>
563 \LuaTeX-ja を plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
564 \begin{verbatim}
565 \input luatexja.sty
566 \end{verbatim}
567 これで({\tt ptex.tex} のように)日本語組版のための最低限の設定がなされる:
568 %</ja>
569
570 \begin{itemize}
571 %<*en>
572 \item The following 6~Japanese fonts are preloaded:
573 \begin{center}
574 \begin{tabular}{ccccc}
575 \toprule
576 \textbf{classification}&\textbf{font name}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
577 \emph{mincho}&Ryumin-Light    &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
578 \emph{gothic}&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
579 \bottomrule
580 \end{tabular}
581 \end{center}
582 %</en>
583 %<*ja>
584 \item 以下の6つの和文フォントが定義される:
585 \begin{center}
586 \begin{tabular}{ccccc}
587 \toprule
588 \textbf{字体}&\textbf{フォント名}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
589 \emph{明朝体}&Ryumin-Light    &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
590 \emph{ゴシック体}&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
591 \bottomrule
592 \end{tabular}
593 \end{center}
594 %</ja>
595 \begin{itemize}
596 %<*en>
597 \item The `Q(級)' is a unit used in Japanese phototypesetting, and
598       $1\,\textrm{Q}=0.25\,\textrm{mm}$. This length is stored in a
599       dimension \verb+\jQ+.
600 %</en>
601 %<*ja>
602 \item `Q(級)' は日本の写植で用いられる単位で,$1\,\textrm{Q}=0.25\,\textrm{mm}$
603       である.この長さは \verb+\jQ+ に保持されている.
604 %</ja>
605
606 %<*en>
607 \item It is widely accepted that the font `Ryumin-Light' and
608       `GothicBBB-Medium' aren't embedded into PDF files, and PDF reader
609       substitute them by some external Japanese fonts (\textit{e.g.},
610       Kozuka Mincho is used for Ryumin-Light in Adobe Reader). We adopt this custom to
611       the default setting.
612 %</en>
613 %<*ja>
614 \item `Ryumin-Light' と `GothicBBB-Medium' は PDF ファイルに埋め込まずに
615       名前参照のみで用いることが広く受け入れられており,この場合 PDF リーダーが
616       適切な外部フォントで代用する(例えば,Adobe Reader では Ryumin-Light は
617       小塚明朝で代替される).そこで,これらをデフォルトのフォントと
618       して採用する.
619 %</ja>
620
621 %<*en>
622 \item A character in an alphabetic font is generally smaller than a
623       Japanese font in the same size. So actual size specification of
624       these Japanese fonts is in fact smaller than that of alphabetic
625       fonts, namely scaled by 0.962216.
626 %</en>
627 %<*ja>
628 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
629       一般に小さい.そこで,これらの和文フォントの実際のサイズは指定された値よりも
630       小さくなるように設定されており,具体的には指定の 0.962216 倍にスケールされる.
631 %</ja>
632 \end{itemize}
633
634 %<*en>
635 \item The amount of glue that are inserted between a \textbf{JAchar} and
636       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
637 %</en>
638 %<*ja>
639 \item \textbf{JAchar} と \textbf{ALchar} の間に入るグルー (\Param{xkanjiskip}) の
640       量は次のように設定されている:
641 %</ja>
642 \[
643  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}} 
644  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
645 \]
646 \end{itemize}
647
648 %<en>\subsection{Using in \LaTeX}
649 %<ja>\subsection{\LaTeX で使う}
650 \label{ssec-ltx}
651
652 \paragraph{\LaTeXe}
653
654 %<*en>
655 Using in \LaTeXe\ is basically same. To set up the minimal environment
656 for Japanese, you only have to load {\tt luatexja.sty}:
657 \begin{verbatim}
658 \usepackage{luatexja}
659 \end{verbatim}
660 It also does minimal settings (counterparts in \pLaTeX\ are {\tt
661 plfonts.dtx} and {\tt pldefs.ltx}):
662 %</en>
663 %<*ja>
664 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
665 設定するためには,{\tt luatexja.sty} を読み込むだけでよい:
666 %</ja>
667
668 \begin{itemize}
669 %<*en>
670 \item {\tt JY3} is the font encoding for Japanese fonts (in horizontal direction).\\
671 When vertical typesetting is supported by \LuaTeX-ja in the future, {\tt JT3} will be used for vertical fonts.
672 %</en>
673 %<*ja>
674 \item {\tt JY3} は和文フォント用のフォントエンコーディングである(横書き用).\\
675 将来的に,\LuaTeX-ja で縦書きがサポートされる際には,{\tt JT3} を縦書き用として
676 用いる予定である.
677 %</ja>
678
679 %<*en>
680 \item Two font families {\tt mc} and {\tt gt} are defined: 
681 \begin{center}
682 \begin{tabular}{ccccc}
683 \toprule
684 \textbf{classification}&\textbf{family}&\verb+\mdseries+&\verb+\bfseries+&\textbf{scale}\\\midrule
685 \emph{mincho}&\tt mc&Ryumin-Light    &GothicBBB-Medium&0.962216\\
686 \emph{gothic}&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
687 \bottomrule
688 \end{tabular}
689 \end{center}
690 Remark that the bold series in both family are same as the medium series of \emph{gothic} family.
691 This is a convention in \pLaTeX. This is a trace that there were only 2~fonts (these are Ryumin-Light 
692 and GothicBBB-Medium) in early yearss of DTP.
693 %</en>
694 %<*ja>
695 \item 2つのフォントファミリ {\tt mc} と {\tt gt} が定義されている:
696 \begin{center}
697 \begin{tabular}{ccccc}
698 \toprule
699 \textbf{字体}&\textbf{ファミリ}&\verb+\mdseries+&\verb+\bfseries+&\textbf{スケール}\\\midrule
700 明朝体&\tt mc&Ryumin-Light    &GothicBBB-Medium&0.962216\\
701 ゴシック体&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
702 \bottomrule
703 \end{tabular}
704 \end{center}
705 どちらのファミリにおいても,その bold シリーズはゴシック体の medium シリーズで
706 あることに注意.これは初期の DTP において和文フォントが2つ(それがちょうど\ 
707 Ryumin-Light, GothicBBB-Medium だった)しか利用できなかった時の名残であり,\pLaTeX{}
708 での標準設定とも同じである.
709 %</ja>
710
711 %<*en>
712 \item Japanese characters in math mode are typeset by the font family {\tt mc}.
713 %</en>
714 %<*ja>
715 \item 数式モード中の和文文字は {\tt mc} ファミリで出力される.
716 %</ja>
717 \end{itemize}
718
719 %<*en>
720 However, above settings are not sufficient for Japanese-based
721 documents. To typeset Japanese-based documents, you are better to use
722 class files other than {\tt article.cls}, {\tt book.cls}, and so on.  At
723 the present, we have the counterparts of \Pkg{jclasses} (standard
724 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
725 Okumura), namely, \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
726 %</en>
727 %<*ja>
728 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
729 日本語文書を組版するためには,{\tt article.cls}, {\tt book.cls} といった
730 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
731 現時点では,\Pkg{jclasses} (\pLaTeX の標準クラス)と \Pkg{jsclasses}
732 (奥村晴彦氏によるクラスファイル)に対応するものとして,\Pkg{ltjclasses},
733 \Pkg{ltjsclasses} がそれぞれ用意されている.
734 %</ja>
735
736 %<*en>
737 \paragraph{{\tt\char92 CID, {\tt\char92 UTF}} and macros in OTF package}
738 Under \pLaTeX, \Pkg{otf} package (developed by Shuzaburo Saito) is
739 used for typesetting characters which is in Adobe-Japan1-6 CID but not
740 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
741 supports some of functions in \Pkg{otf} package.
742 If you want to use these functions, load \Pkg{luatexja-otf} package.
743 %</en>
744 %<*ja>
745 \paragraph{{\tt\char92 CID, {\tt\char92 UTF}} と OTF パッケージのマクロ}
746 \pLaTeX では,JIS~X~0208 にない Adobe-Japan1-6 の文字を出力するために,
747 齋藤修三郎氏による \Pkg{otf} パッケージが用いられていた.このパッケージは
748 広く用いられているため,\LuaTeX-ja においても \Pkg{otf} パッケージの機能の
749 一部をサポートしている.これらの機能を用いるためには \Pkg{luatexja-otf} パッケージ
750 を読み込めばよい.
751 %</ja>
752
753 \begin{LTXexample}
754 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
755
756 \CID{7652}飾区の\CID{13706}野家,
757 葛飾区の吉野家
758 \end{LTXexample}
759 %lltjlisting.sty要修正?:↑「森」の直後で改行.
760
761
762 %<en>\subsection{Changing Fonts}
763 %<ja>\subsection{フォントの変更}
764 \label{ssub-chgfnt}
765
766 %<*en>
767 \paragraph{Remark: Japanese Characters in Math Mode}
768 Since \pTeX\ supports Japanese characters in math mode, there are
769 sources like the following:
770 %</en>
771 %<*ja>
772 \paragraph{意見:数式モード中の和文文字}
773 \pTeX では数式中での和文文字の使用がサポートされていたので,
774 以下のようなソースが存在した:
775 %</ja>
776 \begin{LTXexample}
777 $f_{高温}$~($f_{\text{high temperature}}$).
778 \[ y=(x-1)^2+2\quad{}よって\quad y>0 \]
779 $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
780 \end{LTXexample}
781 %<*en>
782 We (the project members of \LuaTeX-ja) think that using
783 Japanese characters in math mode are allowed if and only if these are used as identifiers.
784 In this point of view, 
785 %</en>
786 %<*ja>
787 \LuaTeX-ja プロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
788 ときのみ許されると考えている.
789 この観点から,
790 %</ja>
791 \begin{itemize}
792 %<*en>
793 \item The lines 1~and~2 above are not correct, since `高温' in above is used as a textual label, and
794 `よって' is used as a conjunction. 
795 %</en>
796 %<*ja>
797 \item 上記数式のうち 1, 2 行目は正しくない.なぜならば `高温' が意味のあるラベルと
798       して,`よって' が接続詞として用いられているからである.
799 %</ja>
800 %<*en>
801 \item However, the line~3 is correct, since `素' is used as an identifier.
802 %</en>
803 %<*ja>
804 \item しかしながら,3行目は `素' が識別子として用いられているので正しい.
805 %</ja>
806 \end{itemize}
807 %<*en>
808 Hence, in our opinion, the above input should be corrected as:
809 %</en>
810 %<*ja>
811 したがって,\LuaTeX-ja プロジェクトの意見としては,上記の入力は次のように直されるべき
812 である:
813 %</ja>
814 \begin{LTXexample}
815 $f_{\text{高温}}$~%
816 ($f_{\text{high temperature}}$).
817 \[ y=(x-1)^2+2\quad 
818   \mathrel{\text{よって}}\quad y>0 \]
819 $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
820 \end{LTXexample}
821 %BUG?: \{\}がなければ「素」がでない.上の段落の「よって」もでてない.
822 %<*en>
823 We also believe that using Japanese characters as identifiers is rare,
824 hence we don't describe how to change Japanese fonts in math mode in
825 this chapter. For the method, please see Part~\ref{part-ref}.
826 %</en>
827 %<*ja>
828 また \LuaTeX-ja プロジェクトでは,和文文字が識別子として用いられることはほとんどない
829 と考えており,したがってこの章では数式モード中の和文フォントを変更する方法については
830 記述しない.この方法については第 \ref{part-ref} 章を参照のこと.
831 %</ja>
832
833 %<*en>
834 \paragraph{plain \TeX}
835 To change Japanese fonts in plain \TeX, you must use the primitive
836 \verb+\jfont+. So please see Part~\ref{part-ref}.
837 %</en>
838 %<*ja>
839 \paragraph{plain \TeX}
840 plain \TeX で和文フォントを変更するためには,\verb+\jfont+ プリミティブを用いなけれ
841 ばならない.第 \ref{part-ref} 章を参照せよ.
842 %</ja>
843
844 %<*en>
845 \paragraph{NFSS2}
846 For \LaTeXe, \LuaTeX-ja simply adopted the font selection system from that
847 of \pLaTeXe\ (in {\tt plfonts.dtx}).
848 %</en>
849 %<*ja>
850 \paragraph{NFSS2}
851 \LaTeXe については,\LuaTeX-ja では単にフォント選択システムを \pLaTeXe\ ({\tt plfonts.dtx})
852 から採用している.
853 %</ja>
854 \begin{itemize}
855 %<*en>
856 \item Two control sequences \verb+\mcdefault+ and \verb+\gtdefault+ are
857       used to specify the default font families for \emph{mincho} and
858       \emph{gothic}, respectively. Default values: \texttt{mc} for
859       \verb+\mcdefault+ and \texttt{gt} for \verb+\gtdefault+.
860 %</en>
861 %<*ja>
862 \item 2つのコントロールシーケンス \verb+\mcdefault+ と \verb+\gtdefault+ がそれぞ
863       れ明朝体とゴシック体のデフォルトのフォントファミリを指定するために用いられる.
864       初期値:\verb+\mcdefault+ は \texttt{mc},\verb+\gtdefault+ は \texttt{gt}.
865 %</ja>
866 %<*en>
867 \item Commands \verb+\fontfamily+, \verb+\fontseries+,
868       \verb+\fontshape+ and \verb+\selectfont+ can be used to change
869       attributes of Japanese fonts. 
870 %</en>
871 %<*ja>
872 \item \verb+\fontfamily+, \verb+\fontseries+, \verb+\fontshape+, そして 
873       \verb+\selectfont+ が和文フォントの属性を変更するために使用できる.
874 %</ja>
875
876 %<*en>
877 \begin{center}
878 \begin{tabular}{cccccc}
879 \toprule
880 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
881 alphabetic fonts
882 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
883 &\verb+\useroman+\\
884 Japanese fonts
885 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
886 &\verb+\usekanji+\\
887 both&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
888 auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
889 \bottomrule
890 \end{tabular}
891 \end{center}
892 %</en>
893 %<*ja>
894 \begin{center}
895 \begin{tabular}{cccccc}
896 \toprule
897 &\textbf{エンコーディング}&\textbf{ファミリ}&\textbf{シリーズ}&\textbf{シェープ}&\textbf{選択}\\\midrule
898 欧文フォント
899 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
900 &\verb+\useroman+\\
901 和文フォント
902 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
903 &\verb+\usekanji+\\
904 両方&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
905 自動選択&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
906 \bottomrule
907 \end{tabular}
908 \end{center}
909 %</ja>
910
911 %<*en>
912       \verb+\fontencoding{<encoding>}+ changes the encoding of alphabetic fonts
913       or Japanese fonts depending on the argument. For example, 
914       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to 
915       \texttt{JY3} and \verb+\fontencoding{T1}+ changes the encoding of 
916       alphabetic fonts to \texttt{T1}.
917       \verb+\fontfamily+ also changes the family of Japanese fonts, alphabetic
918       fonts, \emph{or both}. For detail, see Subsection~\ref{ssub-nfsspat}.
919 %</en>
920 %<*ja>
921       ここで,\verb+\fontencoding{<encoding>}+は,引数により和文側か欧文側かの
922       どちらかが切り替わる.例えば,\verb+\fontencoding{JY3}+は和文フォントの
923       エンコーディングを\texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文
924       フォント側を\texttt{T1}へと変更する.
925       \verb+\fontfamily+も引数により和文側,欧文側,\textbf{あるいは両方}のフォ
926       ントファミリが切り替わる.詳細は\ref{ssub-nfsspat}節を参照すること.
927 %</ja>
928
929 %<*en>
930 \item For defining a Japanese font family, use
931       \verb+\DeclareKanjiFamily+ instead of
932       \verb+\DeclareFontFamily+. However, in the present implementation,
933       using \verb+\DeclareFontFamily+ doesn't cause any problem.
934 %</en>
935 %<*ja>
936 \item 和文フォントファミリの定義には \verb+\DeclareFontFamily+ の代わりに
937       \verb+\DeclareKanjiFamily+ を用いる.しかし,現在の実装では 
938       \verb+\DeclareFontFamily+ を用いても問題は生じない.
939 %</ja>
940 \end{itemize}
941
942 %<*en>
943 \paragraph{fontspec}
944 To coexist with the \Pkg{fontspec} package, it is needed to load
945 \Pkg{luatexja-fontspec} package in the preamble. This additional
946 package automatically loads \Pkg{luatexja} and \Pkg{fontspec}
947 package, if needed.
948 %</en>
949 %<*ja>
950 \Pkg{fontspec} パッケージと同様の機能を和文フォントに対しても用いるためには,
951 \Pkg{luatexja-fontspec} パッケージをプリアンブルで読み込む必要がある.このパッケージ
952 は必要ならば自動で \Pkg{luatexja} パッケージと \Pkg{fontspec} パッケージを読み込む.
953 %</ja>
954
955 %<*en>
956 In \Pkg{luatexja-fontspec} package, the following 7~commands are defined as
957 counterparts of original commands in the \Pkg{fontspec} package:
958 %</en>
959 %<*ja>
960 \Pkg{luatexja-fontspec} パッケージでは,以下の7つのコマンドを \Pkg{fontspec} 
961 パッケージの元のコマンドに対応するものとして定義している:
962 %</ja>
963 %<*en>
964 \begin{center}
965 \begin{tabular}{ccccc}
966 \toprule
967 Japanese fonts
968 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
969 alphabetic fonts
970 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
971 \midrule
972 Japanese fonts
973 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
974 alphabetic fonts
975 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
976 \bottomrule
977 \end{tabular}
978 \end{center}
979 %</en>
980 %<*ja>
981 \begin{center}
982 \begin{tabular}{ccccc}
983 \toprule
984 和文フォント
985 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
986 欧文フォント
987 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
988 \midrule
989 和文フォント
990 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
991 欧文フォント
992 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
993 \bottomrule
994 \end{tabular}
995 \end{center}
996 %</ja>
997
998 \begin{LTXexample}
999   \fontspec[Numbers=OldStyle]{TeX Gyre Termes}
1000   \jfontspec{IPAexMincho}
1001   JIS~X~0213:2004→辻
1002
1003   \addjfontfeatures{CJKShape=JIS1990}
1004   JIS~X~0208:1990→辻
1005 \end{LTXexample}
1006
1007 %<*en>
1008 Note that there is no command named \verb+\setmonojfont+, since it is
1009 popular for Japanese fonts that nearly all Japanese glyphs have same
1010 widths.  Also note that the kerning feature is set off by default in
1011 these 7~commands, since this feature and \textbf{JAglue} will clash (see
1012 \ref{para-kern}).
1013 %</en>
1014 %<*ja>
1015 和文フォントについては全ての和文文字のグリフがほぼ等幅であるのが普通であるため,
1016 \verb+\setmonojfont+ コマンドは存在しないことに注意.また,これらの和文用の7つのコマ
1017 ンドでは Kerning feature はデフォルトでは off となっている.これはこの
1018 feature が \textbf{JAglue} と衝突するためである(\ref{para-kern} 節を見よ).
1019 %</ja>
1020
1021 %<en>\section{Changing Parameters}
1022 %<ja>\section{パラメータの変更}
1023 There are many parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1024 most of them are not stored as internal register of \TeX, but as an
1025 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1026 parameters, you have to use commands \verb+\ltjsetparameter+ and
1027 \verb+\ltjgetparameter+.
1028
1029 %<en>\subsection{Editing the range of \textbf{JAchar}s}
1030 %<ja>\subsection{\textbf{JAchar} の範囲の設定}
1031
1032 To edit the range of \textbf{JAchar}s, You have to assign a non-zero
1033 natural number which is less than 217 to the character range first. This
1034 can be done by using \verb+\ltjdefcharrange+ primitive. For example, the
1035 next line assigns whole characters in Supplementary Multilingual Plane
1036 and the character `漢' to the range number~100.
1037 \begin{lstlisting}
1038 \ltjdefcharrange{100}{"10000-"1FFFF,`漢}
1039 \end{lstlisting}
1040 This assignment of numbers to ranges are always global, so you should
1041 not do this in the middle of a document. 
1042
1043 If some character has been belonged to some non-zero numbered range,
1044 this will be overwritten by the new setting. For example, whole SMP
1045 belong the range~4 in the default setting of \LuaTeX-ja, and if you
1046 specify the above line, then SMP will belong the range~100 and be
1047 removed from the range~4.
1048
1049 After assigning numbers to ranges, the {\sf jacharrange} parameter can
1050 be used to customize which character range will be treated as ranges of
1051 \textbf{JAchar}s, as the following line (this is just the default
1052 setting of \LuaTeX-ja):
1053 \begin{verbatim}
1054 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
1055 \end{verbatim}
1056 The argument to {\sf jacharrange} parameter is a list of integer. Negative interger $-n$ in the list means that `the character range~$n$ is ...'.
1057
1058 \paragraph{Default Setting}
1059 Lua\TeX-ja predefines eight character ranges for convinience. They are
1060 determined from the following data:
1061 \begin{itemize}
1062 \item Blocks in Unicode~6.0.
1063 \item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
1064 \item The \texttt{PXbase} bundle for \upTeX\ by Takayuki Yato.
1065 \end{itemize}
1066
1067 Now we describe these eight ranges. The alphabet `J' or `A' after the
1068 number shows whether characters in the range is treated as
1069 \textbf{JAchar}s or not by default. These settings are similar to \texttt{prefercjk} ...
1070 \begin{description}
1071 \item[Range~8${}^{\text{J}}$] Symbols in the intersection of the upper half of ISO~8859-1
1072          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
1073          consists of the following charatcers:
1074 \begin{multicols}{2}
1075 \begin{itemize}
1076 \def\ch#1#2{\item \char"#1\ ({\tt U+00#1}, #2)}%"
1077 \ch{A7}{Section Sign}
1078 \ch{A8}{Umlaut or diaeresis}
1079 \ch{B0}{Degree sign}
1080 \ch{B1}{Plus-minus sign}
1081 \ch{B4}{Spacing acute}
1082 \ch{B6}{Paragraph sign}
1083 \ch{D7}{Multiplication sign}
1084 \ch{F7}{Division Sign}
1085 \end{itemize}
1086 \end{multicols}
1087 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
1088 This range consist of the following Unicode ranges, \emph{except characters in the range~8 above}:
1089 \begin{multicols}{2}
1090 \begin{itemize}
1091 \item {\tt U+0080}--{\tt U+00FF}: Latin-1 Supplement
1092 \item {\tt U+0100}--{\tt U+017F}: Latin Extended-A
1093 \item {\tt U+0180}--{\tt U+024F}: Latin Extended-B
1094 \item {\tt U+0250}--{\tt U+02AF}: IPA Extensions
1095 \item {\tt U+02B0}--{\tt U+02FF}: Spacing Modifier Letters
1096 \item {\tt U+0300}--{\tt U+036F}: Combining Diacritical Marks
1097 \item {\tt U+1E00}--{\tt U+1EFF}: Latin Extended Additional
1098 \par\ 
1099 \end{itemize}
1100 \end{multicols}
1101 \item[Range~2${}^{\text{J}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1102            fonts) has some of these characters.
1103 \begin{multicols}{2}
1104 \begin{itemize}
1105 \item {\tt U+0370}--{\tt U+03FF}: Greek and Coptic
1106 \item {\tt U+0400}--{\tt U+04FF}: Cyrillic
1107 \item {\tt U+1F00}--{\tt U+1FFF}: Greek Extended
1108 \\\ 
1109 \end{itemize}
1110 \end{multicols}
1111 \item[Range~3${}^{\text{J}}$] Punctuations and Miscellaneous symbols. The block list is
1112            indicated in Table~\ref{table-rng3}.
1113 \begin{table}[!tb]
1114 \caption{Unicode blocks in predefined character range~3.}\label{table-rng3}
1115 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
1116 \begin{center}\small
1117 \begin{tabular}{llll}
1118 "2000--"206F&General Punctuation&
1119 "2070--"209F&Superscripts and Subscripts\\
1120 "20A0--"20CF&Currency Symbols&
1121 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1122 "2100--"214F&Letterlike Symbols&
1123 "2150--"218F&Number Forms\\
1124 "2190--"21FF&Arrows&
1125 "2200--"22FF&Mathematical Operators\\
1126 "2300--"23FF&Miscellaneous Technical&
1127 "2400--"243F&Control Pictures\\
1128 "2500--"257F&Box Drawing&
1129 "2580--"259F&Block Elements\\
1130 "25A0--"25FF&Geometric Shapes&
1131 "2600--"26FF&Miscellaneous Symbols\\
1132 "2700--"27BF&Dingbats&
1133 "2900--"297F&Supplemental Arrows-B\\
1134 "2980--"29FF&Misc.\ Mathematical Symbols-B&
1135 "2B00--"2BFF&Miscellaneous Symbols and Arrows\\
1136 "E000--"F8FF&Private Use Area&
1137 \end{tabular}
1138 \end{center}
1139 \end{table}
1140 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1141            of almost all Unicode blocks which are not in other
1142            predefined ranges. Hence, instead of showing the block list,
1143            we put the definition of this range itself:
1144 \begin{lstlisting}
1145 \ltjdefcharrange{4}{%
1146    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF, 
1147   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB50-"FE0F, 
1148   "FE20-"FE2F, "FE70-"FEFF, "FB00-"FB4F, "10000-"1FFFF} % non-Japanese
1149 \end{lstlisting}
1150 \item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
1151 \item[Range~6${}^{\text{J}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
1152 \begin{table}[!tb]
1153 \caption{Unicode blocks in predefined character range~6.}\label{table-rng6}
1154 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
1155 \begin{center}\small
1156 \begin{tabular}{llll}
1157 "2460--"24FF&Enclosed Alphanumerics&
1158 "2E80--"2EFF&CJK Radicals Supplement\\
1159 "3000--"303F&CJK Symbols and Punctuation&
1160 "3040--"309F&Hiragana\\
1161 "30A0--"30FF&Katakana&
1162 "3190--"319F&Kanbun\\
1163 "31F0--"31FF&Katakana Phonetic Extensions&
1164 "3200--"32FF&Enclosed CJK Letters and Months\\
1165 "3300--"33FF&CJK Compatibility&
1166 "3400--"4DBF&CJK Unified Ideographs Extension A\\
1167 "4E00--"9FFF&CJK Unified Ideographs&
1168 "F900--"FAFF&CJK Compatibility Ideographs\\
1169 "FE10--"FE1F&Vertical Forms&
1170 "FE30--"FE4F&CJK Compatibility Forms\\
1171 "FE50--"FE6F&Small Form Variants&
1172 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)
1173 \end{tabular}
1174 \end{center}
1175 \end{table}
1176 \item[Range~7${}^{\text{J}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
1177 The block list is indicated in Table~\ref{table-rng7}.
1178 \begin{table}[!tb]
1179 \caption{Unicode blocks in predefined character range~7.}\label{table-rng7}
1180 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
1181 \begin{center}\small
1182 \begin{tabular}{llll}
1183 "1100--"11FF&Hangul Jamo&
1184 "2F00--"2FDF&Kangxi Radicals\\
1185 "2FF0--"2FFF&Ideographic Description Characters&
1186 "3100--"312F&Bopomofo\\
1187 "3130--"318F&Hangul Compatibility Jamo&
1188 "31A0--"31BF&Bopomofo Extended\\
1189 "31C0--"31EF&CJK Strokes&
1190 "A000--"A48F&Yi Syllables\\
1191 "A490--"A4CF&Yi Radicals&
1192 "A830--"A83F&Common Indic Number Forms\\
1193 "AC00--"D7AF&Hangul Syllables&
1194 "D7B0--"D7FF&Hangul Jamo Extended-B
1195 \end{tabular}
1196 \end{center}
1197 \end{table}
1198 \end{description}
1199
1200
1201 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
1202 %<ja>\subsection{\Param{kanjiskip} と \Param{xkanjiskip}}
1203 \label{subs-kskip}
1204 \textbf{JAglue} is divided into the following three categories:
1205 \begin{itemize}
1206 \item Glues/kerns specified in JFM. If \verb+\inhibitglue+ is issued
1207       around a Japanese character, this glue will be not inserted at the
1208       place.
1209 \item The default glue which inserted between two \textbf{JAchar}s ({\sf
1210       kanjiskip}).
1211 \item The default glue which inserted between a \textbf{JAchar} and an
1212       \textbf{ALchar} (\Param{xkanjiskip}).
1213 \end{itemize}
1214 The value (a skip) of \Param{kanjiskip} or \Param{xkanjiskip} can be
1215 changed as the following.
1216 \begin{lstlisting}
1217 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt}, 
1218                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
1219 \end{lstlisting}
1220
1221
1222 It may occur that JFM contains the data of `ideal width of {\sf
1223 kanjiskip}' and/or `ideal width of \Param{xkanjiskip}'.
1224 To use these data from JFM, set the value of \Param{kanjiskip} or 
1225 \Param{xkanjiskip} to \verb+\maxdimen+.
1226
1227 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
1228 %<ja>\subsection{\Param{xkanjiskip} の設定の挿入}
1229 It is not desirable that \Param{xkanjiskip} is inserted between every
1230 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
1231 \Param{xkanjiskip} should not be inserted after opening parenthesis
1232 (\textit{e.g.}, compare `(あ' and `(\hskip\ltjgetparameter{xkanjiskip}あ').
1233
1234 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
1235 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
1236 \Param{alxspmode} parameters \textbf{ALchar}s respectively. 
1237 \begin{LTXexample}
1238 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}} 
1239 pあq い!う
1240 \end{LTXexample}
1241
1242 The second argument {\tt preonly} means `the insertion of
1243 \Param{xkanjiskip} is allowed before this character, but not after'.
1244 the other possible values are {\tt postonly}, {\tt allow} and {\tt
1245 inhibit}. For the compatibility with \pTeX, natural numbers between
1246 0~and~3 are also allowed as the second argument\footnote{But we don't
1247 recommend this: since numbers 1~and~2 have opposite meanings in
1248 \Param{jaxspmode} and \Param{alxspmode}.}.
1249
1250 If you want to enable/disable all insertions of \Param{kanjiskip} and
1251 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
1252 parameters to {\tt false}, respectively.
1253
1254
1255 %<en>\subsection{Shifting Baseline}
1256 %<ja>\subsection{ベースラインの移動}
1257 To make a match between a Japanese font and an alphabetic font, sometimes
1258 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
1259 by setting \verb+\ybaselineshift+ to a non-zero length (the
1260 baseline of alphabetic fonts is shifted below). However, for documents
1261 whose main language is not Japanese, it is good to shift the baseline of
1262 Japanese fonts, but not that of alphabetic fonts.
1263 Because of this, \LuaTeX-ja can independently set the shifting amount
1264 of the baseline of alphabetic fonts (\Param{yalbaselineshift}
1265 parameter) and that of Japanese fonts (\Param{yjabaselineshift}
1266 parameter). 
1267
1268 \begin{LTXexample}
1269 \vrule width 150pt height 0.4pt depth 0pt\hskip-120pt
1270 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
1271 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
1272 \end{LTXexample}
1273 Here the horizontal line in above is the baseline of a line.
1274
1275 There is an interesting side-effect: characters in different size can be
1276 vertically aligned center in a line, by setting two parameters appropriately.
1277 The following is an example (beware the value is not well tuned):
1278 \begin{LTXexample}
1279 xyz漢字 
1280 {\scriptsize
1281   \ltjsetparameter{yjabaselineshift=-1pt, 
1282     yalbaselineshift=-1pt}
1283   XYZひらがな
1284 }abcかな
1285 \end{LTXexample}
1286
1287
1288 %<en>\subsection{Cropmark}
1289 %<ja>\subsection{トンボ}
1290 Cropmark is a mark for indicating 4~corners and horizontal/vertical
1291 center of the paper. In Japanese, we call cropmark as tombo(w).
1292 \pLaTeX\ and this \LuaTeX-ja support `tombow' by their kernel.
1293 The following steps are needed to typeset cropmark:
1294
1295 \begin{enumerate}
1296 \item First, define the banner which will be printed at the upper left
1297       of the paper. This is done by assigning a token list to
1298       \verb+\@bannertoken+.
1299
1300 For example, the following sets banner as `{\tt filename (2012-01-01 17:01)}':
1301 \begin{verbatim}
1302 \makeatletter
1303
1304 \hour\time \divide\hour by 60 \@tempcnta\hour \multiply\@tempcnta 60\relax
1305 \minute\time \advance\minute-\@tempcnta
1306 \@bannertoken{%
1307    \jobname\space(\number\year-\two@digits\month-\two@digits\day
1308    \space\two@digits\hour:\two@digits\minute)}%
1309 \end{verbatim}
1310
1311 \item ...
1312 \end{enumerate}
1313
1314
1315 %<en>\part{Reference}
1316 %<ja>\part{リファレンス}
1317 \label{part-ref}
1318 %<en>\section{Font Metric and Japanese Font}
1319 %<ja>\section{フォントメトリックと日本語フォント}
1320 %<en>\subsection{\texttt{\char92jfont} primitive}
1321 %<ja>\subsection{\texttt{\char92jfont} プリミティブ}
1322 To load a font as a Japanese font, you must use the
1323 \verb+\jfont+ primitive instead of~\verb+\font+, while
1324 \verb+\jfont+ admits the same syntax used in~\verb+\font+. 
1325 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
1326 so TrueType/OpenType fonts with features can be used for Japanese fonts:
1327 \begin{LTXexample}
1328 \jfont\tradgt={file:ipaexg.ttf:script=latn;%
1329   +trad;-kern;jfm=ujis} at 14pt
1330 \tradgt{}当/体/医/区
1331 \end{LTXexample}
1332
1333 Note that the defined control sequence
1334 (\verb+\tradgt+ in the example above) using \verb+\jfont+ is not a
1335 \textit{font\_def} token, hence the input like \verb+\fontname\tradgt+
1336 causes a error.  We denote control sequences which are defined in
1337 \verb+\jfont+ by <jfont\_cs>.
1338
1339 \paragraph{Prefix \texttt{psft}}
1340 Besides \texttt{file:}\ and \texttt{name:}\ prefixes, \texttt{psft:}\
1341 can be used a prefix in \verb+\jfont+ (and~\verb+\font+) primitive.
1342 Using this prefix, you can specify a `name-only' Japanese font which
1343 will be not embedded to PDF. Typical use of this prefix is to specify
1344 the `standard' Japanese fonts, namely, `Ryumin-Light' and
1345 `GothicBBB-Medium'. For kerning or other informations, that of Kozuka
1346 Mincho Pr6N Regular (this is a font by Adobe Inc., and included in
1347 Japanese Font Packs for Adore Reader) will be used.
1348
1349
1350 \paragraph{JFM}
1351 As noted in Introduction, a JFM has measurements of characters and
1352 glues/kerns that are automatically inserted for Japanese
1353 typesetting. The structure of JFM will be described in the next
1354 subsection. At the calling of \verb+\jfont+ primitive, you must specify
1355 which JFM will be used for this font by the following keys:
1356
1357 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1358 \item[jfm=<name>]
1359 Specify the name of JFM. A file named \texttt{jfm-<name>.lua} will be searched and/or loaded.
1360
1361 The followings are JFMs shipped with Lua\TeX-ja:
1362 \begin{description}
1363 \item[\tt jfm-ujis.lua] A standard JFM in Lua\TeX-ja. This JFM is
1364       based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
1365       is used in \upTeX. When you use the \Pkg{luatexja-otf} package, please use this JFM.
1366 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, `JIS font
1367            metric' which is widely used in \pTeX. A major difference of
1368            \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
1369            most haracters under \texttt{jfm-ujis.lua} are square-shaped,
1370            while that under \texttt{jfm-jis.lua} are horizontal
1371            rectangles.
1372
1373 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
1374            of the default Japanese font metric shipped with \pTeX. There
1375            are notable difference between this JFM and other 2~JFMs, as
1376            shown in Table~\ref{tab-difjfm}.
1377 \end{description}
1378
1379 \item[jfmvar=<string>] Sometimes there is a need that 
1380 \end{list}
1381
1382 \begin{table}[t]
1383 \caption{Differences between JFMs shipped with \LuaTeX-ja}
1384 \label{tab-difjfm}
1385 \ltjsetparameter{jacharrange={+3}}
1386 \begin{center}
1387 \def\r#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1388 \setbox0=\vtop{\hsize=7\zw\noindent ◆◆◆◆◆◆◆
1389 ある日モモちゃんがお使いで迷子になって泣きました.}\copy0
1390 \vrule height 0pt depth \dp0}}
1391 \def\s#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1392 \setbox0=\vtop{\hsize=7\zw\noindent ちょっと!何}\copy0}}
1393 \def\t#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 19.24432pt \g
1394 \setbox0=\hbox{漢}%
1395 \vrule width 0.4pt height\ht0 depth\dp0\kern-.2pt\copy0
1396 \kern-\wd0\vrule width\wd0height .2pt depth .2pt
1397 \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1398 \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1399 \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}}
1400 \begin{tabular}{rccc}
1401 \toprule
1402 &\tt jfm-ujis.lua&\tt jfm-jis.lua&\tt jfm-min.lua\\
1403 \midrule
1404 Example~1&\r{ujis}&\r{jis}&\r{min}\\
1405 Example~2&\s{ujis}&\s{jis}&\s{min}\\
1406 Bounding Box&\t{ujis}&\t{jis}&\t{min}\\
1407 \bottomrule
1408 \end{tabular}
1409 \end{center}
1410 \ltjsetparameter{jacharrange={-3}}
1411 \end{table}
1412
1413 \paragraph{Note: kern feature}\label{para-kern}
1414 Some fonts have information for inter-glyph spacing. However, this
1415 information is not well-compatible with \LuaTeX-ja.  More concretely,
1416 this kerning space from this information are inserted \emph{before} the
1417 insertion process of \textbf{JAglue}, and this causes incorrect spacing
1418 between two characters when both a glue/kern from the data in the font
1419 and it from JFM are present.
1420
1421 \begin{itemize}
1422 \item You should specify {\tt -kern} in
1423 {\tt\char92jfont} primitive, when you want to use other font features,
1424       such as {\tt script=...}\,.
1425 \item If you want to use Japanese fonts in proportinal width, and use
1426       information from this font, use \texttt{jfm-prop.lua} for its JFM, and ...
1427
1428 TODO: kanjiskip?
1429 \end{itemize}
1430
1431
1432 %<en>\subsection{Structure of JFM file}
1433 %<ja>\subsection{JFM ファイルの構造}
1434 A JFM file is a Lua script which has only one function call:
1435 \begin{verbatim}
1436 luatexja.jfont.define_jfm { ... }
1437 \end{verbatim}
1438 Real data are stored in the table which indicated above by
1439 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
1440 structure of this table.  Note that all lengths in a JFM file are
1441 floating-point numbers in design-size unit.
1442
1443 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1444 \item[dir=<direction>] (required)
1445
1446 The direction of JFM. At the present, only \texttt{'yoko'} is supported.
1447
1448 \item[zw=<length>] (required)
1449
1450 The amount of the length of the `full-width'.
1451
1452 \item[zh=<length>] (required)
1453
1454 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}] (optional)
1455
1456 This field specifies the `ideal' amount of \Param{kanjiskip}. As noted
1457              in Subsection~\ref{subs-kskip}, if the parameter
1458              \Param{kanjiskip} is \verb+\maxdimen+, the value specified
1459              in this field is actually used (if this field is not specified in
1460              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
1461              fields are in design-size unit too.
1462
1463
1464 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}] (optional)
1465
1466 Like the \Param{kanjiskip} field, this field specifies the `ideal'
1467              amount of \Param{xkanjiskip}.
1468
1469 \end{list}
1470
1471 Besides from above fields, a JFM file have several sub-tables those
1472 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
1473 informations of `character class'~$i$. At least, the character class~0 is
1474 always present, so each JFM file must have a sub-table whose index is
1475 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
1476 the following fields:
1477
1478 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1479 \item[chars=\{<character>, ...\}] (required except character class~0)
1480
1481 This field is a list of characters which are in this character
1482              type~$i$. This field is not required if $i=0$, since all
1483              \textbf{JAchar} which are not in any character class other
1484              than 0 (hence, the character class~0 contains most of
1485              \textbf{JAchar}s). In the list, a character can be
1486              specified by its code number, or by the character itself
1487              (as a string of length~1). Moreover, there are `imaginary
1488              characters' which specified in the list. We will describe these later.
1489
1490 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]\ (required)
1491
1492 Specify width of characters in character class~$i$, height, depth and
1493 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height and depth are
1494 as values of these fields. 
1495 But there is one exception: if \texttt{'prop'} is specified in \texttt{width} field, width of a character becomes that of its `real' glyph 
1496
1497 \item[left=<length>, down=<length>, align=<align>]\ 
1498
1499 These fields are for adjusting the position of the `real' glyph. Legal
1500              values of \texttt{align} field are \texttt{'left'},
1501              \texttt{'middle'} and \texttt{'right'}. If one of these
1502              3~fields are omitted, \texttt{left} and \texttt{down} are
1503              treated as~0, and \texttt{align} field is treated as
1504              \texttt{'left'}.
1505 The effects of these 3~fields are indicated in Figure~\ref{fig-pos}.
1506
1507 In most cases, \texttt{left} and \texttt{down} fields are~0, while
1508 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
1509 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed 
1510 when the current character class is the class for opening delimiters'. 
1511 \begin{figure}[!tb]
1512 \begin{minipage}{0.4\textwidth}%
1513 \begin{center}\unitlength=10pt\small
1514 \begin{picture}(15,12)(-1,-4)
1515 \color{black!10!white}% real glyph :step1
1516 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
1517
1518 \color{red!20!white}% real glyph :step1
1519 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
1520
1521 \color{red}% real glyph
1522 \thicklines
1523 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
1524 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
1525 \put(-1,5.5){\line(1,0){6}}
1526 \put(-1,-4){\line(1,0){6}}
1527
1528 \color{green!20!white}% real glyph :step1
1529 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
1530
1531 \color{black}% real glyph :step1
1532 \thicklines
1533 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
1534 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
1535 \put(0,8){\line(1,0){12}}
1536 \put(0,-3){\line(1,0){12}}
1537 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
1538 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
1539 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
1540
1541 \color{green!50!black}% real glyph :step1
1542 \thicklines
1543 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
1544 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
1545 \put(3,7){\line(1,0){6}}
1546 \put(3,-2.5){\line(1,0){6}}
1547 \newsavebox{\eqdist}
1548 \savebox{\eqdist}(0,0)[b]{%
1549   \thinlines
1550   \put(-0.08,0.2){\line(0,-1){0.4}}%
1551   \put(0.08,0.2){\line(0,-1){0.4}}}
1552 \put(1.5,0){\usebox{\eqdist}}
1553 \put(10.5,0){\usebox{\eqdist}}
1554
1555 \color{blue}% shifted
1556 \thicklines
1557 \put(3,-1.5){\vector(-1,0){4}}
1558 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
1559 \put(3,0){\vector(0,-1){1.5}}
1560 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
1561 \end{picture} 
1562 \end{center}
1563 \end{minipage}%
1564 \begin{minipage}{0.6\textwidth}%
1565 Consider a node containing Japanese character whose value of the \texttt{align} 
1566 field is \texttt{'middle'}.
1567 \begin{itemize}
1568 \item The black rectangle is a frame of the node.
1569 Its width, height and depth are specified by JFM.
1570 \item Since the \texttt{align} field is \texttt{'middle'}, 
1571 the `real' glyph is centered horizontally (the green rectangle).
1572 \item Furthermore, the glyph is shifted according to values of fields
1573       \texttt{left} and \texttt{down}. The ultimate position of the real
1574       glyph is indicated by the red rectangle.
1575 \end{itemize}
1576 \end{minipage}
1577 \caption{The position of the `real' glyph.}
1578 \label{fig-pos}
1579 \end{figure}
1580
1581
1582 \item[kern={\{[$j$]=<kern>, ...\}}]
1583
1584 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>\}, ...\}}]
1585 \end{list}
1586
1587 %<*en>
1588 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1589 \item['lineend'] An ending of a line. 
1590 \item['diffmet'] Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
1591 \item['boxbdd'] The beginning/ending of a horizontal box, and the beginging of a noindented paragraph.
1592 \item['parbdd'] The beginning of an (indented) paragraph.
1593 \item['jcharbdd'] A boundary between \textbf{JAchar} and anything else
1594              (such as \textbf{ALchar}, kern, glue, ...).
1595 \item[$-1$] The left/right boundary of an inline math formula.
1596 \end{list}
1597 %</en>
1598
1599 %<*ja>
1600 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
1601 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
1602 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
1603 い組版調整ができるようになっている.以下のその一覧を述べる:
1604 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1605 \item['lineend'] 行の終端を表す.
1606 \item['diffmet'] 
1607
1608 \item['boxbdd'] hboxの先頭と末尾,及びインデントされていない
1609              (\verb+\noindent+で開始された)段落の先頭を表す.
1610 \item['parbdd'] 通常の(\verb+\noindent+で開始されていない)段落の先頭.
1611 \item['jcharbdd'] 和文文字と「その他のもの」(欧文文字,glue,kern等)との境界.
1612 \item[$-1$] 行中数式と地の文との境界.
1613 \end{list}
1614
1615 \paragraph{\pTeX 用和文フォントメトリックの移植}
1616 以下に,\pTeX 用和文フォントメトリックを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
1617 \begin{itemize}
1618 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
1619 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
1620       トメトリック等を移植する場合は,
1621 \begin{itemize}
1622 \item JFM中の全ての数値を$1/0.962216$倍しておく.
1623 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
1624       \LaTeX でのフォント宣言なら,例えば次のように:
1625 \begin{verbatim}
1626 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
1627 \end{verbatim}
1628 \end{itemize}
1629 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
1630       (JFM中に単に書かなければよい).
1631 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
1632       文字クラスに関してはglue/kernの設定はしない.
1633
1634 これは,\pTeX では,
1635       hboxの先頭・末尾とインデントされていない(\verb+\noindent+で開始さ
1636       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
1637 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
1638
1639 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
1640       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
1641       は,段落の最初に手動で\verb+\inhibitglue+を追加するか,あるいは
1642       \verb+\everypar+のhackを行い,それを自動化させるしかなかった.
1643
1644 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
1645 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
1646 \texttt{'parbdd'}を入れれば全角下がりとなる.
1647
1648 \ltjsetparameter{jacharrange={+3}}
1649 \begin{LTXexample}
1650 \jfont\g=psft:Ryumin-Light:jfm=test \g
1651 \parindent1\zw\noindent{}◆◆◆◆◆
1652 \par{}「◆◆←二分下がり
1653 \par{}【◆◆←全角下がり
1654 \par{}〔◆◆←全角二分下がり
1655 \end{LTXexample}
1656 \end{itemize}
1657 \ltjsetparameter{jacharrange={-3}}
1658 %</ja>
1659
1660 %<en>\subsection{Math Font Family}
1661 %<ja>\subsection{数式フォントファミリ}
1662 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
1663 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX can handles 256~families, but
1664 an external package is needed to support this in plain \TeX\ and
1665 \LaTeX.}, and each family has three fonts:
1666 \verb+\textfont+, \verb+\scriptfont+ and \verb+\scriptscriptfont+.
1667
1668 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
1669 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
1670 font families. There is no relation between the value of
1671 \verb+\fam+ and that of \verb+\jfam+; with appropreate settings, 
1672 you can set both \verb+\fam+ and \verb+\jfam+ to~the same value.
1673
1674 \begin{table}[!tb]
1675 \caption{Primitives for Japanese math fonts.}
1676 \label{tab-math}
1677 \begin{center}\def\{{\char`\{}\def\}{\char`\}}
1678 \begin{tabular}{lll}
1679 \toprule
1680 &Japanese fonts&alphabetic fonts\\
1681 \midrule
1682 font family&\verb+\jfam+${}\in [0,256)$&\verb+\fam+\\
1683 text size&\tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\textfont+<fam>=<font\_cs>\\
1684 script size&\tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptfont+<fam>=<font\_cs>\\
1685 scriptscript size&\tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptscriptfont+<fam>=<font\_cs>\\
1686 \bottomrule
1687 \end{tabular}
1688 \end{center}
1689 \end{table}
1690
1691 %<en>\subsection{Callbacks}
1692 %<ja>\subsection{コールバック}
1693 Like \LuaTeX\ itself, \LuaTeX-ja also has callbacks. These callbacks can
1694 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks
1695 \begin{list}{}%
1696 {\def\makelabel#1{\bfseries#1}}
1697 \item[\texttt{luatexja.load\_jfm} callback]
1698 With this callback you can overwrite JFMs.
1699
1700 \begin{verbatim}
1701 function (<table> jfm_info, <string> jfm_name)
1702   return <table> new_jfm_info
1703 end
1704 \end{verbatim}
1705
1706 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except 
1707 this argument has \texttt{chars} field which contains character codes
1708              whose character class is not~0.
1709
1710 An example of this callback is the \texttt{ltjarticle} class, with
1711              forcefully assigning character class~0 to \texttt{'parbdd'}
1712              in the JFM \texttt{jfm-min.lua}. This callback doesn't
1713              replace any code of \LuaTeX-ja.
1714
1715 \item[\texttt{luatexja.define\_font} callback]
1716 This callback and the next callback form a pair, and you can assign letters which don't have
1717              fixed codepoints in Unicode to non-zero character classes.
1718 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
1719 \begin{verbatim}
1720 function (<table> jfont_info, <number> font_number)
1721   return <table> new_jfont_info
1722 end
1723 \end{verbatim}
1724
1725 You may assume that \verb+jfont_info+ has the following fields:
1726 \begin{description}
1727 \item[\tt jfm] The index number of JFM.
1728 \item[\tt size] Font size in a scaled point (${}=2^{-16}\,\textrm{pt}$).
1729 \item[\tt var] The value specified in \texttt{jfmvar=...} at a call of \verb+\jfont+.
1730 \end{description}
1731
1732 The returned table \verb+new_jfont_info+ also should include these three fields. 
1733 The \verb+font_number+ is a font number. 
1734
1735 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
1736              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
1737              CID characters in a JFM. This callback doesn't replace any
1738              code of \LuaTeX-ja.
1739
1740
1741 \item[\texttt{luatexja.find\_char\_class} callback]
1742 This callback is called just when \LuaTeX-ja inready to determine which
1743              character class a character \verb+chr_code+ belongs.
1744 A function used in this callback should be in the following form:
1745 \begin{lstlisting}[numbers=left]
1746 function (<number> char_class, <table> jfont_info, <number> chr_code)
1747   if char_class~=0 then return char_class
1748   else
1749     ....
1750     return (<number> new_char_class or 0)
1751   end
1752 end
1753 \end{lstlisting}
1754
1755 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
1756              routine or previous function calls in this callback, hence
1757              this argument may not be 0. Moreover, the returned
1758              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
1759              is not~0, otherwise you will overwrite the \LuaTeX-ja's
1760              default routine.
1761
1762 This callback doesn't replace any code of \LuaTeX-ja.
1763
1764
1765
1766 \end{list}
1767
1768
1769
1770 %<en>\section{Parameters}
1771 %<ja>\section{パラメータ}
1772 %<en>\subsection{{\tt\char92 ltjsetparameter} primitive}
1773 %<ja>\subsection{{\tt\char92 ltjsetparameter} プリミティブ}
1774 As noted before, \verb+\ltjsetparameter+ and \verb+\ltjgetparameter+ are
1775 primitives for accessing most parameters of \LuaTeX-ja. One of the main
1776 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\ 
1777 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+) 
1778 is the position of \verb+hpack_filter+ callback in the source
1779 of \LuaTeX, see Section~\ref{sec-para}.
1780
1781 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ are primitives
1782 for assigning parameters. These take one argument which is a
1783 \texttt{<key>=<value>} list. Allowed keys are described in the next
1784 subsection.  
1785 The difference between
1786 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ is only the
1787 scope of assignment;
1788 \verb+\ltjsetparameter+ does a local assignment and 
1789 \verb+\ltjglobalsetparameter+ does a global one. 
1790 They also obey the value of \verb+\globaldefs+,
1791 like other assignment.
1792
1793 \verb+\ltjgetparameter+ is the primitive for acquiring parameters. It
1794 always takes a parameter name as first argument, and also takes the
1795 additional argument---a character code, for example---in some cases.
1796 \begin{LTXexample}
1797 \ltjgetparameter{differentjfm}, 
1798 \ltjgetparameter{autospacing},
1799 \ltjgetparameter{prebreakpenalty}{`)}.
1800 \end{LTXexample}
1801 \emph{The return value of\/ {\normalfont\tt\char92ltjgetparameter} is
1802 always a string}. This is outputted by \texttt{tex.write()}, so any
1803 character other than space~`{\tt\char32}'~(U+0020) has the category code
1804 12~(other), while the space has 10~(space).
1805
1806 %<en>\subsection{List of Parameters}
1807 %<ja>\subsection{パラメータ一覧}
1808 The following is the list of parameters which can be specificated by the
1809 \verb+\ltjsetparameter+ command. [\verb+\cs+] indicates the counterpart
1810 in \pTeX, and symbols beside each parameter has the following meaning:
1811 \begin{itemize}
1812 \item No mark: values at the end of the paragraph or the hbox are
1813       adopted in the whole paragraph/hbox.
1814 \item `\ast' : local parameters, which can change everywhere inside a paragraph/hbox.
1815 \item `\dagger': assignments are always global.
1816 \end{itemize}
1817
1818 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1819 \item[\Param{jcharwidowpenalty}\,=<penalty>] [\verb+\jcharwidowpenalty+]
1820
1821 Penalty value for supressing orphans. This penalty is inserted just
1822              after the last \textbf{JAchar} which is not regarded as a
1823              (Japanese) punctuation mark.
1824
1825 \item[\Param{kcatcode}\,=\{<chr\_code>,<natural number>\}]\
1826
1827 An additional attributes having each character whose character code is <chr\_code>.  
1828 At the present version, the lowermost bit of <natural number> indicates
1829              whether the character is considered as a punctuation mark
1830              (see the description of \Param{jcharwidowpenalty} above).
1831
1832
1833 \item[\Param{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\prebreakpenalty+]\ 
1834 %<*ja>
1835 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
1836              この文字の前に挿入/追加されるペナルティの量を指定する.
1837
1838 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,標準で読み込まれる
1839              \texttt{luatexja-kinsoku.tex}において
1840 \begin{verbatim}
1841 \ltjsetparameter{prebreakpenalty={`〙,10000}}
1842 \end{verbatim}
1843 と,最大値の10000が指定されている.他にも,小書きのカナなど,絶対禁止とい
1844              うわけではないができれば行頭にはきて欲しくない場合に,0と
1845              10000の間の値を指定するのも有用であろう.
1846 \begin{verbatim}
1847 \ltjsetparameter{prebreakpenalty={`ゕ,150}}
1848 \end{verbatim}
1849 %</ja>
1850
1851 \item[\Param{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\postbreakpenalty+]
1852 %<*ja>
1853 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
1854              この文字の後に挿入/追加されるペナルティの量を指定する.
1855
1856 \pTeX では,\verb+\prebreakpenalty+, \verb+\postbreakpenalty+において,
1857 \begin{itemize}
1858 \item 一つの文字に対して,pre, postどちらか一つしか指定することができなかっ
1859       た(後から指定した方で上書きされる).
1860 \item pre, post合わせて256文字分の情報を格納することしかできなかった.
1861 \end{itemize}
1862 という制限があったが,\LuaTeX-ja ではこれらの制限は解消されている.
1863 %</ja>
1864
1865 \item[\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\textfont+ in \TeX]
1866 \item[\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\scriptfont+ in \TeX]
1867 \item[\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\scriptscriptfont+ in \TeX]
1868 \item[\Param{yjabaselineshift}\,=<dimen>$^\ast$]\ 
1869 \item[\Param{yalbaselineshift}\,=<dimen>$^\ast$] [\verb+\ybaselineshift+]
1870
1871 \item[\Param{jaxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\inhibitxspcode+]
1872
1873 Setting whether inserting  \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
1874 The followings are allowed for <mode>:
1875 \begin{description}
1876 \item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the charater, nor after the charater.
1877 \item[2, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the charater, but not after.
1878 \item[1, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the charater, but not before.
1879 \item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the charater and after the charater.
1880 This is the default value.
1881 \end{description}
1882
1883 \item[\Param{alxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\xspcode+]
1884
1885 Setting whether inserting \Param{xkanjiskip} is allowed before/after a
1886              \textbf{ALchar} whose character code is <chr\_code>.
1887 The followings are allowed for <mode>:
1888 \begin{description}
1889 \item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited
1890            before the charater, nor after the charater.
1891 \item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed
1892            before the charater, but not after.
1893 \item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed
1894            after the charater, but not before.
1895 \item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both
1896            before the charater and after the charater.
1897 This is the default value.
1898 \end{description}
1899 Note that parameters \Param{jaxspmode} and \Param{alxspmode} use a common table.
1900
1901 \item[\Param{autospacing}\,=<bool>$^\ast$] [\verb+\autospacing+]
1902 \item[\Param{autoxspacing}\,=<bool>$^\ast$] [\verb+\autoxspacing+]
1903 \item[\Param{kanjiskip}\,=<skip>] [\verb+\kanjiskip+]
1904 \item[\Param{xkanjiskip}\,=<skip>] [\verb+\xkanjiskip+]
1905
1906 \item[\Param{differentjfm}\,=<mode>$^\dagger$]
1907
1908 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different. 
1909 The allowed arguments are the followings:
1910 \begin{description}
1911 \item[\texttt{average}]
1912 \item[\texttt{both}]
1913 \item[\texttt{large}]
1914 \item[\texttt{small}]
1915 \end{description}
1916
1917 \item[\Param{jacharrange}\,=<ranges>$^\ast$]
1918 \item[\Param{kansujichar}\,=\{<digit>, <chr\_code>\}] [\verb+\kansujichar+]
1919 \end{list}
1920
1921
1922 %<en>\section{Other Primitives}
1923 %<ja>\section{その他のプリミティブ}
1924 %<en>\subsection{Primitives for Compatibility}
1925 %<ja>\subsection{互換プリミティブ}
1926 The following primtives are implemented for compatibility with \pTeX:
1927 \begin{list}{}{\def\makelabel{\ttfamily\char92 }}
1928 \item[kuten]
1929 \item[jis]
1930 \item[euc]
1931 \item[sjis]
1932 \item[ucs]
1933 \item[kansuji]
1934 \end{list}
1935 %<en>\subsection{{\tt\char92 inhibitglue} primitive}
1936 %<ja>\subsection{{\tt\char92 inhibitglue} プリミティブ}
1937 The primitive \verb+\inhibitglue+ suppresses the insertion of \textbf{JAglue}.
1938 The following is an example, using a special JFM that there will be a glue between 
1939 the beginning of a box and `あ', and also between `あ' and `ウ'.
1940
1941 \begin{LTXexample}
1942 \jfont\g=psft:Ryumin-Light:jfm=test \g
1943 あウあ\inhibitglue{}ウ\inhibitglue\par
1944 あ\par\inhibitglue{}あ
1945 \par\inhibitglue\hrule{}あoff\inhibitglue ice
1946 \end{LTXexample}
1947
1948 With the help of this example, we remark the specification of \verb+\inhibitglue+:
1949 \begin{itemize}
1950 \item The call of \verb+\inhibitglue+ in the (internal) vertical mode is
1951       effective at the beginning of the next paragraph. This is realized
1952       by hacking \verb+\everypar+.
1953 \item The call of \verb+\inhibitglue+ in the (restricted) horizontal
1954       mode is only effective on the spot; does not get over boundary of
1955       paragraphs. Moreover, \verb+\inhibitglue+ cancels ligatures and
1956       kernings, as shown in line~4 of above example.
1957 \item The call of \verb+\inhibitglue+ in math mode is just ignored.
1958 \end{itemize}
1959
1960 %<en>\section{Control Sequences for \LaTeXe}
1961 %<ja>\section{\LaTeXe 用のコントロールシーケンス}
1962 %<en>\subsection{Patch for NFSS2}
1963 %<ja>\subsection{NFSS2 へのパッチ}
1964 \label{ssub-nfsspat}
1965 As described in Subsection~\ref{ssec-ltx}, \LuaTeX-ja simply adopted
1966 \texttt{plfonts.dtx} in \pLaTeXe\ for the Japanese patch for NFSS2.
1967 For an convinience, we will describe
1968 commands which are not described in Subsection~\ref{ssub-chgfnt}.
1969
1970 \begin{cslist}%
1971 \item[DeclareYokoKanjiEncoding\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
1972 In NFSS2 under \LuaTeX-ja, distinction between alphabetic font families
1973              and Japanese font families is only made by its
1974              encoding. For example, encodings OT1 and T1 are for
1975              alphabetic font families, and a Japanese font family cannot
1976              have these encodings. This command defines a new encoding
1977              scheme for Japanese font family (in horizontal direction).
1978
1979 \item[DeclareKanjiEncodingDefaults\{<text-settings>\}\{<math-settings>\}]
1980 \item[DeclareKanjiSubstitution\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
1981 \item[DeclareErrorKanjiFont\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
1982
1983 The above 3~commands are just the counterparts for \verb+DeclareFontEncodingDefaults+ and~others.
1984
1985 \item[reDeclareMathAlphabet\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
1986 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
1987 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>と,和文数式用フォ
1988              ントファミリ変更の命令<ja-cmd>の2つを同時に行う命令として
1989              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
1990              <al-cmd>に同じものを指定する,すなわち,<al-cmd>に和文側も変
1991              更させるようにするのが一般的と思われる.
1992
1993 本コマンドの使用については,\pLaTeX 配布中の\texttt{plfonts.dtx}に詳しく
1994              注意点が述べられているので,そちらを参照されたい.
1995
1996 \item[DeclareRelationFont\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\
1997   \hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
1998 %<*en>
1999 This command sets the `accompanied' alphabetic font family (given by the latter 4~arguments) 
2000 with respect to a Japanese font family given by the former 4~arguments. 
2001 %</en>
2002 %<*ja>
2003 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントファミリに対して,
2004 そのフォントに対応する「従属欧文」フォントファミリを後半の4引数により与える.
2005 %</ja>
2006 \item[SetRelationFont]
2007 This command is almost same as \verb+\DeclareRelationFont+, except that this command does a local 
2008 assignment, where \verb+\DeclareRelationFont+ does a global assignment.
2009 \item[userelfont]
2010 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
2011              font family with respect to current Japanese font family,
2012              which was set by
2013              \verb+\DeclareRelationFont+ or \verb+SetRelationFont+.
2014 Like \verb+\fontfamily+, \verb+\selectfont+ is required to take an effect.
2015
2016 \item[adjustbaseline]
2017 ...
2018
2019 \item[fontfamily\{<family>\}]
2020 {\let\item\origitem
2021 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both}) 
2022 to <family>. Which family will be changed is determined as follows:
2023 \begin{itemize}
2024 \item Let current encoding scheme for Japanese fonts be
2025       <ja-enc>. Current Japanese font family will be changed to
2026       <family>, if one of the following two conditions is met:
2027 \begin{itemize}
2028 \item The family <fam> under the encoding <ja-enc> is already defined by
2029       \verb+\DeclareKanijFamily+.
2030 \item A font definition named \texttt{<enc><ja-enc>.fd} (the filename is
2031       all lowercase) exists.
2032 \end{itemize}
2033 \item Let current encoding scheme for Japanese fonts be
2034       <al-enc>. For alphabetic font family, the criterion as above is used.
2035 \item There is a case which none of the above applies, that is, the font
2036       family named <family> doesn't seem to be defined neither under the
2037       encoding <ja-enc>, nor under <al-enc>. 
2038
2039 In this case, the default family for font substitution is used for
2040       alphabetic and Japanese fonts. Note that current encoding will not
2041       be set to <family>, unlike the original inplementation in \LaTeX.
2042 \end{itemize}
2043 }
2044 \end{cslist}
2045
2046 As closing this subsection, we shall introduce an example of
2047 \verb+SetRelationFont+ and \verb+\userelfont+:
2048 \begin{LTXexample}
2049 \gtfamily{}あいうabc
2050 \SetRelationFont{JY3}{gt}{m}{n}{OT1}{pag}{m}{n}
2051 \userelfont\selectfont{}あいうabc
2052 \end{LTXexample}
2053
2054
2055 %<en>\subsection{Cropmark/`tombow'}
2056 %<ja>\subsection{トンボ}
2057
2058 %<en>\section{Extensions}
2059 %<ja>\section{拡張}
2060 \subsection{{\tt luatexja-fontspec.sty}}
2061
2062 \subsection{{\tt luatexja-otf.sty}}
2063 This optional package supports typesetting charaters in
2064 Adobe-Japan1. {\tt luatexja-otf.sty} offers the following 2~low-level
2065 commands:
2066 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
2067 \item[\char92CID\{<number>\}]
2068 Typeset a character whose CID number is <number>.
2069 \item[\char92UTF\{<hex\_number>\}]
2070 Typeset a character whose character code is <hex\_number> (in hexadecimal).
2071 This command is similar to \verb+\char"+<hex\_number>,\ %"
2072 but please remind remarks below.
2073 \end{list}
2074
2075 \paragraph{Remarks}
2076 Characters by \verb+\CID+ and \verb+\UTF+ commands are different from
2077 ordinary characters in the following points:
2078 \begin{itemize}
2079 \item Always treated as \textbf{JAchar}s.
2080 \item Processing codes for supporting OpenType features (\textit{e.g.},
2081       glyph replacement and kerning) by the \Pkg{luaotfload} package
2082       is not performed to these characters.
2083 \end{itemize}
2084
2085
2086 \paragraph{Additionally Syntax of JFM}
2087 {\tt luatexja-otf.sty} extends the syntax of JFM; the entries of {\tt
2088 chars} table in JFM now allows a string in the form
2089 \verb+'AJ1-xxx'+, which stands for the character 
2090 whose CID number in Adobe-Japan1 is \verb+xxx+. 
2091
2092 %<en>\part{Implementations}
2093 %<ja>\part{実装}
2094 \label{part-imp}
2095 %<en>\section{Storing Parameters}
2096 %<ja>\section{パラメータの保持}
2097 \label{sec-para}
2098 %<en>\subsection{Used Dimensions, Attributes and whatsit nodes}
2099 %<ja>\subsection{用いられる寸法レジスタ,属性レジスタ,whatsit ノード}
2100 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
2101 \begin{list}{}{%
2102 \def\makelabel{\ttfamily}
2103 \def\dim#1{\item[\char92 #1\ \textrm{(dimension)}]}
2104 \def\attr#1{\item[\char92 #1\ \textrm{(attribute)}]}
2105 }
2106
2107 \dim{jQ}
2108 As explained in Subsection~\ref{ssec-plain}, \verb+\jQ+ is equal to
2109                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where `Q'~(also called `級') is
2110                         a unit used in Japanese phototypesetting. So one should not change the value of this dimension. 
2111 \dim{jH}
2112 There is also a unit called `歯' which equals to $0.25\,\textrm{mm}$ and
2113                         used in Japanese phototypesetting. The dimension
2114                         \verb+\jH+ stores this length, similar to \verb+\jQ+. 
2115 \dim{ltj@zw} A temporal register for the `full-width' of current Japanese font.
2116 \dim{ltj@zh} A temporal register for the `full-height' (usually the sum of height of imaginary body and its depth) of current Japanese font.
2117 \attr{jfam} Current number of Japanese font family for math formulas.
2118 \attr{ltj@curjfnt} The font index of current Japanese font.
2119 \attr{ltj@charclass} The character class of Japanese \textit{glyph\_node}.
2120 \attr{ltj@yablshift} The amount of shifting the baseline of alphabetic
2121                         fonts in scaled point ($2^{-16}\,\textrm{pt}$).
2122 \attr{ltj@ykblshift} The amount of shifting the baseline of Japanese
2123                         fonts in scaled point ($2^{-16}\,\textrm{pt}$).
2124 \attr{ltj@autospc} Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
2125 \attr{ltj@autoxspc} Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
2126 \attr{ltj@icflag} An attribute for distinguishing `kinds' of a node. One of the following value is
2127                         assigned to this attribute:
2128 \begin{description}
2129 \item[\textit{italic} (1)] Glues from an itaric correction
2130            (\verb+\/+). This distinction of origins of glues 
2131            (from explicit \verb+\kern+, or from \verb+\/+)
2132            is needed in the insertion process of \Param{xkanjiskip}.
2133 \item[\textit{packed} (2)] 
2134 \item[\textit{kinsoku} (3)] Penalties inserted for the word-wrapping  process of Japanese characters (\emph{kinsoku}).
2135 \item[\textit{from\_jfm} (4)] Glues/kerns from JFM.
2136 \item[\textit{line\_end} (5)] Kerns for ...
2137 \item[\textit{kanji\_skip} (6)] Glues for \Param{kanjiskip}.
2138 \item[\textit{xkanji\_skip} (7)] Glues for \Param{xkanjiskip}.
2139 \item[\textit{processed} (8)] Nodes which is already processed by ...
2140 \item[\textit{ic\_processed} (9)] Glues from an itaric correction, but also already processed.
2141 \item[\textit{boxbdd} (15)] Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
2142 \end{description}
2143 \attr{ltj@kcat$i$} Where $i$~is a natural number which is less than~7.
2144 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
2145 \end{list}
2146
2147 Furthermore, \LuaTeX-ja uses several `user-defined' whatsit nodes for
2148 typesetting. All those nodes store a natural number (hence the node's
2149 \texttt{type} is 100).
2150 \begin{description}
2151 \item[30111] Nodes for indicating that \verb+\inhibitglue+ is
2152            specified. The \texttt{value} field of these nodes doesn't matter.
2153 \item[30112] Nodes for \LuaTeX-ja's stack system (see the next
2154            subsection). The \texttt{value} field of these nodes is
2155            current group.
2156 \item[30113] Nodes for Japanese Characters which the callback process of
2157            luaotfload won't be applied, andd the character code is
2158            stored in the \texttt{value} field. Each node having this
2159            \verb+user_id+ is converted to a `glyph\_node' \emph{after}
2160            the callback process of luaotfload.
2161 \end{description}
2162 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
2163
2164 %<en>\subsection{Stack System of \LuaTeX-ja}
2165 %<ja>\subsection{\LuaTeX-ja のスタックシステム}
2166 \label{ssec-stack}
2167 \paragraph{Background}
2168 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
2169 are stored in it.  To clarify the reason, imagine the parameter
2170 \Param{kanjiskip} is stored by a skip, and consider the following
2171 source:
2172 \begin{LTXexample}
2173 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
2174 \setbox0=\hbox{\ltjsetparameter{kanjiskip=5pt}ほげほげ}
2175 \box0.ぴよぴよ\par
2176 \end{LTXexample}
2177
2178 As described in Part~\ref{part-ref}, the only effective value of
2179 \Param{kanjiskip} in an hbox is the latest value, so the value of
2180 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
2181 However, by the implementation method of \LuaTeX, this `5\,pt' cannot be
2182 known from any callbacks.  In the \texttt{tex/packaging.w} (which is a
2183 file in the source of \LuaTeX), there are the following codes:
2184 \begin{lstlisting}
2185 void package(int c)
2186 {
2187     scaled h;                   /* height of box */
2188     halfword p;                 /* first node in a box */
2189     scaled d;                   /* max depth */
2190     int grp;
2191     grp = cur_group;
2192     d = box_max_depth;
2193     unsave();
2194     save_ptr -= 4;
2195     if (cur_list.mode_field == -hmode) {
2196         cur_box = filtered_hpack(cur_list.head_field,
2197                                  cur_list.tail_field, saved_value(1),
2198                                  saved_level(1), grp, saved_level(2));
2199         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
2200 \end{lstlisting}
2201 Notice that \verb+unsave+ is executed \emph{before}
2202 \verb+filtered_hpack+ (this is where \verb+hpack_filter+ callback is
2203 executed): so `5\,pt' in the above source is orphaned at
2204 \texttt+unsave+, and hence it can't be accessed from \verb+hpack_filter+
2205 callback.
2206
2207 \paragraph{The method}
2208 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
2209 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
2210
2211 These are two \TeX\ count registers for maintaining informations:
2212 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
2213 the \TeX's group level when the last assignment was done.  Parameters
2214 are stored in one big table named \texttt{charprop\_stack\_table}, where
2215 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
2216 a new stack level is created by \verb+\ltjsetparameter+, all data of the
2217 previous level is copied.
2218
2219 To resolve the problem mentioned in `Background' above, \LuaTeX-ja uses
2220 another thing: When a new stack level is about to be created, a whatsit
2221 node whose type, subtype and value are 44~(\textit{user\_defined}),
2222 30112, and current group level respectively is appended to the current
2223 list (we refer this node by \textit{stack\_flag}). This enables us to
2224 know whether assignment is done just inside a hbox. Suppose that the
2225 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
2226 group, then:
2227 \begin{itemize}
2228 \item If there is no \textit{stack\_flag} node in the list of hbox, then
2229       no assignment was occurred inside the hbox. Hence values of
2230       parameters at the end of the hbox are stored in the stack
2231       level~$s$.
2232 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
2233       an assignment was occurred just inside the hbox group. Hence
2234       values of parameters at the end of the hbox are stored in the
2235       stack level~$s+1$.
2236 \item If there are \textit{stack\_flag} nodes but all of their values
2237       are more than~$t+1$, then an assignment was occurred in the box,
2238       but it is done is `more internal' group. Hence values of
2239       parameters at the end of the hbox are stored in the stack
2240       level~$s$.
2241 \end{itemize}
2242
2243 Note that to work this trick correctly, assignments to
2244 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always, 
2245 regardless the value of \verb+\globaldefs+.
2246 This problem is resolved by using
2247 \hbox{\verb+\directlua{tex.globaldefs=0}+} (this assignment is local).
2248
2249
2250 %<en>\section{Linebreak after Japanese Character}
2251 %<ja>\section{和文文字直後の改行}
2252 \label{sec-lbreak}
2253 %<en>\subsection{Reference: Behavior in \pTeX}
2254 %<ja>\subsection{参考: \pTeX の挙動}
2255 %<*en>
2256 In~\pTeX, a linebreak after a Japanese character doesn't emit a space,
2257 since words are not separated by spaces in Japanese writings. However,
2258 this feature isn't fully implemented in \LuaTeX-ja due to the
2259 specification of callbacks in~\LuaTeX. To clarify the difference between
2260 \pTeX~and~\LuaTeX, We briefly describe the handling of a linebreak in~\pTeX, in
2261 this subsection. 
2262
2263 \pTeX's input processor can be described in terms of a finite state
2264 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
2265 internal states are as follows:
2266 \begin{itemize}
2267 \item State~$N$: new line
2268 \item State~$S$: skipping spaces
2269 \item State~$M$: middle of line
2270 \item State~$K$: after a Japanese character
2271 \end{itemize}
2272 The first three states---$N$, $S$~and~$M$---are as same as \TeX's input
2273 processor.  State~$K$ is similar to state~$M$, and is entered after
2274 Japanese characters.  The diagram of state transitions are indicated in
2275 Figure~\ref{fig-ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
2276 after `beginning/ending of a group' characters.
2277 %</en>
2278
2279 %<*ja>
2280 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
2281 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどどこでも改行が可能なため,
2282 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
2283
2284 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
2285 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
2286 以下に述べるような4状態を持っている.
2287
2288 \begin{itemize}
2289 \item State~$N$: 行の開始.
2290 \item State~$S$: 空白読み飛ばし.
2291 \item State~$M$: 行中.
2292 \item State~$K$: 行中(和文文字の後).
2293 \end{itemize}
2294 また,状態遷移は,図\label{fig-ptexipro}のようになっており,図中の数字は
2295 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
2296 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
2297 じものになる.
2298
2299 この図から分かることは,
2300 \begin{quote}
2301 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
2302 \end{quote}
2303 ということである.
2304 %</ja>
2305
2306 \begin{figure}[!tb]
2307 \begin{gather*}
2308  \def\sp{\text{\tt\char32}}
2309  \xymatrix{&&
2310    {\text{scan a cs}}\ar@(r,ul)[dr]&\\
2311 \ar[r]&
2312    *++[o][F-]{N}\ar[ur]^0\ar[dd]_{d,\ g}\ar[u]^{5\ (\text{\tt\char92par})}
2313      \ar@{->}@(d,l)[ddrr]_(0.45){j}&&
2314    *++[o][F-]{S}\ar@(l,dr)[ul]^0\ar@(l,ur)[ddll]_{d,\ g}\ar[u]_{5}
2315      \ar@{->}@(r,r)[dd]^{j}\\&\\&
2316    *++[o][F-]{M}\ar[uuur]^0\ar@(r,dl)[uurr]_(0.55){10\ (\sp)}
2317      \ar[d]_{5\ ({\sp})}\ar@{->}@(dr,dl)[rr]_{j}&&
2318    *++[o][F-]{K}\ar@{->}@(ul,d)[uuul]^0\ar@{->}[ll]^{d}
2319      \ar@{->}@(ur,dr)[uu]^{10\ (\sp)}\ar@{->}[d]_5\\
2320    &&&
2321  }\\
2322  d:=\{3,4,6,7,8,11,12,13\},\quad g:=\{1,2\},\quad j:=(\text{Japanese characters})
2323 \end{gather*}
2324 \begin{itemize}
2325 \item Numbers represent category codes.
2326 \item Category codes 9~(ignored), 14~(comment)~and~15~(invalid) are omitted in above diagram.
2327 \end{itemize}
2328 \caption{State transitions of \pTeX's input processor.}
2329 \label{fig-ptexipro}
2330 \end{figure}
2331
2332
2333 %<en>\subsection{Behavior in \LuaTeX-ja}
2334 %<ja>\subsection{\LuaTeX-ja の挙動}
2335 %<*en>
2336 States in the input processoe of \LuaTeX\ is the same as that of \TeX,
2337 and they can't be customized by any callbacks. Hence, we can only use
2338 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
2339 suppress a space by a linebreak which is after Japanese characters.
2340
2341 However, \verb+token_filter+ callback cannot be used either, since a
2342 character in category code 5~(end-of-line) is converted into an space
2343 token \emph{in the input processor}.  So we can use only the
2344 \verb+process_input_buffer+ callback.  This means that suppressing a
2345 space must be done \emph{just before} an input line is read.
2346
2347 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
2348 \begin{quote}
2349 A character U+FFFFF (its category code is set to 14~(comment) by
2350 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
2351 process it}, if and only if the following two conditions are satisfied:
2352 \begin{enumerate}
2353 \item The category code of the character $\langle${return}$\rangle$
2354       (whose character code is 13) is 5~(end-of-line).
2355 \item The input line matches the following `regular expression':
2356 \[
2357   (\text{any char})^*(\textbf{JAchar})
2358   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
2359 \]
2360 \end{enumerate}
2361 \end{quote}
2362
2363 \paragraph{Remark}
2364 The following example shows the major difference from the behavior of \pTeX:
2365 \begin{LTXexample}
2366 \ltjsetparameter{autoxspacing=false}
2367 \ltjsetparameter{jacharrange={-6}}xあ
2368 y\ltjsetparameter{jacharrange={+6}}zあ
2369 u
2370 \end{LTXexample}
2371 \begin{itemize}
2372 \item There is no space between `x' and `y', since the line~2 ends with a \textbf{JAchar} `あ'
2373 (this `あ' considered as an \textbf{JAchar} at the ending of line~1).
2374 \item There is no space between `あ' (in the line~3) and `u', since the
2375       line~3 ends with an \textbf{ALchar}
2376 (the letter `あ' considered as an \textbf{ALchar} at the ending of line~2).
2377 \end{itemize}
2378 %</en>
2379
2380 %<*ja>
2381 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,callbackによりユーザが
2382 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
2383 きそうなcallbackとしては,\verb+process_input_buffer+や
2384 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
2385 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
2386 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
2387 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
2388 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
2389
2390 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
2391 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
2392 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
2393
2394 \begin{quote}
2395 各入力行に対し,\textbf{その入力行が読まれる前の内部状態で}
2396 以下の2条件が満たされている場合,\LuaTeX-jaはU+FFFFF番の文字
2397 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
2398 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
2399 \begin{enumerate}
2400 \item 改行文字(文字コード13番)のカテゴリーコードが5~(end-of-line)である.
2401 \item 入力行は次の「正規表現」にマッチしている:
2402 \[
2403   (\text{any char})^*(\textbf{JAchar})
2404   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
2405 \]
2406 \end{enumerate}
2407 \end{quote}
2408
2409 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.最初の条件は,
2410 \texttt{verbatim}系環境などの日本語対応マクロを書かなくてすませるためのものである.
2411 しかしながら,完全に同じ挙動が実現できたわけではない.
2412 差異は,次の例が示すように,和文文字の範囲を変更した行の改行において見られる:
2413 \begin{LTXexample}
2414 \ltjsetparameter{autoxspacing=false}
2415 \ltjsetparameter{jacharrange={-6}}xあ
2416 y\ltjsetparameter{jacharrange={+6}}zあ
2417 u
2418 \end{LTXexample}
2419 もし\pTeX とまったく同じ挙動を示すならば,出力は
2420 「\hbox{\ltjsetparameter{autoxspacing=false}x yzあu}」となるべきである.しかし,実際には
2421 上のように異なる挙動となっている.
2422 \begin{itemize}
2423 \item 2行目は「あ」という和文文字で終わる(2行目を処理する前の時点では,
2424       「あ」は和文文字扱いである)ため,直後の改行文字は無視される.
2425 \item 3行目は「あ」という欧文文字で終わる(2行目を処理する前の時点では,
2426       「あ」は欧文文字扱いである)ため,直後の改行文字は空白に置き換わる.
2427 \end{itemize}
2428 このため,トラブルを避けるために,和文文字の範囲を\verb+\ltjsetparameter+で編集した場合,
2429 その行はそこで改行するようにした方がいいだろう.
2430 %</ja>
2431
2432
2433 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
2434 %<ja>\section{JFM グルーの挿入,\Param{kanjiskip} と \Param{xkanjiskip}}
2435 %<en>\subsection{Overview}
2436 %<ja>\subsection{概要}
2437 %<*en>
2438 NOT COMPLETED
2439 %</en>
2440
2441 %<*ja>
2442 \LuaTeX-ja における和文処理グルーの挿入方法は,\pTeX のそれとは全く異なる.
2443 \pTeX では次のような仕様であった:
2444 \begin{itemize}
2445 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
2446 追加する過程で行われる.
2447 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
2448 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
2449 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
2450 \end{itemize}
2451 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
2452 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
2453 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
2454 カーニング処理がノードベースになったことに対応する変更である.
2455
2456 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,下の図\ref{fig-clu}のよう
2457 に「塊」を単位にして行われる.大雑把にいうと,「塊」は文字とそれに付随す
2458 るノード達(アクセント位置補正用のkernや,イタリック補正)をまとめたもの
2459 であり,2つの塊の間には,ペナルティ,\verb+\vadjust+,whatsitなど,行組版
2460 には関係しないものがある.そのため,……
2461 %</ja>
2462
2463 % \begin{figure}[!tb]
2464 % \unitlength=10mm
2465 % \end{figure}
2466
2467 %<en>\subsection{Definition of a `cluster'}
2468 %<ja>\subsection{「クラスタ」の定義}
2469
2470 \begin{defn}
2471 A \emph{cluster} is a list of nodes in one of the following forms, with the \textit{id} of it:
2472 \begin{enumerate}
2473 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
2474       nodes come from a hbox which is already packaged, by unpackaging
2475       (\verb+\unhbox+).
2476       The \textit{id} is \textit{id\_pbox}.
2477 \item A inline math formula, including two \textit{math\_node}s at the boundary of it:
2478 HOGE
2479       The \textit{id} is \textit{id\_math}.
2480 \item A \textit{glyph\_node} with nodes which relate with it: 
2481 HOGE
2482 The \textit{id} is \textit{id\_jglyph} or
2483 \textit{id\_glyph}, according to whether the \textit{glyph\_node}
2484 represents a Japanese character or not.
2485 \item An box-like node, that is, an hbox, an vbox and an rule (\verb+\vrule+). 
2486 The \textit{id} is \textit{id\_hlist} if the node is an
2487       hbox which is not shifted vertically, or \textit{id\_box\_like}
2488       otherwise.
2489 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
2490 The \textit{id} is \textit{id\_glue}, \textit{id\_kern}
2491       and \textit{id\_disc}, respectively.
2492 %Just a node which will \dots, \textit{i.e.}, a node which is \emph{not} one of the following:
2493 %\textit{ins\_node}, \textit{mark\_node}, \textit{adjust\_node}, \textit{whatsit\_node}
2494 %and \textit{penalty\_node}.
2495 \end{enumerate}
2496 We denote a cluster by \textit{Np}, \textit{Nq} and \textit{Nr}.
2497 \end{defn}
2498
2499 Internally, a cluster is represented by a table $\textit{Np}$ with the following fields.
2500
2501 \begin{description}
2502 \def\makelabel#1{\textbf{\textit{#1}}}
2503 \item[first, last] The first/last node of the cluster.
2504 \item[id] The \textit{id} in above definition.
2505 \item[nuc]
2506
2507 % jachar
2508 \item[auto\_kspc, auto\_xspc]
2509 \item[xspc\_before, xspc\_after]
2510
2511 % alchar, jachar
2512 \item[pre, post]
2513 \item[char]
2514 \item[class]
2515 \item[lend]
2516 \item[met, var]
2517 \end{description}
2518 \end{document}