OSDN Git Service

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