1 %#! lualatex -shell-escape manual.ins
3 %<en>\documentclass[a4paper,titlepage]{article}
4 %<ja>\documentclass[a4paper,titlepage]{ltjsarticle}
5 \usepackage[margin=20mm,footskip=5mm]{geometry}
7 \usepackage{amsmath,amssymb,xcolor,pict2e,multienum,amsthm,float}
8 \usepackage{booktabs,listings,lltjlisting,showexpl,multicol}
9 \usepackage{luatexja-otf}
10 \usepackage{luatexja-fontspec}
11 \usepackage[unicode]{hyperref}
15 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
16 \DeclareRobustCommand\LuaTeX{Lua\TeX}
17 \DeclareRobustCommand\pdfTeX{pdf\TeX}
18 \DeclareRobustCommand\pTeX{p\kern-.05em\TeX}
19 \DeclareRobustCommand\upTeX{p\kern-.05em\TeX}
20 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
21 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
22 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\kern-.125em\pTeX}
24 \ltjsetparameter{jacharrange={-3}}
25 \theoremstyle{definition}
26 %<en>\newtheorem{defn}{Definition}
27 %<ja>\newtheorem{defn}{定義}
29 \newenvironment{cslist}{%
30 \leftskip2em\parindent=0pt\def\makelabel##1{{\tt\char92##1}}
31 \def\{{\char`\{}\def\}{\char`\}}
33 \def\item[##1]{\par\smallskip\par\hskip-\leftskip\makelabel{##1}\par}
37 \long\def\@makecaption#1#2{%
38 \vskip\abovecaptionskip
39 \sbox\@tempboxa{{\small #1. #2}}%
40 \ifdim \wd\@tempboxa >\hsize
43 \global \@minipagefalse
44 \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
46 \vskip\belowcaptionskip}
50 \title{The \LuaTeX-ja package}
51 \author{The \LuaTeX-ja project team}
54 \title{\LuaTeX-jaパッケージ}
55 \author{\LuaTeX-jaプロジェクトチーム}
59 basicstyle=\ttfamily\small, pos=o, breaklines=true,
60 numbers=none, rframe={}, basewidth=0.5em
63 \parskip=\smallskipamount
64 \protected\def\Param#1{\textsf{#1}} % parameter name
65 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
69 \def<#1>{{\normalfont\rm\itshape$\langle$#1$\rangle$}}
76 {\Large\bf This documentation is far from complete. It may have many
77 grammatical (and contextual) errors.}
80 \textbf{\large 本ドキュメントはまだまだ未完成です.}
84 %<en>\part{User's manual}
85 %<ja>\part{ユーザーズマニュアル}
87 %<en>\section{Introduction}
91 The \LuaTeX-ja package is a macro package for typesetting high-quality
92 Japanese documents when using \LuaTeX.
95 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
96 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
99 %<en>\subsection{Backgrounds}
103 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
104 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
105 extension of \TeX: so it can produce high-quality Japanese documents
106 without using very complicated macros. But this point is a mixed
107 blessing: \pTeX\ is left behind from other extensions of \TeX,
108 especially \eTeX\ and pdf\TeX, and from changes about
109 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
112 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
113 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
114 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
115 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
116 もなってしまった:\pTeX という(組版的に)満足なものがあったため,海外で
117 行われている数々の\TeX の拡張──例えば\eTeX や\pdfTeX ──や,TrueType,
118 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
123 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
124 of \pTeX) and \epTeX\ (merging of \pTeX\ and
125 \eTeX\ extension), have developed to fill those gaps to some
126 extent, but gaps still exist.
129 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
130 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
131 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
132 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
133 るようになった.だが,\pdfTeX 拡張(pdf直接出力やmicro-typesetting)を
134 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
139 However, the appearance of \LuaTeX\ changed the whole situation. With
140 using Lua `callbacks', users can customize the internal processing of
141 \LuaTeX. So there is no need to modify sources of engines to
142 support Japanese typesetting: to do this, we only have to write Lua
143 scripts for appropriate callbacks.
146 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
147 `callback'を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
148 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
149 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
150 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
151 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
155 %<en>\subsection{Major Changes from \pTeX}
156 %<ja>\subsection{\pTeX からの主な変更点}
159 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
160 target of development was to implement features of \pTeX. However,
161 \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
162 specifications/behaviors of \pTeX\ were not adopted}.
165 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
166 能をLuaコードにより実装することであった.しかし,開発が進むにつれ,\pTeX
167 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
168 ているような状況も発見された.そのため,\textbf{\LuaTeX-ja は,もはや
169 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
174 The followings are major changes from \pTeX:
177 以下は \pTeX からの主な変更点である.
182 \item A Japanese font is a tuple of a `real' font, a Japanese font
183 metric (\textbf{JFM}, for short), and an optional string called
187 \item 和文フォントは「実際の」フォント,和文フォントメトリック(JFM と呼ぶ),そ
188 して `variation' と呼ばれる文字列の組である.
192 \item In \pTeX, a linebreak after Japanese character is ignored (and
193 doesn't yield a space), since linebreaks (in source files) are
194 permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
195 doesn't have this function completely, because of a specification
199 \item 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
200 直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
201 \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
205 \item The insertion process of glues/kerns between two Japanese
206 characters and between a Japanese character and other characters
207 (we refer these glues/kerns as \textbf{JAglue}) is rewritten from
211 \item 2つの和文文字の間,和文文字と欧文文字の間に入るグルー/カーン
212 (\textbf{JAglue} と呼ぶ)の挿入処理が0から書き直されている.
217 \item As \LuaTeX's internal character handling is `node-based'
218 (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
219 insertion process of \textbf{JAglue} is now `node-based'.
222 \item \LuaTeX の内部での文字の扱いが「ノードベース」になっているように(例えば,
223 \verb+of{}fice+ で合字は抑制されない),\textbf{JAglue} の挿入処理も
228 \item Furthermore, nodes between two characters which have no effects in
229 linebreak (\textit{e.g.}, \verb+\special+ node) and kerns from
230 italic correction are ignored in the insertion process.
233 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば
234 \verb+\special+ ノード)や,イタリック補正に伴う挿入されるカーンは
239 \item \emph{Caution: due to above two points, many methods which did the
240 dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
241 effective anymore.} In concrete terms, the following two methods are not effective anymore:
244 \item \textbf{注意:上の2つの変更により,従来 \textbf{JAglue} の挿入処理を分断するのに
245 使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
251 If you want to do so, please put an empty hbox between it instead:
254 もし同じことをやりたければ,空のhboxを間に挟むようにしてください:
262 \item In the process, two Japanese fonts which only differ in their `real'
263 fonts are identified.
266 \item 処理中では,2つの和文フォントは,「実際の」フォントのみが異なる場合に同一視
272 \item At the present, vertical typesetting (\emph{tategaki}), is not
273 supported in \LuaTeX-ja.
276 \item 現時点では,縦書きは \LuaTeX-ja ではサポートされていない.
282 For detailed information, see Part~\ref{part-imp}.
285 詳細については第 \ref{part-imp} 部を見よ.
288 %<en>\subsection{Notations}
289 %<ja>\subsection{用語と記法}
292 In this document, the following terms and notations are used:
295 本ドキュメントでは,以下の用語と記法を用いる:
300 \item Characters are divided into two types:
307 \item \textbf{JAchar}: standing for Japanese characters such as
308 Hiragana, Katakana, Kanji and other punctuation marks for
312 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった和文文字の
317 \item \textbf{ALchar}: standing for all other characters like alphabets.
320 \item \textbf{ALchar}: アルファベットを始めとする,その他全ての文字を指す.
325 We say `alphabetic fonts' for fonts used in \textbf{ALchar}, and `Japanese fonts' for fonts used in \textbf{JAchar}.
328 そして,\textbf{ALchar} の出力に用いられるフォントを「欧文フォント」と呼び,
329 \textbf{JAchar} の出力に用いられるフォントを「和文フォント」と呼ぶ.
333 \item A word in a sans-serif font (like \Param{prebreakpenalty})
334 means an internal parameter for Japanese typesetting, and it
335 is used as a key in \verb+\ltjsetparameter+ command.
338 \item サンセリフ体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
339 パラメータを表し,これらは \verb+\ltjsetparameter+ コマンドのキーとして
344 \item A word in typewriter font with underline (like \Pkg{fontspec})
345 means a package or a class of \LaTeX.
348 \item 下線付きのタイプライタ体で書かれた語(例:\Pkg{fontspec})は \LaTeX の
353 \item The word `primitive' is used not only for primitives in \LuaTeX,
354 but also for control sequences that defined in the core module of
358 \item 「プリミティブ」という語を,\LuaTeX のプリミティブだけではなく \LuaTeX-ja
359 のコアモジュールで定義されたコントロールシーケンスに対しても用いる.
363 \item In this document, natural numbers start from~0.
366 \item 本ドキュメントでは,自然数は0から始まる.
370 %<en>\subsection{About the project}
371 %<ja>\subsection{プロジェクトについて}
374 \paragraph{Project Wiki} Project Wiki is under construction.
377 \paragraph{プロジェクト Wiki} プロジェクト Wiki は構築中である.
382 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
383 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
388 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
389 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
394 This project is hosted by SourceForge.JP.
397 本プロジェクトは SourceForge.JP のサービスを用いて運営されている.
400 %<en>\paragraph{Members}\
401 %<ja>\paragraph{開発メンバー}\
403 \begin{multienumerate}
404 \def\labelenumi{$\bullet$}
405 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
406 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
407 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{}
411 \begin{multienumerate}
412 \def\labelenumi{$\bullet$}
413 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
414 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
415 \mitemxxx{本田 知亮}{齋藤修三郎}{}
420 % \paragraph{Acknowledgments} -- 挿入するならここ
423 %<en>\section{Getting Started}
425 %<en>\subsection{Installation}
426 %<ja>\subsection{インストール}
429 To install the \LuaTeX-ja\ package, you will need:
432 \LuaTeX-ja パッケージのインストールには,次のものが必要である.
436 \item \LuaTeX\ (version 0.65.0-beta or later) and its supporting packages.\\
437 If you are using \TeX~Live~2011 or current W32\TeX, you don't have to worry.
440 \item \LuaTeX(バージョン 0.65.0-beta 以降)とその支援パッケージ.
441 \TeX~Live~2011 や W32\TeX の最新版ならば問題ない.
444 \item The source archive of \LuaTeX-ja, of course{\tt:)}
447 \item \LuaTeX-ja のソースアーカイブ(もちろん {\tt:)}).
452 The installation methods are as follows:
459 \item Download the source archive.
461 At the present, \LuaTeX-ja has no official release, so you have to retrieve
462 the archive from the repository.
463 You can retrieve the Git repository via
466 \item ソースアーカイブをダウンロードする.
468 現時点では,\LuaTeX-ja の公式リリースはないので,レポジトリからアーカイブを
470 次のようにすることで,Git レポジトリを取得することができる:
473 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
476 or download the archive of HEAD in \texttt{master} branch from
479 もしくは,\texttt{master} ブランチの HEAD アーカイブを以下からダウンロードすることができる:
482 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
486 Note that the forefront of development may not be in \texttt{master} branch.
489 開発中の最新の成果は \texttt{master} ブランチには含まれていないかもしれないことに注意.
493 \item Extract the archive. You will see {\tt src/} and several other sub-directories.
496 \item アーカイブを展開する.{\tt src/} をはじめとしたいくつかのディレクトリができる.
500 \item Copy all the contents of {\tt src/} into one of your \texttt{TEXMF} tree.
503 \item {\tt src/} の中身全てを自分の \texttt{TEXMF} ツリーにコピーする.
507 \item If {\tt mktexlsr} is needed to update the filename database, make it so.
510 \item もし {\tt mktexlsr} を実行する必要があればそうする.
514 %<en>\subsection{Cautions}
515 %<ja>\subsection{注意点}
519 \item The encoding of your source file must be UTF-8. No other
520 encodings, such as EUC-JP or Shift-JIS, are not supported.
523 \item 原稿のソースファイルの文字コードは UTF-8 でなければならない.
524 EUC-JP や Shift-JIS は使用できない.
528 \item May be conflict with other packages.
530 For example, the default setting of \textbf{JAchar} in the present
531 version does not coexist with the \Pkg{unicode-math}
532 package. Putting the following line in preamble makes that
533 mathematical symbols will be typeset correctly, but several
534 Japanese characters will be treated as an \textbf{ALchar} as
538 \item いくつかのパッケージと衝突する.
540 例えば,\textbf{JAchar} の範囲の設定がデフォルトのままだと,現行の
541 バージョンでは \Pkg{unicode-math} パッケージと共存できない.
542 以下の行をプリアンブルに追加することで数学記号が正しく出るように
543 なるが,副作用としていくつかの和文文字が \textbf{ALchar} として
547 \ltjsetparameter{jacharrange={-3, -8}}
551 %<en>\subsection{Using in plain \TeX}
552 %<ja>\subsection{plain \TeX で使う}
556 To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
560 This does minimal settings (like {\tt ptex.tex}) for typesetting Japanese documents:
563 \LuaTeX-ja を plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
567 これで({\tt ptex.tex} のように)日本語組版のための最低限の設定がなされる:
572 \item The following 6~Japanese fonts are preloaded:
574 \begin{tabular}{ccccc}
576 \textbf{classification}&\textbf{font name}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
577 \emph{mincho}&Ryumin-Light &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
578 \emph{gothic}&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
584 \item 以下の6つの和文フォントが定義される:
586 \begin{tabular}{ccccc}
588 \textbf{字体}&\textbf{フォント名}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
589 \emph{明朝体}&Ryumin-Light &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
590 \emph{ゴシック体}&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
597 \item The `Q(級)' is a unit used in Japanese phototypesetting, and
598 $1\,\textrm{Q}=0.25\,\textrm{mm}$. This length is stored in a
599 dimension \verb+\jQ+.
602 \item `Q(級)' は日本の写植で用いられる単位で,$1\,\textrm{Q}=0.25\,\textrm{mm}$
603 である.この長さは \verb+\jQ+ に保持されている.
607 \item It is widely accepted that the font `Ryumin-Light' and
608 `GothicBBB-Medium' aren't embedded into PDF files, and PDF reader
609 substitute them by some external Japanese fonts (\textit{e.g.},
610 Kozuka Mincho is used for Ryumin-Light in Adobe Reader). We adopt this custom to
614 \item `Ryumin-Light' と `GothicBBB-Medium' は PDF ファイルに埋め込まずに
615 名前参照のみで用いることが広く受け入れられており,この場合 PDF リーダーが
616 適切な外部フォントで代用する(例えば,Adobe Reader では Ryumin-Light は
617 小塚明朝で代替される).そこで,これらをデフォルトのフォントと
622 \item A character in an alphabetic font is generally smaller than a
623 Japanese font in the same size. So actual size specification of
624 these Japanese fonts is in fact smaller than that of alphabetic
625 fonts, namely scaled by 0.962216.
628 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
629 一般に小さい.そこで,これらの和文フォントの実際のサイズは指定された値よりも
630 小さくなるように設定されており,具体的には指定の 0.962216 倍にスケールされる.
635 \item The amount of glue that are inserted between a \textbf{JAchar} and
636 an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
639 \item \textbf{JAchar} と \textbf{ALchar} の間に入るグルー (\Param{xkanjiskip}) の
643 (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
644 = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
648 %<en>\subsection{Using in \LaTeX}
649 %<ja>\subsection{\LaTeX で使う}
655 Using in \LaTeXe\ is basically same. To set up the minimal environment
656 for Japanese, you only have to load {\tt luatexja.sty}:
658 \usepackage{luatexja}
660 It also does minimal settings (counterparts in \pLaTeX\ are {\tt
661 plfonts.dtx} and {\tt pldefs.ltx}):
664 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
665 設定するためには,{\tt luatexja.sty} を読み込むだけでよい:
670 \item {\tt JY3} is the font encoding for Japanese fonts (in horizontal direction).\\
671 When vertical typesetting is supported by \LuaTeX-ja in the future, {\tt JT3} will be used for vertical fonts.
674 \item {\tt JY3} は和文フォント用のフォントエンコーディングである(横書き用).\\
675 将来的に,\LuaTeX-ja で縦書きがサポートされる際には,{\tt JT3} を縦書き用として
680 \item Two font families {\tt mc} and {\tt gt} are defined:
682 \begin{tabular}{ccccc}
684 \textbf{classification}&\textbf{family}&\verb+\mdseries+&\verb+\bfseries+&\textbf{scale}\\\midrule
685 \emph{mincho}&\tt mc&Ryumin-Light &GothicBBB-Medium&0.962216\\
686 \emph{gothic}&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
690 Remark that the bold series in both family are same as the medium series of \emph{gothic} family.
691 This is a convention in \pLaTeX. This is a trace that there were only 2~fonts (these are Ryumin-Light
692 and GothicBBB-Medium) in early yearss of DTP.
695 \item 2つのフォントファミリ {\tt mc} と {\tt gt} が定義されている:
697 \begin{tabular}{ccccc}
699 \textbf{字体}&\textbf{ファミリ}&\verb+\mdseries+&\verb+\bfseries+&\textbf{スケール}\\\midrule
700 明朝体&\tt mc&Ryumin-Light &GothicBBB-Medium&0.962216\\
701 ゴシック体&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
705 どちらのファミリにおいても,その bold シリーズはゴシック体の medium シリーズで
706 あることに注意.これは初期の DTP において和文フォントが2つ(それがちょうど\
707 Ryumin-Light, GothicBBB-Medium だった)しか利用できなかった時の名残であり,\pLaTeX{}
712 \item Japanese characters in math mode are typeset by the font family {\tt mc}.
715 \item 数式モード中の和文文字は {\tt mc} ファミリで出力される.
720 However, above settings are not sufficient for Japanese-based
721 documents. To typeset Japanese-based documents, you are better to use
722 class files other than {\tt article.cls}, {\tt book.cls}, and so on. At
723 the present, we have the counterparts of \Pkg{jclasses} (standard
724 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
725 Okumura), namely, \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
728 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
729 日本語文書を組版するためには,{\tt article.cls}, {\tt book.cls} といった
730 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
731 現時点では,\Pkg{jclasses} (\pLaTeX の標準クラス)と \Pkg{jsclasses}
732 (奥村晴彦氏によるクラスファイル)に対応するものとして,\Pkg{ltjclasses},
733 \Pkg{ltjsclasses} がそれぞれ用意されている.
737 \paragraph{{\tt\char92 CID, {\tt\char92 UTF}} and macros in OTF package}
738 Under \pLaTeX, \Pkg{otf} package (developed by Shuzaburo Saito) is
739 used for typesetting characters which is in Adobe-Japan1-6 CID but not
740 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
741 supports some of functions in \Pkg{otf} package.
742 If you want to use these functions, load \Pkg{luatexja-otf} package.
745 \paragraph{{\tt\char92 CID, {\tt\char92 UTF}} と OTF パッケージのマクロ}
746 \pLaTeX では,JIS~X~0208 にない Adobe-Japan1-6 の文字を出力するために,
747 齋藤修三郎氏による \Pkg{otf} パッケージが用いられていた.このパッケージは
748 広く用いられているため,\LuaTeX-ja においても \Pkg{otf} パッケージの機能の
749 一部をサポートしている.これらの機能を用いるためには \Pkg{luatexja-otf} パッケージ
754 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
756 \CID{7652}飾区の\CID{13706}野家,
759 %lltjlisting.sty要修正?:↑「森」の直後で改行.
762 %<en>\subsection{Changing Fonts}
763 %<ja>\subsection{フォントの変更}
767 \paragraph{Remark: Japanese Characters in Math Mode}
768 Since \pTeX\ supports Japanese characters in math mode, there are
769 sources like the following:
772 \paragraph{意見:数式モード中の和文文字}
773 \pTeX では数式中での和文文字の使用がサポートされていたので,
777 $f_{高温}$~($f_{\text{high temperature}}$).
778 \[ y=(x-1)^2+2\quad{}よって\quad y>0 \]
779 $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
782 We (the project members of \LuaTeX-ja) think that using
783 Japanese characters in math mode are allowed if and only if these are used as identifiers.
784 In this point of view,
787 \LuaTeX-ja プロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
793 \item The lines 1~and~2 above are not correct, since `高温' in above is used as a textual label, and
794 `よって' is used as a conjunction.
797 \item 上記数式のうち 1, 2 行目は正しくない.なぜならば `高温' が意味のあるラベルと
798 して,`よって' が接続詞として用いられているからである.
801 \item However, the line~3 is correct, since `素' is used as an identifier.
804 \item しかしながら,3行目は `素' が識別子として用いられているので正しい.
808 Hence, in our opinion, the above input should be corrected as:
811 したがって,\LuaTeX-ja プロジェクトの意見としては,上記の入力は次のように直されるべき
816 ($f_{\text{high temperature}}$).
818 \mathrel{\text{よって}}\quad y>0 \]
819 $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
821 %BUG?: \{\}がなければ「素」がでない.上の段落の「よって」もでてない.
823 We also believe that using Japanese characters as identifiers is rare,
824 hence we don't describe how to change Japanese fonts in math mode in
825 this chapter. For the method, please see Part~\ref{part-ref}.
828 また \LuaTeX-ja プロジェクトでは,和文文字が識別子として用いられることはほとんどない
829 と考えており,したがってこの章では数式モード中の和文フォントを変更する方法については
830 記述しない.この方法については第 \ref{part-ref} 章を参照のこと.
834 \paragraph{plain \TeX}
835 To change Japanese fonts in plain \TeX, you must use the primitive
836 \verb+\jfont+. So please see Part~\ref{part-ref}.
839 \paragraph{plain \TeX}
840 plain \TeX で和文フォントを変更するためには,\verb+\jfont+ プリミティブを用いなけれ
841 ばならない.第 \ref{part-ref} 章を参照せよ.
846 For \LaTeXe, \LuaTeX-ja simply adopted the font selection system from that
847 of \pLaTeXe\ (in {\tt plfonts.dtx}).
851 \LaTeXe については,\LuaTeX-ja では単にフォント選択システムを \pLaTeXe\ ({\tt plfonts.dtx})
856 \item Two control sequences \verb+\mcdefault+ and \verb+\gtdefault+ are
857 used to specify the default font families for \emph{mincho} and
858 \emph{gothic}, respectively. Default values: \texttt{mc} for
859 \verb+\mcdefault+ and \texttt{gt} for \verb+\gtdefault+.
862 \item 2つのコントロールシーケンス \verb+\mcdefault+ と \verb+\gtdefault+ がそれぞ
863 れ明朝体とゴシック体のデフォルトのフォントファミリを指定するために用いられる.
864 初期値:\verb+\mcdefault+ は \texttt{mc},\verb+\gtdefault+ は \texttt{gt}.
867 \item Commands \verb+\fontfamily+, \verb+\fontseries+,
868 \verb+\fontshape+ and \verb+\selectfont+ can be used to change
869 attributes of Japanese fonts.
872 \item \verb+\fontfamily+, \verb+\fontseries+, \verb+\fontshape+, そして
873 \verb+\selectfont+ が和文フォントの属性を変更するために使用できる.
878 \begin{tabular}{cccccc}
880 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
882 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
885 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
887 both&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
888 auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
895 \begin{tabular}{cccccc}
897 &\textbf{エンコーディング}&\textbf{ファミリ}&\textbf{シリーズ}&\textbf{シェープ}&\textbf{選択}\\\midrule
899 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
902 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
904 両方&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
905 自動選択&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
912 \verb+\fontencoding{<encoding>}+ changes the encoding of alphabetic fonts
913 or Japanese fonts depending on the argument. For example,
914 \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
915 \texttt{JY3} and \verb+\fontencoding{T1}+ changes the encoding of
916 alphabetic fonts to \texttt{T1}.
917 \verb+\fontfamily+ also changes the family of Japanese fonts, alphabetic
918 fonts, \emph{or both}. For detail, see Subsection~\ref{ssub-nfsspat}.
921 ここで,\verb+\fontencoding{<encoding>}+は,引数により和文側か欧文側かの
922 どちらかが切り替わる.例えば,\verb+\fontencoding{JY3}+は和文フォントの
923 エンコーディングを\texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文
924 フォント側を\texttt{T1}へと変更する.
925 \verb+\fontfamily+も引数により和文側,欧文側,\textbf{あるいは両方}のフォ
926 ントファミリが切り替わる.詳細は\ref{ssub-nfsspat}節を参照すること.
930 \item For defining a Japanese font family, use
931 \verb+\DeclareKanjiFamily+ instead of
932 \verb+\DeclareFontFamily+. However, in the present implementation,
933 using \verb+\DeclareFontFamily+ doesn't cause any problem.
936 \item 和文フォントファミリの定義には \verb+\DeclareFontFamily+ の代わりに
937 \verb+\DeclareKanjiFamily+ を用いる.しかし,現在の実装では
938 \verb+\DeclareFontFamily+ を用いても問題は生じない.
944 To coexist with the \Pkg{fontspec} package, it is needed to load
945 \Pkg{luatexja-fontspec} package in the preamble. This additional
946 package automatically loads \Pkg{luatexja} and \Pkg{fontspec}
950 \Pkg{fontspec} パッケージと同様の機能を和文フォントに対しても用いるためには,
951 \Pkg{luatexja-fontspec} パッケージをプリアンブルで読み込む必要がある.このパッケージ
952 は必要ならば自動で \Pkg{luatexja} パッケージと \Pkg{fontspec} パッケージを読み込む.
956 In \Pkg{luatexja-fontspec} package, the following 7~commands are defined as
957 counterparts of original commands in the \Pkg{fontspec} package:
960 \Pkg{luatexja-fontspec} パッケージでは,以下の7つのコマンドを \Pkg{fontspec}
961 パッケージの元のコマンドに対応するものとして定義している:
965 \begin{tabular}{ccccc}
968 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
970 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
973 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
975 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
982 \begin{tabular}{ccccc}
985 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
987 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
990 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
992 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
999 \fontspec[Numbers=OldStyle]{TeX Gyre Termes}
1000 \jfontspec{IPAexMincho}
1003 \addjfontfeatures{CJKShape=JIS1990}
1008 Note that there is no command named \verb+\setmonojfont+, since it is
1009 popular for Japanese fonts that nearly all Japanese glyphs have same
1010 widths. Also note that the kerning feature is set off by default in
1011 these 7~commands, since this feature and \textbf{JAglue} will clash (see
1015 和文フォントについては全ての和文文字のグリフがほぼ等幅であるのが普通であるため,
1016 \verb+\setmonojfont+ コマンドは存在しないことに注意.また,これらの和文用の7つのコマ
1017 ンドでは Kerning feature はデフォルトでは off となっている.これはこの
1018 feature が \textbf{JAglue} と衝突するためである(\ref{para-kern} 節を見よ).
1021 %<en>\section{Changing Parameters}
1022 %<ja>\section{パラメータの変更}
1023 There are many parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1024 most of them are not stored as internal register of \TeX, but as an
1025 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1026 parameters, you have to use commands \verb+\ltjsetparameter+ and
1027 \verb+\ltjgetparameter+.
1029 %<en>\subsection{Editing the range of \textbf{JAchar}s}
1030 %<ja>\subsection{\textbf{JAchar} の範囲の設定}
1032 To edit the range of \textbf{JAchar}s, You have to assign a non-zero
1033 natural number which is less than 217 to the character range first. This
1034 can be done by using \verb+\ltjdefcharrange+ primitive. For example, the
1035 next line assigns whole characters in Supplementary Multilingual Plane
1036 and the character `漢' to the range number~100.
1038 \ltjdefcharrange{100}{"10000-"1FFFF,`漢}
1040 This assignment of numbers to ranges are always global, so you should
1041 not do this in the middle of a document.
1043 If some character has been belonged to some non-zero numbered range,
1044 this will be overwritten by the new setting. For example, whole SMP
1045 belong the range~4 in the default setting of \LuaTeX-ja, and if you
1046 specify the above line, then SMP will belong the range~100 and be
1047 removed from the range~4.
1049 After assigning numbers to ranges, the {\sf jacharrange} parameter can
1050 be used to customize which character range will be treated as ranges of
1051 \textbf{JAchar}s, as the following line (this is just the default
1052 setting of \LuaTeX-ja):
1054 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
1056 The argument to {\sf jacharrange} parameter is a list of integer. Negative interger $-n$ in the list means that `the character range~$n$ is ...'.
1058 \paragraph{Default Setting}
1059 Lua\TeX-ja predefines eight character ranges for convinience. They are
1060 determined from the following data:
1062 \item Blocks in Unicode~6.0.
1063 \item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
1064 \item The \texttt{PXbase} bundle for \upTeX\ by Takayuki Yato.
1067 Now we describe these eight ranges. The alphabet `J' or `A' after the
1068 number shows whether characters in the range is treated as
1069 \textbf{JAchar}s or not by default. These settings are similar to \texttt{prefercjk} ...
1071 \item[Range~8${}^{\text{J}}$] Symbols in the intersection of the upper half of ISO~8859-1
1072 (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
1073 consists of the following charatcers:
1074 \begin{multicols}{2}
1076 \def\ch#1#2{\item \char"#1\ ({\tt U+00#1}, #2)}%"
1077 \ch{A7}{Section Sign}
1078 \ch{A8}{Umlaut or diaeresis}
1079 \ch{B0}{Degree sign}
1080 \ch{B1}{Plus-minus sign}
1081 \ch{B4}{Spacing acute}
1082 \ch{B6}{Paragraph sign}
1083 \ch{D7}{Multiplication sign}
1084 \ch{F7}{Division Sign}
1087 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
1088 This range consist of the following Unicode ranges, \emph{except characters in the range~8 above}:
1089 \begin{multicols}{2}
1091 \item {\tt U+0080}--{\tt U+00FF}: Latin-1 Supplement
1092 \item {\tt U+0100}--{\tt U+017F}: Latin Extended-A
1093 \item {\tt U+0180}--{\tt U+024F}: Latin Extended-B
1094 \item {\tt U+0250}--{\tt U+02AF}: IPA Extensions
1095 \item {\tt U+02B0}--{\tt U+02FF}: Spacing Modifier Letters
1096 \item {\tt U+0300}--{\tt U+036F}: Combining Diacritical Marks
1097 \item {\tt U+1E00}--{\tt U+1EFF}: Latin Extended Additional
1101 \item[Range~2${}^{\text{J}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1102 fonts) has some of these characters.
1103 \begin{multicols}{2}
1105 \item {\tt U+0370}--{\tt U+03FF}: Greek and Coptic
1106 \item {\tt U+0400}--{\tt U+04FF}: Cyrillic
1107 \item {\tt U+1F00}--{\tt U+1FFF}: Greek Extended
1111 \item[Range~3${}^{\text{J}}$] Punctuations and Miscellaneous symbols. The block list is
1112 indicated in Table~\ref{table-rng3}.
1114 \caption{Unicode blocks in predefined character range~3.}\label{table-rng3}
1115 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
1116 \begin{center}\small
1117 \begin{tabular}{llll}
1118 "2000--"206F&General Punctuation&
1119 "2070--"209F&Superscripts and Subscripts\\
1120 "20A0--"20CF&Currency Symbols&
1121 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1122 "2100--"214F&Letterlike Symbols&
1123 "2150--"218F&Number Forms\\
1124 "2190--"21FF&Arrows&
1125 "2200--"22FF&Mathematical Operators\\
1126 "2300--"23FF&Miscellaneous Technical&
1127 "2400--"243F&Control Pictures\\
1128 "2500--"257F&Box Drawing&
1129 "2580--"259F&Block Elements\\
1130 "25A0--"25FF&Geometric Shapes&
1131 "2600--"26FF&Miscellaneous Symbols\\
1132 "2700--"27BF&Dingbats&
1133 "2900--"297F&Supplemental Arrows-B\\
1134 "2980--"29FF&Misc.\ Mathematical Symbols-B&
1135 "2B00--"2BFF&Miscellaneous Symbols and Arrows\\
1136 "E000--"F8FF&Private Use Area&
1140 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1141 of almost all Unicode blocks which are not in other
1142 predefined ranges. Hence, instead of showing the block list,
1143 we put the definition of this range itself:
1145 \ltjdefcharrange{4}{%
1146 "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
1147 "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB50-"FE0F,
1148 "FE20-"FE2F, "FE70-"FEFF, "FB00-"FB4F, "10000-"1FFFF} % non-Japanese
1150 \item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
1151 \item[Range~6${}^{\text{J}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
1153 \caption{Unicode blocks in predefined character range~6.}\label{table-rng6}
1154 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
1155 \begin{center}\small
1156 \begin{tabular}{llll}
1157 "2460--"24FF&Enclosed Alphanumerics&
1158 "2E80--"2EFF&CJK Radicals Supplement\\
1159 "3000--"303F&CJK Symbols and Punctuation&
1160 "3040--"309F&Hiragana\\
1161 "30A0--"30FF&Katakana&
1162 "3190--"319F&Kanbun\\
1163 "31F0--"31FF&Katakana Phonetic Extensions&
1164 "3200--"32FF&Enclosed CJK Letters and Months\\
1165 "3300--"33FF&CJK Compatibility&
1166 "3400--"4DBF&CJK Unified Ideographs Extension A\\
1167 "4E00--"9FFF&CJK Unified Ideographs&
1168 "F900--"FAFF&CJK Compatibility Ideographs\\
1169 "FE10--"FE1F&Vertical Forms&
1170 "FE30--"FE4F&CJK Compatibility Forms\\
1171 "FE50--"FE6F&Small Form Variants&
1172 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)
1176 \item[Range~7${}^{\text{J}}$] Characters used in CJK languages, but not included in Adobe-Japan1-6.
1177 The block list is indicated in Table~\ref{table-rng7}.
1179 \caption{Unicode blocks in predefined character range~7.}\label{table-rng7}
1180 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
1181 \begin{center}\small
1182 \begin{tabular}{llll}
1183 "1100--"11FF&Hangul Jamo&
1184 "2F00--"2FDF&Kangxi Radicals\\
1185 "2FF0--"2FFF&Ideographic Description Characters&
1186 "3100--"312F&Bopomofo\\
1187 "3130--"318F&Hangul Compatibility Jamo&
1188 "31A0--"31BF&Bopomofo Extended\\
1189 "31C0--"31EF&CJK Strokes&
1190 "A000--"A48F&Yi Syllables\\
1191 "A490--"A4CF&Yi Radicals&
1192 "A830--"A83F&Common Indic Number Forms\\
1193 "AC00--"D7AF&Hangul Syllables&
1194 "D7B0--"D7FF&Hangul Jamo Extended-B
1201 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
1202 %<ja>\subsection{\Param{kanjiskip} と \Param{xkanjiskip}}
1204 \textbf{JAglue} is divided into the following three categories:
1206 \item Glues/kerns specified in JFM. If \verb+\inhibitglue+ is issued
1207 around a Japanese character, this glue will be not inserted at the
1209 \item The default glue which inserted between two \textbf{JAchar}s ({\sf
1211 \item The default glue which inserted between a \textbf{JAchar} and an
1212 \textbf{ALchar} (\Param{xkanjiskip}).
1214 The value (a skip) of \Param{kanjiskip} or \Param{xkanjiskip} can be
1215 changed as the following.
1217 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
1218 xkanjiskip={0.25\zw plus 1pt minus 1pt}}
1222 It may occur that JFM contains the data of `ideal width of {\sf
1223 kanjiskip}' and/or `ideal width of \Param{xkanjiskip}'.
1224 To use these data from JFM, set the value of \Param{kanjiskip} or
1225 \Param{xkanjiskip} to \verb+\maxdimen+.
1227 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
1228 %<ja>\subsection{\Param{xkanjiskip} の設定の挿入}
1229 It is not desirable that \Param{xkanjiskip} is inserted between every
1230 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
1231 \Param{xkanjiskip} should not be inserted after opening parenthesis
1232 (\textit{e.g.}, compare `(あ' and `(\hskip\ltjgetparameter{xkanjiskip}あ').
1234 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
1235 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
1236 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
1238 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
1242 The second argument {\tt preonly} means `the insertion of
1243 \Param{xkanjiskip} is allowed before this character, but not after'.
1244 the other possible values are {\tt postonly}, {\tt allow} and {\tt
1245 inhibit}. For the compatibility with \pTeX, natural numbers between
1246 0~and~3 are also allowed as the second argument\footnote{But we don't
1247 recommend this: since numbers 1~and~2 have opposite meanings in
1248 \Param{jaxspmode} and \Param{alxspmode}.}.
1250 If you want to enable/disable all insertions of \Param{kanjiskip} and
1251 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
1252 parameters to {\tt false}, respectively.
1255 %<en>\subsection{Shifting Baseline}
1256 %<ja>\subsection{ベースラインの移動}
1257 To make a match between a Japanese font and an alphabetic font, sometimes
1258 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
1259 by setting \verb+\ybaselineshift+ to a non-zero length (the
1260 baseline of alphabetic fonts is shifted below). However, for documents
1261 whose main language is not Japanese, it is good to shift the baseline of
1262 Japanese fonts, but not that of alphabetic fonts.
1263 Because of this, \LuaTeX-ja can independently set the shifting amount
1264 of the baseline of alphabetic fonts (\Param{yalbaselineshift}
1265 parameter) and that of Japanese fonts (\Param{yjabaselineshift}
1269 \vrule width 150pt height 0.4pt depth 0pt\hskip-120pt
1270 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
1271 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
1273 Here the horizontal line in above is the baseline of a line.
1275 There is an interesting side-effect: characters in different size can be
1276 vertically aligned center in a line, by setting two parameters appropriately.
1277 The following is an example (beware the value is not well tuned):
1281 \ltjsetparameter{yjabaselineshift=-1pt,
1282 yalbaselineshift=-1pt}
1288 %<en>\subsection{Cropmark}
1289 %<ja>\subsection{トンボ}
1290 Cropmark is a mark for indicating 4~corners and horizontal/vertical
1291 center of the paper. In Japanese, we call cropmark as tombo(w).
1292 \pLaTeX\ and this \LuaTeX-ja support `tombow' by their kernel.
1293 The following steps are needed to typeset cropmark:
1296 \item First, define the banner which will be printed at the upper left
1297 of the paper. This is done by assigning a token list to
1298 \verb+\@bannertoken+.
1300 For example, the following sets banner as `{\tt filename (2012-01-01 17:01)}':
1304 \hour\time \divide\hour by 60 \@tempcnta\hour \multiply\@tempcnta 60\relax
1305 \minute\time \advance\minute-\@tempcnta
1307 \jobname\space(\number\year-\two@digits\month-\two@digits\day
1308 \space\two@digits\hour:\two@digits\minute)}%
1315 %<en>\part{Reference}
1318 %<en>\section{Font Metric and Japanese Font}
1319 %<ja>\section{フォントメトリックと日本語フォント}
1320 %<en>\subsection{\texttt{\char92jfont} primitive}
1321 %<ja>\subsection{\texttt{\char92jfont} プリミティブ}
1322 To load a font as a Japanese font, you must use the
1323 \verb+\jfont+ primitive instead of~\verb+\font+, while
1324 \verb+\jfont+ admits the same syntax used in~\verb+\font+.
1325 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
1326 so TrueType/OpenType fonts with features can be used for Japanese fonts:
1328 \jfont\tradgt={file:ipaexg.ttf:script=latn;%
1329 +trad;-kern;jfm=ujis} at 14pt
1333 Note that the defined control sequence
1334 (\verb+\tradgt+ in the example above) using \verb+\jfont+ is not a
1335 \textit{font\_def} token, hence the input like \verb+\fontname\tradgt+
1336 causes a error. We denote control sequences which are defined in
1337 \verb+\jfont+ by <jfont\_cs>.
1339 \paragraph{Prefix \texttt{psft}}
1340 Besides \texttt{file:}\ and \texttt{name:}\ prefixes, \texttt{psft:}\
1341 can be used a prefix in \verb+\jfont+ (and~\verb+\font+) primitive.
1342 Using this prefix, you can specify a `name-only' Japanese font which
1343 will be not embedded to PDF. Typical use of this prefix is to specify
1344 the `standard' Japanese fonts, namely, `Ryumin-Light' and
1345 `GothicBBB-Medium'. For kerning or other informations, that of Kozuka
1346 Mincho Pr6N Regular (this is a font by Adobe Inc., and included in
1347 Japanese Font Packs for Adore Reader) will be used.
1351 As noted in Introduction, a JFM has measurements of characters and
1352 glues/kerns that are automatically inserted for Japanese
1353 typesetting. The structure of JFM will be described in the next
1354 subsection. At the calling of \verb+\jfont+ primitive, you must specify
1355 which JFM will be used for this font by the following keys:
1357 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1359 Specify the name of JFM. A file named \texttt{jfm-<name>.lua} will be searched and/or loaded.
1361 The followings are JFMs shipped with Lua\TeX-ja:
1363 \item[\tt jfm-ujis.lua] A standard JFM in Lua\TeX-ja. This JFM is
1364 based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
1365 is used in \upTeX. When you use the \Pkg{luatexja-otf} package, please use this JFM.
1366 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, `JIS font
1367 metric' which is widely used in \pTeX. A major difference of
1368 \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
1369 most haracters under \texttt{jfm-ujis.lua} are square-shaped,
1370 while that under \texttt{jfm-jis.lua} are horizontal
1373 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
1374 of the default Japanese font metric shipped with \pTeX. There
1375 are notable difference between this JFM and other 2~JFMs, as
1376 shown in Table~\ref{tab-difjfm}.
1379 \item[jfmvar=<string>] Sometimes there is a need that
1383 \caption{Differences between JFMs shipped with \LuaTeX-ja}
1385 \ltjsetparameter{jacharrange={+3}}
1387 \def\r#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1388 \setbox0=\vtop{\hsize=7\zw\noindent ◆◆◆◆◆◆◆
1389 ある日モモちゃんがお使いで迷子になって泣きました.}\copy0
1390 \vrule height 0pt depth \dp0}}
1391 \def\s#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1392 \setbox0=\vtop{\hsize=7\zw\noindent ちょっと!何}\copy0}}
1393 \def\t#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 19.24432pt \g
1395 \vrule width 0.4pt height\ht0 depth\dp0\kern-.2pt\copy0
1396 \kern-\wd0\vrule width\wd0height .2pt depth .2pt
1397 \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1398 \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1399 \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}}
1400 \begin{tabular}{rccc}
1402 &\tt jfm-ujis.lua&\tt jfm-jis.lua&\tt jfm-min.lua\\
1404 Example~1&\r{ujis}&\r{jis}&\r{min}\\
1405 Example~2&\s{ujis}&\s{jis}&\s{min}\\
1406 Bounding Box&\t{ujis}&\t{jis}&\t{min}\\
1410 \ltjsetparameter{jacharrange={-3}}
1413 \paragraph{Note: kern feature}\label{para-kern}
1414 Some fonts have information for inter-glyph spacing. However, this
1415 information is not well-compatible with \LuaTeX-ja. More concretely,
1416 this kerning space from this information are inserted \emph{before} the
1417 insertion process of \textbf{JAglue}, and this causes incorrect spacing
1418 between two characters when both a glue/kern from the data in the font
1419 and it from JFM are present.
1422 \item You should specify {\tt -kern} in
1423 {\tt\char92jfont} primitive, when you want to use other font features,
1424 such as {\tt script=...}\,.
1425 \item If you want to use Japanese fonts in proportinal width, and use
1426 information from this font, use \texttt{jfm-prop.lua} for its JFM, and ...
1432 %<en>\subsection{Structure of JFM file}
1433 %<ja>\subsection{JFM ファイルの構造}
1434 A JFM file is a Lua script which has only one function call:
1436 luatexja.jfont.define_jfm { ... }
1438 Real data are stored in the table which indicated above by
1439 \verb+{ ... }+. So, the rest of this subsection are devoted to describe the
1440 structure of this table. Note that all lengths in a JFM file are
1441 floating-point numbers in design-size unit.
1443 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1444 \item[dir=<direction>] (required)
1446 The direction of JFM. At the present, only \texttt{'yoko'} is supported.
1448 \item[zw=<length>] (required)
1450 The amount of the length of the `full-width'.
1452 \item[zh=<length>] (required)
1454 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}] (optional)
1456 This field specifies the `ideal' amount of \Param{kanjiskip}. As noted
1457 in Subsection~\ref{subs-kskip}, if the parameter
1458 \Param{kanjiskip} is \verb+\maxdimen+, the value specified
1459 in this field is actually used (if this field is not specified in
1460 JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
1461 fields are in design-size unit too.
1464 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}] (optional)
1466 Like the \Param{kanjiskip} field, this field specifies the `ideal'
1467 amount of \Param{xkanjiskip}.
1471 Besides from above fields, a JFM file have several sub-tables those
1472 indices are natural numbers. The table indexed by~$i\in\omega$ stores
1473 informations of `character class'~$i$. At least, the character class~0 is
1474 always present, so each JFM file must have a sub-table whose index is
1475 \texttt{[0]}. Each sub-table (its numerical index is denoted by $i$) has
1476 the following fields:
1478 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1479 \item[chars=\{<character>, ...\}] (required except character class~0)
1481 This field is a list of characters which are in this character
1482 type~$i$. This field is not required if $i=0$, since all
1483 \textbf{JAchar} which are not in any character class other
1484 than 0 (hence, the character class~0 contains most of
1485 \textbf{JAchar}s). In the list, a character can be
1486 specified by its code number, or by the character itself
1487 (as a string of length~1). Moreover, there are `imaginary
1488 characters' which specified in the list. We will describe these later.
1490 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]\ (required)
1492 Specify width of characters in character class~$i$, height, depth and
1493 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height and depth are
1494 as values of these fields.
1495 But there is one exception: if \texttt{'prop'} is specified in \texttt{width} field, width of a character becomes that of its `real' glyph
1497 \item[left=<length>, down=<length>, align=<align>]\
1499 These fields are for adjusting the position of the `real' glyph. Legal
1500 values of \texttt{align} field are \texttt{'left'},
1501 \texttt{'middle'} and \texttt{'right'}. If one of these
1502 3~fields are omitted, \texttt{left} and \texttt{down} are
1503 treated as~0, and \texttt{align} field is treated as
1505 The effects of these 3~fields are indicated in Figure~\ref{fig-pos}.
1507 In most cases, \texttt{left} and \texttt{down} fields are~0, while
1508 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
1509 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
1510 when the current character class is the class for opening delimiters'.
1512 \begin{minipage}{0.4\textwidth}%
1513 \begin{center}\unitlength=10pt\small
1514 \begin{picture}(15,12)(-1,-4)
1515 \color{black!10!white}% real glyph :step1
1516 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
1518 \color{red!20!white}% real glyph :step1
1519 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
1521 \color{red}% real glyph
1523 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
1524 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
1525 \put(-1,5.5){\line(1,0){6}}
1526 \put(-1,-4){\line(1,0){6}}
1528 \color{green!20!white}% real glyph :step1
1529 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
1531 \color{black}% real glyph :step1
1533 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
1534 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
1535 \put(0,8){\line(1,0){12}}
1536 \put(0,-3){\line(1,0){12}}
1537 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
1538 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
1539 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
1541 \color{green!50!black}% real glyph :step1
1543 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
1544 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
1545 \put(3,7){\line(1,0){6}}
1546 \put(3,-2.5){\line(1,0){6}}
1547 \newsavebox{\eqdist}
1548 \savebox{\eqdist}(0,0)[b]{%
1550 \put(-0.08,0.2){\line(0,-1){0.4}}%
1551 \put(0.08,0.2){\line(0,-1){0.4}}}
1552 \put(1.5,0){\usebox{\eqdist}}
1553 \put(10.5,0){\usebox{\eqdist}}
1555 \color{blue}% shifted
1557 \put(3,-1.5){\vector(-1,0){4}}
1558 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
1559 \put(3,0){\vector(0,-1){1.5}}
1560 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
1564 \begin{minipage}{0.6\textwidth}%
1565 Consider a node containing Japanese character whose value of the \texttt{align}
1566 field is \texttt{'middle'}.
1568 \item The black rectangle is a frame of the node.
1569 Its width, height and depth are specified by JFM.
1570 \item Since the \texttt{align} field is \texttt{'middle'},
1571 the `real' glyph is centered horizontally (the green rectangle).
1572 \item Furthermore, the glyph is shifted according to values of fields
1573 \texttt{left} and \texttt{down}. The ultimate position of the real
1574 glyph is indicated by the red rectangle.
1577 \caption{The position of the `real' glyph.}
1582 \item[kern={\{[$j$]=<kern>, ...\}}]
1584 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>\}, ...\}}]
1588 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1589 \item['lineend'] An ending of a line.
1590 \item['diffmet'] Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
1591 \item['boxbdd'] The beginning/ending of a horizontal box, and the beginging of a noindented paragraph.
1592 \item['parbdd'] The beginning of an (indented) paragraph.
1593 \item['jcharbdd'] A boundary between \textbf{JAchar} and anything else
1594 (such as \textbf{ALchar}, kern, glue, ...).
1595 \item[$-1$] The left/right boundary of an inline math formula.
1600 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
1601 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
1602 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
1603 い組版調整ができるようになっている.以下のその一覧を述べる:
1604 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1605 \item['lineend'] 行の終端を表す.
1608 \item['boxbdd'] hboxの先頭と末尾,及びインデントされていない
1609 (\verb+\noindent+で開始された)段落の先頭を表す.
1610 \item['parbdd'] 通常の(\verb+\noindent+で開始されていない)段落の先頭.
1611 \item['jcharbdd'] 和文文字と「その他のもの」(欧文文字,glue,kern等)との境界.
1612 \item[$-1$] 行中数式と地の文との境界.
1615 \paragraph{\pTeX 用和文フォントメトリックの移植}
1616 以下に,\pTeX 用和文フォントメトリックを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
1618 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
1619 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
1622 \item JFM中の全ての数値を$1/0.962216$倍しておく.
1623 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
1624 \LaTeX でのフォント宣言なら,例えば次のように:
1626 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
1629 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
1631 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
1632 文字クラスに関してはglue/kernの設定はしない.
1635 hboxの先頭・末尾とインデントされていない(\verb+\noindent+で開始さ
1636 れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
1637 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
1639 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
1640 段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
1641 は,段落の最初に手動で\verb+\inhibitglue+を追加するか,あるいは
1642 \verb+\everypar+のhackを行い,それを自動化させるしかなかった.
1644 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
1645 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
1646 \texttt{'parbdd'}を入れれば全角下がりとなる.
1648 \ltjsetparameter{jacharrange={+3}}
1650 \jfont\g=psft:Ryumin-Light:jfm=test \g
1651 \parindent1\zw\noindent{}◆◆◆◆◆
1657 \ltjsetparameter{jacharrange={-3}}
1660 %<en>\subsection{Math Font Family}
1661 %<ja>\subsection{数式フォントファミリ}
1662 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
1663 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX can handles 256~families, but
1664 an external package is needed to support this in plain \TeX\ and
1665 \LaTeX.}, and each family has three fonts:
1666 \verb+\textfont+, \verb+\scriptfont+ and \verb+\scriptscriptfont+.
1668 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
1669 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
1670 font families. There is no relation between the value of
1671 \verb+\fam+ and that of \verb+\jfam+; with appropreate settings,
1672 you can set both \verb+\fam+ and \verb+\jfam+ to~the same value.
1675 \caption{Primitives for Japanese math fonts.}
1677 \begin{center}\def\{{\char`\{}\def\}{\char`\}}
1678 \begin{tabular}{lll}
1680 &Japanese fonts&alphabetic fonts\\
1682 font family&\verb+\jfam+${}\in [0,256)$&\verb+\fam+\\
1683 text size&\tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\textfont+<fam>=<font\_cs>\\
1684 script size&\tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptfont+<fam>=<font\_cs>\\
1685 scriptscript size&\tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptscriptfont+<fam>=<font\_cs>\\
1691 %<en>\subsection{Callbacks}
1692 %<ja>\subsection{コールバック}
1693 Like \LuaTeX\ itself, \LuaTeX-ja also has callbacks. These callbacks can
1694 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks
1696 {\def\makelabel#1{\bfseries#1}}
1697 \item[\texttt{luatexja.load\_jfm} callback]
1698 With this callback you can overwrite JFMs.
1701 function (<table> jfm_info, <string> jfm_name)
1702 return <table> new_jfm_info
1706 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
1707 this argument has \texttt{chars} field which contains character codes
1708 whose character class is not~0.
1710 An example of this callback is the \texttt{ltjarticle} class, with
1711 forcefully assigning character class~0 to \texttt{'parbdd'}
1712 in the JFM \texttt{jfm-min.lua}. This callback doesn't
1713 replace any code of \LuaTeX-ja.
1715 \item[\texttt{luatexja.define\_font} callback]
1716 This callback and the next callback form a pair, and you can assign letters which don't have
1717 fixed codepoints in Unicode to non-zero character classes.
1718 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
1720 function (<table> jfont_info, <number> font_number)
1721 return <table> new_jfont_info
1725 You may assume that \verb+jfont_info+ has the following fields:
1727 \item[\tt jfm] The index number of JFM.
1728 \item[\tt size] Font size in a scaled point (${}=2^{-16}\,\textrm{pt}$).
1729 \item[\tt var] The value specified in \texttt{jfmvar=...} at a call of \verb+\jfont+.
1732 The returned table \verb+new_jfont_info+ also should include these three fields.
1733 The \verb+font_number+ is a font number.
1735 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
1736 package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
1737 CID characters in a JFM. This callback doesn't replace any
1741 \item[\texttt{luatexja.find\_char\_class} callback]
1742 This callback is called just when \LuaTeX-ja inready to determine which
1743 character class a character \verb+chr_code+ belongs.
1744 A function used in this callback should be in the following form:
1745 \begin{lstlisting}[numbers=left]
1746 function (<number> char_class, <table> jfont_info, <number> chr_code)
1747 if char_class~=0 then return char_class
1750 return (<number> new_char_class or 0)
1755 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
1756 routine or previous function calls in this callback, hence
1757 this argument may not be 0. Moreover, the returned
1758 \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
1759 is not~0, otherwise you will overwrite the \LuaTeX-ja's
1762 This callback doesn't replace any code of \LuaTeX-ja.
1770 %<en>\section{Parameters}
1771 %<ja>\section{パラメータ}
1772 %<en>\subsection{{\tt\char92 ltjsetparameter} primitive}
1773 %<ja>\subsection{{\tt\char92 ltjsetparameter} プリミティブ}
1774 As noted before, \verb+\ltjsetparameter+ and \verb+\ltjgetparameter+ are
1775 primitives for accessing most parameters of \LuaTeX-ja. One of the main
1776 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
1777 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
1778 is the position of \verb+hpack_filter+ callback in the source
1779 of \LuaTeX, see Section~\ref{sec-para}.
1781 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ are primitives
1782 for assigning parameters. These take one argument which is a
1783 \texttt{<key>=<value>} list. Allowed keys are described in the next
1785 The difference between
1786 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ is only the
1787 scope of assignment;
1788 \verb+\ltjsetparameter+ does a local assignment and
1789 \verb+\ltjglobalsetparameter+ does a global one.
1790 They also obey the value of \verb+\globaldefs+,
1791 like other assignment.
1793 \verb+\ltjgetparameter+ is the primitive for acquiring parameters. It
1794 always takes a parameter name as first argument, and also takes the
1795 additional argument---a character code, for example---in some cases.
1797 \ltjgetparameter{differentjfm},
1798 \ltjgetparameter{autospacing},
1799 \ltjgetparameter{prebreakpenalty}{`)}.
1801 \emph{The return value of\/ {\normalfont\tt\char92ltjgetparameter} is
1802 always a string}. This is outputted by \texttt{tex.write()}, so any
1803 character other than space~`{\tt\char32}'~(U+0020) has the category code
1804 12~(other), while the space has 10~(space).
1806 %<en>\subsection{List of Parameters}
1807 %<ja>\subsection{パラメータ一覧}
1808 The following is the list of parameters which can be specificated by the
1809 \verb+\ltjsetparameter+ command. [\verb+\cs+] indicates the counterpart
1810 in \pTeX, and symbols beside each parameter has the following meaning:
1812 \item No mark: values at the end of the paragraph or the hbox are
1813 adopted in the whole paragraph/hbox.
1814 \item `\ast' : local parameters, which can change everywhere inside a paragraph/hbox.
1815 \item `\dagger': assignments are always global.
1818 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1819 \item[\Param{jcharwidowpenalty}\,=<penalty>] [\verb+\jcharwidowpenalty+]
1821 Penalty value for supressing orphans. This penalty is inserted just
1822 after the last \textbf{JAchar} which is not regarded as a
1823 (Japanese) punctuation mark.
1825 \item[\Param{kcatcode}\,=\{<chr\_code>,<natural number>\}]\
1827 An additional attributes having each character whose character code is <chr\_code>.
1828 At the present version, the lowermost bit of <natural number> indicates
1829 whether the character is considered as a punctuation mark
1830 (see the description of \Param{jcharwidowpenalty} above).
1833 \item[\Param{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\prebreakpenalty+]\
1835 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
1836 この文字の前に挿入/追加されるペナルティの量を指定する.
1838 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,標準で読み込まれる
1839 \texttt{luatexja-kinsoku.tex}において
1841 \ltjsetparameter{prebreakpenalty={`〙,10000}}
1843 と,最大値の10000が指定されている.他にも,小書きのカナなど,絶対禁止とい
1844 うわけではないができれば行頭にはきて欲しくない場合に,0と
1845 10000の間の値を指定するのも有用であろう.
1847 \ltjsetparameter{prebreakpenalty={`ゕ,150}}
1851 \item[\Param{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\postbreakpenalty+]
1853 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
1854 この文字の後に挿入/追加されるペナルティの量を指定する.
1856 \pTeX では,\verb+\prebreakpenalty+, \verb+\postbreakpenalty+において,
1858 \item 一つの文字に対して,pre, postどちらか一つしか指定することができなかっ
1860 \item pre, post合わせて256文字分の情報を格納することしかできなかった.
1862 という制限があったが,\LuaTeX-ja ではこれらの制限は解消されている.
1865 \item[\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\textfont+ in \TeX]
1866 \item[\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\scriptfont+ in \TeX]
1867 \item[\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\scriptscriptfont+ in \TeX]
1868 \item[\Param{yjabaselineshift}\,=<dimen>$^\ast$]\
1869 \item[\Param{yalbaselineshift}\,=<dimen>$^\ast$] [\verb+\ybaselineshift+]
1871 \item[\Param{jaxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\inhibitxspcode+]
1873 Setting whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
1874 The followings are allowed for <mode>:
1876 \item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the charater, nor after the charater.
1877 \item[2, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the charater, but not after.
1878 \item[1, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the charater, but not before.
1879 \item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the charater and after the charater.
1880 This is the default value.
1883 \item[\Param{alxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\xspcode+]
1885 Setting whether inserting \Param{xkanjiskip} is allowed before/after a
1886 \textbf{ALchar} whose character code is <chr\_code>.
1887 The followings are allowed for <mode>:
1889 \item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited
1890 before the charater, nor after the charater.
1891 \item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed
1892 before the charater, but not after.
1893 \item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed
1894 after the charater, but not before.
1895 \item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both
1896 before the charater and after the charater.
1897 This is the default value.
1899 Note that parameters \Param{jaxspmode} and \Param{alxspmode} use a common table.
1901 \item[\Param{autospacing}\,=<bool>$^\ast$] [\verb+\autospacing+]
1902 \item[\Param{autoxspacing}\,=<bool>$^\ast$] [\verb+\autoxspacing+]
1903 \item[\Param{kanjiskip}\,=<skip>] [\verb+\kanjiskip+]
1904 \item[\Param{xkanjiskip}\,=<skip>] [\verb+\xkanjiskip+]
1906 \item[\Param{differentjfm}\,=<mode>$^\dagger$]
1908 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
1909 The allowed arguments are the followings:
1911 \item[\texttt{average}]
1912 \item[\texttt{both}]
1913 \item[\texttt{large}]
1914 \item[\texttt{small}]
1917 \item[\Param{jacharrange}\,=<ranges>$^\ast$]
1918 \item[\Param{kansujichar}\,=\{<digit>, <chr\_code>\}] [\verb+\kansujichar+]
1922 %<en>\section{Other Primitives}
1923 %<ja>\section{その他のプリミティブ}
1924 %<en>\subsection{Primitives for Compatibility}
1925 %<ja>\subsection{互換プリミティブ}
1926 The following primtives are implemented for compatibility with \pTeX:
1927 \begin{list}{}{\def\makelabel{\ttfamily\char92 }}
1935 %<en>\subsection{{\tt\char92 inhibitglue} primitive}
1936 %<ja>\subsection{{\tt\char92 inhibitglue} プリミティブ}
1937 The primitive \verb+\inhibitglue+ suppresses the insertion of \textbf{JAglue}.
1938 The following is an example, using a special JFM that there will be a glue between
1939 the beginning of a box and `あ', and also between `あ' and `ウ'.
1942 \jfont\g=psft:Ryumin-Light:jfm=test \g
1943 あウあ\inhibitglue{}ウ\inhibitglue\par
1944 あ\par\inhibitglue{}あ
1945 \par\inhibitglue\hrule{}あoff\inhibitglue ice
1948 With the help of this example, we remark the specification of \verb+\inhibitglue+:
1950 \item The call of \verb+\inhibitglue+ in the (internal) vertical mode is
1951 effective at the beginning of the next paragraph. This is realized
1952 by hacking \verb+\everypar+.
1953 \item The call of \verb+\inhibitglue+ in the (restricted) horizontal
1954 mode is only effective on the spot; does not get over boundary of
1955 paragraphs. Moreover, \verb+\inhibitglue+ cancels ligatures and
1956 kernings, as shown in line~4 of above example.
1957 \item The call of \verb+\inhibitglue+ in math mode is just ignored.
1960 %<en>\section{Control Sequences for \LaTeXe}
1961 %<ja>\section{\LaTeXe 用のコントロールシーケンス}
1962 %<en>\subsection{Patch for NFSS2}
1963 %<ja>\subsection{NFSS2 へのパッチ}
1964 \label{ssub-nfsspat}
1965 As described in Subsection~\ref{ssec-ltx}, \LuaTeX-ja simply adopted
1966 \texttt{plfonts.dtx} in \pLaTeXe\ for the Japanese patch for NFSS2.
1967 For an convinience, we will describe
1968 commands which are not described in Subsection~\ref{ssub-chgfnt}.
1971 \item[DeclareYokoKanjiEncoding\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
1972 In NFSS2 under \LuaTeX-ja, distinction between alphabetic font families
1973 and Japanese font families is only made by its
1974 encoding. For example, encodings OT1 and T1 are for
1975 alphabetic font families, and a Japanese font family cannot
1976 have these encodings. This command defines a new encoding
1977 scheme for Japanese font family (in horizontal direction).
1979 \item[DeclareKanjiEncodingDefaults\{<text-settings>\}\{<math-settings>\}]
1980 \item[DeclareKanjiSubstitution\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
1981 \item[DeclareErrorKanjiFont\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
1983 The above 3~commands are just the counterparts for \verb+DeclareFontEncodingDefaults+ and~others.
1985 \item[reDeclareMathAlphabet\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
1986 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
1987 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>と,和文数式用フォ
1988 ントファミリ変更の命令<ja-cmd>の2つを同時に行う命令として
1989 <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
1990 <al-cmd>に同じものを指定する,すなわち,<al-cmd>に和文側も変
1991 更させるようにするのが一般的と思われる.
1993 本コマンドの使用については,\pLaTeX 配布中の\texttt{plfonts.dtx}に詳しく
1994 注意点が述べられているので,そちらを参照されたい.
1996 \item[DeclareRelationFont\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\
1997 \hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
1999 This command sets the `accompanied' alphabetic font family (given by the latter 4~arguments)
2000 with respect to a Japanese font family given by the former 4~arguments.
2003 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントファミリに対して,
2004 そのフォントに対応する「従属欧文」フォントファミリを後半の4引数により与える.
2006 \item[SetRelationFont]
2007 This command is almost same as \verb+\DeclareRelationFont+, except that this command does a local
2008 assignment, where \verb+\DeclareRelationFont+ does a global assignment.
2010 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
2011 font family with respect to current Japanese font family,
2013 \verb+\DeclareRelationFont+ or \verb+SetRelationFont+.
2014 Like \verb+\fontfamily+, \verb+\selectfont+ is required to take an effect.
2016 \item[adjustbaseline]
2019 \item[fontfamily\{<family>\}]
2021 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
2022 to <family>. Which family will be changed is determined as follows:
2024 \item Let current encoding scheme for Japanese fonts be
2025 <ja-enc>. Current Japanese font family will be changed to
2026 <family>, if one of the following two conditions is met:
2028 \item The family <fam> under the encoding <ja-enc> is already defined by
2029 \verb+\DeclareKanijFamily+.
2030 \item A font definition named \texttt{<enc><ja-enc>.fd} (the filename is
2031 all lowercase) exists.
2033 \item Let current encoding scheme for Japanese fonts be
2034 <al-enc>. For alphabetic font family, the criterion as above is used.
2035 \item There is a case which none of the above applies, that is, the font
2036 family named <family> doesn't seem to be defined neither under the
2037 encoding <ja-enc>, nor under <al-enc>.
2039 In this case, the default family for font substitution is used for
2040 alphabetic and Japanese fonts. Note that current encoding will not
2041 be set to <family>, unlike the original inplementation in \LaTeX.
2046 As closing this subsection, we shall introduce an example of
2047 \verb+SetRelationFont+ and \verb+\userelfont+:
2050 \SetRelationFont{JY3}{gt}{m}{n}{OT1}{pag}{m}{n}
2051 \userelfont\selectfont{}あいうabc
2055 %<en>\subsection{Cropmark/`tombow'}
2056 %<ja>\subsection{トンボ}
2058 %<en>\section{Extensions}
2060 \subsection{{\tt luatexja-fontspec.sty}}
2062 \subsection{{\tt luatexja-otf.sty}}
2063 This optional package supports typesetting charaters in
2064 Adobe-Japan1. {\tt luatexja-otf.sty} offers the following 2~low-level
2066 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
2067 \item[\char92CID\{<number>\}]
2068 Typeset a character whose CID number is <number>.
2069 \item[\char92UTF\{<hex\_number>\}]
2070 Typeset a character whose character code is <hex\_number> (in hexadecimal).
2071 This command is similar to \verb+\char"+<hex\_number>,\ %"
2072 but please remind remarks below.
2076 Characters by \verb+\CID+ and \verb+\UTF+ commands are different from
2077 ordinary characters in the following points:
2079 \item Always treated as \textbf{JAchar}s.
2080 \item Processing codes for supporting OpenType features (\textit{e.g.},
2081 glyph replacement and kerning) by the \Pkg{luaotfload} package
2082 is not performed to these characters.
2086 \paragraph{Additionally Syntax of JFM}
2087 {\tt luatexja-otf.sty} extends the syntax of JFM; the entries of {\tt
2088 chars} table in JFM now allows a string in the form
2089 \verb+'AJ1-xxx'+, which stands for the character
2090 whose CID number in Adobe-Japan1 is \verb+xxx+.
2092 %<en>\part{Implementations}
2095 %<en>\section{Storing Parameters}
2096 %<ja>\section{パラメータの保持}
2098 %<en>\subsection{Used Dimensions, Attributes and whatsit nodes}
2099 %<ja>\subsection{用いられる寸法レジスタ,属性レジスタ,whatsit ノード}
2100 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
2102 \def\makelabel{\ttfamily}
2103 \def\dim#1{\item[\char92 #1\ \textrm{(dimension)}]}
2104 \def\attr#1{\item[\char92 #1\ \textrm{(attribute)}]}
2108 As explained in Subsection~\ref{ssec-plain}, \verb+\jQ+ is equal to
2109 $1\,\textrm{Q}=0.25\,\textrm{mm}$, where `Q'~(also called `級') is
2110 a unit used in Japanese phototypesetting. So one should not change the value of this dimension.
2112 There is also a unit called `歯' which equals to $0.25\,\textrm{mm}$ and
2113 used in Japanese phototypesetting. The dimension
2114 \verb+\jH+ stores this length, similar to \verb+\jQ+.
2115 \dim{ltj@zw} A temporal register for the `full-width' of current Japanese font.
2116 \dim{ltj@zh} A temporal register for the `full-height' (usually the sum of height of imaginary body and its depth) of current Japanese font.
2117 \attr{jfam} Current number of Japanese font family for math formulas.
2118 \attr{ltj@curjfnt} The font index of current Japanese font.
2119 \attr{ltj@charclass} The character class of Japanese \textit{glyph\_node}.
2120 \attr{ltj@yablshift} The amount of shifting the baseline of alphabetic
2121 fonts in scaled point ($2^{-16}\,\textrm{pt}$).
2122 \attr{ltj@ykblshift} The amount of shifting the baseline of Japanese
2123 fonts in scaled point ($2^{-16}\,\textrm{pt}$).
2124 \attr{ltj@autospc} Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
2125 \attr{ltj@autoxspc} Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
2126 \attr{ltj@icflag} An attribute for distinguishing `kinds' of a node. One of the following value is
2127 assigned to this attribute:
2129 \item[\textit{italic} (1)] Glues from an itaric correction
2130 (\verb+\/+). This distinction of origins of glues
2131 (from explicit \verb+\kern+, or from \verb+\/+)
2132 is needed in the insertion process of \Param{xkanjiskip}.
2133 \item[\textit{packed} (2)]
2134 \item[\textit{kinsoku} (3)] Penalties inserted for the word-wrapping process of Japanese characters (\emph{kinsoku}).
2135 \item[\textit{from\_jfm} (4)] Glues/kerns from JFM.
2136 \item[\textit{line\_end} (5)] Kerns for ...
2137 \item[\textit{kanji\_skip} (6)] Glues for \Param{kanjiskip}.
2138 \item[\textit{xkanji\_skip} (7)] Glues for \Param{xkanjiskip}.
2139 \item[\textit{processed} (8)] Nodes which is already processed by ...
2140 \item[\textit{ic\_processed} (9)] Glues from an itaric correction, but also already processed.
2141 \item[\textit{boxbdd} (15)] Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
2143 \attr{ltj@kcat$i$} Where $i$~is a natural number which is less than~7.
2144 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
2147 Furthermore, \LuaTeX-ja uses several `user-defined' whatsit nodes for
2148 typesetting. All those nodes store a natural number (hence the node's
2149 \texttt{type} is 100).
2151 \item[30111] Nodes for indicating that \verb+\inhibitglue+ is
2152 specified. The \texttt{value} field of these nodes doesn't matter.
2153 \item[30112] Nodes for \LuaTeX-ja's stack system (see the next
2154 subsection). The \texttt{value} field of these nodes is
2156 \item[30113] Nodes for Japanese Characters which the callback process of
2157 luaotfload won't be applied, andd the character code is
2158 stored in the \texttt{value} field. Each node having this
2159 \verb+user_id+ is converted to a `glyph\_node' \emph{after}
2160 the callback process of luaotfload.
2162 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
2164 %<en>\subsection{Stack System of \LuaTeX-ja}
2165 %<ja>\subsection{\LuaTeX-ja のスタックシステム}
2167 \paragraph{Background}
2168 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
2169 are stored in it. To clarify the reason, imagine the parameter
2170 \Param{kanjiskip} is stored by a skip, and consider the following
2173 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
2174 \setbox0=\hbox{\ltjsetparameter{kanjiskip=5pt}ほげほげ}
2178 As described in Part~\ref{part-ref}, the only effective value of
2179 \Param{kanjiskip} in an hbox is the latest value, so the value of
2180 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
2181 However, by the implementation method of \LuaTeX, this `5\,pt' cannot be
2182 known from any callbacks. In the \texttt{tex/packaging.w} (which is a
2183 file in the source of \LuaTeX), there are the following codes:
2187 scaled h; /* height of box */
2188 halfword p; /* first node in a box */
2189 scaled d; /* max depth */
2195 if (cur_list.mode_field == -hmode) {
2196 cur_box = filtered_hpack(cur_list.head_field,
2197 cur_list.tail_field, saved_value(1),
2198 saved_level(1), grp, saved_level(2));
2199 subtype(cur_box) = HLIST_SUBTYPE_HBOX;
2201 Notice that \verb+unsave+ is executed \emph{before}
2202 \verb+filtered_hpack+ (this is where \verb+hpack_filter+ callback is
2203 executed): so `5\,pt' in the above source is orphaned at
2204 \texttt+unsave+, and hence it can't be accessed from \verb+hpack_filter+
2207 \paragraph{The method}
2208 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
2209 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
2211 These are two \TeX\ count registers for maintaining informations:
2212 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
2213 the \TeX's group level when the last assignment was done. Parameters
2214 are stored in one big table named \texttt{charprop\_stack\_table}, where
2215 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
2216 a new stack level is created by \verb+\ltjsetparameter+, all data of the
2217 previous level is copied.
2219 To resolve the problem mentioned in `Background' above, \LuaTeX-ja uses
2220 another thing: When a new stack level is about to be created, a whatsit
2221 node whose type, subtype and value are 44~(\textit{user\_defined}),
2222 30112, and current group level respectively is appended to the current
2223 list (we refer this node by \textit{stack\_flag}). This enables us to
2224 know whether assignment is done just inside a hbox. Suppose that the
2225 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
2228 \item If there is no \textit{stack\_flag} node in the list of hbox, then
2229 no assignment was occurred inside the hbox. Hence values of
2230 parameters at the end of the hbox are stored in the stack
2232 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
2233 an assignment was occurred just inside the hbox group. Hence
2234 values of parameters at the end of the hbox are stored in the
2236 \item If there are \textit{stack\_flag} nodes but all of their values
2237 are more than~$t+1$, then an assignment was occurred in the box,
2238 but it is done is `more internal' group. Hence values of
2239 parameters at the end of the hbox are stored in the stack
2243 Note that to work this trick correctly, assignments to
2244 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
2245 regardless the value of \verb+\globaldefs+.
2246 This problem is resolved by using
2247 \hbox{\verb+\directlua{tex.globaldefs=0}+} (this assignment is local).
2250 %<en>\section{Linebreak after Japanese Character}
2251 %<ja>\section{和文文字直後の改行}
2253 %<en>\subsection{Reference: Behavior in \pTeX}
2254 %<ja>\subsection{参考: \pTeX の挙動}
2256 In~\pTeX, a linebreak after a Japanese character doesn't emit a space,
2257 since words are not separated by spaces in Japanese writings. However,
2258 this feature isn't fully implemented in \LuaTeX-ja due to the
2259 specification of callbacks in~\LuaTeX. To clarify the difference between
2260 \pTeX~and~\LuaTeX, We briefly describe the handling of a linebreak in~\pTeX, in
2263 \pTeX's input processor can be described in terms of a finite state
2264 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
2265 internal states are as follows:
2267 \item State~$N$: new line
2268 \item State~$S$: skipping spaces
2269 \item State~$M$: middle of line
2270 \item State~$K$: after a Japanese character
2272 The first three states---$N$, $S$~and~$M$---are as same as \TeX's input
2273 processor. State~$K$ is similar to state~$M$, and is entered after
2274 Japanese characters. The diagram of state transitions are indicated in
2275 Figure~\ref{fig-ptexipro}. Note that \pTeX\ doesn't leave state~$K$
2276 after `beginning/ending of a group' characters.
2280 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
2281 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどどこでも改行が可能なため,
2282 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
2284 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
2285 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
2289 \item State~$N$: 行の開始.
2290 \item State~$S$: 空白読み飛ばし.
2291 \item State~$M$: 行中.
2292 \item State~$K$: 行中(和文文字の後).
2294 また,状態遷移は,図\label{fig-ptexipro}のようになっており,図中の数字は
2295 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
2296 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
2301 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
2308 \def\sp{\text{\tt\char32}}
2310 {\text{scan a cs}}\ar@(r,ul)[dr]&\\
2312 *++[o][F-]{N}\ar[ur]^0\ar[dd]_{d,\ g}\ar[u]^{5\ (\text{\tt\char92par})}
2313 \ar@{->}@(d,l)[ddrr]_(0.45){j}&&
2314 *++[o][F-]{S}\ar@(l,dr)[ul]^0\ar@(l,ur)[ddll]_{d,\ g}\ar[u]_{5}
2315 \ar@{->}@(r,r)[dd]^{j}\\&\\&
2316 *++[o][F-]{M}\ar[uuur]^0\ar@(r,dl)[uurr]_(0.55){10\ (\sp)}
2317 \ar[d]_{5\ ({\sp})}\ar@{->}@(dr,dl)[rr]_{j}&&
2318 *++[o][F-]{K}\ar@{->}@(ul,d)[uuul]^0\ar@{->}[ll]^{d}
2319 \ar@{->}@(ur,dr)[uu]^{10\ (\sp)}\ar@{->}[d]_5\\
2322 d:=\{3,4,6,7,8,11,12,13\},\quad g:=\{1,2\},\quad j:=(\text{Japanese characters})
2325 \item Numbers represent category codes.
2326 \item Category codes 9~(ignored), 14~(comment)~and~15~(invalid) are omitted in above diagram.
2328 \caption{State transitions of \pTeX's input processor.}
2329 \label{fig-ptexipro}
2333 %<en>\subsection{Behavior in \LuaTeX-ja}
2334 %<ja>\subsection{\LuaTeX-ja の挙動}
2336 States in the input processoe of \LuaTeX\ is the same as that of \TeX,
2337 and they can't be customized by any callbacks. Hence, we can only use
2338 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
2339 suppress a space by a linebreak which is after Japanese characters.
2341 However, \verb+token_filter+ callback cannot be used either, since a
2342 character in category code 5~(end-of-line) is converted into an space
2343 token \emph{in the input processor}. So we can use only the
2344 \verb+process_input_buffer+ callback. This means that suppressing a
2345 space must be done \emph{just before} an input line is read.
2347 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
2349 A character U+FFFFF (its category code is set to 14~(comment) by
2350 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
2351 process it}, if and only if the following two conditions are satisfied:
2353 \item The category code of the character $\langle${return}$\rangle$
2354 (whose character code is 13) is 5~(end-of-line).
2355 \item The input line matches the following `regular expression':
2357 (\text{any char})^*(\textbf{JAchar})
2358 \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
2364 The following example shows the major difference from the behavior of \pTeX:
2366 \ltjsetparameter{autoxspacing=false}
2367 \ltjsetparameter{jacharrange={-6}}xあ
2368 y\ltjsetparameter{jacharrange={+6}}zあ
2372 \item There is no space between `x' and `y', since the line~2 ends with a \textbf{JAchar} `あ'
2373 (this `あ' considered as an \textbf{JAchar} at the ending of line~1).
2374 \item There is no space between `あ' (in the line~3) and `u', since the
2375 line~3 ends with an \textbf{ALchar}
2376 (the letter `あ' considered as an \textbf{ALchar} at the ending of line~2).
2381 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,callbackによりユーザが
2382 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
2383 きそうなcallbackとしては,\verb+process_input_buffer+や
2384 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
2385 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
2386 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
2387 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
2388 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
2390 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
2391 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
2392 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
2395 各入力行に対し,\textbf{その入力行が読まれる前の内部状態で}
2396 以下の2条件が満たされている場合,\LuaTeX-jaはU+FFFFF番の文字
2397 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
2398 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
2400 \item 改行文字(文字コード13番)のカテゴリーコードが5~(end-of-line)である.
2401 \item 入力行は次の「正規表現」にマッチしている:
2403 (\text{any char})^*(\textbf{JAchar})
2404 \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
2409 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.最初の条件は,
2410 \texttt{verbatim}系環境などの日本語対応マクロを書かなくてすませるためのものである.
2411 しかしながら,完全に同じ挙動が実現できたわけではない.
2412 差異は,次の例が示すように,和文文字の範囲を変更した行の改行において見られる:
2414 \ltjsetparameter{autoxspacing=false}
2415 \ltjsetparameter{jacharrange={-6}}xあ
2416 y\ltjsetparameter{jacharrange={+6}}zあ
2419 もし\pTeX とまったく同じ挙動を示すならば,出力は
2420 「\hbox{\ltjsetparameter{autoxspacing=false}x yzあu}」となるべきである.しかし,実際には
2423 \item 2行目は「あ」という和文文字で終わる(2行目を処理する前の時点では,
2424 「あ」は和文文字扱いである)ため,直後の改行文字は無視される.
2425 \item 3行目は「あ」という欧文文字で終わる(2行目を処理する前の時点では,
2426 「あ」は欧文文字扱いである)ため,直後の改行文字は空白に置き換わる.
2428 このため,トラブルを避けるために,和文文字の範囲を\verb+\ltjsetparameter+で編集した場合,
2429 その行はそこで改行するようにした方がいいだろう.
2433 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
2434 %<ja>\section{JFM グルーの挿入,\Param{kanjiskip} と \Param{xkanjiskip}}
2435 %<en>\subsection{Overview}
2436 %<ja>\subsection{概要}
2442 \LuaTeX-ja における和文処理グルーの挿入方法は,\pTeX のそれとは全く異なる.
2443 \pTeX では次のような仕様であった:
2445 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
2447 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
2448 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
2449 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
2451 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
2452 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
2453 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
2454 カーニング処理がノードベースになったことに対応する変更である.
2456 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,下の図\ref{fig-clu}のよう
2457 に「塊」を単位にして行われる.大雑把にいうと,「塊」は文字とそれに付随す
2458 るノード達(アクセント位置補正用のkernや,イタリック補正)をまとめたもの
2459 であり,2つの塊の間には,ペナルティ,\verb+\vadjust+,whatsitなど,行組版
2460 には関係しないものがある.そのため,……
2463 % \begin{figure}[!tb]
2467 %<en>\subsection{Definition of a `cluster'}
2468 %<ja>\subsection{「クラスタ」の定義}
2471 A \emph{cluster} is a list of nodes in one of the following forms, with the \textit{id} of it:
2473 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$. These
2474 nodes come from a hbox which is already packaged, by unpackaging
2476 The \textit{id} is \textit{id\_pbox}.
2477 \item A inline math formula, including two \textit{math\_node}s at the boundary of it:
2479 The \textit{id} is \textit{id\_math}.
2480 \item A \textit{glyph\_node} with nodes which relate with it:
2482 The \textit{id} is \textit{id\_jglyph} or
2483 \textit{id\_glyph}, according to whether the \textit{glyph\_node}
2484 represents a Japanese character or not.
2485 \item An box-like node, that is, an hbox, an vbox and an rule (\verb+\vrule+).
2486 The \textit{id} is \textit{id\_hlist} if the node is an
2487 hbox which is not shifted vertically, or \textit{id\_box\_like}
2489 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
2490 The \textit{id} is \textit{id\_glue}, \textit{id\_kern}
2491 and \textit{id\_disc}, respectively.
2492 %Just a node which will \dots, \textit{i.e.}, a node which is \emph{not} one of the following:
2493 %\textit{ins\_node}, \textit{mark\_node}, \textit{adjust\_node}, \textit{whatsit\_node}
2494 %and \textit{penalty\_node}.
2496 We denote a cluster by \textit{Np}, \textit{Nq} and \textit{Nr}.
2499 Internally, a cluster is represented by a table $\textit{Np}$ with the following fields.
2502 \def\makelabel#1{\textbf{\textit{#1}}}
2503 \item[first, last] The first/last node of the cluster.
2504 \item[id] The \textit{id} in above definition.
2508 \item[auto\_kspc, auto\_xspc]
2509 \item[xspc\_before, xspc\_after]