OSDN Git Service

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