OSDN Git Service

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