OSDN Git Service

Updated documents.
[luatex-ja/luatexja.git] / doc / luatexja.dtx
1 %<*!showexpl>
2 %#! lualatex -shell-escape
3
4 % To typeset this manual, you need following two fonts:
5 %  - KozMinPr6N-Regular.otf
6 %  - KozGoPr6N-Medium.otf
7 %  - KozGoPr6N-Regular.otf
8
9 %%%%% section ==> 章
10 %%%%% subsection => 節
11
12 %<en>\documentclass[a4paper,titlepage]{article}
13 %<ja>\documentclass[a4paper,titlepage]{ltjsarticle}
14
15 %%%%%%%%
16 \makeatletter
17 %%%%%%%%
18 \directlua{if jit then jit.on() end}
19 %<*en>
20 \usepackage[margin=25mm,lmargin=30mm,rmargin=30mm,footskip=6mm]{geometry}
21 \usepackage{luatexja-adjust}\ltjdisableadjust
22 \parskip=\smallskipamount
23 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
24     {3.25ex \@plus1ex \@minus.2ex}%
25     {-1em}%
26     {\normalfont\normalsize\bfseries\raisebox{.2ex}{$\mdlgblksquare\mkern1mu$}}}
27 %</en>
28 %<*ja>
29 \usepackage[textwidth=45\zw, lines=45, footskip=6mm]{geometry}
30 \usepackage{luatexja-adjust}%\ltjdisableadjust
31 \advance\leftmargini-1\zw\advance\leftmarginii-1\zw
32 %</ja>
33
34 \usepackage{amsmath,array,tikz,pict2e,multienum,float}
35 \usepackage{booktabs,multicol,luatexja-ruby}
36 \usepackage[all]{xy}
37 \usepackage{lltjext,alltt}
38
39 %%%%%%%% listings
40
41 %%%%%%%% IVS
42
43 \def\IVS#1{\char\numexpr "E0100+#1\relax}%"
44 \def\IVSA#1#2#3#4#5{%
45   \textcolor{blue}{\raisebox{3.5pt}{\tt%
46     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
47 }
48 {\catcode`\%=11
49   \gdef\IVSB#1{\expandafter\IVSA\directlua{
50     local cat_str = luatexbase.catcodetables['string']
51     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
52 }}}
53
54 \usepackage{listings,showexpl,enumitem}
55 \lstset{
56   basicstyle=\ttfamily\small, pos=r, breaklines=true,
57   numbers=none, rframe={}, basewidth=0.5em, numberstyle=\tiny, numbersep=0.5em,
58   explpreset={numberstyle=\tiny, numbers=left, numbersep=1em, columns=fixed}
59 }
60 % Suppress output from showexpl to stdout.
61 \let\SX@Info\relax
62
63 %%%%%%%% colors
64 %% modified from http://jfly.iam.u-tokyo.ac.jp/colorset/
65 \usepackage{transparent}
66 \definecolor{red}{rgb}{1, 0.16, 0}
67 \definecolor{blue}{rgb}{0, 0.25, 1}
68 \definecolor{gray}{rgb}{.50, .53, .56}
69 \definecolor{green}{rgb}{.21, .63, .42}
70 \definecolor{cyan}{rgb}{0.40, .80, 1}
71 \definecolor{b_gray}{rgb}{0.78, 0.78, 0.80}
72 \definecolor{b_pink}{rgb}{1, 0.82, 0.82}
73 \definecolor{b_green}{rgb}{.53, .91, .69}
74 \definecolor{b_cyan}{rgb}{0.70, .92, 98}
75
76 %%%%%%%% hyperref
77 \usepackage{hyperref,bookmark}
78 %<*en>
79 \title{The \LuaTeX-ja package}
80 \author{The \LuaTeX-ja project team}
81 %</en>
82 %<*ja>
83 \title{\LuaTeX-jaパッケージ}
84 \author{\LuaTeX-jaプロジェクトチーム}
85 %</ja>
86 \hypersetup{%
87         unicode,
88         colorlinks,
89         allbordercolors=1 1 1,
90         allcolors=blue,
91 %<*en>
92         pdfauthor={The LuaTeX-ja project team},
93         pdftitle={The LuaTeX-ja package}
94 %</en>
95 %<*ja>
96         pdfauthor={LuaTeX-jaプロジェクトチーム},
97         pdftitle={LuaTeX-jaパッケージ}
98 %</ja>
99 }
100
101 %%%%%%%% definition env.
102 \usepackage{amsthm}
103 \theoremstyle{definition}
104 %<en>\newtheorem{defn}{Definition}
105 %<ja>\newtheorem{defn}{定義}
106
107 %%%%%%%% fonts
108 \usepackage{luatexja-otf}
109 %<ja>\usepackage{lmodern}
110 \directlua{luatexja.otf.enable_ivs()}
111 \usepackage[match]{luatexja-fontspec}
112 \usepackage[kozuka-pr6n]{luatexja-preset}
113 \setmonojfont{KozGoPr6N-Regular.otf}
114 %<*ja>
115 \def\emph#1{\textbf{\textgt{#1}}}
116 \def\headfont{\normalfont\bfseries\gtfamily}
117 \usepackage{amssymb}
118 %</ja>
119 %<*en>
120 \usepackage{unicode-math}
121 \setmainfont[Ligatures=TeX]{TeX Gyre Termes}
122 \setsansfont[Scale=0.95,Ligatures=TeX]{TeX Gyre Heros}
123 \setmathfont{xits-math.otf}
124 \frenchspacing
125 %</en>
126
127 %%%%%%%% logo
128 \usepackage{metalogo}
129 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
130 \DeclareRobustCommand\LuaTeX{Lua\TeX}
131 \DeclareRobustCommand\pdfTeX{pdf\TeX}
132 \DeclareRobustCommand\pTeX{p\kern-.15em\TeX}
133 \DeclareRobustCommand\upTeX{up\kern-.15em\TeX}
134 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
135 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
136 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\kern-.125em\pTeX}
137
138 %%%%%%%% other macros
139 \newlist{cslist}{description}{1}
140 \setlist[cslist]{%
141     style=nextline,font=\mdseries\ttfamily,
142     before*=\def\<{\char`\<}\def\>{\char`\>}\def\{{\char`\{}\def\}{\char`\}},
143 %<ja> leftmargin=2\zw,
144 %<en> leftmargin=2em,
145 }
146
147 \def\labelenumii{(\arabic{enumii})}
148 \long\def\@makecaption#1#2{%
149   \vskip\abovecaptionskip
150   \sbox\@tempboxa{{\small #1. #2}}%
151   \ifdim \wd\@tempboxa >\hsize
152     {\small #1. #2}\par
153   \else
154     \global \@minipagefalse
155     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
156   \fi
157   \vskip\belowcaptionskip}
158
159 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
160 \def\cs#1{\texttt{\upshape\textbackslash #1}}
161
162 %%%%%%%%
163 \makeatother
164 %%%%%%%%
165
166 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
167   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}\strut#2\cr}}}}}\,}
168 \def\HNode#1#2#3#4{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
169   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}%
170   width:\hfill\ #2\cr height:\hfill\ #3\cr depth:\hfill\ #4\cr
171   }}}}}\,}
172
173 \protected\def\Param#1{\hyperlink{fld:#1}{\textsf{#1}}} % parameter name
174 \protected\def\DParam#1{\hypertarget{fld:#1}{\textsf{#1}}} % parameter name (definition)
175 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
176
177
178 \begin{document}
179 \lstset{
180   vscmd=\IVSB
181 }
182
183 \catcode`\<=13
184 \def<#1>{{\normalfont\rm\itshape$\langle$#1\/$\rangle$}}
185 \let\LARG=<
186 \maketitle
187
188 \tableofcontents
189 \bigskip
190
191 %<*en>
192 \textbf{This documentation is far from complete. It may have many
193 grammatical (and contextual) errors.} Also, several parts
194 are written in Japanese only.
195 %</en>
196 %<*ja>
197 \emph{\large 本ドキュメントはまだまだ未完成です.}
198 %</ja>
199
200 \clearpage
201 %<en>\part{User's manual}
202 %<ja>\part{ユーザーズマニュアル}
203
204 %<en>\section{Introduction}
205 %<ja>\section{はじめに}
206
207
208 %<*en>
209 The \LuaTeX-ja package is a macro package for typesetting high-quality
210 Japanese documents when using \LuaTeX.
211 %</en>
212 %<*ja>
213 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
214 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
215 %</ja>
216 %<en>\subsection{Backgrounds}
217 %<ja>\subsection{背景}
218
219 %<*en>
220 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
221 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
222 extension of \TeX: so it can produce high-quality Japanese documents
223 without using very complicated macros. But this point is a mixed
224 blessing: \pTeX\ is left behind from other extensions of \TeX,
225 especially \eTeX\ and \pdfTeX, and from changes about
226 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
227 %</en>
228 %<*ja>
229 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
230 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
231 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
232 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
233 もなってしまった.\pTeX という(組版的に)満足なものがあったため,海外で
234 行われている数々の\TeX の拡張――例えば\eTeX や\pdfTeX ――や,TrueType,
235 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
236 を怠ってしまったのだ.
237 %</ja>
238
239 %<*en>
240 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
241 of \pTeX) and \epTeX\ (merging of \pTeX\ and
242 \eTeX\ extension), have developed to fill those gaps to some
243 extent, but gaps still exist.
244 %</en>
245 %<*ja>
246 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
247 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
248 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
249 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
250 るようになった.だが,\pdfTeX 拡張(PDF直接出力やmicro-typesetting)を
251 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
252 る.
253 %</ja>
254
255 %<*en>
256 However, the appearance of \LuaTeX\ changed the whole situation. With
257 using Lua ``callbacks'', users can customize the internal processing of
258 \LuaTeX. So there is no need to modify sources of engines to
259 support Japanese typesetting: to do this, we only have to write Lua
260 scripts for appropriate callbacks.
261 %</en>
262 %<*ja>
263 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
264 ``callback''を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
265 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
266 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
267 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
268 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
269 が始まったパッケージである.
270 %</ja>
271
272 %<en>\subsection{Major Changes from \pTeX}
273 %<ja>\subsection{\pTeX からの主な変更点}
274 \label{ssec:chgptex}
275
276 %<*en>
277 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
278 target of development was to implement features of \pTeX. However, 
279 implementing all feature of \pTeX\ is impossible, 
280 since all process of \LuaTeX-ja must be implemented only by Lua and \TeX\ macros.
281 Hence \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
282 specifications/behaviors of \pTeX\ were not adopted}.
283 %</en>
284 %<*ja>
285 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
286 能をLuaコードにより実装することであった.しかし,(\pTeX はエンジン拡張であったのに対し)
287 \LuaTeX-jaはLuaコードと\TeX マクロを用いて全てを実装していなければならないため,\pTeX
288 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
289 ているような状況も発見された.そのため,\emph{\LuaTeX-jaは,もはや
290 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
291 れば,そこは積極的に改める.}
292 %</ja>
293
294 %<*en>
295 The followings are major changes from \pTeX.
296 For more detailed information, see Part~\ref{part-imp} or other sections of this manual.
297 %</en>
298 %<*ja>
299 以下は \pTeX からの主な変更点である.
300 より詳細については第\ref{part-imp}部など本文書の残りを参照.
301 %</ja>
302
303 %<*en>
304 \paragraph{Command names} \pTeX\ addes several primitives, such as \cs{kanjiskip}, 
305 \cs{prebreakpenalty},~and,~\cs{ifydir}. They can be used as follows:
306 %</en>
307 %<*ja>
308 \paragraph{命令の名称} 例えば\pTeX で追加された次のようなプリミティブ
309 %</ja>
310 \begin{verbatim}
311 \kanjiskip=10pt  \dimen0=kanjiskip
312 \tbaselineshift=0.1zw
313 \dimen0=\tbaselineshift
314 \prebreakpenalty`ぁ=100
315 \ifydir ... \fi
316 \end{verbatim}
317 %<en> However, we cannot use them under \LuaTeX-ja. 
318 %<en> Instead of them, we have to write as the following.
319 %<ja> は\LuaTeX-jaには存在しない.\LuaTeX-jaでは以下のように記述することになる.
320 \begin{verbatim}
321 \ltjsetparameter{kanjiskip=10pt}  \dimen0=\ltjgetparameter{kanjiskip}
322 \ltjsetparameter{talbaselineshift=0.1\zw}
323 \dimen0=\ltjgetparameter{talbaselineshift}
324 \ltjsetparameter{prebreakpenalty={`ぁ,100}}
325 \ifnum\ltjgetparemeter{direction}=4 ... \fi
326 \end{verbatim}
327 %<*en> 
328 Note that \pTeX\ adds new two useful units, namely \texttt{zw}~and~\texttt{zh}.
329 As shown above, they are changed by \cs{zw}~and\cs{zh} respectively, in \LuaTeX-ja.
330 %</en>
331 %<*ja>
332 特に注意してほしいのは,\pTeX で追加された \texttt{zw} と \texttt{zh} という単位を
333 \LuaTeX-ja で扱うには,\cs{zw}, \cs{zh} と制御綴の形にしないといけないという点である.
334 %</ja>
335
336 %<*en>
337 \paragraph{Linebreak after a Japanese character}
338 In \pTeX, a line break after Japanese character is ignored (and
339       doesn't yield a space), since line breaks (in source files) are
340       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
341       doesn't have this feature completely, because of a specification
342       of \LuaTeX. For the detail, see Section~\ref{sec-lbreak}.
343 %</en>
344 %<*ja>
345 \paragraph{和文文字直後の改行}
346 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
347       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
348       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
349       詳しくは\ref{sec-lbreak}章を参照.
350 %</ja>
351
352 %<*en>
353
354 \paragraph{Spaces related to Japanese characters}
355 The insertion process of glues/kerns between two Japanese
356       characters and between a Japanese character and other characters
357       (we refer glues/kerns of both kinds as \textbf{JAglue}) is rewritten from
358       scratch.
359 %</en>
360 %<*ja>
361 \paragraph{和文関連の空白}
362 2つの和文文字の間や,和文文字と欧文文字の間に入るグルー/カーン
363       (両者をあわせて\textbf{JAglue}と呼ぶ)の挿入処理が0から書き直されている.
364 %</ja>
365
366 \begin{itemize}
367 %<*en>
368 \item As \LuaTeX's internal ligature handling is ``node-based''
369       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
370       insertion process of \textbf{JAglue} is now ``node-based''.
371 %</en>
372 %<*ja>
373 \item \LuaTeX の内部での合字の扱いは「ノード」を単位として行われるようになっている(例えば,
374       \verb+of{}fice+ で合字は抑制されない).それに合わせ,\textbf{JAglue}の挿入処理も
375       ノード単位で実行される.
376 %</ja>
377
378 %<*en>
379 \item Furthermore, nodes between two characters which have no effects in
380       line break (\textit{e.g.}, \cs{special} node) and kerns from
381       italic correction are ignored in the insertion process.
382 %</en>
383 %<*ja>
384 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \cs{special} ノード)や,
385   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
386 %</ja>
387
388 %<*en>
389 \item \emph{Caution: due to above two points, many methods which did for the
390       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
391       effective anymore.} In concrete terms, the following two methods are not effective anymore:
392 %</en>
393 %<*ja>
394 \item \emph{注意:上の2つの変更により,従来\textbf{JAglue}の挿入処理を分断するのに
395       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
396 %</ja>
397 \begin{lstlisting}
398 ちょ{}っと    ちょ\/っと
399 \end{lstlisting}
400 %<*en>
401       If you want to do so, please put an empty horizontal box (hbox) between it instead:
402 %</en>
403 %<*ja>
404       もし同じことをやりたければ,空の水平ボックス(hbox)を間に挟めばよい:
405 %</ja>
406 \begin{lstlisting}
407 ちょ\hbox{}っと
408 \end{lstlisting}
409
410 %<*en>
411 \item In the process, two Japanese fonts which only differ in their ``real''
412       fonts are identified.
413 %</en>
414 %<*ja>
415 \item 処理中では,2つの和文フォントは,実フォントが異なるだけの場合には同一視
416       される.
417 %</ja>
418 \end{itemize}
419
420 %<*en>
421 \paragraph{Directions}
422 From version ********, \LuaTeX-ja supports vertical writing;
423 but this feature must \emph{not} be confused with $\Omega$-style direction support of \LuaTeX\
424 itself. ...
425 %</en>
426 %<*ja>
427 \paragraph{組方向}
428 ****版からは,不安定ながらも\LuaTeX-ja における縦組みをサポートしている.
429 なお,\LuaTeX 本体も,$\Omega$流の組方向をサポートしているが,それとは全くの別物であること
430 に注意してほしい.
431 \LuaTeX のコールバックや実装により,特に異なった組方向のボックスを扱う場合には
432 \cs{wd}, \cs{ht}, \cs{dp}等の仕様が異なるので注意.詳細は第\ref{sec-direction}節を参照.
433 %</ja>
434
435 %<*en>
436 \paragraph{\cs{discretionary}}
437 Japanese characters in discretionary break (\cs{discretionary}) is not supported.
438 %</en>
439 %<*ja>
440 \paragraph{\cs{discretionary}}
441  \cs{discretionary} 内に直接和文文字を記述することは,\pTeX においても想定されていなかった
442  感があるが.\LuaTeX-jaにおいても想定していない.和文文字をどう
443       しても使いたい場合は \cs{hbox} で括ること.
444 %</ja>
445
446
447
448 %<en>\subsection{Notations}
449 %<ja>\subsection{用語と記法}
450
451 %<*en>
452 In this document, the following terms and notations are used:
453 %</en>
454 %<*ja>
455 本ドキュメントでは,以下の用語と記法を用いる:
456 %</ja>
457 \begin{itemize}
458 %<*en>
459 \item Characters are classified into following two types.
460       Note that the classification can be customized by a user
461       (see Subsection~\ref{ssec-setrange}).
462 %</en>
463 %<*ja>
464 \item 文字は次の2種類に分けられる.この類別は固定されているものではなく,ユーザが後から変更可能である
465       (\ref{ssec-setrange}節を参照).
466 %</ja>
467 \begin{itemize}
468 %<*en>
469 \item \textbf{JAchar}: standing for characters which is used in Japanese typesetting,
470       such as Hiragana,~Katakana, Kanji, and~other Japanese punctuation marks.
471 %</en>
472 %<*ja>
473 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった
474       日本語組版に使われる文字のことを指す.
475 %</ja>
476
477 %<en>\item \textbf{ALchar}: standing for all other characters like latin alphabets.
478 %<ja>\item \textbf{ALchar}: ラテンアルファベットを始めとする,その他全ての文字を指す.
479 \end{itemize}
480
481 %<*en>
482 We say \emph{alphabetic fonts} for fonts used in \textbf{ALchar},
483 and \emph{Japanese fonts} for fonts used in \textbf{JAchar}.
484 %</en>
485 %<*ja>
486 そして,\textbf{ALchar}の出力に用いられるフォントを\emph{欧文フォント}と呼び,
487 \textbf{JAchar}の出力に用いられるフォントを\emph{和文フォント}と呼ぶ.
488 %</ja>
489 %<*en>
490 \item A word in a sans-serif font (like \Param{prebreakpenalty})
491       means an internal parameter for Japanese typesetting, and it
492       is used as a key in \cs{ltjsetparameter} command.
493 %</en>
494 %<*ja>
495 \item サンセリフ体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
496       パラメータを表し,これらは \cs{ltjsetparameter} 命令のキーとして
497       用いられる.
498 %</ja>
499 %<*en>
500 \item A word in typewriter font with underline (like \Pkg{fontspec})
501       means a package or a class of \LaTeX.
502 %</en>
503 %<*ja>
504 \item 下線付きタイプライタ体の語(例:\Pkg{fontspec})は\LaTeX の
505       パッケージやクラスを表す.
506 %</ja>
507 %<*en>
508 \item In this document, natural numbers start from~zero.
509   $\omega$ denotes the set of all natural numbers.
510 %</en>
511 %<*ja>
512 \item 本ドキュメントでは,自然数は0から始まる.自然数全体の集合は$\omega$と表記する.
513 %</ja>
514 \end{itemize}
515
516 %<en>\subsection{About the Project}
517 %<ja>\subsection{プロジェクトについて}
518
519 %<en>\paragraph{Project Wiki} Project Wiki is under construction.
520 %<ja>\paragraph{プロジェクトWiki} プロジェクトWikiは構築中である.
521 %<*en>
522 \begin{itemize}
523 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
524 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
525 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28zh%29} (Chinese)
526 \end{itemize}
527 %</en>
528 %<*ja>
529 \begin{itemize}
530 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
531 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
532 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28zh%29}(中国語)
533 \end{itemize}
534 %</ja>
535
536 %<en>This project is hosted by SourceForge.JP.
537 %<ja>本プロジェクトはSourceForge.JPのサービスを用いて運営されている.
538
539 %<en>\paragraph{Members}\
540 %<ja>\paragraph{開発メンバー}\
541
542 %<*en>
543 \begin{multienumerate}
544 \def\labelenumi{$\bullet$}
545 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
546 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
547 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
548 \end{multienumerate}
549 %</en>
550 %<*ja>
551 \begin{multienumerate}
552 \def\labelenumi{$\bullet$}
553 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
554 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
555 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
556 \end{multienumerate}
557 %</ja>
558
559 % \paragraph{Acknowledgments} -- 挿入するならここ
560
561 \clearpage
562 %<en>\section{Getting Started}
563 %<ja>\section{使い方}
564 %<en>\subsection{Installation}
565 %<ja>\subsection{インストール}
566
567 %<en>The following packages are needed for the \LuaTeX-ja\ package.
568 %<ja>\LuaTeX-jaパッケージには,次のパッケージ類が必要である.
569 \begin{itemize}
570 \item \LuaTeX\ snapshot rev~5024 (or later)
571 \item \Pkg{luaotfload} v2.5 (or later)
572 \item \Pkg{adobemapping} (Adobe cmap and pdfmapping files)
573 \item \Pkg{everysel} (if you want to use \LuaTeX-ja with \LaTeXe)
574 %<en>\item \emph{IPAex fonts}(\url{http://ipafont.ipa.go.jp/})
575 %<ja>\item \emph{IPAexフォント(\url{http://ipafont.ipa.go.jp/})}
576 \end{itemize}
577
578 %<*en>
579 \emph{This version of \LuaTeX-ja no longer supports \TeX~Live~2013 (or older version).
580 If you want to use this version with \TeX~Live~2014, you have to build a development
581 version of \LuaTeX\ from its source.}
582
583 \medskip
584
585 Now \LuaTeX-ja is available from
586 CTAN (in the \texttt{macros/luatex/generic/luatexja} directory), and
587 the following distributions:
588   \begin{itemize}
589   \item MiK\TeX\ (in \texttt{luatexja.tar.lzma}); see the next subsection
590   \item \TeX\ Live (in \texttt{texmf-dist/tex/luatex/luatexja})
591   \item W32\TeX\ (in \texttt{luatexja.tar.xz})
592   \end{itemize}
593 IPAex fonts are also available in these distributions.
594 %</en>
595 %<*ja>
596 \emph{本バージョンの\LuaTeX-jaは\TeX~Live~2013以前では動作しない.\TeX~Live~2014で
597 用いたい場合は,自力で\LuaTeX 開発版をソースからビルドする必要がある.}
598
599 \medskip
600
601 現在,\LuaTeX-jaはCTAN (\texttt{macros/luatex/generic/luatexja})に収録されている他,
602 以下のディストリビューションにも収録されている:
603   \begin{itemize}
604   \item MiK\TeX\ (\texttt{luatexja.tar.lzma})
605   \item \TeX\ Live (\texttt{texmf-dist/tex/luatex/luatexja})
606   \item W32\TeX\ (\texttt{luatexja.tar.xz})
607   \end{itemize}
608 これらのディストリビューションはIPAexフォントも収録している.
609 W32\TeX においてはIPAexフォントは \texttt{luatexja.tar.xz} 内にある.
610 %</ja>
611
612 % %<*ja>
613 % 例えば\TeX~Live~2015を利用しているなら,\LuaTeX-jaは\TeX~Live manager (\texttt{tlmgr})を
614 % 使ってインストールすることができる.
615 % \begin{lstlisting}
616 % $ tlmgr install luatexja
617 % \end{lstlisting}
618 % %</ja>
619 % %<*en>
620 % If you are using \TeX~Live~2015, you can install \LuaTeX-ja
621 % from \TeX~Live manager (\texttt{tlmgr}):
622 % \begin{lstlisting}
623 % $ tlmgr install luatexja
624 % \end{lstlisting}
625 % %</en>
626
627 %<en>\paragraph{Manual installation}
628 %<ja>\paragraph{手動インストール方法}
629
630 \begin{enumerate}
631 %<*en>
632 \item Download the source, by one of the following method.
633       At the present, \LuaTeX-ja has no \emph{stable} release.
634
635 \begin{itemize}
636 \item Clone the Git repository:
637 \begin{lstlisting}
638 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
639 \end{lstlisting}
640 \item Download the \texttt{tar.gz} archive of HEAD in the \texttt{master} branch from
641 \begin{flushleft}
642 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
643 \end{flushleft}
644 \end{itemize}
645
646 Note that the \texttt{master} branch, and hence the archive in CTAN, are not updated frequently;
647 the forefront of development is not the \texttt{master} branch.
648 %</en>
649 %<*ja>
650 \item ソースを以下のいずれかの方法で取得する.現在公開されているのはあくまでも
651       開発版であって,安定版でないことに注意.
652
653 \begin{itemize}
654 \item Gitリポジトリをクローンする:
655 \begin{lstlisting}
656 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
657 \end{lstlisting}
658 \item \texttt{master}ブランチのスナップショット(\texttt{tar.gz}形式)をダウンロードする.
659 \begin{flushleft}
660 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
661 \end{flushleft}
662 \end{itemize}
663 \texttt{master}ブランチ(従って,CTAN内のアーカイブも)はたまにしか更新されないことに注意.
664 主な開発は\texttt{master}の外で行われ,比較的まとまってきたらそれを\texttt{master}に
665 反映させることにしている.
666 %</ja>
667
668 %<*en>
669 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
670 But only the contents in \texttt{src/} are needed to work \LuaTeX-ja.
671 %</en>
672 %<*ja>
673 \item 「Gitリポジトリをクローン」以外の方法でアーカイブを取得したならば,それを展開する.
674       \texttt{src/}をはじめとしたいくつかのディレクトリができるが,
675       動作には\texttt{src/}以下の内容だけで十分.
676 %</ja>
677
678 %<*en>
679 \item If you downloaded this package from CTAN, you have to run following commands
680     to generate classes
681     and \texttt{ltj-kinsoku.lua} (the file which stores default ``\textit{kinsoku}'' parameters):
682 %</en>
683 %<*ja>
684 \item もしCTANから本パッケージを取得したのであれば,日本語用クラスファイルや
685 標準の禁則処理用パラメータを
686 格納した \texttt{ltj-kinsoku.lua} を生成するために,
687 以下を実行する必要がある:
688 %</ja>
689 \begin{lstlisting}
690 $ cd src
691 $ lualatex ltjclasses.ins
692 $ lualatex ltjsclasses.ins
693 $ lualatex ltjltxdoc.ins
694 $ luatex   ltj-kinsoku_make.tex
695 \end{lstlisting}
696 %<*en>
697 Note that \texttt{*.\{dtx,ins\}} and \texttt{ltj-kinsoku\_make.tex} are not needed in regular use.
698 %</en>
699 %<*ja>
700 ここで使用した \texttt{*.\{dtx,ins\}} と \texttt{ltj-kinsoku\_make.tex} は
701 通常の使用にあたっては必要ない.
702 %</ja>
703
704
705
706 %<*en>
707 \item Copy all the contents of \texttt{src/} into one of your \texttt{TEXMF} tree.
708       \texttt{TEXMF/tex/luatex/luatexja/} is an example location.
709       If you cloned entire Git repository, making a symbolic link of \texttt{src/}
710       instead copying is also good.
711 %</en>
712 %<*ja>
713 \item \texttt{src}の中身を自分の\texttt{TEXMF}ツリーにコピーする.
714       場所の例としては,例えば
715 \begin{quote}
716  \texttt{TEXMF/tex/luatex/luatexja/}
717 \end{quote}
718       がある.
719       シンボリックリンクが利用できる環境で,かつリポジトリを直接取得したのであれば,
720       (更新を容易にするために)コピーではなくリンクを貼ることを勧める.
721 %</ja>
722 %<*en>
723 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
724 %</en>
725 %<*ja>
726 \item 必要があれば,\texttt{mktexlsr}を実行する.
727 %</ja>
728 \end{enumerate}
729
730 %<*en>
731 \subsection{Cautions}
732 For changes from \pTeX, see Subsection~\ref{ssec:chgptex}.
733 %</en>
734 %<*ja>
735 \subsection{注意点}
736 \pTeX からの変更点として,\ref{ssec:chgptex}節も熟読するのが望ましい.
737 ここでは一般的な注意点を述べる.
738 %</ja>
739 \begin{itemize}
740 %<*en>
741 \item The encoding of your source file must be UTF-8. No other
742       encodings, such as EUC-JP or Shift-JIS, are not supported.
743 %</en>
744 %<*ja>
745 \item 原稿のソースファイルの文字コードはUTF-8固定である.
746       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
747 %</ja>
748 %<*en>
749 \item \LuaTeX-ja is very slower than \pTeX.
750 Generally speaking, LuaJIT\TeX\ processes \LuaTeX-ja
751 about 30\% faster than \LuaTeX, but not always.
752 %</en>
753 %<*ja>
754 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
755 コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
756 LuaJIT\TeX を用いると\LuaTeX のだいたい1.3倍の速度で動くようであるが,
757 IPA mj明朝などの大きいフォントを用いた場合には\LuaTeX よりも遅くなることもある.
758 %</ja>
759 \item%
760 %<*en>
761 \textbf{Note for MiK\TeX\ users}\quad
762 \LuaTeX-ja requires that several CMap files%
763 \footnote{\texttt{UniJIS2004-UTF32-\{H,V\}} and \texttt{Adobe-Japan1-UCS2}.}
764 must be found from \LuaTeX.
765 Strictly speaking, those CMaps are needed
766 only in the first run of \LuaTeX-ja after installing or updating.
767 But it seems that MiK\TeX\ does not satisfy this condition,
768 so you will encounter an error like the following:
769 %</en>
770 %<*ja>
771 \LuaTeX-jaが動作するためには,\emph{導入・更新後の初回起動時に}
772 \texttt{UniJIS2004-UTF32-\{H,V\}}, \texttt{Adobe-Japan1-UCS2}という3つのCMapが
773 \LuaTeX によって見つけられることが必要である.
774 しかしMiK\TeX ではそのようになっていないので,次のエラーが発生するだろう:
775 %</ja>
776 \begin{lstlisting}
777 ! LuaTeX error ...iles (x86)/MiKTeX 2.9/tex/luatex/luatexja/ltj-rmlgbm.lua
778 bad argument #1 to 'open' (string expected, got nil)
779 \end{lstlisting}
780
781 %<*en>
782 If so, please execute a batch file which is written on
783 \href{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{ the Project Wiki (English)}.
784 This batch file creates a temporary directory, copy CMaps in it,
785 run \LuaTeX-ja in this directory, and finally delete the temporary directory.
786 %</en>
787 %<*ja>
788 そのような場合には,
789 \href{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{%
790   プロジェクトWiki英語版トップページ}中に書かれているバッチファイルを
791 実行して欲しい.このバッチファイルは,作業用ディレクトリにCMap達を
792 コピーし,その中で\LuaTeX-ja の初回起動を行い,作業用ディレクトリを消す作業をしている.
793 %</ja>
794
795 \end{itemize}
796
797 %<en>\subsection{Using in plain \TeX}
798 %<ja>\subsection{plain \TeX で使う}
799 \label{ssec-plain}
800
801 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
802 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
803 \begin{lstlisting}
804 \input luatexja.sty
805 \end{lstlisting}
806 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
807 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
808
809 \begin{itemize}
810 %<*en>
811 \item The following 12~Japanese fonts are preloaded:
812 \begin{center}\small
813 \begin{tabular}{cccccc}
814 \toprule
815 \textbf{direction}&
816 \textbf{classification}&\textbf{font name}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
817 \smash{\raisebox{-1ex}{\emph{yoko} (horizontal)}}&
818 \emph{mincho}&IPAex Mincho&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
819 &\emph{gothic}&IPAex Gothic&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
820 \midrule
821 \smash{\raisebox{-1ex}{\emph{tate} (vertical)}}&
822 \emph{mincho}&IPAex Mincho&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
823 &\emph{gothic}&IPAex Gothic&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
824 \bottomrule
825 \end{tabular}
826 \end{center}
827 %</en>
828 %<*ja>
829 \item 以下の12個の和文フォントが定義される:
830 \begin{center}\small
831 \begin{tabular}{cccccc}
832 \toprule
833 \emph{組方向}&\emph{字体}&\emph{フォント名}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
834 \smash{\raisebox{-1ex}{横組}}&
835 明朝体&IPAex明朝&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
836 &ゴシック体&IPAexゴシック&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
837 \midrule
838 \smash{\raisebox{-1ex}{縦組}}&
839 明朝体&IPAex明朝&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
840 &ゴシック体&IPAexゴシック&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
841 \bottomrule
842 \end{tabular}
843 \end{center}
844 %</ja>
845 \begin{itemize}
846 %<*en>
847 \item With \texttt{luatexja.cfg}, one can use other fonts
848 as ``default'' Japanese fonts (Subsection~\ref{ssec-cfg}).
849 %</en>
850 %<*ja>
851 \item \texttt{luatexja.cfg} を用いることによって,標準和文フォントを
852 IPAexフォントから別のフォントに置き換えることができる.\ref{ssec-cfg}節を参照.
853 %</ja>
854
855 %<*en>
856 \item A character in an alphabetic font is generally smaller than a
857       Japanese font in the same size. So actual size specification of
858       these Japanese fonts is in fact smaller than that of alphabetic
859       fonts, namely scaled by 0.962216.
860 %</en>
861 %<*ja>
862 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
863       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
864       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
865       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
866 %</ja>
867 \end{itemize}
868
869 %<*en>
870 \item The amount of glue that are inserted between a \textbf{JAchar} and
871       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
872 %</en>
873 %<*ja>
874 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{xkanjiskip})の
875       量は次のように設定されている:
876 %</ja>
877 \[
878  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
879  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
880 \]
881 \end{itemize}
882
883 %<en>\subsection{Using in \LaTeX}
884 %<ja>\subsection{\LaTeX で使う}
885 \label{ssec-ltx}
886
887 %<*en>
888 Using in \LaTeXe\ is basically same. To set up the minimal environment
889 for Japanese, you only have to load \texttt{luatexja.sty}:
890 %</en>
891 %<*ja>
892 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
893 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
894 %</ja>
895 \begin{lstlisting}
896 \usepackage{luatexja}
897 \end{lstlisting}
898 %<*en>
899 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
900 plfonts.dtx} and \texttt{pldefs.ltx}):
901 %</en>
902 %<*ja>
903 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
904 なされる:
905 %</ja>
906
907 \begin{itemize}
908 %<*en>
909 \item Font encodings for Japanese fonts is \texttt{JY3}~(for horizontal direction) and
910 \texttt{JT3}~(for vertical direction).
911 %</en>
912 %<*ja>
913 \item 和文フォントのエンコーディングとしては,横組用には \texttt{JY3},縦組用には\
914 \texttt{JT3}が用いられる.
915 %</ja>
916
917 %<*en>
918 \item Traditionally, Japanese documents use two typeface categories: \emph{mincho}~(明朝体) and
919  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
920       is used in the headings or for emphasis.
921 \begin{center}\small
922 \begin{tabular}{lllc}
923 \toprule
924 \textbf{classification}&&&\textbf{family name}\\\midrule
925 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
926 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
927 \bottomrule
928 \end{tabular}
929 \end{center}
930 \item
931 By default, the following fonts are used for \emph{mincho} and \emph{gothic}:
932 \begin{center}\small
933 \begin{tabular}{ccccc}
934 \toprule
935 \textbf{classification}&\textbf{family}&\cs{mdseries}&\cs{bfseries}&\textbf{scale}\\\midrule
936 \emph{mincho} (明朝体)&\tt mc&IPAex Mincho&IPAex Gothic&0.962216\\
937 \emph{gothic} (\textgt{ゴシック体})&\tt gt&IPAex Gothic&IPAex Gothic&0.962216\\
938 \bottomrule
939 \end{tabular}
940 \end{center}
941 Note that the bold series in both family are same as the medium series of \emph{gothic}
942      family. There is no italic nor slanted shape for
943       these \texttt{mc}~and~\texttt{gt}.
944 %</en>
945 %<*ja>
946 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる:
947 \begin{center}\small
948 \begin{tabular}{cllc}
949 \toprule
950 \emph{字体}&&&\emph{ファミリ名}\\\midrule
951 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
952 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
953 \bottomrule
954 \end{tabular}
955 \end{center}
956 \item 標準では,次のフォントファミリが用いられる:
957 \begin{center}\small
958 \begin{tabular}{ccccc}
959 \toprule
960 \emph{字体}&\emph{ファミリ}&\cs{mdseries}&\cs{bfseries}&\emph{スケール}\\\midrule
961 明朝体&\tt mc&IPAex明朝&IPAexゴシック&0.962216\\
962 ゴシック体&\tt gt&IPAexゴシック&IPAexゴシック&0.962216\\
963 \bottomrule
964 \end{tabular}
965 \end{center}
966 どちらのファミリにおいても,そのboldシリーズで使われるフォントは
967 ゴシック体のmediumシリーズで使われるフォントと同じであることに注意.
968 また,どちらのファミリでもイタリック体・スラント体は定義されない.
969 %</ja>
970
971 %<en>\item Japanese characters in math mode are typeset by the font family \texttt{mc}.
972 %<ja>\item 数式モード中の和文文字は明朝体(\texttt{mc})で出力される.
973
974 %<*en>
975 \item If you use the \Pkg{beamer} class with the default font theme (which uses sans serif
976       fonts) and with \LuaTeX-ja, you might want to change default Japanese fonts to
977       \emph{gothic} family. The following line  changes  the default Japanese font family
978       to \emph{gothic}:
979 %</en>
980 %<*ja>
981 \item \Pkg{beamer}クラスを既定のフォント設定で使う場合,既定欧文フォントがサンセリフなの
982       で,既定和文フォントもゴシック体にしたいと思うかもしれない.その場合はプリアンブルに
983 次を書けばよい:
984 %</ja>
985 \begin{lstlisting}
986  \renewcommand{\kanjifamilydefault}{\gtdefault}
987 \end{lstlisting}
988
989
990 \end{itemize}
991
992 %<*en>
993 However, above settings are not sufficient for Japanese-based
994 documents. To typeset Japanese-based documents, you are better to use
995 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
996 the present, we have the counterparts of \Pkg{jclasses} (standard
997 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
998 Okumura), namely, \Pkg{ltjclasses}\footnote{%
999   \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls},
1000   \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls}.
1001   The latter \texttt{ltjt*.cls} are for vertically writtened Japanese documents.
1002 } and \Pkg{ltjsclasses}\footnote{%
1003   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}.
1004 %</en>
1005 %<*ja>
1006 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
1007 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
1008 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
1009 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}
1010 (奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,
1011 \Pkg{ltjclasses}\footnote{%
1012   横組用は \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls} であり,
1013   縦組用は \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls} である.
1014 },
1015 \Pkg{ltjsclasses}\footnote{%
1016   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}%
1017 がそれぞれ用意されている.
1018 %</ja>
1019
1020 %<*ja>
1021 \paragraph{脚注とボトムフロートの出力順序}
1022 オリジナルの\LaTeX では脚注がボトムフロートの上に来るようになっており,
1023 \pLaTeX では脚注がボトムフロートの下に来るように変更されている.
1024
1025 \LuaTeX-jaでは「欧文クラスの中にちょっとだけ日本語を入れる」という利用も考慮し,
1026 脚注とボトムフロートの順序は\LaTeX 通りとした.もし\pLaTeX の出力順序が好みならば,
1027 \Pkg{stfloats}パッケージを利用して
1028 \begin{lstlisting}
1029  \usepackage{stfloats}\fnbelowfloat
1030 \end{lstlisting}
1031 のようにすればよい.\Pkg{footmisc}パッケージを \texttt{bottom}\ オプションを指定して
1032 読み込むという方法もあるが,それだとボトムフロートと脚注の間が開いてしまう.
1033 %</ja>
1034 %%% ↑は英訳しない
1035
1036 %<*en>
1037 \paragraph{\Pkg{geometry} package and classes for vertical writing}
1038 It is well-known that the \Pkg{geometry} package produces the following error, when classes for
1039 vertical writing is used:
1040 %</en>
1041 %<*ja>
1042 \paragraph{縦組での\Pkg{geometry}パッケージ}
1043 \pLaTeX の縦組用標準クラスファイルでは\Pkg{geometry}パッケージを利用することは出来ず,
1044 %</ja>
1045 \begin{lstlisting}
1046 ! Incompatible direction list can't be unboxed.
1047 \@begindvi ->\unvbox \@begindvibox 
1048                                    \global \let \@begindvi \@empty 
1049 \end{lstlisting}
1050 %<*en>
1051 Now, \LuaTeX-ja automatically applies the patch \Pkg{lltjp-geometry} to the
1052 \Pkg{geometry} package, when the direction of the document is \emph{tate} (vertical
1053 writing).
1054 This patch \Pkg{lltjp-geometry} also can be used in \pLaTeX; for the detail, please refer 
1055 \url{lltjp-geometry.pdf}~(Japanese).
1056 %</en>
1057 %<*ja>
1058 というようなエラーが発生することが知られている.
1059 \LuaTeX-jaでは, \texttt{ltjtarticle.cls} といった縦組クラスの下でも
1060 \Pkg{geometry}パッケージが利用できるようにパッチ\Pkg{lltjp-geometry}パッケージを自動的に当てている.
1061
1062 なお,\Pkg{lltjp-geometry}パッケージは\pTeX 系列でも明示的に読み込むことによって
1063 使用可能である.詳細や注意事項は \url{lltjp-geometry.pdf} を参照のこと.
1064 %</ja>
1065
1066
1067 %<en>\section{Changing Fonts}
1068 %<ja>\section{フォントの変更}
1069
1070 \subsection{plain \TeX~and~\LaTeXe}
1071 \label{ssec-chgfnt}
1072
1073 \paragraph{plain \TeX}
1074 %<*en>
1075 To change Japanese fonts in plain \TeX, you must use the command
1076 \cs{jfont}~and~\cs{tfont}. So please see Subsection~\ref{ssec-jfont}.
1077 %</en>
1078 %<*ja>
1079 plain \TeX で和文フォントを変更するためには,
1080 \pTeX のように \cs{jfont} 命令や \cs{tfont} 命令を直接用いる.
1081 \ref{ssec-jfont}節を参照.
1082 %</ja>
1083
1084 \paragraph{\LaTeXe\ (NFSS2)}
1085 %<*en>
1086 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
1087 %</en>
1088 %<*ja>
1089 \LaTeXe については,\LuaTeX-jaではフォント選択システムを\pLaTeXe\ (\texttt{plfonts.dtx})
1090 の大部分をそのまま採用している.
1091 %</ja>
1092 \begin{itemize}
1093 %<*en>
1094 \item Commands \cs{fontfamily}, \cs{fontseries},
1095       \cs{fontshape}, and \cs{selectfont} can be used to change
1096       attributes of Japanese fonts.
1097 %</en>
1098 %<*ja>
1099 \item \cs{fontfamily}, \cs{fontseries}, \cs{fontshape}, そして
1100       \cs{selectfont} が和文フォントの属性を変更するために使用できる.
1101 %</ja>
1102
1103 %<*en>
1104 \begin{center}\small
1105 \begin{tabular}{cccccc}
1106 \toprule
1107 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
1108 alphabetic fonts
1109 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1110 &\cs{useroman}\\
1111 Japanese fonts
1112 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1113 &\cs{usekanji}\\
1114 both&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1115 auto select&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1116 \bottomrule
1117 \end{tabular}
1118 \end{center}
1119 %</en>
1120 %<*ja>
1121 \begin{center}\small
1122 \begin{tabular}{cccccc}
1123 \toprule
1124 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェープ}&\emph{選択}\\\midrule
1125 欧文
1126 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1127 &\cs{useroman}\\
1128 和文
1129 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1130 &\cs{usekanji}\\
1131 両方&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1132 自動選択&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1133 \bottomrule
1134 \end{tabular}
1135 \end{center}
1136 %</ja>
1137
1138 %<*en>
1139       \verb+\fontencoding{+<encoding>\verb+}+ changes the encoding of alphabetic fonts
1140       or Japanese fonts depending on the argument. For example,
1141       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
1142       \texttt{JY3},and \verb+\fontencoding{T1}+ changes the encoding of
1143       alphabetic fonts to \texttt{T1}.
1144       \cs{fontfamily} also changes the current Japanese font family,
1145       the current alphabetic font family, \emph{or both}.
1146       For the detail, see Subsection~\ref{ssec-nfsspat}.
1147 %</en>
1148 %<*ja>
1149       ここで,\verb+\fontencoding{+<encoding>\verb+}+ は,引数により和文側か欧文
1150       側かのどちらかのエンコーディングを変更する.例えば,
1151       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1152       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1153       \texttt{T1}へと変更する.\cs{fontfamily} も引数により和文側,欧文
1154       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1155       \ref{ssec-nfsspat}節を参照すること.
1156 %</ja>
1157
1158 %<*en>
1159 \item For defining a Japanese font family, use
1160       \cs{DeclareKanjiFamily} instead of
1161       \cs{DeclareFontFamily}. However, in the present implementation,
1162       using \cs{DeclareFontFamily} doesn't cause any problem.
1163 \item Defining a Japanese font shape can be done by usual \cs{DeclareFontShape}:
1164 %</en>
1165 %<*ja>
1166 \item 和文フォントファミリの定義には \cs{DeclareFontFamily} の
1167       代わりに \cs{DeclareKanjiFamily} を用いる.しかし,現在の
1168       実装では \cs{DeclareFontFamily} を用いても問題は生じない.
1169 \item 和文フォントのシェイプを定義するには,通常の \cs{DeclareFontShape} を使えば良い:
1170 %</ja>
1171 \begin{lstlisting}
1172 \DeclareFontShape{JY3}{mc}{bx}{n}{<-> s*KozMinPr6N-Bold:jfm=ujis;-kern}{}
1173     % Kozuka Mincho Pr6N Bold
1174 \end{lstlisting}
1175 %<*ja>
1176 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1177 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} と,その\LaTeX 版の\
1178 \cs{DeclareAlternateKanjiFont}(\ref{ssec-nfsspat}節)を参照せよ.
1179 %</ja>
1180
1181 \end{itemize}
1182
1183 %<*en>
1184 \paragraph{Remark: Japanese characters in math mode}
1185 Since \pTeX\ supports Japanese characters in math mode, there are
1186 sources like the following:
1187 %</en>
1188 %<*ja>
1189 \paragraph{注意:数式モード中の和文文字}
1190 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1191 以下のようなソースが見られた:
1192 %</ja>
1193
1194 \begin{LTXexample}
1195 $f_{高温}$~($f_{\text{high temperature}}$).
1196 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1197 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1198 \end{LTXexample}
1199 %<*en>
1200 We (the project members of \LuaTeX-ja) think that using
1201 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1202 In this point of view,
1203 %</en>
1204 %<*ja>
1205 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1206 ときのみ許されると考えている.
1207 この観点から,
1208 %</ja>
1209
1210 \begin{itemize}
1211 %<*en>
1212 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1213 ``よって'' is used as a conjunction.
1214 %</en>
1215 %<*ja>
1216 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1217       して,「よって」が接続詞として用いられているからである.
1218 %</ja>
1219 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1220 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1221 \end{itemize}
1222 %<en>Hence, in our opinion, the above input should be corrected as:
1223 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1224 \begin{LTXexample}
1225 $f_{\text{高温}}$~%
1226 ($f_{\text{high temperature}}$).
1227 \[ y=(x-1)^2+2\quad
1228   \mathrel{\text{よって}}\quad y>0 \]
1229 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1230 \end{LTXexample}
1231 %<*en>
1232 We also believe that using Japanese characters as identifiers is rare,
1233 hence we don't describe how to change Japanese fonts in math mode in
1234 this chapter. For the method, please see Subsection~\ref{ssec-math}.
1235 %</en>
1236 %<*ja>
1237 また\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1238 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1239 記述しない.この方法については\ref{ssec-math}節を参照のこと.
1240 %</ja>
1241
1242
1243 \subsection{fontspec}
1244 \label{ssec-fontspec}
1245 %<*en>
1246 To coexist with the \Pkg{fontspec} package, it is needed to load
1247 \Pkg{luatexja-fontspec} package in the preamble, as follows:
1248 \begin{quote}
1249 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1250 \end{quote}
1251 This \Pkg{luatexja-fontspec} package
1252 automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1253 package, if needed.
1254 %</en>
1255 %<*ja>
1256 \Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場合,
1257 \Pkg{luatexja-fontspec}パッケージを読み込む:
1258 \begin{quote}
1259 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1260 \end{quote}
1261 このパッケージ
1262 は必要ならば自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1263 %</ja>
1264
1265 %<*en>
1266 In \Pkg{luatexja-fontspec} package, the following seven~commands are defined as
1267 counterparts of original commands in the \Pkg{fontspec} package:
1268 %</en>
1269 %<*ja>
1270 \Pkg{luatexja-fontspec}パッケージでは,以下の7つのコマンドを\Pkg{fontspec}
1271 パッケージの元のコマンドに対応するものとして定義している:
1272 %</ja>
1273 %<*en>
1274 \begin{center}\small
1275 \begin{tabular}{ccccc}
1276 \toprule
1277 Japanese fonts
1278 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}$^*$\\
1279 alphabetic fonts
1280 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1281 \midrule
1282 Japanese fonts
1283 &\cs{newjfontfamily}&\cs{newjfontface}
1284 &\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1285 alphabetic fonts
1286 &\cs{newfontfamily}&\cs{newfontface}
1287 &\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1288 \bottomrule
1289 \end{tabular}
1290 \end{center}
1291 %</en>
1292 %<*ja>
1293 \begin{center}\small
1294 \begin{tabular}{cccc}
1295 \toprule
1296 和文
1297 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}\\
1298 欧文
1299 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}\\
1300 \midrule
1301 和文
1302 &\cs{newjfontfamily}&\cs{newjfontface}&\cs{defaultjfontfeatures}\\
1303 欧文
1304 &\cs{newfontfamily}&\cs{newfontface}&\cs{defaultfontfeatures}\\
1305 \midrule
1306 和文
1307 &\cs{addjfontfeatures}\\
1308 欧文
1309 &\cs{addfontfeatures}\\
1310 \bottomrule
1311 \end{tabular}
1312 \end{center}
1313 %</ja>
1314 %<*en>
1315 The package option of \Pkg{luatexja-fontspec} are the followings:
1316 \begin{cslist}
1317  \item[match]
1318 If this option is specified, usual family-changing commands such as
1319 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
1320
1321 Note that \emph{\cs{setmonojfont} is defined
1322 if and only if this \texttt{\textup{match}} option is specified}.
1323
1324  \item[pass=<opts>]
1325 Specify options <opts> which will be passed to the \Pkg{fontspec} package.
1326 \end{cslist}
1327 The reason that \cs{setmonojfont} is not defined by default is that
1328 it is popular for Japanese fonts that nearly all Japanese glyphs have same
1329 widths.  Also note that kerning information in a font is not used
1330 (that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands.
1331 This is because of the compatibility with previous versions of \LuaTeX-ja
1332 (see \ref{para-kern}).
1333 %</en>
1334 %<*ja>
1335 \Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである:
1336 \begin{cslist}
1337  \item[match]
1338 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
1339 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
1340 欧文フォントだけでなく和文フォントも変更するようになる.
1341
1342 \emph{なお,\cs{setmonojfont} はこの \texttt{match} オプションが
1343 指定された時のみ定義される.}この命令は標準の「タイプライタ体に対応する和文フォント」を指定する.
1344
1345  \item[pass=<opts>]
1346 \Pkg{fontspec} パッケージに渡すオプション <opts> を指定する.
1347 \end{cslist}
1348 標準で \cs{setmonojfont} コマンドが定義されないのは,
1349 和文フォントではほぼ全ての和文文字のグリフが等幅であるのが伝統的であったことによる.
1350 また,これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
1351 言い換えれば \texttt{kern} featureは標準では無効化となっている.
1352 これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
1353 %</ja>
1354
1355 \begin{LTXexample}[width=0.4\textwidth]
1356 \fontspec[Numbers=OldStyle]{LMSans10-Regular}
1357 \jfontspec[CJKShape=NLC]{KozMinPr6N-Regular}
1358 JIS~X~0213:2004→辻
1359
1360 \jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular}
1361 JIS~X~0208:1990→辻
1362 \end{LTXexample}
1363
1364 %<en>\subsection{Presets}
1365 %<ja>\subsection{プリセット設定}
1366 \label{ssec-preset}
1367
1368 %<*en>
1369 To use standard Japanese font settings easily, one can load \Pkg{luatexja-preset}
1370 package with several options. This package provides functions in a part of
1371 \Pkg{japanese-otf} package and a part of \Pkg{PXchfon} package by Takayuki Yato,
1372 and loads \Pkg{luatexja-fontspec}, hence \Pkg{fontspec} internally.
1373
1374 If you need to pass some options to \Pkg{fontspec}, load \Pkg{fontspec} manually
1375 before \Pkg{luatexja-preset}:
1376 %</en>
1377 %<*ja>
1378 よく使われている和文フォント設定を一行で指定できるようにしたのが
1379 \Pkg{luatexja-preset}パッケージである.このパッケージは,
1380 \Pkg{otf}パッケージの一部機能と八登崇之氏による\Pkg{PXchfon}パッケージの一部機能とを
1381 合わせたような格好をしており,内部で\Pkg{luatexja-fontspec},従って
1382 \Pkg{fontspec}を読み込んでいる.
1383
1384 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
1385 \footnote{例えば,数式フォントまで置換されてしまい,\cs{mathit}によってギリシャ文字の
1386 斜体大文字が出なくなる,など.}場合は,
1387 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
1388 %</ja>
1389 \begin{lstlisting}
1390 \usepackage[no-math]{fontspec}
1391 \usepackage[...]{luatexja-preset}
1392 \end{lstlisting}
1393
1394 %<en>\paragraph{General options}
1395 %<ja>\paragraph{一般的なオプション}
1396 \begin{cslist}[before*=]
1397
1398 \item[nodeluxe]
1399 %<*en>
1400 Use one-weighted \textit{mincho} and \textit{gothic} font families.
1401 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and
1402 \verb+\gtfamily\mdseries+ use the same font.
1403 \emph{This option is enabled by default.}
1404 %</en>
1405 %<*ja>
1406 \LaTeXe 環境下での標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
1407 より具体的に言うと,この設定の下では
1408 \ \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+,
1409 \verb+\gtfamily\mdseries+はみな同じフォントとなる.
1410 \emph{このオプションは標準で有効になっている.}
1411 %</ja>
1412 \item[deluxe]
1413 %<*en>
1414 Use \textit{mincho} with two weights (medium~and~bold),
1415 \textit{gothic} with three weights (medium, bold~and~heavy), and \textit{rounded gothic}%
1416 \footnote{Provided by \cs{mgfamily} and \cs{textmg},
1417 because \textit{rounded gothic} is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
1418 The heavy weight of \textit{gothic} can be used by ``changing the family'' \cs{gtebfamily},
1419 or \verb+\textgteb{...}+.
1420 This is because \Pkg{fontspec} package can handle only medium (\cs{mdseries}) and
1421 bold (\cs{bfseries}).
1422 %</en>
1423 %<*ja>
1424 明朝体2ウェイト・ゴシック体3ウェイトと,
1425 丸ゴシック体 (\cs{mgfamily}, \verb+\textmg{...}+) を使用可能とする.
1426 ゴシック体は細字・太字・極太の3ウェイトがあるが,
1427 極太ゴシック体はファミリの切り替え (\cs{gtebfamily}, \verb+\textgteb{...}+) %
1428 で実現している.\Pkg{fontspec}では通常 (\cs{mdseries}) と太字 (\cs{bfseries}) しか扱えないために
1429 このような中途半端な実装になっている.
1430 %</ja>
1431 \item[expert]
1432 %<*en>
1433 Use horizontal/vertical kana alternates, and define a command \cs{rubyfamily} to use kana
1434 characters designed for ruby.
1435 %</en>
1436 %<ja>横組・縦組専用仮名を用いる.また,\cs{rubyfamily} でルビ用仮名が使用可能となる.
1437 \item[bold]
1438 %<en>Substitute bold series of \textit{gothic} for  bold series of \textit{mincho}.
1439 %<ja>「明朝の太字」をゴシック体の太字によって代替する.
1440 \item[90jis]
1441 %<en>Use 90JIS glyph variants if possible.
1442 %<ja>出来る限り90JISの字形を使う.
1443 \item[jis2004]
1444 %<en>Use JIS2004 glyph variants if possible.
1445 %<ja>出来る限りJIS2004の字形を使う.
1446 \item[jis]
1447 %<*en>
1448 Use the JFM \texttt{jfm-jis.lua}, instead of \texttt{jfm-ujis.lua}, which is the default JFM of
1449 \LuaTeX-ja.
1450 %</en>
1451 %<*ja>
1452 用いるJFMを(JISフォントメトリック類似の)\texttt{jfm-jis.lua}にする.このオプションがない時は
1453 \LuaTeX-ja標準の\texttt{jfm-ujis.lua}が用いられる.
1454 %</ja>
1455 \end{cslist}
1456 %<*en>
1457 Note that \texttt{90jis} and \texttt{jis2004} only affect with \textit{mincho},
1458 \textit{gothic} (and possibly \textit{rounded gothic}) defined by this package.
1459 We didn't taken account of  when both \texttt{90jis} and \texttt{jis2004} are specified.
1460 %</en>
1461 %<*ja>
1462 \texttt{90jis}と\texttt{jis2004}については本パッケージで定義された
1463 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.両オプションが
1464 同時に指定された場合の動作については全く考慮していない.
1465 %</ja>
1466
1467 %<en>\paragraph{Presets for multi weight}
1468 %<ja>\paragraph{多ウェイト用プリセットの一覧}
1469 %<*en>
1470 Besides \texttt{morisawa-pro}~and~\texttt{morisawa-pr6n} presets,
1471 fonts are specified by font name, not by file name.
1472 %</en>
1473 %<*ja>
1474 \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
1475 (ファイル名でなく)フォント名で行われる.
1476 %</ja>
1477 \begin{cslist}[style=standard]
1478  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
1479 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1480  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
1481 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1482  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1483
1484 %<*en>
1485 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
1486 There is not rounded gothic family in Kozuka fonts.
1487 %</en>
1488 %<*ja>
1489 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
1490 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
1491 %</ja>
1492 \begin{center}\small
1493 \begin{tabular}{cllll}
1494 \toprule
1495 \bf family&\bf series&\tt kozuka-pro&\tt kozuka-pr6&\tt kozuka-pr6n\\
1496 \midrule
1497  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
1498 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1499 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1500  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
1501 \midrule
1502  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
1503  &\smash{\raisebox{1.5ex}{medium}}
1504  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
1505 \cmidrule(l){2-5}
1506 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1507 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1508  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
1509  &heavy&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1510 \midrule
1511 %<en>\textit{rounded gothic}
1512 %<ja>\gt 丸ゴシック
1513 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1514 \bottomrule
1515 \end{tabular}
1516 \end{center}
1517
1518 %<*en>
1519 In above table, starred fonts (KozGo\dots-Regular) are used for medium series of \textit{gothic},
1520 \emph{if and only if \texttt{deluxe} option is specified}.
1521 %</en>
1522 %<*ja>
1523 上の表において,*つきのフォント(KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション指定時に}
1524 ゴシック体細字として用いられる.
1525 %</ja>
1526
1527 %<ja>\medskip
1528
1529  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
1530 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1531  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
1532
1533 %<*en>
1534 Hiragino fonts are bundled with Mac OS~X 10.5 or later.
1535 Some editions of a Japanese word-processor ``一太郎2012'' includes Hiragino ProN fonts.
1536 Note that the heavy weight of \textit{gothic} family only supports
1537 Adobe-Japan1-3 character collection (Std/StdN).
1538 %</en>
1539 %<*ja>
1540 ヒラギノフォントは,Mac OS~X以外にも,一太郎2012の上位エディションにもバンドルされている.
1541 極太ゴシックとして用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
1542 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
1543 %</ja>
1544 \begin{center}\small
1545 \begin{tabular}{clll}
1546 \toprule
1547 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
1548 \midrule
1549  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
1550 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1551 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1552  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
1553 \midrule
1554  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
1555  &\smash{\raisebox{1.5ex}{medium}}
1556  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1557 \cmidrule(l){2-4}
1558 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1559 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1560  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1561  &heavy&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
1562 \midrule
1563 %<en>\textit{rounded gothic}
1564 %<ja>\gt 丸ゴシック
1565 &&Hiragino~Maru~Gothic~ProN~W4&Hiragino~Maru~Gothic~ProN~W4\\
1566 \bottomrule
1567 \end{tabular}
1568 \end{center}
1569
1570 %<ja>\newpage
1571
1572  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
1573 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1574  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1575
1576 \begin{center}\small
1577 \begin{tabular}{cl>{\tt}l>{\tt}l}
1578 \toprule
1579 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
1580 \midrule
1581  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
1582 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1583 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1584  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
1585 \midrule
1586  &medium
1587  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
1588 %<en>\textit{gothic}%
1589 %<ja>\gt ゴシック
1590  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
1591  &heavy&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
1592 \midrule
1593 %<en>\textit{rounded gothic}
1594 %<ja>\gt 丸ゴシック
1595 &&A-OTF-Jun101Pro-Light.otf&A-OTF-ShinMGoPr6N-Light.otf\\
1596 \bottomrule
1597 \end{tabular}
1598 \end{center}
1599
1600  \item[yu-win]  Yu fonts bundled with Windows~8.1.
1601 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1602  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks.
1603
1604 \begin{center}\small
1605 \begin{tabular}{clll}
1606 \toprule
1607 \bf family&\bf series&\tt yu-win&\tt yu-osx\\
1608 \midrule
1609  &medium&YuMincho-Regular&YuMincho~Medium\\
1610 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1611 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1612  &bold&YuMincho-Demibold&YuMincho~Demibold\\
1613 \midrule
1614  &&YuGothic-Regular*&YuGothic~Medium*\\
1615  &\smash{\raisebox{1.5ex}{medium}}
1616  &YuGothic-Bold&YuGothic~Bold\\
1617 \cmidrule(l){2-4}
1618 %<en>\textit{gothic}%
1619 %<ja>\gt ゴシック
1620  &bold&YuGothic-Bold&YuGothic~Bold\\
1621  &heavy&YuGothic-Bold&YuGothic~Bold\\
1622 \midrule
1623 %<en>\textit{rounded gothic}
1624 %<ja>\gt 丸ゴシック
1625 &&YuGothic-Bold&YuGothic~Bold\\
1626 \bottomrule
1627 \end{tabular}
1628 \end{center}
1629
1630 \end{cslist}
1631 %<en>\paragraph{Presets for single weight}
1632 %<ja>\paragraph{単ウェイト用プリセット一覧}
1633 %<*en>
1634 Next, we describe settings for using only single weight.
1635 In four settings below, we use same fonts for medium and bold (and heavy) weights.
1636 (Hence \verb+\mcfamily\bfseries+ and \verb+\mcfamily\mdseries+ yields same Japanese fonts,
1637 even if \texttt{deluxe} option is also specified).
1638 %</en>
1639 %<*ja>
1640 次に,単ウェイト用の設定を述べる.この4設定では「細字」「太字」の区別はない.
1641 また,丸ゴシック体はゴシック体と同じフォントを用いる.
1642 %</ja>
1643 \par\nobreak\medskip
1644 {\centering\small
1645 \begin{tabular}{lllll}
1646 \toprule
1647 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
1648 \midrule
1649 %<*en>
1650 \it mincho&Ryumin-Light (non-embedded)
1651 &IPA Mincho&IPAex Mincho&MS Mincho\\
1652 \it gothic&GothicBBB-Medium (non-embedded)
1653 &IPA Gothic&IPAex Gothic&MS Gothic\\
1654 %</en>
1655 %<*ja>
1656 \gtfamily 明朝体&Ryumin-Light(非埋込)
1657 &IPA明朝&IPAex明朝&MS明朝\\
1658 \gtfamily ゴシック体&GothicBBB-Medium(非埋込)
1659 &IPAゴシック&IPAexゴシック&MSゴシック\\
1660 %</ja>
1661 \bottomrule
1662 \end{tabular}\par\medskip}
1663
1664 %<en>\paragraph{Using HG fonts}
1665 %<ja>\paragraph{HGフォントの利用}
1666 %<*en>
1667 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
1668 %</en>
1669 %<*ja>
1670 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
1671 多ウェイト化した設定もある.
1672 %</ja>
1673 \par\nobreak\medskip
1674 {\centering\small
1675 \begin{tabular}{llll}
1676 \toprule
1677 &\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
1678 \midrule
1679 %<*en>
1680 \bf mincho medium
1681 &IPA Mincho&IPAex Mincho&MS Mincho\\\midrule
1682 \bf mincho bold&
1683 \multicolumn{3}{c}{HG Mincho E}\\\midrule
1684 \bf Gothic medium\\
1685 ~~without \texttt{deluxe}
1686 &IPA Gothic&IPAex Gothic&MS Gothic\\
1687 ~~with {\tt jis2004}
1688 &IPA Gothic&IPAex Gothic&MS Gothic\\
1689 \cmidrule(lr){1-4}
1690 ~~otherwise&
1691 \multicolumn{3}{c}{HG Gothic M}\\\midrule
1692 \bf gothic bold&
1693 \multicolumn{3}{c}{HG Gothic E}\\\midrule
1694 \bf gothic heavy&
1695 \multicolumn{3}{c}{HG Soei Kaku Gothic UB}\\\midrule
1696 \bf rounded gothic&
1697 \multicolumn{3}{c}{HG Maru Gothic PRO}\\
1698 %</en>
1699 %<*ja>
1700 \gtfamily 明朝体細字
1701 &IPA明朝&IPAex明朝&MS明朝\\\midrule
1702 \gtfamily 明朝体太字&
1703 \multicolumn{3}{c}{HG明朝E}\\\midrule
1704 \gtfamily ゴシック体細字\\
1705  単ウェイト時
1706 &IPAゴシック&IPAexゴシック&MSゴシック\\
1707  {\tt jis2004}指定時
1708 &IPAゴシック&IPAexゴシック&MSゴシック\\
1709 \cmidrule(lr){1-4}
1710  それ以外の時&
1711 \multicolumn{3}{c}{HGゴシックM}\\\midrule
1712 \gtfamily ゴシック体太字&
1713 \multicolumn{3}{c}{HGゴシックE}\\\midrule
1714 \gtfamily ゴシック体極太&
1715 \multicolumn{3}{c}{HG創英角ゴシックUB}\\\midrule
1716 \gtfamily 丸ゴシック体&
1717 \multicolumn{3}{c}{HG丸ゴシック体PRO}\\
1718 %</ja>
1719 \bottomrule
1720 \end{tabular}\par\medskip}
1721
1722 %<*en>
1723 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
1724 are internally specified by:
1725 \begin{description}
1726 \item[default] by font name (\texttt{HGMinchoE}, etc.).
1727 \item[{\tt 90jis}] by file name (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
1728 \item[{\tt jis2004}] by file name (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
1729 \end{description}
1730 %</en>
1731 %<*ja>
1732 \newpage
1733 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
1734 \begin{description}
1735 \item[標準] フォント名(\texttt{HGMinchoE} など)
1736 \item[{\tt 90jis}指定時] ファイル名 (%
1737 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
1738 \item[{\tt jis2004}指定時] ファイル名 (%
1739 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
1740 \end{description}
1741 として指定を行っているので注意すること.
1742 %</ja>
1743
1744
1745 %<*en>
1746 \subsection{\cs{CID}, \cs{UTF}, and macros in \Pkg{japanese-otf} package}
1747 Under \pLaTeX, \Pkg{japanese-otf} package (developed by Shuzaburo Saito) is
1748 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1749 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1750 supports some of functions in \Pkg{japanese-otf} package.
1751 If you want to use these functions, load \Pkg{luatexja-otf} package.
1752 %</en>
1753 %<*ja>
1754 \subsection{\cs{CID}, \cs{UTF}と\Pkg{otf}パッケージのマクロ}
1755 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1756 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1757 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1758 一部をサポートしている.これらの機能を用いるためには\Pkg{luatexja-otf}パッケージ
1759 を読み込めばよい.
1760 %</ja>
1761
1762 \begin{LTXexample}
1763 \jfontspec{KozMinPr6N-Regular.otf}
1764 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
1765
1766 \CID{7652}飾区の\CID{13706}野家,
1767 \CID{1481}城市,葛西駅,
1768 高崎と\CID{8705}\UTF{FA11}
1769
1770 \aj半角{はんかくカタカナ}
1771 \end{LTXexample}
1772
1773 %<*ja>
1774 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1775 \begin{cslist}
1776 \item[deluxe] 明朝体・ゴシック体各2ウェイトと,丸ゴシック体を扱えるようになる.
1777 \item[expert] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も
1778 \ \cs{rubyfamily}\ によって扱えるようになる.
1779 \item[bold] ゴシック体を標準で太いウェイトのものに設定する.
1780 \end{cslist}
1781 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1782 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1783 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1784
1785 これら3オプションについては,
1786 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1787 あるいは対応する内容を\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節 (NFSS2) や
1788 \ref{ssec-fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1789 %</ja>
1790
1791 %<en>\subsection{Changing default Japanese fonts}
1792 %<ja>\subsection{標準和文フォントの変更}
1793 \label{ssec-cfg}
1794 %<*en>
1795 If \texttt{luatexja.cfg} can be seen from \LuaTeX, \LuaTeX-ja automatically reads it.
1796 The main use of \texttt{luatexja.cfg} is for changing default Japanese fonts,
1797 when IPAex fonts cannot be installed in \TeX~system.
1798 One should not overuse this \texttt{luatexja.cfg}; fonts which will be used in
1799 a document should be specified in its source.
1800
1801 For example,
1802 \begin{lstlisting}
1803 \def\ltj@stdmcfont{IPAMincho}
1804 \def\ltj@stdgtfont{IPAGothic}
1805 \end{lstlisting}
1806 makes that IPA~Mincho and IPA~Gothic will be used as default Japanese fonts, instead of
1807 IPAex~Mincho and IPAex~Gothic.
1808
1809 For another example, the following two lines makes that
1810 non-embedded fonts Ryumin-Light~and~GothicBBB-Medium as default Japanese fonts
1811 (as the earlier version of \LuaTeX-ja):
1812 \begin{lstlisting}
1813 \def\ltj@stdmcfont{psft:Ryumin-Light}
1814 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1815 \end{lstlisting}
1816 %</en>
1817 %<*ja>
1818 \LuaTeX から見える位置に \texttt{luatexja.cfg} があれば,\LuaTeX-jaはそれを読み込む.
1819 このファイルを用いるとplain~\TeX, \LaTeXe における標準和文フォントを
1820 IPAex明朝・IPAexゴシックから変更することができる.
1821 しかし,基本的には\emph{文章中で用いるフォントは(例えば \Pkg{luatexja-preset} などで)
1822 文書ソース内で指定するべき}であり,この \texttt{luatexja.cfg} は,
1823 「IPAexフォントがインストールできない」など,IPAexフォントが使用できない場合にのみ
1824 応急処置的に用いるべきである.
1825
1826 例えば
1827 \begin{lstlisting}
1828 \def\ltj@stdmcfont{IPAMincho}
1829 \def\ltj@stdgtfont{IPAGothic}
1830 \end{lstlisting}
1831 と記述しておけば,標準和文フォントがIPA明朝・IPAゴシックへと変
1832 更される.
1833
1834
1835 なお,20140906.0以前のバージョンのように,
1836 Ryumin-Light, GothicBBB-Mediumという名前の非埋込フォントを用いる場合は
1837 \begin{lstlisting}
1838 \def\ltj@stdmcfont{psft:Ryumin-Light}
1839 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1840 \end{lstlisting}
1841 と記述すればよい.
1842 %</ja>
1843
1844
1845 %<en>\section{Changing Parameters}
1846 %<ja>\section{パラメータの変更}
1847
1848 %<*en>
1849 There are many parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1850 most of them are not stored as internal register of \TeX, but as an
1851 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1852 parameters, you have to use commands \cs{ltjsetparameter} and
1853 \cs{ltjgetparameter}.
1854 %</en>
1855 %<*ja>
1856 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1857 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1858 これらのパラメータを設定・取得するためには \cs{ltjsetparameter} と \cs{ltjgetparameter} を
1859 用いる.
1860 %</ja>
1861
1862 %<en>\subsection{Editing the Range of \textbf{JAchar}s}
1863 %<ja>\subsection{\textbf{JAchar}の範囲の設定}
1864 \label{ssec-setrange}
1865
1866 %<*en>
1867 \LuaTeX-ja divides the Unicode codespace \texttt{U+0080}--\texttt{U+10FFFF}
1868 into \emph{character ranges},
1869 numbered 1 to 217. The grouping can be (globally) customized by \cs{ltjdefcharrange}.
1870 The next line adds whole characters in Supplementary Ideographic Plane
1871 and the character ``漢'' to the character range~100.
1872 %</en>
1873 %<*ja>
1874 \LuaTeX-jaは,Unicodeの \texttt{U+0080}--\texttt{U+10FFFF} の空間を
1875 1番から217番までの\emph{文字範囲}に分割している.
1876 区分けは \cs{ltjdefcharrange} を用いることで(グローバルに)変更することができ,
1877 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1878 %</ja>
1879 \begin{lstlisting}
1880 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1881 \end{lstlisting}
1882 %<*en>
1883 A character can belong to only one character range.
1884 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
1885 and if you execute the above line, then SIP will belong to the range~100 and be
1886 removed from the range~4.
1887 %</en>
1888 %<*ja>
1889 各文字はただ一つの文字範囲に所属することができる.
1890 例えば,SIPは全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1891 属しているが,上記の指定を行えばSIPは100番に属すようになり,4番からは除かれる.
1892 %</ja>
1893
1894 %<*en>
1895 The distinction between \textbf{ALchar} and \textbf{JAchar} is done for character ranges.
1896 This can be edited by setting the \textsf{jacharrange} parameter.
1897 For example, this is just the default setting of \LuaTeX-ja, and
1898 it sets
1899 \begin{itemize}
1900  \item a character which belongs character ranges 1,~4, and~5 is \textbf{ALchar},
1901  \item a character which belongs character ranges 2,~3, 6, 7, and~8 is \textbf{JAchar}.
1902 \end{itemize}
1903 %</en>
1904 %<*ja>
1905 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1906 これは\textsf{jacharrange}パラメータによって編集できる.
1907 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1908 \begin{itemize}
1909  \item 1番,4番,5番の文字範囲に属する文字は\textbf{ALchar}.
1910  \item 2番,3番,6番,7番,8番の文字範囲に属する文字は\textbf{JAchar}.
1911 \end{itemize}
1912 %</ja>
1913 \begin{lstlisting}
1914 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
1915 \end{lstlisting}
1916 %<*en>
1917 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
1918 Negative integer $-n$ in the list means that ``each character in the range~$n$ is an
1919 \textbf{ALchar}'',
1920 and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
1921 %</en>
1922 %<*ja>
1923 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
1924 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
1925 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
1926 %</ja>
1927
1928 %<*en>
1929 \paragraph{Default setting}
1930 \LuaTeX-ja predefines eight character ranges for convenience. They are
1931 determined from the following data:
1932 %</en>
1933 %<*ja>
1934 \paragraph{初期設定}
1935 \LuaTeX-jaでは8つの文字範囲を予め定義しており,
1936 これらは以下のデータに基づいて決定している.
1937 %</ja>
1938 \begin{itemize}
1939 %<en>\item Blocks in Unicode~6.0.
1940 %<ja>\item Unicode~6.0のブロック.
1941 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
1942 %<ja>\item Adobe-Japan1-6のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
1943 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
1944 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
1945 \end{itemize}
1946
1947 %<*en>
1948 Now we describe these eight ranges. The superscript ``J'' or ``A'' after the
1949 number shows whether each character in the range is treated as
1950 \textbf{JAchar}s or not by default. These settings are similar to the
1951 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
1952 Any characters above \texttt{U+0080} which does not belong to
1953 these eight ranges belongs to the character range~217.
1954 %</en>
1955 %<*ja>
1956 以下ではこれら8つの文字範囲について記述する.添字のアルファベット「J」「A」
1957 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの設定は
1958 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものである.
1959 なお,\texttt{U+0080} 以降でこれら8つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
1960 %</ja>
1961 \begin{description}
1962 %<*en>
1963
1964 \item[Range~8${}^{\text{J}}$] The intersection of the upper half of ISO~8859-1
1965          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
1966          consists of the following characters:
1967 %</en>
1968 %<*ja>
1969 \item[範囲8${}^{\text{J}}$] ISO~8859-1の上位領域(ラテン1補助)と
1970                              JIS~X~0208の共通部分.この文字範囲は
1971                              以下の文字で構成される:
1972 %</ja>
1973 \begin{multicols}{2}
1974 \begin{itemize}
1975 \def\ch#1#2{\item \char"#1\ (\texttt{U+00#1}, #2)}%"
1976 \ch{A7}{Section Sign}
1977 \ch{A8}{Diaeresis}
1978 \ch{B0}{Degree sign}
1979 \ch{B1}{Plus-minus sign}
1980 \ch{B4}{Spacing acute}
1981 \ch{B6}{Paragraph sign}
1982 \ch{D7}{Multiplication sign}
1983 \ch{F7}{Division Sign}
1984 \end{itemize}
1985 \end{multicols}
1986
1987 %<*en>
1988 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
1989 This range consists of the following Unicode ranges, \emph{except characters in the range~8 above}:
1990 %</en>
1991 %<*ja>
1992 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-6との共通部分があるもの.
1993                              この範囲は以下のUnicodeのブロックのうち
1994                              \emph{範囲8を除いた}部分で構成されている:
1995 %</ja>
1996 \begin{multicols}{2}
1997 \begin{itemize}
1998 \item \texttt{U+0080}--\texttt{U+00FF}: Latin-1 Supplement
1999 \item \texttt{U+0100}--\texttt{U+017F}: Latin Extended-A
2000 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
2001 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
2002 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
2003 \item \texttt{U+0300}--\texttt{U+036F}: \\\null\hfill Combining Diacritical Marks
2004 \item \texttt{U+1E00}--\texttt{U+1EFF}: \\\null\hfill Latin Extended Additional
2005 \par\
2006 \end{itemize}
2007 \end{multicols}
2008 %<*en>
2009 \item[Range~2${}^{\text{J}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
2010            fonts) has some of these characters.
2011 %</en>
2012 %<*ja>
2013 \item[範囲2${}^{\text{J}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
2014                              和文フォント)はこれらの文字を持つ.
2015 %</ja>
2016 \begin{multicols}{2}
2017 \begin{itemize}
2018 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
2019 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
2020 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
2021 \\\
2022 \end{itemize}
2023 \end{multicols}
2024 %<*en>
2025 \item[Range~3${}^{\text{J}}$] Punctuations and Miscellaneous symbols. The block list is
2026            indicated in Table~\ref{table-rng3}.
2027 %</en>
2028 %<*ja>
2029 \item[範囲3${}^{\text{J}}$] 句読点と記号類.ブロックのリストは表\ref{table-rng3}%
2030                              に示してある.
2031 %</ja>
2032 \begin{table}[!tb]
2033 %<en>\caption{Unicode blocks in predefined character range~3.}\medskip
2034 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
2035 \label{table-rng3}
2036 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2037 \centering\small
2038 \begin{tabular}{llll}
2039 "2000--"206F&General Punctuation&
2040 "2070--"209F&Superscripts and Subscripts\\
2041 "20A0--"20CF&Currency Symbols&
2042 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
2043 "2100--"214F&Letterlike Symbols&
2044 "2150--"218F&Number Forms\\
2045 "2190--"21FF&Arrows&
2046 "2200--"22FF&Mathematical Operators\\
2047 "2300--"23FF&Miscellaneous Technical&
2048 "2400--"243F&Control Pictures\\
2049 "2500--"257F&Box Drawing&
2050 "2580--"259F&Block Elements\\
2051 "25A0--"25FF&Geometric Shapes&
2052 "2600--"26FF&Miscellaneous Symbols\\
2053 "2700--"27BF&Dingbats&
2054 "2900--"297F&Supplemental Arrows-B\\
2055 "2980--"29FF&Misc.\ Mathematical Symbols-B&
2056 "2B00--"2BFF&Miscellaneous Symbols and Arrows
2057 \end{tabular}
2058 \end{table}
2059 %<*en>
2060 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
2061            of almost all Unicode blocks which are not in other
2062            predefined ranges. Hence, instead of showing the block list,
2063            we put the definition of this range itself:
2064 %</en>
2065 %<*ja>
2066 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
2067                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
2068                              で構成されている.したがって,ブロックのリストを示す
2069                              代わりに,範囲の定義そのものを示す:
2070 %</ja>
2071 \begin{lstlisting}
2072 \ltjdefcharrange{4}{%
2073    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
2074   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F,
2075   "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese
2076 \end{lstlisting}
2077 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
2078 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
2079 %<en>\item[Range~6${}^{\text{J}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
2080 %<ja>\item[範囲6${}^{\text{J}}$] 日本語で用いられる文字.ブロックのリストは表\ref{table-rng6}に示す.
2081 \begin{table}[!tb]
2082 %<en>\caption{Unicode blocks in predefined character range~6.}\medskip
2083 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
2084 \label{table-rng6}
2085 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2086 \centering\small
2087 \begin{tabular}{llll}
2088 "2460--"24FF&Enclosed Alphanumerics&
2089 "2E80--"2EFF&CJK Radicals Supplement\\
2090 "3000--"303F&CJK Symbols and Punctuation&
2091 "3040--"309F&Hiragana\\
2092 "30A0--"30FF&Katakana&
2093 "3190--"319F&Kanbun\\
2094 "31F0--"31FF&Katakana Phonetic Extensions&
2095 "3200--"32FF&Enclosed CJK Letters and Months\\
2096 "3300--"33FF&CJK Compatibility&
2097 "3400--"4DBF&CJK Unified Ideographs Extension A\\
2098 "4E00--"9FFF&CJK Unified Ideographs&
2099 "F900--"FAFF&CJK Compatibility Ideographs\\
2100 "FE10--"FE1F&Vertical Forms&
2101 "FE30--"FE4F&CJK Compatibility Forms\\
2102 "FE50--"FE6F&Small Form Variants&
2103 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)\\
2104 "{E0}100--"{E0}1EF&Variation Selectors Supplement
2105 \end{tabular}
2106 \end{table}
2107 %<*en>
2108 \item[Range~7${}^{\text{J}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
2109 The block list is indicated in Table~\ref{table-rng7}.
2110 %</en>
2111 %<*ja>
2112 \item[範囲7${}^{\text{J}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-6に
2113                             含まれていないもの.
2114                             ブロックのリストは表\ref{table-rng7}に示す.
2115 %</ja>
2116 \begin{table}[!tb]
2117 %<en>\caption{Unicode blocks in predefined character range~7.}\medskip
2118 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
2119 \label{table-rng7}
2120 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2121 \centering\small
2122 \begin{tabular}{llll}
2123 "1100--"11FF&Hangul Jamo&
2124 "2F00--"2FDF&Kangxi Radicals\\
2125 "2FF0--"2FFF&Ideographic Description Characters&
2126 "3100--"312F&Bopomofo\\
2127 "3130--"318F&Hangul Compatibility Jamo&
2128 "31A0--"31BF&Bopomofo Extended\\
2129 "31C0--"31EF&CJK Strokes&
2130 "A000--"A48F&Yi Syllables\\
2131 "A490--"A4CF&Yi Radicals&
2132 "A830--"A83F&Common Indic Number Forms\\
2133 "AC00--"D7AF&Hangul Syllables&
2134 "D7B0--"D7FF&Hangul Jamo Extended-B
2135 \end{tabular}
2136 \end{table}
2137 \end{description}
2138
2139 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
2140 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
2141 \label{subs-kskip}
2142
2143 %<en>\textbf{JAglue} is divided into the following three categories:
2144 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
2145 \begin{itemize}
2146 %<*en>
2147 \item Glues/kerns specified in JFM. If \cs{inhibitglue} is issued
2148       around a Japanese character, this glue will not be inserted at the
2149       place.
2150 %</en>
2151 %<*ja>
2152 \item JFMで指定されたグルー/カーン.もし \cs{inhibitglue} が和文文字の周りで
2153       発行されていれば,このグルーは挿入されない.
2154 %</ja>
2155 %<*en>
2156 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
2157       kanjiskip}).
2158 %</en>
2159 %<*ja>
2160 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{kanjiskip}).
2161 %</ja>
2162 %<*en>
2163 \item The default glue which inserted between a \textbf{JAchar} and an
2164       \textbf{ALchar} (\Param{xkanjiskip}).
2165 %</en>
2166 %<*ja>
2167 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{xkanjiskip}).
2168 %</ja>
2169 \end{itemize}
2170 %<*en>
2171 The value (a skip) of \Param{kanjiskip} or
2172 \Param{xkanjiskip} can be changed as the following.
2173 Note that only their values \emph{at the end of a paragraph or a hbox are
2174 adopted in the whole paragraph or the whole hbox.
2175 }
2176 %</en>
2177 %<*ja>
2178 \Param{kanjiskip}や\Param{xkanjiskip}の値
2179 は以下のようにして変更可能である.
2180 %</ja>
2181 \begin{lstlisting}
2182 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
2183                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
2184 \end{lstlisting}
2185 %<*en>
2186 Here \cs{zw} is a internal dimension
2187 which stores fullwidth of the current Japanese font.
2188 This \cs{zw} can be used as the unit \texttt{zw} in \pTeX.
2189
2190 The value of these parameter can be get by \cs{ltjgetparameter}.
2191 Note that the result by \cs{ltjgetparameter} is \emph{not} the internal quantities,
2192 but \emph{a string} (hence \cs{the} cannot be prefixed).
2193 %</en>
2194 %<*ja>
2195 ここで,\cs{zw} は現在の和文フォントの全角幅を表す長さであり,
2196 \pTeX における長さ単位 \texttt{zw} と同じように使用できる.
2197
2198 これらのパラメータの値は以下のように取得できる.
2199 戻り値は内部値ではなく\emph{文字列}である(\cs{the} は前置できない)ことに注意してほしい:
2200 %</ja>
2201 \begin{LTXexample}
2202 kanjiskip: \ltjgetparameter{kanjiskip},\\
2203 xkanjiskip: \ltjgetparameter{xkanjiskip}
2204 \end{LTXexample}
2205
2206 %<*en>
2207 It may occur that JFM contains the data of ``ideal width of
2208 \Param{kanjiskip}''
2209 and/or ``ideal width of \Param{xkanjiskip}''.
2210 To use these data from JFM, set the value of \Param{kanjiskip} or
2211 \Param{xkanjiskip} to \cs{maxdimen}
2212 (these ``ideal width'' cannot be retrived by \cs{ltjgetparameter}).
2213 %</en>
2214 %<*ja>
2215 JFMは「望ましい\Param{kanjiskip}の値」や
2216 「望ましい\Param{xkanjiskip}の値」を持っていることがある.
2217 これらのデータを使うためには,\Param{kanjiskip}や%
2218 \Param{xkanjiskip}の値を \cs{maxdimen} の値に設定すればよいが,
2219 \cs{ltjgetparameter} によって取得することはできないので注意が必要である.
2220 %</ja>
2221
2222 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
2223 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
2224
2225 %<*en>
2226 It is not desirable that \Param{xkanjiskip} is inserted into every
2227 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
2228 \Param{xkanjiskip} should not be inserted after opening parenthesis
2229 (\textit{e.g.}, compare ``(あ'' and ``(\hskip\ltjgetparameter{xkanjiskip}あ'').
2230 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
2231 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
2232 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
2233 %</en>
2234 %<*ja>
2235 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
2236 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
2237 後には挿入されるべきではない(「(あ」と「(\hskip\ltjgetparameter{xkanjiskip}あ」を
2238 比べてみよ).
2239 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
2240 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
2241 \Param{alxspmode}をそれぞれ変えることで制御することができる.
2242 %</ja>
2243 \begin{LTXexample}
2244 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
2245 pあq い!う
2246 \end{LTXexample}
2247
2248 %<*en>
2249 The second argument \texttt{preonly} means that the insertion of
2250 \Param{xkanjiskip} is allowed before this character, but not after.
2251 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{inhibit}.
2252 %</en>
2253 %<*ja>
2254 2つ目の引数の \texttt{preonly}は「\Param{xkanjiskip}の挿入はこの文字の
2255 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
2256 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
2257 %</ja>
2258
2259 %<*en>
2260 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
2261 on the current version. Therefore, line~1 in the code above can be rewritten
2262 as follows:
2263 %</en>
2264 %<*ja>
2265 なお,現行の
2266 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
2267 上のコードの1行目を次のように変えても同じことになる:
2268 %</ja>
2269 \begin{lstlisting}
2270 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
2271 \end{lstlisting}
2272 %<*en>
2273 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec-param}).
2274 %</en>
2275 %<*ja>
2276 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec-param}節を参照).
2277 %</ja>
2278
2279 %<*en>
2280 If you want to enable/disable all insertions of \Param{kanjiskip} and
2281 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
2282 parameters to \texttt{true}/\texttt{false}, respectively.
2283 %</en>
2284 %<*ja>
2285 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
2286 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2287 \texttt{true}/\texttt{false}に設定すればよい.
2288 %</ja>
2289
2290 %<en>\subsection{Shifting the baseline}
2291 %<ja>\subsection{ベースラインの移動}
2292 %<*en>
2293 To make a match between a Japanese font and an alphabetic font, sometimes
2294 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2295 by setting \cs{ybaselineshift} (or \cs{tbaselineshift}) to a non-zero length (the
2296 baseline of \textbf{ALchar} is shifted below). However, for documents
2297 whose main language is not Japanese, it is good to shift the baseline of
2298 Japanese fonts, but not that of alphabetic fonts.
2299 Because of this, \LuaTeX-ja can independently set the shifting amount
2300 of the baseline of alphabetic fonts and that of Japanese fonts.
2301 \begin{center}
2302  \small
2303 \begin{tabular}{>{\bfseries}lcc}
2304 \toprule
2305 &\bfseries Horizontal writing (\emph{yoko} direction) etc.
2306 &\bfseries Vertical writing(\emph{tate} direction)\\
2307 \midrule
2308 Alphabetic fonts&\Param{yalbaselineshift}
2309      parameter&\Param{talbaselineshift} parameter\\
2310 Japanese fonts&\Param{yjabaselineshift}
2311      parameter&\Param{tjabaselineshift} parameter\\
2312 \bottomrule
2313 \end{tabular}
2314 \end{center}
2315 %</en>
2316 %<*ja>
2317 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2318 必要になる.\pTeX ではこれは \cs{ybaselineshift}(または\cs{tbaselineshift})を設定することで
2319 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2320 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2321 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2322 と和文フォントのベースラインのシフト量を独立に設定できるようになっている.
2323 \begin{center}
2324  \small
2325 \begin{tabular}{>{\bfseries}lcc}
2326 \toprule
2327 &\bfseries 横組など&\bfseries 縦組\\
2328 \midrule
2329 欧文フォントのシフト量&\Param{yalbaselineshift}
2330      parameter&\Param{talbaselineshift} parameter\\
2331 和文フォントのシフト量&\Param{yjabaselineshift}
2332      parameter&\Param{tjabaselineshift} parameter\\
2333 \bottomrule
2334 \end{tabular}
2335 \end{center}
2336 %</ja>
2337
2338 %<*en>
2339 Here the horizontal line in the below example is the baseline of a line.
2340 %</en>
2341 %<*ja>
2342 下の例において引かれている水平線がベースラインである.
2343 %</ja>
2344 \begin{LTXexample}
2345 \vrule width 150pt height 0.4pt depth 0pt \hskip-120pt
2346 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2347 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2348 \end{LTXexample}
2349
2350 %<*en>
2351 There is an interesting side-effect: characters in different size can be
2352 vertically aligned center in a line, by setting two parameters appropriately.
2353 The following is an example (beware the value is not well tuned):
2354 %</en>
2355 %<*ja>
2356 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2357 異なる文字を中心線に揃えることができる.
2358 以下は一つの例である(値はあまり調整されていないことに注意):
2359 %</ja>
2360 \begin{LTXexample}
2361 xyz漢字
2362 {\scriptsize
2363   \ltjsetparameter{yjabaselineshift=-1pt,
2364     yalbaselineshift=-1pt}
2365   XYZひらがな
2366 }abcかな
2367 \end{LTXexample}
2368
2369 %<*en>
2370 Note that setting positive \Param{yalbaselineshift}~or~\Param{talbaselineshift}
2371 parameters does not increase the depth of one-letter ``syllable'' $p$ of \textbf{Alchar}, if
2372 its left-protrusion~(\cs{lpcode}) and right-protrusion~(\cs{rpcode}) are both non-zero.
2373 This is because
2374 \begin{itemize}
2375 \item These two parameters are implemented by setting yoffset field of a
2376 glyph node, and this does not increase the depth of the glyph.
2377 \item To cope with the above situation, \LuaTeX-ja automatically supplies
2378 a rule in every ``syllable''.
2379 \item However, we cannot use this ``supplying a rule'' method if \dots
2380 \end{itemize}
2381
2382 This problem does not apply for \Param{yjabaselineshift}~nor~\Param{tjabaselineshift}.
2383 %</en>
2384 %<*ja>
2385 なお,以下の場合には1文字の\textbf{ALchar}からなる「音節」の深さは増加しないことに注意.
2386 \begin{itemize}
2387  \item \Param{yalbaselineshift},~\Param{talbaselineshift}パラメータが正になっている.
2388  \item 「音節」を構成する唯一の文字$p$の
2389 左余白への突出量(\cs{lpcode}),右余白への突出量(\cs{rpcode})がどちらも非零である.
2390 \end{itemize}
2391 \Param{yjabaselineshift},~\Param{tjabaselineshift}パラメータについてはこのような問題は起こらない.
2392 %</ja>
2393
2394 %<*ja>
2395 \paragraph{数式における挙動:\pTeX との違い}
2396 \textbf{ALchar}のベースラインを補正する \Param{yalbaselineshift} パラメータは
2397 ほぼ\pTeX における \cs{ybaselineshift} に対応しているものであるが,
2398 数式中の挙動は異なっているので注意が必要である.
2399 例えば,表\ref{tab:math_bsa}のように,数式中に明示的に現れた \cs{hbox} は,
2400 \begin{itemize}
2401  \item \pTeX では,ボックス全体が \cs{ybaselineshift} だとシフトされるので,
2402  表\ref{tab:math_bsa}中の``い''のように,ボックス中の和文文字は
2403  \ \cs{ybaselineshift} だけシフトされ,一方,``for all''のように,
2404  ボックス内の欧文文字は2重にシフトされることになる.
2405  \item 一方,\LuaTeX-jaではそのようなことはおこらず,
2406  数式中に明示的に現れた \cs{hbox} はシフトしない.そのため,
2407  表\ref{tab:math_bsa}中の``い''も``for all''も,それぞれ本文中に
2408  書かれたときと同じ上下位置に組まれる.
2409 \end{itemize}
2410 \begin{table}
2411 \small\centering
2412 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2413 \label{tab:math_bsa}
2414 \newdimen\origbaselineskip
2415 \origbaselineskip=\baselineskip
2416 \begin{tabular}{lp{30\zw}}
2417 \toprule
2418 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2419 \begin{lstlisting}
2420 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2421 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2422 \end{lstlisting}\\
2423 \noalign{\vskip-\origbaselineskip}
2424 \midrule
2425 \emph{\pTeX}&
2426 {\ltjsetparameter{yalbaselineshift=10pt}%
2427 数式abc: $あa\lower10pt\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2428 $\Phi\vdash F(x)\ \lower10pt\hbox{for all}\ x\in A$
2429 \par}\\
2430 \midrule
2431 \emph{\LuaTeX-ja}&
2432 {\ltjsetparameter{yalbaselineshift=10pt}%
2433 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2434 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2435 \par}\\
2436 \noalign{\vskip-\origbaselineskip}
2437 \bottomrule
2438 \end{tabular}
2439 \end{table}
2440 %</ja>
2441
2442
2443 \clearpage
2444 %<en>\part{Reference}
2445 %<ja>\part{リファレンス}
2446 \label{part-ref}
2447 \suppressfloats[t]
2448 %<*ja>
2449 \section{\LuaTeX-jaにおける \cs{catcode}}
2450 \label{sec-catcode}
2451 \subsection{予備知識:\pTeX と\upTeX における \cs{kcatcode}}
2452 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2453 は \cs{kcatcode} の値によって決定されるのであった.
2454 詳細は表\ref{table-kcat}を参照されたい.
2455 %</ja>
2456 %<*en>
2457 \section{\cs{catcode} in \LuaTeX-ja}
2458 \label{sec-catcode}
2459 \subsection{Preliminaries: \cs{kcatcode} in \pTeX\ and \upTeX}
2460 In \pTeX~and~\upTeX, the value of \cs{kcatcode} determines
2461 whether a Japanese character can be used in a control word.
2462 For the detail, see Table~\ref{table-kcat}.
2463 %</en>
2464
2465 \begin{table}[t]
2466 \small
2467 \caption{\cs{kcatcode} in \upTeX}
2468 \label{table-kcat}
2469 %<en>\medskip
2470
2471 \noindent\hfill
2472 \begin{tabular}{ccccc}
2473 \toprule
2474 \bfseries \cs{kcatcode}&
2475 %<*en>
2476 \bfseries meaning&
2477 \bfseries control word&
2478 \bfseries widow penalty\hbox{}$^*$&
2479 \bfseries linebreak\\
2480 %</en>
2481 %<*ja>
2482 \bfseries 意図&
2483 \bfseries 制御綴中に使用&
2484 \bfseries 文字ウィドウ処理\hbox{}$^*$&
2485 \bfseries 直後での改行\\
2486 %</ja>
2487 \midrule
2488 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2489 16&kanji&Y&Y&ignored\\
2490 17&kana&Y&Y&ignored\\
2491 18&other&N&N&ignored\\
2492 19&hangul&Y&Y&space\\
2493 \bottomrule
2494 \end{tabular}\hfill\null
2495
2496 \medskip
2497
2498 %<*ja>
2499 文字ウィドウ処理\hbox{}$^*$: 「漢字が一文字だけ次の行に行くのを防ぐ」\
2500 \cs{jcharwidowpenalty} が,
2501 その文字の直前に挿入されうるか否か,を示す.
2502 %</ja>
2503 \end{table}
2504
2505 %<*en>
2506 \cs{kcatcode} can be set by a row of JIS~X~0208 in \pTeX,
2507 and generally by a Unicode block\footnote{%
2508   \upTeX\ divides \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)
2509   into three subblocks, and \cs{kcatcode} can be set by a subblock.
2510 }
2511 in \upTeX. So characters which can be used in a control word
2512 slightly differ between \pTeX~and~\upTeX.
2513 %</en>
2514 %<*ja>
2515 \pTeX では \cs{kcatcode} はJIS~X~0208の区単位,
2516 \upTeX では概ねUnicodeブロック単位\footnote{%
2517   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2518   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2519   それぞれ別々に \cs{kcatcode} が指定できるようになっている.
2520 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2521 制御綴内で使用可能な文字が微妙に異なっている.
2522 %</ja>
2523
2524 %<*en>
2525 \subsection{Case of \LuaTeX-ja}
2526 The role of \cs{kcatcode} in \pTeX~and~\upTeX\ can be
2527 divided into the following four kinds,
2528 and \LuaTeX-ja can control these four kinds separately:
2529 \begin{itemize}
2530  \item
2531 \emph{Distinction between \textbf{JAchar} or \textbf{ALchar}}
2532 is controlled by using the character range, see Subsection~\ref{ssec-setrange}.
2533  \item
2534 \emph{Whether the character can be used in a control word}
2535 is controlled by setting \cs{catcode} to 11~(enabled) or 12~(disabled), as usual.
2536  \item
2537 \emph{Whether \Param{jcharwidowpenalty} can be inserted before the character}
2538 is controlled by the lowermost bit of the \Param{kcatcode} parameter.
2539  \item
2540 \emph{Ignoring linebreak after a \textbf{JAchar}} is always ignored.
2541 \end{itemize}
2542 %</en>
2543 %<*ja>
2544 \subsection{\LuaTeX-jaの場合}
2545 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \cs{kcatcode} の役割を
2546 分割している:
2547 \begin{description}
2548  \item[欧文/和文の区別 (\upTeX)]
2549 \cs{ltjdefcharrange} と\textsf{jacharrange}パラメータ(\ref{ssec-setrange}節)
2550  \item[制御綴中に使用可か]
2551 \LuaTeX 自身の \cs{catcode} でよい
2552  \item[\Param{jcharwidowpenalty}が挿入可か]
2553 \Param{kcatcode}パラメータの最下位ビット
2554  \item[直後の改行の無視]
2555 日本語しか想定していないので\textbf{JAchar}については一律有効
2556 \end{description}
2557 %</ja>
2558
2559 %<*en>
2560 Default setting of \cs{catcode} of \LuaTeX\ can be found
2561 in \texttt{luatex-unicode-letters.tex},
2562 which is based on \texttt{unicode-letters.tex} (for \XeTeX).
2563 However, the default setting of \cs{catcode} differs
2564 between \XeTeX\ and \LuaTeX, by the following reasons:
2565 \begin{itemize}
2566  \item \texttt{luatex-unicode-letters.tex} is based on old \texttt{unicode-letters.tex}.
2567  \item The latter half of \texttt{unicode-letters.tex} sets
2568 \cs{catcode} of Kanji and kana characters to 11,
2569 via setting \cs{XeTeXcharclass}.
2570
2571 However, this latter half is simply omitted in
2572 \texttt{luatex-unicode-letters.tex}, hence
2573 \cs{catcode} of Kanji and kana characters remains 12 in \LuaTeX.
2574 \end{itemize}
2575 In other words, Kanji nor kana characters cannot be used in
2576 a control word, in the default setting of \LuaTeX.
2577
2578 This would be inconvenient for \pTeX~users to shifting to \LuaTeX-ja,
2579 since several control words containing Kanji, such as \verb+\西暦+,
2580 are used in \pTeX.
2581 Hence, \LuaTeX-ja have a counterpart of \texttt{unicode-letters.tex}
2582 for \LuaTeX, \emph{to match the \cs{catcode} setting with that of \XeTeX.}
2583 %</en>
2584 %<*ja>
2585 ネイティブにUnicode全部の文字を扱える\XeTeX や\LuaTeX では,
2586 文字が制御綴内で使用できるかは通常の欧文文字と同じく \cs{catcode}
2587 で指定することとなる.\XeTeX における \cs{catcode} の初期設定は\
2588 \texttt{unicode-letters.tex} 中に記述されており,\LuaTeX ではそれを
2589 元にした \texttt{luatex-unicode-letters.tex} を用いている.
2590
2591 だが,\XeTeX における \cs{catcode} の初期設定と
2592 \LuaTeX におけるそれは一致していない:
2593 \begin{itemize}
2594  \item \texttt{luatex-unicode-letters.tex} の元になった\
2595 \texttt{unicode-letters.tex} が古い
2596  \item \texttt{unicode-letters.tex} の後半部では
2597 \cs{XeTeXcharclass} の設定を行なっており,
2598 それによって漢字や仮名の \cs{catcode} が11に設定されている.
2599
2600 しかし,\texttt{luatex-unicode-letters.tex} ではこの「後半部」が
2601 まるごと省略されており,漢字や仮名の \cs{catcode} は12のまま.
2602 \end{itemize}
2603 言い換えると,\LuaTeX の初期状態では漢字や仮名を制御綴内に
2604 使用することはできない.
2605
2606 これでは \pTeX で使用できた \verb+\西暦+ などが使えないこととなり,
2607 \LuaTeX-jaへの移行で手間が生じる.そのため,\LuaTeX-jaでは
2608 \texttt{unicode-letters.tex} の後半部にあたる内容を自前でパッチし,
2609 結果として\textbf{\XeTeX における初期設定と同じになるようにしている.}
2610 %</ja>
2611
2612 \begin{table}
2613  \centering\small
2614 %<en>\caption{Difference of the set of non-kanji JIS~X~0208 characters which can be used in a control word}
2615 %<ja>\caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2616 %<en>\medskip
2617 \label{table-kcat-diff}
2618 \def\D#1#2#3#4{%
2619   {\fboxsep0pt\fcolorbox{cyan}{white}%
2620   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2621 \leavevmode\hbox to 0pt{\hss\begin{tabular}{cccccc}
2622 \toprule
2623 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2624 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2625 \midrule
2626 \D 3000&1&1&N&N&Y\\
2627 \D 30FB&1&6&N&Y&N\\
2628 \D 309B&1&11&N&Y&N\\
2629 \D 309C&1&12&N&Y&N\\
2630 \D FF40&1&14&N&N&Y\\
2631 \D FF3E&1&16&N&N&Y\\
2632 \D FFE3&1&17&N&N&Y\\
2633 \D FF3F&1&18&N&N&Y\\
2634 \D 30FD&1&19&N&Y&Y\\
2635 \D 30FE&1&20&N&Y&Y\\
2636 \D 309D&1&21&N&Y&Y\\
2637 \D 309E&1&22&N&Y&Y\\
2638 \D 3003&1&23&N&N&Y\\
2639 \D 4EDD&1&24&N&Y&Y\\
2640 \D 3005&1&25&N&N&Y\\
2641 \D 3006&1&26&N&N&Y\\
2642 \D 3007&1&27&N&N&Y\\
2643 \D 30FC&1&28&N&Y&Y\\
2644 \bottomrule
2645 \end{tabular}\qquad
2646 \begin{tabular}{cccccc}
2647 \toprule
2648 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2649 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2650 \midrule
2651 \D FF0F&1&31&N&N&Y\\
2652 \D FF3C&1&32&N&N&Y\\
2653 \D FF5C&1&35&N&N&Y\\
2654 \D FF0B&1&60&N&N&Y\\
2655 \D FF1D&1&65&N&N&Y\\
2656 \D FF1C&1&67&N&N&Y\\
2657 \D FF1E&1&68&N&N&Y\\
2658 \D FF03&1&84&N&N&Y\\
2659 \D FF06&1&85&N&N&Y\\
2660 \D FF0A&1&86&N&N&Y\\
2661 \D FF20&1&87&N&N&Y\\
2662 \D 3012&2&9&N&N&Y\\
2663 \D 3013&2&14&N&N&Y\\
2664 \D FFE2&2&44&N&N&Y\\
2665 \D 212B&2&82&N&N&Y\\
2666 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Greek letters (row 6)}&Y&N&Y\\
2667 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Cyrillic letters (row 7)}&N&N&Y\\
2668 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&Y&N&Y\\
2669 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&N&N&Y\\
2670 $\vphantom{\D 3000}$\\
2671 \bottomrule
2672 \end{tabular}\hss}\par
2673 \end{table}
2674
2675 %<*en>
2676 \subsection{Non-kanji Characters in a Control Word}
2677 Because the engine differ, so non-kanji JIS~X~0208 characters
2678 which can be used in a control word differ in \pTeX, in \upTeX,~and~in \LuaTeX-ja.
2679 Table~\ref{table-kcat-diff} shows the difference.
2680 Except for four characters ``・'',~``゛'', ``゜'',~``゠'',
2681 \LuaTeX-ja admits more characters in a control word than \upTeX.
2682 \emph{Note that the ideographic space~\texttt{U+3000} can be used
2683 in a control word in \LuaTeX-ja.}
2684
2685 Difference becomes larger, if we consider
2686 non-kanji JIS~X~0213 characters.
2687 For the detail, see \url{https://github.com/h-kitagawa/kct}.
2688 %</en>
2689 %<*ja>
2690 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2691
2692 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2693 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2694 異なっているところだけを載せると,表\ref{table-kcat-diff}のようになる.
2695 「・」「゛」「゜」「゠」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2696 制御綴に使用可能になっている.
2697 \textbf{特に重要なのは,全角空白(\texttt{U+3000})が
2698 \LuaTeX-jaでは制御綴中に使用可能であることである.}
2699
2700 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2701 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\
2702 \texttt{kct-uni-out.pdf} などを参照すること.
2703 %</ja>
2704
2705
2706 %<*en>
2707 \section{Directions}
2708 \LuaTeX\ supports four $\Omega$-style directions: \texttt{TLT},~\texttt{TRT}, \texttt{RTT}
2709 and \texttt{LTL}.
2710 However, neither directions are not well-suited for typesetting Japanese vertically, hence we
2711 implemented vertical writing by rotating \texttt{TLT}-box by 90~degrees.
2712 %</en>
2713 %<*ja>
2714 \section{縦組}
2715 \label{sec-direction}
2716 \LuaTeX 本体でも,$\Omega$・$\aleph$由来の機能として,複数の組方向をサポートしている.
2717 しかし,\LuaTeX がサポートするのは \texttt{TLT},~\texttt{TRT}, \texttt{RTT},~\texttt{LTL}\
2718 のみであり,日本語の縦組に使うのは望ましくない\footnote{%
2719 和文文字だけならば \texttt{RTT} を使えばなんとかなると思うが,
2720 欧文文字が入ってきた場合はうまくいかず,\texttt{RTR} という組方向が必要になる.
2721 }.そのため,\LuaTeX-jaでは横組(\texttt{TLT})で組んだボックスを回転させる方式で
2722 縦組を実装した.
2723 %</ja>
2724
2725 %<ja>\subsection{サポートする組方向}
2726 \begin{table}[t]
2727 %<ja>\caption{\LuaTeX-ja のサポートする組方向}
2728 %<en>\caption{Directions supported by \LuaTeX-ja}
2729 %<en>\medskip
2730 \label{tab-dir}
2731 \centering\small
2732 \def\obox#1{%
2733   \setbox0=\hbox{\yoko\hbox{#1%
2734   \large\ltjsetparameter{talbaselineshift=0pt}%
2735   \vrule height 25pt width 0.4pt depth 15pt\kern-.2pt%
2736   \raise25pt\hbox to 0pt{\hss\composite{*r^@{>>}}\hss}%
2737   \raise-15pt\hbox to 0pt{\hss\composite{*l^@{>|}}\hss}\kern.2pt%
2738   \vrule height.2pt depth.2pt width 60pt\hbox to 0pt{\hss\composite{*d^@{>}}\hss}\kern-60pt
2739   \hbox to 60pt{\,銀は、Ag\hss}}}%
2740   \raise\dimexpr 0.5\ltjgetdp0-0.5\ltjgetht0\box0%
2741 }
2742 %<*ja>
2743 \begin{tabular}{>{\bfseries}lcccc}
2744 \toprule
2745 &横組&縦組 &\cs{dtou}「dtou方向」&「utod方向」\\
2746 \midrule
2747 命令&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2748 字送り方向&水平右向き(→)&垂直下向き(↓)&垂直上向き(↑)&垂直下向き(↓)\\
2749 行送り方向&垂直下向き(↓)&水平左向き(←)&水平右向き(→)&水平左向き(←)\\
2750 使用する和文フォント&横組用(\cs{jfont})&縦組用(\cs{tfont})&
2751 \multicolumn{2}{c}{%
2752   横組用(\cs{jfont})の$90^\circ$回転}\\[\smallskipamount]
2753 組版例\null $^*$ &\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2754 \noalign{\medskip}
2755 \bottomrule
2756 \end{tabular}
2757
2758 \medskip\raggedright
2759 \def\R#1{%
2760   \raise0.38\zw\hbox{%
2761     \vrule height.2pt  depth.2pt width2\zw%
2762     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2763   }%
2764 }
2765 $^*$\ 幅(width),高さ(height),深さ(depth)の増加方向を,
2766 それぞれ「\R{>}」,「\R{>>}」,「\R{>|}」で表している.
2767 \raggedright
2768 %</ja>
2769
2770 %<*en>
2771 \begin{tabular}{>{\bfseries}lcccc}
2772 \toprule
2773 &horizontal (\emph{yoko}~direction)&vertical (\emph{tate}~direction)&%
2774   \emph{dtou} direction&\emph{utod} direction\\
2775 \midrule
2776 Commands&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2777 Beginning of the page&Top&Right&Left&Right\\
2778 Beginning of the line&Left&Top&Bottom&Top\\
2779 Used Japanese font&horizontal (\cs{jfont})&vertical (\cs{tfont})&
2780 \multicolumn{2}{c}{%
2781   horizontal ($90^\circ$ rotated)}\\[\smallskipamount]
2782 Example&\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2783 \noalign{\medskip}
2784 (Notation used in $\Omega$)&TLT&RTR, RTT&LBL&RTR\\
2785 \bottomrule
2786 \end{tabular}
2787
2788 \medskip\raggedright
2789 \def\R#1{%
2790   \raise0.38\zw\hbox{%
2791     \vrule height.2pt  depth.2pt width2\zw%
2792     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2793   }%
2794 }
2795 \raggedright
2796 %</en>
2797 \end{table}
2798
2799 %<*en>
2800 \LuaTeX-ja supports four directions, as shown in Table~\ref{tab-dir}.
2801 The second column (\emph{yoko} direction) is just horizontal writing,
2802 and the third column (\emph{tate} direction) is vertical writing.
2803 The fourth column (\emph{dtou} direction) is actually a hidden feature of \pTeX.
2804 We implemented this for debugging purpose.
2805 The fifth column (\emph{utod} direction) corresponds the ``\texttt{tate (math) direction}'' of \pTeX.
2806
2807 Directions can be changed by \cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod},
2808 only when the current list is null. Also, the direction of a math formula is changed to
2809 \emph{utod}, when the direction outside the math formula is \emph{tate} (vertical writing).
2810 %</en>
2811
2812 %<*ja>
2813 \LuaTeX-jaがサポートする組方向は表\ref{tab-dir}に示す4つである.
2814 4列目の \cs{dtou} は聞き慣れない命令だと思うが,
2815 実は\pTeX に同名の命令が(ドキュメントには書かれていないが)存在する.
2816 Down-TO-Upの意味なのだろう.\cs{dtou} を使用する機会はないだろうが,
2817 \LuaTeX-jaではデバッグ用に実装している.
2818 5列目の \cs{utod} は,\pTeX で言う「縦数式ディレクション」に相当するものである.
2819
2820 組方向は,\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod} をそれぞれ使用することで,
2821 現在作成中のリストやボックスが空の時にのみ変更可能である.
2822 また,縦組中の数式内のボックスは\pTeX と同じように組方向が \cs{utod} となる.
2823 %</ja>
2824
2825 %<*en>
2826 \subsection{Boxes in different direction}
2827
2828 As in \pTeX, one can use boxes of different direction in one document.
2829 The below is an example.
2830 \begin{LTXexample}
2831 ここは横組%     yoko
2832 \hbox{\tate %   tate
2833   \hbox{縦組}%  tate
2834   の中に
2835   \hbox{\yoko 横組の内容}% yoko
2836   を挿入する
2837 }
2838 また横組に戻る% yoko
2839 \end{LTXexample}
2840
2841 Table~\ref{tab-diffdir} shows how a box is arranged when
2842 the direction  inside the box and that outside the box differ.
2843 %</en>
2844 %<*ja>
2845 \subsection{異方向のボックス}
2846
2847 縦組の中に「42」などの2桁以上の算用数字を横組で組むなど,
2848 異なる組方向を混在させることがしばしば行われる.
2849 組方向の混在も\pTeX と同じようにできる:
2850 \begin{LTXexample}
2851 ここは横組%     yoko
2852 \hbox{\tate %   tate
2853   \hbox{縦組}%  tate
2854   の中に
2855   \hbox{\yoko 横組の内容}% yoko
2856   を挿入する
2857 }
2858 また横組に戻る% yoko
2859 \end{LTXexample}
2860
2861 異なる組方向のボックスを配置した場合にどう組まれるかの仕様も,\pTeX を
2862 踏襲している.表\ref{tab-diffdir}に示す.
2863 %</ja>
2864
2865 \begin{table}[t]
2866 %<ja>\caption{異方向のボックスの配置}
2867 %<en>\caption{Boxes in different direction}
2868 %<en>\medskip
2869 \label{tab-diffdir}
2870  \centering\small\unitlength3mm
2871  \def\TATEeg{%
2872    \hbox{\smash{\begin{picture}(0,0)(-2,0)
2873      \thicklines
2874      \polyline(-2,0)(-2,-7)(5,-7)(5,0)
2875      \put(0,0){\circle*{0.3}}
2876      \put(2.5,-4){\makebox(0,0){\hbox{\tate\bfseries \emph{tate}/\emph{utod}}}}
2877      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
2878      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
2879      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
2880    \end{picture}}}
2881  }
2882  \def\DTOUeg{%
2883    \hbox{\smash{\begin{picture}(0,0)(-5,0)
2884      \thicklines
2885      \polyline(-5,0)(-5,7)(2,7)(2,0)
2886      \put(0,0){\circle*{0.3}}
2887      \put(-2.5,4){\makebox(0,0){\hbox{\dtou\bfseries \emph{dtou}}}}
2888      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
2889      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
2890      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
2891    \end{picture}}}
2892  }
2893  \def\YOKOeg{%
2894    \hbox{\smash{\begin{picture}(0,0)
2895      \thicklines
2896      \polyline(0,5)(7,5)(7,-2)(0,-2)
2897      \put(4,2.5){\makebox(0,0){\hbox{\yoko\bfseries \emph{yoko}}}}
2898      \put(0,0){\circle*{0.3}}
2899      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
2900      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
2901      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
2902    \end{picture}}}
2903  }
2904 \begin{tabular}{ccc}
2905 \toprule
2906 %<ja>\emph{横組中に配置}&\emph{縦組中に配置}&%
2907 %<ja>\emph{組方向 \cs{dtou} 中に配置}\\
2908 %<en>\textbf{typeset in \emph{yoko} direction}
2909 %<en>&\textbf{typeset in \emph{tate} or \emph{utod} direction}
2910 %<en>&\textbf{typeset in \emph{dtou} direction}\\
2911 \midrule
2912  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2913    \put(0,0){\line(1,0){3.8}}
2914    \put(4,7){\TATEeg}
2915    \put(11.2,0){\line(1,0){3.8}}
2916 %
2917    \put(2,7){\line(1,0){1.8}}
2918    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
2919    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
2920    \put(3,-2){\vector(0,1){2}}
2921    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
2922 %
2923    \put(4,7.2){\line(0,1){1.8}}
2924    \put(11,7.2){\line(0,1){1.8}}
2925    \put(6,8){\vector(-1,0){2}}
2926    \put(9,8){\vector(1,0){2}}
2927    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
2928 %
2929  \end{picture}\vspace{-\baselineskip}
2930    \begin{align*}
2931    W_{\mathrm{Y}} &= h_{\mathrm{T}}+d_{\mathrm{T}},\\
2932    H_{\mathrm{Y}} &= w_{\mathrm{T}},\\
2933    D_{\mathrm{Y}} &=0\,\mathrm{pt}
2934    \end{align*}%
2935  }&
2936  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2937    \put(7.5,-0.2){\line(0,-1){2.8}}
2938    \put(4,2){\YOKOeg}
2939    \put(7.5, 7.2){\line(0,1){3.8}}
2940 %
2941    \put(2,7){\line(1,0){1.8}}
2942    \put(2,0){\line(1,0){1.8}}
2943    \put(3,5){\vector(0,1){2}}
2944    \put(3,2){\vector(0,-1){2}}
2945    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
2946 %
2947    \put(4,7.2){\line(0,1){1.8}}
2948    \put(11,7.2){\line(0,1){1.8}}
2949    \put(8,8){\vector(-1,0){0.5}\vector(1,0){3}}
2950    \put(7,8){\vector(-1,0){3}\vector(1,0){0.5}}
2951    \put(9.25,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
2952    \put(5.75,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
2953 %
2954  \end{picture}\vspace{-\baselineskip}
2955    \begin{align*}
2956    W_{\mathrm{T}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
2957    H_{\mathrm{T}} &= w_{\mathrm{Y}}/2,\\
2958    D_{\mathrm{T}} &= w_{\mathrm{Y}}/2
2959    \end{align*}%
2960  }&
2961  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2962    \put(11,-0.2){\line(0,-1){2.8}}
2963    \put(4,2){\YOKOeg}
2964    \put(11, 7.2){\line(0,1){3.8}}
2965 %
2966    \put(2,7){\line(1,0){1.8}}
2967    \put(2,0){\line(1,0){1.8}}
2968    \put(3,5){\vector(0,1){2}}
2969    \put(3,2){\vector(0,-1){2}}
2970    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
2971 %
2972    \put(4,7.2){\line(0,1){1.8}}
2973    \put(11,7.2){\line(0,1){1.8}}
2974    \put(7.5,8){\vector(-1,0){3.5}\vector(1,0){3.5}}
2975    \put(13,8){\vector(-1,0){2}}
2976    \put(7.5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
2977    \put(12,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
2978 %
2979  \end{picture}\vspace{-\baselineskip}
2980    \begin{align*}
2981    W_{\mathrm{D}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
2982    H_{\mathrm{D}} &= w_{\mathrm{Y}},\\
2983    D_{\mathrm{D}} &= 0\,\mathrm{pt}
2984    \end{align*}%
2985  }%
2986 \\\midrule
2987  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2988    \put(0,0){\line(1,0){3.8}}
2989    \put(4,0){\DTOUeg}
2990    \put(11.2,0){\line(1,0){3.8}}
2991 %
2992    \put(2,7){\line(1,0){1.8}}
2993    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
2994    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
2995    \put(3,-2){\vector(0,1){2}}
2996    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
2997 %
2998    \put(4,7.2){\line(0,1){1.8}}
2999    \put(11,7.2){\line(0,1){1.8}}
3000    \put(6,8){\vector(-1,0){2}}
3001    \put(9,8){\vector(1,0){2}}
3002    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3003 %
3004  \end{picture}\vspace{-\baselineskip}
3005    \begin{align*}
3006    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3007    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
3008    D_{\mathrm{Y}} &= 0\,pt
3009    \end{align*}%
3010  }&
3011  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3012    \put(9,-0.2){\line(0,-1){2.8}}
3013    \put(4,0){\DTOUeg}
3014    \put(9, 7.2){\line(0,1){3.8}}
3015 %
3016    \put(2,7){\line(1,0){1.8}}
3017    \put(2,0){\line(1,0){1.8}}
3018    \put(3,5){\vector(0,1){2}}
3019    \put(3,2){\vector(0,-1){2}}
3020    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3021 %
3022    \put(4,7.2){\line(0,1){1.8}}
3023    \put(11,7.2){\line(0,1){1.8}}
3024    \put(6.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3025    \put(10,8){\vector(-1,0){1}\vector(1,0){1}}
3026    \put(10,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3027    \put(6.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3028 %
3029  \end{picture}\vspace{-\baselineskip}
3030    \begin{align*}
3031    W_{\mathrm{T}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3032    H_{\mathrm{T}} &= d_{\mathrm{D}},\\
3033    D_{\mathrm{T}} &= h_{\mathrm{D}}
3034    \end{align*}%
3035  }&
3036  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3037    \put(6,-0.2){\line(0,-1){2.8}}
3038    \put(4,7){\TATEeg}
3039    \put(6, 7.2){\line(0,1){3.8}}
3040 %
3041    \put(2,7){\line(1,0){1.8}}
3042    \put(2,0){\line(1,0){1.8}}
3043    \put(3,5){\vector(0,1){2}}
3044    \put(3,2){\vector(0,-1){2}}
3045    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3046 %
3047    \put(4,7.2){\line(0,1){1.8}}
3048    \put(11,7.2){\line(0,1){1.8}}
3049    \put(5,8){\vector(-1,0){1}\vector(1,0){1}}
3050    \put(8.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3051    \put(5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3052    \put(8.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3053 %
3054  \end{picture}\vspace{-\baselineskip}
3055    \begin{align*}
3056    W_{\mathrm{D}} &= w_{\mathrm{T}},\\
3057    H_{\mathrm{D}} &= d_{\mathrm{T}},\\
3058    D_{\mathrm{D}} &= h_{\mathrm{T}}
3059    \end{align*}%
3060  }\\
3061 \bottomrule
3062 \end{tabular}
3063 \end{table}
3064
3065
3066
3067 %<*en>
3068 \paragraph{\cs{wd} and direction}
3069 In \pTeX, \cs{wd},~\cs{ht},~\cs{dp} means the dimensions of a box register
3070 \emph{with respact to the current direction}.
3071 This means that the value of \cs{wd0} etc.\ might differ when the current direction is
3072 different, even if \cs{box0} stores the same box.
3073 However, this no longer applies in \LuaTeX-ja.
3074
3075 \begin{LTXexample}
3076 % yoko direction
3077 \setbox0=\hbox to 20pt{foo}
3078 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3079 \wd0=100pt
3080 \the\wd0,~\hbox{\tate \the\wd0}
3081 \end{LTXexample}
3082
3083 To access box dimensions \emph{with respect to current direction},
3084 one have to use the following commands instead of \cs{wd} wtc.
3085 \begin{cslist}
3086
3087  \item[\cs{ltjgetwd}\{<num>\}\textrm{, }\cs{ltjgetht}\{<num>\}\textrm{, }%
3088   \cs{ltjgetdp}\{<num>\}]
3089 These commands return \emph{an internal dimension} of \cs{box<num>} with respect to
3090 the current direction. One can use these in \cs{dimexpr} primitive, as the followings.
3091 \begin{lstlisting}
3092 \dimexpr 2\ltjgetwd{42}-3pt\relax, \the\ltjgetwd{1701}
3093 \end{lstlisting}
3094 By its implementaion,  the argument must be grouped as \verb+\ltjgetwd{42}+,
3095 if the argument consists of more than one token.
3096 \begin{LTXexample}[width=0.3\textwidth]
3097 \parindent0pt
3098 \setbox32767=\hbox{\yoko よこぐみ}
3099 \fboxsep=0mm\fbox{\copy32767}
3100 \vbox{\hsize=20mm
3101 \yoko YOKO \the\ltjgetwd{32767}, \\
3102   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3103 \vbox{\hsize=20mm\raggedleft
3104 \tate TATE \the\ltjgetwd{32767}, \\
3105   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3106 \vbox{\hsize=20mm\raggedleft
3107 \dtou DTOU \the\ltjgetwd{32767}, \\
3108   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3109 \end{LTXexample}
3110
3111  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3112   \cs{ltjsetdp}<num>=<dimen>]
3113 These commands set the dimension of \cs{box<num>}. Unlike \cs{ltjgetwd}, one does not need
3114         to group the argument <num>; four calls of \cs{ltjsetwd} below have the same meaning.
3115 \begin{lstlisting}
3116 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3117 \end{lstlisting}
3118
3119 \end{cslist}
3120 %</en>
3121 %<*ja>
3122 \paragraph{\cs{wd} 達と組方向}
3123 ボックスレジスタ \cs{box}<num> にセットされているボックスの幅・高さ・深さの取得や
3124 変更にはそれぞれ \cs{wd},~\cs{ht},~\cs{dp} プリミティブを用いるのであった.
3125 \pTeX ではこれらのプリミティブは,「現在の組方向におけるボックスの寸法」を指すもので,
3126 同じボックスに対しても現在の組方向によって返る値は異なるもであった.
3127
3128 \LuaTeX-jaにおいては状況が異なり,\cs{wd},~\cs{ht},~\cs{dp} が返す値は
3129 現在の組方向には依存しない.下の例のように,横組のボックスが格納されていれば
3130 \cs{wd}等は常に「横組におけるボックスの寸法」を意味する.
3131
3132 \begin{LTXexample}
3133 % yoko direction
3134 \setbox0=\hbox to 20pt{foo}
3135 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3136 \wd0=100pt
3137 \the\wd0,~\hbox{\tate \the\wd0}
3138 \end{LTXexample}
3139
3140 \pTeX のように現在の組方向に応じたボックスの寸法の取得・設定を行うには,
3141 代わりに次の命令を使用する.
3142
3143 \begin{cslist}
3144
3145  \item[\cs{ltjgetwd}\{<num>\}\textrm{, }\cs{ltjgetht}\{<num>\}\textrm{, }%
3146   \cs{ltjgetdp}\{<num>\}]
3147 現在の組方向に応じたボックスの寸法の取得を行う.結果は内部長さであるため,
3148 \begin{lstlisting}
3149 \dimexpr 2\ltjgetwd{42}-3pt\relax, \the\ltjgetwd{1701}
3150 \end{lstlisting}
3151 のように \cs{wd}<num> の代わりとして扱うことができる.引数が1桁の場合は,
3152 \cs{ltjgetwd3} のように引数をグループで括らなくても良いが,そうでない場合は
3153 (通常の命令への引数のように)\verb+\ltjgetwd{42}+ とグループに括る必要がある%
3154 \footnote{\cs{afterassignment} を利用して実装すればグループに括る必要がなくなるのでは,と思
3155               うかもしれないが,それでは本文中に書いた例のように \cs{dimexpr} 中で使用でき
3156               なくなってしまう.}.
3157 使用例は以下の通りである.
3158 \begin{LTXexample}[width=0.3\textwidth]
3159 \parindent0pt
3160 \setbox32767=\hbox{\yoko よこぐみ}
3161 \fboxsep=0mm\fbox{\copy32767}
3162 \vbox{\hsize=20mm
3163 \yoko YOKO \the\ltjgetwd{32767}, \\
3164   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3165 \vbox{\hsize=20mm\raggedleft
3166 \tate TATE \the\ltjgetwd{32767}, \\
3167   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3168 \vbox{\hsize=20mm\raggedleft
3169 \dtou DTOU \the\ltjgetwd{32767}, \\
3170   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3171 \end{LTXexample}
3172
3173  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3174   \cs{ltjsetdp}<num>=<dimen>]
3175 現在の組方向に応じたボックスの寸法の設定を行う.\cs{afterassignment} を2回利用して
3176 実装しているので,次の4通りは全て同じ意味である.
3177 \begin{lstlisting}
3178 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3179 \end{lstlisting}
3180
3181 設定値は「横組」「縦組及び \cs{utod} 方向」「\cs{dtou} 方向」
3182 の3種ごとに独立して記録される.参考として,Gitリポジトリ内の
3183               \verb+test/test55-boxdim_diffdir.{tex,pdf}+ を挙げておく.
3184
3185 \end{cslist}
3186 %</ja>
3187
3188 %<*en>
3189 \subsection{Getting current direction}
3190 The \Param{direction} parameter returns the current direction, and
3191 the \Param{boxdir} parameter (with the argumant <num>)
3192 returns the direction of a box register \cs{box}<num>.
3193 The returned value of these parameters are a \emph{string}:
3194 \begin{center}
3195 \small
3196 \begin{tabular}{>{\bfseries}lccccc}
3197 \toprule
3198 Direction&\emph{yoko}&\emph{tate}&\emph{dtou}&\emph{utod}&(empty)\\
3199 \midrule
3200 Returned value&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3201 \bottomrule
3202 \end{tabular}
3203 \end{center}
3204 \begin{LTXexample}[width=0.3\textwidth]
3205 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3206 \hbox{\yoko \DIR}, \hbox{\tate\DIR},
3207 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3208 \hbox{\tate$\hbox{tate math: \DIR}$}
3209
3210 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3211 \end{LTXexample}
3212 %</en>
3213 %<*ja>
3214 \subsection{組方向の取得}
3215 「現在の組方向」や「<num>番のボックスの組方向」は,
3216 \pTeX では \cs{ifydir} や \cs{ifybox}<num> といった条件判断文を使って
3217 判断することができた.
3218 しかし,\LuaTeX-jaはあくまでも\TeX マクロとLuaコードで
3219 記述されており,それでは新たな条件判断命令を作るのは難しい.
3220
3221 \LuaTeX-jaでは,\Param{direction}パラメータで現在の組方向を,
3222 \Param{boxdir}パラメータ(と追加の引数<num>)によって
3223 \cs{box}<num>の組方向をそれぞれ取得できるようにした.
3224 戻り値は文字列である:
3225 \begin{center}
3226 \small
3227 \begin{tabular}{>{\bfseries}lccccc}
3228 \toprule
3229 組方向&\emph{横組}&\emph{tate縦組}&\emph{dtou方向}&\emph{utod方向}&(未割り当て)\\
3230 \midrule
3231 戻り値&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3232 \bottomrule
3233 \end{tabular}
3234 \end{center}
3235
3236 \begin{LTXexample}[width=0.3\textwidth]
3237 \leavevmode\def\DIR{\ltjgetparameter{ direction}}
3238 \hbox{\yoko\DIR}, \hbox{\tate\DIR},
3239 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3240 \hbox{\tate$\hbox{tate math: \DIR}$}
3241
3242 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3243 \end{LTXexample}
3244
3245 これらを用いれば,例えば
3246 \pTeX の \cs{ifydir},~\cs{ifybox200} と同等の条件判断を
3247 \begin{lstlisting}
3248 \ifnum\ltjgetparameter{direction}=4
3249 \ifnum\ltjgetparameter{boxdir}{200}=4
3250 \end{lstlisting}
3251 のように行うことができる.
3252 \cs{iftdir} は少々面倒であるが
3253 \begin{lstlisting}
3254 \ifnum\numexpr
3255   \ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8=3
3256 \end{lstlisting}
3257 とすればよい.
3258 %</ja>
3259
3260 %<*en>
3261 \subsection{Overridden box primitives}
3262 To cope with multiple directions, the following primitives are
3263 overridden by \LuaTeX-ja, using~\verb+\protected\def+.
3264 \begin{cslist}[style=standard]
3265  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3266  \item[\cs{vadjust}\{<material>\}]
3267  \item[\cs{insert}<number>\{<material>\}]
3268  \item[\cs{lastbox}]
3269  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3270  \item[\cs{vcenter}]
3271 \end{cslist}
3272 %</en>
3273 %<*ja>
3274 \subsection{プリミティブの再定義}
3275 異なる組方向に対応するために,以下に挙げるプリミティブは
3276 \LuaTeX-jaによる前処理もしくは後処理が行われるように
3277 \ \verb+\protected\def+ により再定義してある.
3278
3279 \begin{cslist}
3280  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3281  ボックスの組方向が現在のリストと異なる場合は事前にエラーメッセージを出力する.
3282  \pTeX と異なり,エラーを無視して無理矢理 \cs{unhbox}, \cs{unvbox} を
3283  続行させることもできるが,その場合の組版結果は保証しない.
3284  \item[\cs{vadjust}\{<material>\}] 一旦プリミティブ本来の挙動を行う.その後,<material>の組方向が
3285  周囲の垂直リストの組方向と一致しない場合にエラーを出力し,
3286  該当の \cs{vadjust} を無効にする.
3287  \item[\cs{insert}<number>\{<material>\}]
3288  一旦プリミティブ本来の挙動を行い,その後<material>内の各ボックス・罫線の直前に組方向を示
3289               すdirection whatsitを挿入する.
3290  \item[\cs{lastbox}] ボックスの「中身」を現在の組方向に合わせるためのノード
3291               (\textit{dir\_box}という)を必要ならば除去し,
3292  正しく「中身」のボックスが返されるように前処理をする.
3293  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3294  一方,こちらでは必要に応じて\textit{dir\_box}を作成する前処理を追加している.
3295 \end{cslist}
3296 %</ja>
3297
3298 %<en>\section{Font Metric and Japanese Font}
3299 %<ja>\section{フォントメトリックと和文フォント}
3300 %<en>\subsection{\cs{jfont}}
3301 %<ja>\subsection{\cs{jfont} 命令}
3302 \label{ssec-jfont}
3303
3304 %<*en>
3305 To load a font as a Japanese font (for horizontal direction), you must use the
3306 \cs{jfont} instead of~\cs{font}, while
3307 \cs{jfont} admits the same syntax used in~\cs{font}.
3308 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
3309 so TrueType/OpenType fonts with features can be used for Japanese fonts:
3310 %</en>
3311 %<*ja>
3312 フォントを(横組用)和文フォントとして読み込むためには,\cs{jfont} を
3313 \ \cs{font} プリミティブの代わりに用いる.
3314 \cs{jfont} の文法は \cs{font} と同じである.
3315 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
3316 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
3317 ことができる:
3318 %</ja>
3319 \begin{LTXexample}[width=0.3\textwidth]
3320 \jfont\tradgt={file:KozMinPr6N-Regular.otf:script=latn;%
3321   +trad;-kern;jfm=ujis} at 14pt
3322 \tradgt 当/体/医/区
3323 \end{LTXexample}
3324
3325 %<*en>
3326 Note that the defined control sequence
3327 (\cs{tradgt} in the example above) using \cs{jfont} is not a
3328 \textit{font\_def} token,  but a macro.
3329 Hence the input like \verb+\fontname\tradgt+
3330 causes a error.  We denote control sequences which are defined in
3331 \cs{jfont} by <jfont\_cs>.
3332 %</en>
3333 %<*ja>
3334 なお,\cs{jfont} で定義された制御綴(上の例だと \cs{tradgt})
3335 は\textit{font\_def}トークンではなくマクロである.従って,\verb+\fontname\tradgt+ のような
3336 入力はエラーとなる.以下では \cs{jfont} で定義された
3337 制御綴を<jfont\_cs>で表す.
3338 %</ja>
3339
3340 \paragraph{JFM}
3341 %<*en>
3342 a JFM has measurements of characters and
3343 glues/kerns that are automatically inserted for Japanese
3344 typesetting. The structure of JFM will be described in the next
3345 subsection. At the calling of \cs{jfont}, you must specify
3346 which JFM will be used for this font by the following keys:
3347 %</en>
3348 %<*ja>
3349 JFMは文字と和文組版で自動的に挿入される
3350 グルー/カーンの寸法情報を持っている.JFMの構造は次の節で述べる.
3351 \cs{jfont} 命令の呼び出しの際には,どのJFMを用いるのかを以下のキーで
3352 指定する必要がある:
3353 %</ja>
3354
3355
3356 \begin{table}[t]
3357 %<en>\caption{Differences between horizontal JFMs shipped with \LuaTeX-ja}
3358 %<ja>\caption{\LuaTeX-ja に同梱されている横組用JFMの違い}
3359 %<en>\medskip
3360 \label{tab-difjfm}
3361 \ltjsetparameter{jacharrange={+3}}
3362 \centering\small
3363 \def\r#1#2{%
3364   \hbox{\Large\vrule
3365   \parbox[b]{7\zw}{%
3366     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3367     ◆◆◆◆◆◆◆
3368     ある日モモちゃんがお使いで迷子になって泣きました.
3369   }\vrule}}
3370 \def\s#1#2{%
3371   \Large
3372   \parbox[b]{7\zw}{%
3373     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3374     ちょっと!何
3375   }}
3376 \def\t#1#2#3{\hbox to 0pt{\hss%
3377   \setbox0=\hbox{\addjfontfeatures{YokoFeatures={JFM=#1}}\huge #3}%
3378   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3379   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3380   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3381   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3382   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3383 {\Large\tabcolsep0pt
3384 \begin{tabular}{m{8\zw}m{8\zw}m{8\zw}}
3385 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{jis}{black}&
3386 \leavevmode\hbox to 0pt{\r{jis}{black}\hss}\r{min}{red}&
3387 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{min}{red}\\
3388 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{jis}{black}&
3389 \leavevmode\hbox to 0pt{\s{jis}{black}\hss}\s{min}{red}&
3390 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{min}{red}\\
3391 \leavevmode\qquad\t{ujis}{blue}{漢}\t{jis}{black}{漢}\qquad
3392            \t{ujis}{blue}{っ}\t{jis}{black}{っ}&
3393 \leavevmode\qquad\t{jis}{black}{漢}\t{min}{red}{漢}\qquad
3394            \t{jis}{black}{っ}\t{min}{red}{っ}&
3395 \leavevmode\qquad\t{ujis}{blue}{漢}\t{min}{red}{漢}\qquad
3396            \t{ujis}{blue}{っ}\t{min}{red}{っ}\\
3397 \end{tabular}\par}
3398
3399 (\textcolor{blue}{Blue: \texttt{jfm-ujis.lua}},
3400 \textcolor{black}{Black: \texttt{jfm-jis.lua}},
3401 \textcolor{red}{Red: \texttt{jfm-min.lua}})
3402 \ltjsetparameter{jacharrange={-3}}
3403 \end{table}
3404
3405 \begin{cslist}
3406 \item[jfm=<name>]
3407 %<*en>
3408 Specify the name of (horizontal) JFM.
3409 If specified JFM has not been loaded, \LuaTeX-ja search and load
3410 a file named \texttt{jfm-<name>.lua}.
3411
3412 The following JFMs are shipped with \LuaTeX-ja:
3413 %</en>
3414 %<*ja>
3415 用いる(横組用)JFMの名前を指定する.もし以前に指定されたJFMが読み込まれていなければ,
3416 \texttt{jfm-<name>.lua}を読み込む.以下の横組用JFMが\LuaTeX-jaには同梱されている:
3417 %</ja>
3418 \begin{description}
3419 %<*en>
3420 \item[\tt jfm-ujis.lua] A standard JFM in \LuaTeX-ja. This JFM is
3421   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
3422   is used in \upTeX. When you use the \Pkg{luatexja-otf} package, you should use this JFM.
3423 %</en>
3424 %<*ja>
3425 \item[\tt jfm-ujis.lua] \LuaTeX-jaの標準JFMである.このJFMは\upTeX で
3426   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
3427   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
3428 %</ja>
3429 %<*en>
3430 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, ``JIS font
3431   metric'' which is widely used in \pTeX. A major difference between
3432   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
3433   most characters under \texttt{jfm-ujis.lua} are square-shaped,
3434   while that under \texttt{jfm-jis.lua} are horizontal
3435   rectangles.
3436 %</en>
3437 %<*ja>
3438 \item[\tt jfm-jis.lua] \pTeX で広く用いられている「JISフォントメトリック」
3439   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua} とこの
3440   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
3441   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状であることと,
3442   \texttt{jfm-ujis.lua} では「?」「!」の直後に半角空白が挿入されることである.
3443 %</ja>
3444 %<*en>
3445 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
3446   of the default Japanese font metric shipped with \pTeX.
3447 %</en>
3448 %<*ja>
3449 \item[\tt jfm-min.lua] \pTeX に同梱されているデフォルトの和文用TFM
3450 (\verb+min10.tfm+)に相当し,行末で文字が揃うようにするために「っ」など一部の文字幅が変わっ
3451            ている.\verb+min10.tfm+ については\cite{min10}が詳しい.
3452 %</ja>
3453 \end{description}
3454 %<*en>
3455 The difference among these three~JFMs is  shown in Table~\ref{tab-difjfm}.
3456 %</en>
3457 %<*ja>
3458 これら3つのJFMの違いは表\ref{tab-difjfm}に示した.表中の文例の一部には,
3459 \cite{min10}の図3,~4のものを用いた.
3460 %</ja>
3461
3462 \begin{figure}
3463 \begin{LTXexample}[width=0.3\textwidth]
3464 \ltjsetparameter{differentjfm=both}
3465 \jfont\F=file:KozMinPr6N-Regular.otf:jfm=ujis
3466 \jfont\G=file:KozGoPr6N-Medium.otf:jfm=ujis
3467 \jfont\H=file:KozGoPr6N-Medium.otf:jfm=ujis;jfmvar=hoge
3468 \F ){\G 【】}( % halfwidth space
3469    ){\H 『』}( % fullwidth space
3470
3471 ほげ,{\G 「ほげ」}(ほげ)\par
3472 ほげ,{\H 「ほげ」}(ほげ)% pTeX-like
3473
3474 \ltjsetparameter{differentjfm=paverage}
3475 \end{LTXexample}
3476 \caption{Example of \texttt{jfmvar} key}
3477 \label{fig:jfmvar}
3478 \end{figure}
3479
3480 %<*en>
3481 \item[jfmvar=<string>]
3482 Sometimes there is a need that \ldots.
3483 %</en>
3484 %<*ja>
3485 \item[jfmvar=<string>]
3486 標準では,JFMとサイズが同じで,
3487   実フォントだけが異なる2つの和文フォントは「区別されない」.例えば
3488 図\ref{fig:jfmvar}において,最初の「)」と「【」の実フォントは異なるが,
3489 JFMもサイズも同じなので,普通に「)【」と入力した時と同じように半角空きとなる.
3490
3491 しかし,JFMとサイズが同じであっても,\texttt{jfmvar} キーの異なる
3492 2つの和文フォント,例えば図\ref{fig:jfmvar}で言う \cs{F} と \cs{H},
3493 は「区別される」.異なる和文フォントに異なる \texttt{jfmvar} キーを割り当て,
3494 かつ\Param{differentjfm}パラメータを \texttt{both} に設定すれば,
3495 \pTeX と似た状況で組版されることになる.
3496 %</ja>
3497 \end{cslist}
3498
3499 \begin{figure}
3500 \begin{LTXexample}[pos=t]
3501 \newcommand\test{\vrule ダイナミックダイクマ\vrule\\}
3502 \jfont\KMFW = KozMinPr6N-Regular:jfm=prop;-kern at 17pt
3503 \jfont\KMFK = KozMinPr6N-Regular:jfm=prop at 17pt % kern is activated
3504 \jfont\KMPW = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;-kern at 17pt
3505 \jfont\KMPK = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;+kern at 17pt
3506 \begin{multicols}{2}
3507 \ltjsetparameter{kanjiskip=0pt}
3508 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3509
3510 \ltjsetparameter{kanjiskip=3pt}
3511 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3512 \end{multicols}
3513 \end{LTXexample}
3514 \caption{Kerning information and \Param{kanjiskip}}
3515 \label{fig:kern-jfm}
3516 \end{figure}
3517
3518 %<en>\paragraph{Using kerning information in a font}
3519 %<ja>\paragraph{ペアカーニング情報の使用}
3520 \label{para-kern}
3521 %<*en>
3522 Some fonts have information for inter-glyph spacing.
3523 This version of \LuaTeX-ja treats kerning spaces like an italic correction;
3524 any glue and/or kern from the JFM and a kerning space can coexist.
3525 See Figure~\ref{fig:kern-jfm} for detail.
3526
3527 Note that in \cs{setmainjfont} etc.\ which are provided by \Pkg{luatexja-fontspec}
3528 package, kerning option is set \emph{off} (\texttt{Kerning=Off}) by default,
3529 because of the compatibility with previous versions of \LuaTeX-ja.
3530 %</en>
3531 %<*ja>
3532 いくつかのフォントはグリフ間のスペースについての情報を持っている.
3533 このカーニング情報は以前の\LuaTeX-ja とはあまり相性が良くなかったが,
3534 本バージョンではカーニングによる空白はイタリック補正と同様に扱うことになっている.
3535 つまり,カーニング由来の空白とJFM由来のグルー・カーンは同時に入りうる.
3536 図\ref{fig:kern-jfm}を参照.
3537 \begin{itemize}
3538  \item \emph{\cs{jfont} や,
3539 NFSS2用の命令(\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節)における指定では
3540 カーニング情報は標準で使用する}ことになっているようである.
3541 言い換えれば,カーニング情報を使用しない設定にするには,面倒でも
3542 \begin{lstlisting}
3543 \jfont\hoge=KozMinPr6N-Regular:jfm=ujis;-kern at 3.5mm
3544 \DeclareFontShape{JY3}{fuga}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern}{}
3545 \end{lstlisting}
3546 のように,\texttt{-kern} という指定を自分で追加しなければいけない.
3547  \item
3548 一方,\emph{\Pkg{luatexja-fontspec} の提供する \cs{setmainjfont}\
3549 などの命令の標準設定ではカーニング情報は使用しない}(\texttt{Kerning=Off})
3550 ことになっている.これは以前のバージョンの\LuaTeX-jaとの互換性のためである.
3551 \end{itemize}
3552 %</ja>
3553
3554 %<*ja>
3555 \paragraph{\texttt{extend}と\texttt{slant}}
3556 OpenType font featureと見かけ上同じような形式で指定できるものに,
3557 \begin{description}
3558 \item[\texttt{extend=}<extend>] 横方向に<extend>倍拡大する.
3559 \item[\texttt{slant=}<slant>] <slant>に指定された割合だけ傾ける.
3560 \end{description}
3561 の2つがある.
3562 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
3563 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
3564 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
3565 正しくない:
3566 %</ja>
3567 %<*en>
3568 \paragraph{\texttt{extend} and \texttt{slant}}
3569 The following setting can be specified as OpenType font features:
3570 \begin{cslist}[style=standard]
3571 \item[\cs{extend=}<extend>] expand the font horizontally by <extend>.
3572 \item[\cs{slant=}<slant>] slant the font.
3573 \end{cslist}
3574 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
3575 settings; you have to write new JFMs on purpose.
3576 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
3577 letter-spacing and the width of italic correction are not correct:
3578 %</en>
3579 \begin{LTXexample}[width=0.3\textwidth]
3580 \jfont\E=KozMinPr6N-Regular:extend=1.5;jfm=ujis;-kern
3581 \E あいうえお
3582
3583 \jfont\S=KozMinPr6N-Regular:slant=1;jfm=ujis;-kern
3584 \S あいう\/ABC
3585 \end{LTXexample}
3586
3587 %<en>\subsection{\cs{tfont}}
3588 %<ja>\subsection{\cs{tfont} 命令}
3589
3590
3591 \begin{table}[t]
3592 %<en>\caption{Differences between vertical JFMs shipped with \LuaTeX-ja}
3593 %<ja>\caption{\LuaTeX-ja に同梱されている縦組用 JFM の違い}
3594 %<en>\medskip
3595 \label{tab-difjfm-tate}
3596 \catcode`\<=12\catcode`\>=12
3597 \ltjsetparameter{jacharrange={+3}}
3598 \small
3599
3600 \def\r#1#2{%
3601   \hbox{\tate\Large\vrule
3602   \parbox{7\zw}{%
3603     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3604     ◆◆◆◆◆◆◆
3605     ある日モモちゃんがお使いで迷子になって泣きました.
3606   }\vrule}}
3607 \def\s#1#2{%
3608   \hbox{\tate\Large
3609   \parbox{7\zw}{%
3610     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3611     ちょっと!何
3612   }}}
3613 \def\t#1#2#3{\hbox to 0pt{\hss%
3614   \setbox0=\hbox{\addjfontfeatures{TateFeatures={JFM=#1}}\huge #3}%
3615   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3616   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3617   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3618   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3619   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3620
3621 \begin{minipage}{.7\textwidth}
3622 \centering
3623 \leavevmode\hbox to 0pt{\r{ujisv}{blue}\hss}\r{tmin}{red}\quad
3624 \leavevmode\hbox to 0pt{\s{ujisv}{blue}\hss}\s{tmin}{red}\quad
3625 \raise4\zw\hbox{\tate\Large\t{ujisv}{black}{漢}\t{tmin}{red}{漢}\qquad
3626            \t{ujisv}{black}{っ}\t{tmin}{red}{っ}}
3627 \end{minipage}%
3628 \begin{minipage}{.3\textwidth}
3629 \textcolor{blue}{Blue: \texttt{jfm-ujisv.lua}}\\
3630 \textcolor{red}{Red: \texttt{jfm-tmin.lua}}
3631 \end{minipage}
3632 \ltjsetparameter{jacharrange={-3}}
3633 \end{table}
3634
3635 %<*en>
3636 ...
3637 %</en>
3638 %<*ja>
3639 \cs{tfont} はフォントを縦組用の和文フォントとして読み込む命令であり,
3640 \cs{tfont} の文法は \cs{jfont} と同じである.
3641 \cs{tfont} で定義された縦組用和文フォントは,
3642 以下の点が \cs{jfont} による横組用和文フォントとは異なる:
3643 \begin{itemize}
3644  \item 自動的に \texttt{vert}, \texttt{vrt2} の両OpenType featureが有効化される.
3645 但し,以下の例の3行目に示すように,明示的に \texttt{vert}, \texttt{vrt2}(のいずれか)の
3646 有効・無効を指定した場合は別である.
3647 \begin{lstlisting}
3648 \tfont\S=file:KozMinPr6N-Regular.otf:jfm=ujisv 
3649     % vert and vrt2 are automatically activated
3650 \tfont\T=file:KozMinPr6N-Regular.otf:jfm=ujisv;-vert % vert and vrt2 are not activated
3651 \end{lstlisting}
3652  \item \ref{ssec-math}節で述べる,数式中の和文フォントには縦組用和文フォントは指定できない.
3653  \item \texttt{jfm=<name>}\ の部分には縦組用JFMを指定する.
3654 以下の縦組用JFMが\LuaTeX-jaには同梱されており,違いを表\ref{tab-difjfm-tate}に示した.
3655 \begin{description}
3656 \item[\tt jfm-ujisv.lua] \LuaTeX-jaの標準縦組用JFMである.このJFMは\upTeX で
3657   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-v.tfm+ を
3658   元にしている.
3659 \item[\tt jfm-tmin.lua] \pTeX に同梱されているデフォルトの和文用縦組TFM
3660   である \verb+tmin10.tfm+ に相当し,\texttt{min10.tfm} と同様に
3661   「っ」など一部の文字幅が狭められている.
3662 \end{description}
3663 \end{itemize}
3664
3665 なお,\pTeX では,\cs{font},~\cs{jfont},~\cs{tfont}のどれでも欧文フォント・横組用和文フォン
3666 ト・縦組用和文フォントの定義が可能であったが,\LuaTeX-jaではそうでないので注意.
3667 %</ja>
3668
3669 %<en>\subsection{Prefix \texttt{psft}}
3670 %<ja>\subsection{\texttt{psft}プリフィックス}
3671 \label{ssec-psft}
3672 %<*en>
3673 Besides ``\texttt{file:}''\ and ``\texttt{name:}''\ prefixes which
3674 are introduced in the \Pkg{luaotfload} package,
3675 \LuaTeX-ja adds ``\texttt{psft:}''\ prefix in \cs{jfont} (and~\cs{font}),
3676 to specify a ``name-only'' Japanese font which
3677 will not be embedded to PDF.
3678 Note that these non-embedded fonts under current \LuaTeX\ has Identity-H encoding,
3679 and this violates the standard ISO32000-1:2008~(\cite{pdfstd}).
3680
3681 \emph{OpenType font features, such as ``{\tt +jp90}'',
3682 have no meaning in name-only fonts using ``{\tt psft:}''\ prefix,
3683 because we can't expect what fonts are actually used by the PDF reader.}
3684 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
3685 with \texttt{psft} prefix, because they are only simple linear transformations.
3686 %</en>
3687 %<*ja>
3688 \Pkg{luaotfload}で使用可能になった
3689 \texttt{file:}\ と \texttt{name:}\ のプリフィックスに加えて,
3690 \cs{jfont}(と \cs{font} プリミティブ)では
3691 \texttt{psft:}プリフィックスを用いることができる.
3692 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
3693 和文フォントを指定することができる.
3694 なお,現行の\LuaTeX で非埋め込みフォントを作成するとPDF内でのエンコーディングが
3695 Identity-Hとなり,PDFの標準規格ISO32000-1:2008~(\cite{pdfstd})に非準拠になってしまう
3696 ので注意してほしい.
3697
3698 \emph{\texttt{psft} プリフィックスの下では
3699 \texttt{+jp90} などのOpenType font featureの効力はない.
3700 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
3701 表示に用いられるか予測できないからである.}\
3702 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
3703 \texttt{psft} プリフィックスでも使用可能である.
3704 %</ja>
3705
3706 %<en>\paragraph{\texttt{cid} key}
3707 %<ja>\paragraph{\texttt{cid}キー}
3708 \label{para-cid}
3709
3710 %<*en>
3711 The default font defined by using \texttt{psft:} prefix is for Japanese typesetting;
3712 it is Adobe-Japan1-6 CID-keyed font.
3713 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
3714 for Chinese or Korean typesetting.
3715 %</en>
3716 %<*ja>
3717 標準で\texttt{psft:}プリフィックスで定義されるフォントは日本語用のもので
3718 あり,Adobe-Japan1-6のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
3719 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
3720 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
3721
3722 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
3723 %</ja>
3724 \begin{lstlisting}[numbers=left]
3725 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-6;jfm=jis}     % Japanese
3726 \jfont\testD={psft:Ryumin-Light:jfm=jis}                        % default value is Adobe-Japan1-6
3727 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-6;jfm=jis} % Traditional Chinese
3728 \jfont\testG={psft:SimSun:cid=Adobe-GB1-5;jfm=jis}              % Simplified Chinese
3729 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}           % Korean
3730 \end{lstlisting}
3731 %<*en>
3732 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
3733 as JFM for Chinese and Korean fonts.
3734 %</en>
3735 %<*ja>
3736 上のコードでは中国語・韓国語用フォントに対してもJFMに
3737 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
3738 %</ja>
3739
3740 %<*en>
3741 At present, \LuaTeX-ja supports only 4 values written in the sample code above.
3742 Specifying other values, e.g.,
3743 %</en>
3744 %<*ja>
3745 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた4つの値しかサポートしていない.
3746 %</ja>
3747 \begin{lstlisting}
3748 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
3749 \end{lstlisting}
3750 %<*en>
3751 produces the following error:
3752 %</en>
3753 %<*ja>
3754 のようにそれら以外の値を指定すると,エラーが発生する:
3755 %</ja>
3756 \begin{lstlisting}[numbers=left]
3757 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
3758
3759 See the luatexja package documentation for explanation.
3760 Type  H <return>  for immediate help.
3761 <to be read again>
3762                    \par
3763 l.78
3764
3765 ? h
3766 I couldn't find any non-embedded font information for the CID
3767 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
3768 Please contact the LuaTeX-ja project team.
3769 ?
3770 \end{lstlisting}
3771
3772 %<en>\subsection{Structure of a JFM File}
3773 %<ja>\subsection{JFMファイルの構造}
3774 \label{ssec-jfm-str}
3775 %<en>A JFM file is a Lua script which has only one function call:
3776 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
3777 \begin{lstlisting}
3778 luatexja.jfont.define_jfm { ... }
3779 \end{lstlisting}
3780 %<*en>
3781 Real data are stored in the table which indicated above by
3782 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
3783 structure of this table.  Note that all lengths in a JFM file are
3784 floating-point numbers in design-size unit.
3785 %</en>
3786 %<*ja>
3787 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
3788 以下ではこのテーブルの構造について記す.
3789 なお,JFMファイル中の長さは全てdesign-sizeを単位とする浮動小数点数であることに
3790 注意する.
3791 %</ja>
3792
3793 \begin{cslist}[style=standard]
3794
3795 \item[dir=<direction>]
3796 %<en>(required)
3797 %<ja>(必須)
3798
3799 %<*en>
3800 The direction of JFM. \texttt{'yoko'}~(horizontal)
3801 or \texttt{'tate'}~(vertical) are supported.
3802 %</en>
3803 %<*ja>
3804 JFMの書字方向.\texttt{'yoko'}(横組)と \texttt{'tate'}(縦組)がサポートされる.
3805 %</ja>
3806
3807 \item[zw=<length>]
3808 %<en>(required)
3809 %<ja>(必須)
3810
3811 %<en>The amount of the length of the ``full-width''.
3812 %<*ja>
3813 「全角幅」の長さ.この量が \cs{zw} の長さとなる.\pTeX では
3814 「全角幅」\texttt{1zw} は「文字クラス0の文字」の幅と決められていたが,
3815 \LuaTeX-jaではここで指定する.
3816 %</ja>
3817
3818 \item[zh=<length>]
3819 %<en>(required)
3820 %<ja>(必須)
3821
3822 %<en>The amount of the ``full-height'' (height + depth).
3823 %<*ja>
3824 「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
3825 \pTeX では 「全角高さ」\texttt{1zh} は「文字クラス0の文字」の高さと深さの和と決められていたが,
3826 \LuaTeX-jaではここで指定する.
3827 %</ja>
3828
3829 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}]
3830 %<en>(optional)
3831 %<ja>(任意)
3832
3833 %<*en>
3834 This field specifies the ``ideal'' amount of \Param{kanjiskip}. As noted
3835              in Subsection~\ref{subs-kskip}, if the parameter
3836              \Param{kanjiskip} is \cs{maxdimen}, the value specified
3837              in this field is actually used (if this field is not specified in
3838              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
3839              fields are in design-size unit too.
3840 %</en>
3841 %<*ja>
3842 理想的な\Param{kanjiskip}の量を指定する.\ref{subs-kskip}節で述べたように,
3843 もし\Param{kanjiskip}が \cs{maxdimen} の値ならば,このフィールドで指定された
3844 値が実際には用いられる(指定なしは0\,ptとして扱われる).<stretch>と<shrink>のフィールドもdesign-size
3845 が単位であることに注意せよ.
3846 %</ja>
3847
3848 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}]
3849 %<en>(optional)
3850 %<ja>(任意)
3851
3852 %<*en>
3853 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
3854              amount of \Param{xkanjiskip}.
3855 %</en>
3856 %<*ja>
3857 \texttt{kanjiskip}フィールドと同様に,\Param{xkanjiskip}の理想的な量を
3858 指定する.
3859 %</ja>
3860 \end{cslist}
3861
3862 %<*en>
3863 \paragraph{Character classes}
3864 Besides from above fields, a JFM file have several sub-tables those
3865 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
3866 information of \emph{character class}~$i$. At least, the character class~0 is
3867 always present, so each JFM file must have a sub-table whose index is
3868 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
3869 the following fields:
3870 %</en>
3871 %<*ja>
3872 \paragraph{文字クラス}
3873 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
3874 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
3875 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
3876 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
3877 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
3878 %</ja>
3879
3880 \begin{cslist}[style=standard]
3881 \item[chars=\{<character>, ...\}]
3882 %<en>(required except character class~0)
3883 %<ja>(文字クラス0を除いて必須)
3884
3885 %<*en>
3886 This field is a list of characters which are in this character
3887              type~$i$. This field is optional if $i=0$, since all
3888              \textbf{JAchar} which do not belong  any character classes other
3889              than 0 are in the character class 0
3890              (hence, the character class~0 contains most of
3891              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
3892 \begin{itemize}
3893 \item a Unicode code point
3894 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
3895 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
3896 \item several ``imaginary'' characters (We will describe these later.)
3897 \end{itemize}
3898 %</en>
3899 %<*ja>
3900 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
3901 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
3902 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
3903 \begin{itemize}
3904 \item Unicode におけるコード番号
3905 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
3906 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
3907 \item いくつかの「仮想的な文字」(後に説明する)
3908 \end{itemize}
3909 %</ja>
3910
3911 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]
3912 %<en>(required)
3913 %<ja>(必須)
3914
3915 %<*en>
3916 Specify the width of characters in character class~$i$, the height, the depth and
3917 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
3918 as values of these fields.
3919
3920 But there is one exception: \texttt{width} field can be \texttt{'prop'}.
3921 This means that width of a character becomes that of its ``real'' glyph.
3922 %</en>
3923 %<*ja>
3924 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
3925 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
3926 値であるものとして扱われる.
3927
3928 例外として,\emph{\texttt{width} フィールドには数値以外に \texttt{'prop'} が指定可能である}.
3929 この場合,文字の幅はその「実際の」グリフの幅となる.OpenTypeの \texttt{prop} featureと併用
3930              すれば,これによってプロポーショナル組を行うことができる.
3931 %</ja>
3932
3933 \item[left=<length>, down=<length>, align=<align>]\
3934
3935 %<*en>
3936 These fields are for adjusting the position of the ``real'' glyph. Legal
3937              values of \texttt{align} field are \texttt{'left'},
3938              \texttt{'middle'}, and \texttt{'right'}. If one of these
3939              3~fields are omitted, \texttt{left} and \texttt{down} are
3940              treated as~0, and \texttt{align} field is treated as
3941              \texttt{'left'}.
3942 The effects of these 3~fields are indicated in
3943 Figures \ref{fig-pos}~and~\ref{fig-pos-tate}.
3944 %</en>
3945 %<*ja>
3946 これらのフィールドは実際のグリフの位置を調整するためにある.
3947 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
3948 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
3949 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
3950 \ \texttt{'left'} であるものとして扱われる.
3951 これら3つのフィールドの意味については図\ref{fig-pos}(横組用和文フォント),
3952 図\ref{fig-pos-tate}(縦組用和文フォント)で説明する.
3953 %</ja>
3954
3955 %<*en>
3956 In most cases, \texttt{left} and \texttt{down} fields are~0, while
3957 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
3958 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
3959 when the current character class is the class for opening delimiters'.
3960 %</en>
3961 %<*ja>
3962 多くの場合,\texttt{left}と\texttt{down}は0である一方,
3963 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
3964 珍しいことではない.
3965 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
3966 文字クラスが開き括弧類であるときに実際必要である.
3967 %</ja>
3968
3969 \begin{figure}[!tb]
3970 \begin{minipage}{0.4\textwidth}%
3971 \begin{center}\unitlength=10pt\small
3972 \begin{picture}(15,12)(-1,-4)
3973 \color{b_gray}% jfm
3974 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
3975
3976 \color{b_pink}% step1
3977 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
3978
3979 \color{red}% real glyph
3980 \thicklines
3981 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
3982 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
3983 \put(-1,5.5){\line(1,0){6}}
3984 \put(-1,-4){\line(1,0){6}}
3985
3986 \color{b_green}% real glyph
3987 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
3988
3989 \color{black}% jfm
3990 \thicklines
3991 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
3992 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
3993 \put(0,8){\line(1,0){12}}
3994 \put(0,-3){\line(1,0){12}}
3995 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
3996 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
3997 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
3998
3999 \color{green}% step1
4000 \thicklines
4001 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4002 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
4003 \put(3,7){\line(1,0){6}}
4004 \put(3,-2.5){\line(1,0){6}}
4005 \newsavebox{\eqdist}
4006 \savebox{\eqdist}(0,0)[b]{%
4007   \thinlines
4008   \put(-0.08,0.2){\line(0,-1){0.4}}%
4009   \put(0.08,0.2){\line(0,-1){0.4}}}
4010 \put(1.5,0){\usebox{\eqdist}}
4011 \put(10.5,0){\usebox{\eqdist}}
4012
4013 \color{blue}% shifted
4014 \thicklines
4015 \put(3,-1.5){\vector(-1,0){4}}
4016 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
4017 \put(3,0){\vector(0,-1){1.5}}
4018 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
4019 \end{picture}
4020 \end{center}
4021 \end{minipage}%
4022 \begin{minipage}{0.6\textwidth}%
4023 %<*en>
4024 Consider a  Japanese character node which belongs to
4025 a character class whose the \texttt{align}
4026 field is \texttt{'middle'}.
4027 %</en>
4028 %<*ja>
4029 \texttt{align}フィールドの値が \texttt{'middle'} であるような文字クラスに属する
4030 和文文字ノードを考えよう.
4031 %</ja>
4032 \begin{itemize}
4033 \item
4034 %<*en>
4035 The black rectangle is the imaginary body of the node.
4036 Its width, height, and depth are specified by JFM.
4037 %</en>
4038 %<*ja>
4039 黒色の長方形はノードの枠であり,
4040 その幅,高さ,深さはJFMによって指定されている.
4041 %</ja>
4042 \item
4043 %<*en>
4044 Since the \texttt{align} field is \texttt{'middle'},
4045 the ``real'' glyph is centered horizontally (the green rectangle) first.
4046 %</en>
4047 %<*ja>
4048 \texttt{align}フィールドは \texttt{'middle'} なので,
4049 実際のグリフの位置はまず水平方向に中央揃えしたものとなる(緑色の長方形).
4050 %</ja>
4051 \item
4052 %<*en>
4053 Furthermore, the glyph is shifted according to values of fields
4054       \texttt{left} and \texttt{down}. The ultimate position of the real
4055       glyph is indicated by the red rectangle.
4056 %</en>
4057 %<*ja>
4058 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
4059 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
4060 %</ja>
4061 \end{itemize}
4062 \end{minipage}
4063 \medskip
4064
4065 \caption{%
4066 %<en>The position of the real glyph (horizontal Japanese fonts)
4067 %<ja>横組和文フォントにおける「実際の」グリフの位置
4068 }
4069 \label{fig-pos}
4070 \end{figure}
4071 \begin{figure}[!tb]
4072 \begin{minipage}{0.4\textwidth}%
4073 \begin{center}\unitlength=10pt\small
4074 \begin{picture}(15,12)(-6,0)
4075 \color{b_gray}% jfm
4076 \put(-6,0){\vrule width 12\unitlength height 11\unitlength}
4077
4078 \color{b_pink}% real glyph
4079 \put(-6.5,5.5){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4080
4081 \color{red}% real glyph
4082 \thicklines
4083 \put(-6.5,5.5){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4084 \put( 1.5,5.5){\line(0,1){6}\line(0,-1){3}}
4085 \put(-6.5,11.5){\line(1,0){8}}
4086 \put(-6.5,2.5){\line(1,0){8}}
4087
4088 \color{b_green}% step1
4089 \put(-4,3){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4090
4091 \color{black}% jfm
4092 \thicklines
4093 \put(0,11){\vector(1,0){6}\vector(-1,0){6}\vector(0,-1){11}}
4094 \put(0,0){\line(1,0){6}\line(-1,0){6}}
4095 \put(-6,0){\line(0,1){11}}
4096 \put( 6,0){\line(0,1){11}}
4097 \put( 3,10.8){\makebox(0,0)[t]{\texttt{height}}}
4098 \put(-3,10.8){\makebox(0,0)[t]{\texttt{depth}}}
4099 \put(0.2,5.5){\makebox(0,0)[l]{\texttt{width}}}
4100
4101 \color{green}% step1
4102 \thicklines
4103 \put(-4,3){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4104 \put( 4,3){\line(0,1){6}\line(0,-1){3}}
4105 \put(-4,9){\line(1,0){8}}
4106 \put(-4,0){\line(1,0){8}}
4107 \savebox{\eqdist}(0,0)[b]{%
4108   \thinlines
4109   \put(-0.08,0.2){\line(0,-1){0.4}}%
4110   \put(0.08,0.2){\line(0,-1){0.4}}}
4111 \put(2,9){\usebox{\eqdist}}
4112 \put(-2,9){\usebox{\eqdist}}
4113
4114
4115 \color{blue}% shifted
4116 \thicklines
4117 \put(-4,3){\vector(0,1){2.5}}
4118 \put(-3.8,4.25){\makebox(0,0)[l]{\texttt{left}}}
4119 \put(-4,5.5){\vector(-1,0){2.5}}
4120 \put(-5.,5.7){\makebox(0,0)[b]{\texttt{down}}}
4121 \end{picture}
4122 \end{center}
4123 \end{minipage}%
4124 \begin{minipage}{0.6\textwidth}%
4125 %<*en>
4126 (\dots)
4127 %</en>
4128 %<*ja>
4129 \texttt{align}フィールドの値が \texttt{'right'} であるような文字クラスに属する
4130 和文文字を考えよう.
4131 \begin{itemize}
4132 \item
4133 実際のグリフの「垂直位置」は,まずベースラインが文字の物理的な左右方向の中央を通る
4134 位置となる.
4135 \item
4136 また,この場合 \texttt{align} フィールドは \texttt{'right'} なので,
4137 「水平位置」は字送り方向に「右寄せ」したものとなる(緑色の長方形).
4138 \item
4139 その後さらに \texttt{left} と \texttt{down} の値に従ってシフトされる
4140 のは横組用和文フォントと変わらない.
4141 \end{itemize}
4142 %</ja>
4143 \end{minipage}
4144 \medskip
4145
4146 \caption{%
4147 %<en>The position of the real glyph (vertical Japanese fonts)
4148 %<ja>縦組和文フォントにおける「実際の」グリフの位置
4149 }
4150 \label{fig-pos-tate}
4151 \end{figure}
4152
4153 \item[kern={\{[$j$]=<kern>, [$j'$]=\{<kern>, [<ratio>]\}, ...\}}]
4154
4155 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>, [<priority>], [<ratio>]\}, ...\}}]\
4156 %<*ja>
4157
4158 文字クラス$i$の文字と$j$の文字の間に挿入されるkernやglueの量を指定する.
4159
4160              <priority>は \Pkg{luatexja-adjust} による優先順位付き
4161              行長調整(\ref{ssec-adj}節)が有効なときのみ意味を持つ.
4162 このフィールドは省略可能であり,行調整処理におけるこのglueの優先
4163              度を$-2$から$+2$の間の整数で指定する.大きい値ほど「伸びやすく,縮みやすい」
4164              ことを意味する.省略時の値
4165              は0であり,範囲外の値が指定されたときの動作は未定義である.
4166
4167 <ratio>も省略可能フィールドであり,$-1$から$+1$の実数値をとる.省略時の値は0である.
4168 \begin{itemize}
4169 \item $-1$はこのグルーが「前の文字」由来であることを示す.
4170 \item $+1$はこのグルーが「後の文字」由来であることを示す.
4171 \item それ以外の値は,「前の文字」由来のグルーと「後の文字」由来の
4172 グルーが混合されていることを示す.
4173 \end{itemize}
4174 なお,このフィールドの値は\Param{differentjfm}の値が
4175 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
4176
4177 例えば,\cite{x4051}では,句点と中点の間には,
4178 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
4179 \begin{itemize}
4180 \item <width>には$0.5+0.25=0.75$を指定する.
4181 \item <ratio>には次の値を指定する.
4182 \[
4183  -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13
4184 \]
4185 \end{itemize}
4186 %</ja>
4187 %<*en>
4188 \
4189
4190 Specifies the width of kern or glue which will be inserted
4191 between characters in character class~$i$ and those in character class~$j$.
4192
4193 <priority> is an integer in $[-2,2]$ (treated as 0 if omitted), and this is
4194 used only in line adjustment with priority by \Pkg{luatexja-adjust}
4195 (see Subsection~\ref{ssec-adj}). Higher value means the glue is easy to shretch,
4196 and is also easy to shrink.
4197
4198 <ratio> is also an optional value between $-1$ and 1. For example,
4199 The width of a glue between an ideographic full stop ``。''
4200 and a fullwidth middle dot ``・'' is three-fourth of fullwidth,
4201 namely halfwidth from the ideographic full stop, and
4202 quarter-width from the fullwidth middle dot.  In this case,
4203 we specify <ratio> to
4204 \[
4205   -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13.
4206 \]
4207 %</en>
4208
4209
4210 \item[end\_stretch=<kern>, end\_shrink=<kern>]
4211 %<*ja>
4212 (任意)
4213
4214 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
4215              末に来た時に,行長を詰める調整・伸ばす調整のた
4216              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
4217 %</ja>
4218
4219 \end{cslist}
4220
4221 %<*ja>
4222 \paragraph{文字クラスの決定}
4223 文字からその文字の属する文字クラスを算出する過程は少々複雑である.
4224 次の内容を一部に含んだ \texttt{jfm-test.lua} を用いて説明する.
4225 %</ja>
4226 %<*en>
4227 \paragraph{Character to character classes}
4228 We explain how the character class of a character is determined,
4229 using  \texttt{jfm-test.lua} which contains the following:
4230 %</en>
4231 \begin{lstlisting}
4232    [0] = {
4233       chars = { '漢' },
4234       align = 'left', left = 0.0, down = 0.0,
4235       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
4236    },
4237    [2000] = {
4238       chars = { '。', 'ヒ' },
4239       align = 'left', left = 0.0, down = 0.0,
4240       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
4241    },
4242 \end{lstlisting}
4243 %<ja>ここで,次のような入力とその実行結果を考える:
4244 %<en>Now consider the following input/output:
4245 \begin{LTXexample}[width=0.3\textwidth]
4246 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+hwid
4247 \setbox0\hbox{\a ヒ漢}
4248 \the\wd0
4249 \end{LTXexample}
4250 %<*en>
4251 Now we look why the above source outputs 15\,pt.
4252 \begin{enumerate}
4253 \item The character ``ヒ'' is converted to its half width  form ``ヒ'' by \verb+hwid+ feature.
4254 \item According to the JFM, the character class of ``ヒ'' is 2000, hence its width is halfwidth.
4255 \item The character class of ``漢'' is zero,  hence its width is fullwidth.
4256 \item Hence the width of \cs{hbox} equals to 15\,pt.
4257 \end{enumerate}
4258 This example shows that the character class of a character is generally determined \emph{after
4259 applying font features by \Pkg{luaotfload}}.
4260 %</en>
4261 %<*ja>
4262 上記の出力結果が,15\,ptとなっているのは理由によるものである:
4263 \begin{enumerate}
4264 \item \verb+hwid+ featureによって「ヒ」が半角幅のグリフ「ヒ」と置き換わる(\Pkg{luaotfload} による処理).
4265 \item JFMによれば,この「ヒ」のグリフの文字クラスは2000である.
4266 \item 以上により文字クラス2000とみなされるため,結果として「ヒ」の幅は半角だと認識される.
4267 \end{enumerate}
4268 この例は,\emph{文字クラスの決定はfont featureの適用によるグリフ置換の後に行われる}ことを
4269 示している.
4270 %</ja>
4271
4272 %<*en>
4273 However, ...
4274 Consider the following input:
4275 %</en>
4276 %<*ja>
4277 但し,JFMによって決まる置換後のグリフの文字クラスが0である場合は,
4278 状況は異なる.
4279 %</ja>
4280 \begin{LTXexample}[width=0.3\textwidth]
4281 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+vert
4282 \a 漢。\inhibitglue 漢
4283 \end{LTXexample}
4284 %<*en>
4285 Here, the character class of the ideographic full stop ``。''~(\texttt{U+3002}) is determined
4286 as following:
4287 \begin{enumerate}
4288 \item As the case of ``ヒ'', the ideographic full stop ``。'' is converted to its vertical
4289       form ``\char"FE12''~(\texttt{U+FE12}).%"
4290 \item The character class of ``\char"FE12'' is \emph{zero}.
4291 \item However, \LuaTeX-ja remembers that this ``\char"FE12'' is obtained from ``。'' by
4292       font features. The character class of ``。'' is \emph{non-zero value}, namely, 2000.
4293 \item Hence the ideographic full stop ``。'' in above belongs the character class~2000.
4294 \end{enumerate}
4295 %</en>
4296 %<*ja>
4297 ここで,句点「。」(\texttt{U+3002})の文字クラスは,以下のようにして決まる.
4298 \begin{enumerate}
4299 \item \Pkg{luaotfload} によって縦組用句点のグリフに置き換わる.
4300 \item 置換後のグリフは \texttt{U+FE12} であり,JFMに従えば文字クラスは\emph{0}と判定される.
4301 \item この場合,置換前の横組用句点のグリフによって文字クラスを判定する.
4302 \item 結果として,上の出力例中の句点の文字クラスは2000となる.
4303 \end{enumerate}
4304 %</ja>
4305
4306
4307 %<ja>\paragraph{仮想的な文字}
4308 %<en>\paragraph{Imaginary characters}
4309 %<*en>
4310 As described before, you can specify several \emph{imaginary characters} in
4311 \texttt{chars} field. The most of these characters are regarded as the
4312 characters of class 0 in \pTeX.
4313 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
4314 The following is the list of imaginary characters:
4315 %</en>
4316 %<*ja>
4317 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
4318 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
4319 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
4320 い組版調整ができるようになっている.以下でその一覧を述べる:
4321 %</ja>
4322
4323 \begin{cslist}
4324 %%\item['diffmet']
4325 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
4326 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
4327
4328 \item['boxbdd']
4329 %<en>The beginning/ending of a hbox, and the beginning of a noindented (i.e., began by \cs{noindent}) paragraph.
4330 %<ja>hboxの先頭と末尾,及びインデントされていない(\cs{noindent} で開始された)段落の先頭を表す.
4331
4332 \item['parbdd']
4333 %<en>The beginning of an (indented) paragraph.
4334 %<ja>通常の(\cs{noindent} で開始されていない)段落の先頭.
4335
4336 \item['jcharbdd']
4337 %<en>A boundary between \textbf{JAchar} and anything else (such as \textbf{ALchar}, kern, glue,\,\ldots).
4338 %<ja>和文文字と「その他のもの」(欧文文字,glue,kern等)との境界.
4339
4340 \item[$-1$]
4341 %<en>The left/right boundary of an inline math formula.
4342 %<ja>行中数式と地の文との境界.
4343 \end{cslist}
4344
4345 %<en>\paragraph{Porting JFM from \pTeX}
4346 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
4347
4348 % ToDo: English version.
4349
4350 %<*en>
4351 See Japanese version of this manual.
4352 %</en>
4353
4354 %<*ja>
4355 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
4356 \begin{itemize}
4357 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
4358 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
4359       トメトリック等を移植する場合は,次のようにするべきである:
4360 \begin{itemize}
4361 \item JFM中の全ての数値を$1/0.962216$倍しておく.
4362 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
4363       \LaTeX でのフォント宣言なら,例えば次のように:
4364 \begin{lstlisting}
4365 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
4366 \end{lstlisting}
4367 \end{itemize}
4368 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
4369       (JFM中に単に書かなければよい).
4370 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
4371       文字クラスに関してはグルー/カーンの設定はしない.
4372
4373 これは,\pTeX では,
4374       hboxの先頭・末尾とインデントされていない(\cs{noindent} で開始さ
4375       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
4376 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
4377
4378 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
4379       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
4380       は,段落の最初に手動で \cs{inhibitglue} を追加するか,あるいは
4381       \ \cs{everypar} のハックを行い,それを自動化させるしかなかった.
4382
4383 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
4384 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
4385 \texttt{'parbdd'}を入れれば全角下がりとなる.
4386
4387 \begin{LTXexample}[width=0.4\textwidth]
4388 \jfont\g=KozMinPr6N-Regular:jfm=test \g
4389 \parindent1\zw\noindent{}◆◆◆◆◆
4390 \par 「◆◆←二分下がり
4391 \par 【◆◆←全角下がり
4392 \par 〔◆◆←全角二分下がり
4393 \end{LTXexample}
4394 \end{itemize}
4395
4396 但し,\cs{everypar} を利用している場合にはこの仕組みは正しく動かない.
4397 そのような例としては箇条書き中の \cs{item} で始まる段落があり,\Pkg{ltjsclasses}では
4398 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
4399 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
4400 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
4401 %</ja>
4402
4403
4404 %<en>\subsection{Math Font Family}
4405 %<ja>\subsection{数式フォントファミリ}
4406 \label{ssec-math}
4407
4408 %<*en>
4409 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
4410 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
4411 an external package is needed to support this in plain \TeX\ and
4412 \LaTeX.}, and each family has three fonts:
4413 \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}.
4414 %</en>
4415 %<*ja>
4416 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
4417   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
4418   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
4419   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
4420 \cs{textfont}, \cs{scriptfont} そして \cs{scriptscriptfont} である.
4421 %</ja>
4422
4423 %<*en>
4424 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
4425 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
4426 font families. There is no relation between the value of
4427 \cs{fam} and that of \cs{jfam}; with appropriate settings,
4428 you can set both \cs{fam} and \cs{jfam} to the same value.
4429 Here <jfont\_cs> in the argument of \Param{jatextfont} etc.\ is
4430 a control sequence which is defined by \cs{jfont}, i.e.,
4431 a \emph{horizontal} Japanese font.
4432 %</en>
4433 %<*ja>
4434 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
4435 表\ref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
4436 ものを示している.\cs{fam} と \cs{jfam} の値の間には関係はなく,
4437 適切な設定の下では \cs{fam} と \cs{jfam} の両方に同じ値を設定することができる.
4438 \Param{jatextfont} 他の第2引数<jfont\_cs>は,\cs{jfont} で定義された
4439 \emph{横組用}和文フォントである.\cs{tfont} で定義された
4440 \emph{縦組用}和文フォントを指定することは想定していない.
4441 %</ja>
4442
4443 \begin{table}[!tb]
4444 %<en>\caption{Commands for Japanese math fonts}
4445 %<ja>\caption{和文数式フォントに対する命令}
4446 \label{tab-math}
4447 %<en>\medskip
4448 \centering
4449 \def\{{\char`\{}\def\}{\char`\}}\small
4450 \begin{tabular}{ll}
4451 \toprule
4452 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
4453 %<ja>\bf 和文フォント&\bf 欧文フォント\\
4454 \midrule
4455 \cs{jfam}${}\in [0,256)$&\cs{fam}\\
4456 \tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{textfont}<fam>=<font\_cs>\\
4457 \tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptfont}<fam>=<font\_cs>\\
4458 \tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptscriptfont}<fam>=<font\_cs>\\
4459 \bottomrule
4460 \end{tabular}
4461 \end{table}
4462
4463 %<en>\subsection{Callbacks}
4464 %<ja>\subsection{コールバック}
4465
4466 %<*en>
4467 \LuaTeX-ja also has several callbacks. These callbacks can
4468 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
4469 %</en>
4470 %<*ja>
4471 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
4472 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
4473 関数などを用いることでアクセスすることができる.
4474 %</ja>
4475 \begin{description}[font=\bfseries, style=nextline]
4476 %<en>\item[\texttt{luatexja.load\_jfm} callback]
4477 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
4478 %<*en>
4479 With this callback you can overwrite JFMs.
4480 This callback is called when a new JFM is loaded.
4481 %</en>
4482 %<*ja>
4483 このコールバックを用いることでJFMを上書きすることができる.
4484 このコールバックは新しいJFMが読み込まれるときに呼び出される.
4485 %</ja>
4486
4487 \begin{lstlisting}[numbers=left]
4488 function (<table> jfm_info, <string> jfm_name)
4489   return <table> new_jfm_info
4490 end
4491 \end{lstlisting}
4492
4493 %<*en>
4494 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
4495 this argument has \texttt{chars} field which contains character codes
4496              whose character class is not~0.
4497 %</en>
4498 %<*ja>
4499 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
4500 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
4501 %</ja>
4502
4503 %<*en>
4504 An example of this callback is the \texttt{ltjarticle} class, with
4505              forcefully assigning character class~0 to \texttt{'parbdd'}
4506              in the JFM \texttt{jfm-min.lua}.
4507 %</en>
4508 %<*ja>
4509 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
4510 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
4511 %</ja>
4512
4513 %<en>\item[\texttt{luatexja.define\_jfont} callback]
4514 %<ja>\item[\texttt{luatexja.define\_jfont}コールバック]
4515 %<*en>
4516 This callback and the next callback form a pair, and you can assign characters
4517  which do not have fixed code points in Unicode to non-zero character classes.
4518 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
4519 %</en>
4520 %<*ja>
4521 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
4522 番号を持たない文字を非零の文字クラスに割り当てることができる.
4523 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
4524 %</ja>
4525
4526 \begin{lstlisting}[numbers=left]
4527 function (<table> jfont_info, <number> font_number)
4528   return <table> new_jfont_info
4529 end
4530 \end{lstlisting}
4531 %<*en>
4532 \verb+jfont_info+ has the following fields,
4533 \emph{which may not overwritten by a user}:
4534 \begin{description}
4535 \item[\texttt{size}]
4536 The font size specified at \cs{jfont} in scaled points ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$).
4537 \item[\texttt{zw}, \texttt{zh}, \texttt{kanjiskip}, \texttt{xkanjiskip}]
4538 These are scaled value of those specified by the JFM, by the font size.
4539 \item[\texttt{jfm}]
4540 The internal number of the JFM.
4541 \item[\texttt{var}]
4542 The value of \texttt{jfmvar}~key, which is specified at \cs{jfont}.
4543 The default value is the empty string.
4544 \item[\texttt{chars}]
4545 The mapping table from character codes to its character classes.\\
4546 The specification \texttt{[i].chars=\{<character>, ...\}} in the JFM will be  stored in this
4547            field as \texttt{chars=\{[<character>]=\,$i$, ...\}}.
4548 \item[\texttt{char\_type}]
4549 For $i\in\omega$, \texttt{char\_type[$i$]} is information of characters whose class is
4550            $i$, and has the following fields:
4551 \begin{itemize}
4552  \item \texttt{width},~\texttt{height}, \texttt{depth},
4553   \texttt{italic}, \texttt{down},~\texttt{left}\ are just
4554        scaled value of those specified by the JFM, by the font size.
4555  \item \texttt{align} is a number which is determined from \texttt{align}~field in the JFM:
4556 \[
4557  \begin{cases}
4558   0&\text{\texttt{'left'} and the default value}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4559  \end{cases}
4560 \]
4561 \item For $j\in \omega$, \texttt{[$j$]} stores a kern or a glue which will be inserted
4562 between character class~$i$ and class~$j$.
4563
4564 If a kern will be inserted, the value of this field is \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}},
4565 where <kern\_node> is a node\footnote{%
4566  This version of \LuaTeX-ja uses ``direct access
4567       model'' for accessing nodes, if possible. }.
4568 If a glue will be inserted, we have \texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}},
4569 where <spec\_node> is also a node, and $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$.
4570 \end{itemize}
4571 \end{description}
4572 %</en>
4573 %<*ja>
4574 \verb+jfont_info+ は最低限以下のフィールドを持つが,これらを書き換えてはならない:
4575 \begin{cslist}
4576 \item[size]
4577 実際に使われるフォントサイズ(sp単位).$1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$.
4578 \item[zw\textrm{, }zh\textrm{, }kanjiskip\textrm{, }xkanjiskip]
4579 JFMファイルで指定されているそれぞれの値をフォントサイズに合わせてスケーリングしたものを
4580 sp単位で格納している.
4581 \item[jfm]
4582 利用されているJFMを識別するための番号.
4583 \item[var]
4584 \cs{jfont},~\cs{tfont} で指定された \texttt{jfmvar} キーの値(未指定のときは空文字列).
4585 \item[chars]
4586 文字コードから文字クラスへの対応が記述されたテーブル.\\
4587 JFM内の \texttt{[i].chars=\{<character>, ...\}} という指定は\
4588 \texttt{chars=\{[<character>]=\,$i$, ...\}} という形式に変換されている.
4589 \item[char\_type]
4590 $i\in\omega$に対して,\texttt{char\_type[$i$]} は文字クラス$i$の文字の寸法を格納しており,
4591 以下のフィールドを持つ.
4592 \begin{itemize}
4593  \item \texttt{width},~\texttt{height}, \texttt{depth},
4594   \texttt{italic}, \texttt{down},~\texttt{left}\ は
4595 JFMで指定されているそれぞれの値をスケーリングしたものである.
4596  \item \texttt{align} はJFMで指定されている値によって,
4597 \[
4598  \begin{cases}
4599   0&\text{\texttt{'left'}や省略時}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4600  \end{cases}
4601 \]
4602 のいずれかの値をとる.
4603 \item $j\in \omega$に対して,\texttt{[$j$]} は文字クラス$i$の文字と$j$の文字の間に挿入されるkern
4604       やglueを格納している.
4605 間に入るものがkernであれば,このフィールドの値は\
4606 \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}} である.
4607 <kern\_node>はkernを表すノードそのものである\footnote{%
4608 本バージョンではノードのアクセス手法にdirect access
4609       modelを用いている.そのため,例えば\LuaTeX\ beta-0.78.2では,単なる自然数のようにし
4610       か見えないことに注意.
4611 }.
4612 glueであれば,\texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}} である.
4613 <spec\_node>はglueの長さを表すノードそのものであり,
4614       $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$である.
4615 \end{itemize}
4616 \item[ascent\textrm{, }descent]
4617 ……
4618 \item[chars\_cbcache] 
4619 ……
4620 \end{cslist}
4621 %</ja>
4622
4623 %<*en>
4624 The returned table \verb+new_jfont_info+ also should include these fields, but
4625 you are free to add more fields (to use them in the \texttt{luatexja.find\_char\_class} callback).
4626 The \verb+font_number+ is a font number.
4627 %</en>
4628 %<*ja>
4629 戻り値の \verb+new_jfont_info+ テーブルも上に述べたフィールドをそのまま含まなければならないが,
4630 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
4631 \verb+font_number+ はフォント番号である.
4632 %</ja>
4633
4634 %<*en>
4635 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
4636              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
4637              CID characters in a JFM. This callback doesn't replace any
4638              code of \LuaTeX-ja.
4639 %</en>
4640 %<*ja>
4641 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
4642 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
4643 用いられている.
4644 %</ja>
4645
4646 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
4647 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
4648 %<*en>
4649 This callback is called just when \LuaTeX-ja is trying to determine which
4650              character class a character \verb+chr_code+ belongs.
4651 A function used in this callback should be in the following form:
4652 %</en>
4653 %<*ja>
4654 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
4655 属するかを決定しようとする際に呼び出される.
4656 このコールバックで呼び出される関数は次の形をしていなければならない:
4657 %</ja>
4658 \begin{lstlisting}[numbers=left]
4659 function (<number> char_class, <table> jfont_info, <number> chr_code)
4660   if char_class~=0 then return char_class
4661   else
4662     ....
4663     return (<number> new_char_class or 0)
4664   end
4665 end
4666 \end{lstlisting}
4667
4668 %<*en>
4669 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
4670              routine or previous function calls in this callback, hence
4671              this argument may not be 0. Moreover, the returned
4672              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
4673              is not~0, otherwise you will overwrite the \LuaTeX-ja's
4674              default routine.
4675 %</en>
4676 %<*ja>
4677 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
4678 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
4679 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
4680 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
4681 デフォルトルーチンを書き換えることになる.
4682 %</ja>
4683
4684 %<en>\item[\texttt{luatexja.set\_width} callback]
4685 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
4686 %<*en>
4687 This callback is called when \LuaTeX-ja is trying to encapsule a
4688              \textbf{JAchar} \textit{glyph\_node}, to adjust its
4689              dimension and position.
4690 %</en>
4691 %<*ja>
4692 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
4693 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
4694 %</ja>
4695 \begin{lstlisting}[numbers=left]
4696 function (<table> shift_info, <table> jfont_info, <number> char_class)
4697   return <table> new_shift_info
4698 end
4699 \end{lstlisting}
4700
4701 %<*en>
4702 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
4703 \texttt{down} and \texttt{left} fields, which are the amount of shifting
4704              down/left the character in a scaled point.
4705 %</en>
4706 %<*ja>
4707 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
4708 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
4709 文字の下/左へのシフト量(sp単位)である.
4710 %</ja>
4711
4712 %<*en>
4713 A good example is \Pkg{test/valign.lua}.
4714 After loading this file, the vertical position of glyphs is automatically
4715 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
4716 to be that of letters in the character class~0. For example, suppose that
4717 \begin{itemize}
4718 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
4719   (the standard values of Japanese OpenType fonts);
4720 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
4721   (the standard values of Japanese TrueType fonts).
4722 \end{itemize}
4723 Then, the position of glyphs is shifted up by
4724 %</en>
4725 %<*ja>
4726 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
4727              JFM内で規定された文字クラス0の文字における$(\hbox{高
4728              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
4729              下位置が自動調整される.例えば,
4730 \begin{itemize}
4731 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
4732 (和文OpenTypeフォントの標準値)
4733 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
4734 \end{itemize}
4735 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にぜらされることとなる:
4736 %</ja>
4737 \[
4738  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
4739 \]
4740 \end{description}
4741
4742
4743
4744 %<en>\section{Parameters}
4745 %<ja>\section{パラメータ}
4746 \subsection{\cs{ltjsetparameter}}
4747 \label{ssec-param}
4748
4749 %<*en>
4750 As described before, \cs{ltjsetparameter} and \cs{ltjgetparameter} are
4751 commands for accessing most parameters of \LuaTeX-ja. One of the main
4752 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
4753 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
4754 is the position of \verb+hpack_filter+ callback in the source
4755 of \LuaTeX, see Section~\ref{sec-para}.
4756 %</en>
4757 %<*ja>
4758 先に述べたように,\LuaTeX-jaのほとんどの内部パラメータにアクセスするには
4759 \cs{ltjsetparameter}(または \cs{ltjglobalsetparameter})と \cs{ltjgetparameter} を用いる.
4760 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
4761 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
4762 コールバックの位置にある.\ref{sec-para}章を参照.
4763 %</ja>
4764
4765 %<*en>
4766 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} are commands
4767 for assigning parameters. These take one argument which is a
4768 \texttt{<key>=<value>} list.
4769 The difference between
4770 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} is only the
4771 scope of assignment;
4772 \cs{ltjsetparameter} does a local assignment and
4773 \cs{ltjglobalsetparameter} does a global one.
4774 They also obey the value of \cs{globaldefs}, like other assignments.
4775 %</en>
4776 %<*ja>
4777 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} はパラメータを
4778 指定するための命令で,\texttt{<key>=<value>}のリストを
4779 引数としてとる.
4780 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} の違いはスコープの
4781 違いのみで,
4782 \cs{ltjsetparameter} はローカルな設定を行うのに対し,
4783 \cs{ltjglobalsetparameter} はグローバルな設定を行う.
4784 また,他のパラメータ指定と同様に \cs{globaldefs} の値にも従う.
4785 %</ja>
4786
4787 %<*en>
4788 The following is the list of parameters which can be specified by the
4789 \cs{ltjsetparameter} command. [\cs{cs}] indicates the counterpart
4790 in \pTeX, and symbols beside each parameter has the following meaning:
4791 %</en>
4792 %<*ja>
4793 以下は \cs{ltjsetparameter} に指定することができるパラメータの一覧である.
4794 [\cs{cs}]は\pTeX における対応物を示す.
4795 また,それぞれのパラメータの右上の記号には次の意味がある:
4796 %</ja>
4797 \begin{itemize}
4798 %<*en>
4799 \item ``\ast'' : values at the end of a paragraph or a hbox are
4800 adopted in the whole paragraph or the whole hbox.
4801 %</en>
4802 %<*ja>
4803 \item ``\ast'':段落やhboxの終端での値がその段落/hbox全体で用いられる.
4804 %</ja>
4805 %<*en>
4806 \item ``\dagger'': assignments are always global.
4807 %</en>
4808 %<*ja>
4809 \item ``\dagger'':指定は常にグローバルになる.
4810 %</ja>
4811 \end{itemize}
4812
4813 \begin{cslist}[style=standard]
4814 \item[\DParam{jcharwidowpenalty}\,=<penalty>$^\ast$] [\cs{jcharwidowpenalty}]\
4815
4816 %<*en>
4817 Penalty value for suppressing orphans. This penalty is inserted just
4818              after the last \textbf{JAchar} which is not regarded as a
4819              (Japanese) punctuation mark.
4820 %</en>
4821 %<*ja>
4822 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
4823 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
4824 挿入される.
4825 %</ja>
4826
4827 \item[\DParam{kcatcode}\,=\{<chr\_code>,<natural number>\}$^\ast$]\
4828
4829 %<*en>
4830 An additional attributes which each character whose character code is <chr\_code> has.
4831 At the present version, the lowermost bit of <natural number> indicates
4832              whether the character is considered as a punctuation mark
4833              (see the description of \Param{jcharwidowpenalty} above).
4834 %</en>
4835 %<*ja>
4836 文字コードが<chr\_code>の文字が持つ付加的な属性値.
4837 現在のバージョンでは,<natural number>の最下位ビットが,その文字が句読点と
4838 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
4839 %</ja>
4840
4841 \item[\DParam{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$] [\cs{prebreakpenalty}]\
4842
4843 %<*ja>
4844 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
4845              この文字の前に挿入/追加されるペナルティの量を指定する.
4846
4847 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
4848 \begin{lstlisting}
4849 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4850 \end{lstlisting}
4851 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
4852              うわけではないができれば行頭にはきて欲しくない場合に,0と
4853              10000の間の値を指定するのも有用であろう.
4854 %</ja>
4855 %<*en>
4856 Set a penalty which is inserted automatically before the character <chr\_code>,
4857 to prevent a line starts from this character. For example, a line cannot started
4858 with one of closing brackets ``〗'', so \LuaTeX-ja sets
4859 \begin{lstlisting}
4860 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4861 \end{lstlisting}
4862 by default.
4863 %</en>
4864
4865
4866 \item[\DParam{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$]
4867            [\cs{postbreakpenalty}]\
4868
4869 %<*ja>
4870 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
4871              この文字の後に挿入/追加されるペナルティの量を指定する.
4872
4873 \pTeX では,\cs{prebreakpenalty}, \cs{postbreakpenalty}において,
4874 \begin{itemize}
4875 \item 一つの文字に対して,pre, postどちらか一つしか指定することができない%
4876   \footnote{後から指定した方で上書きされる.}
4877 \item pre, post合わせて256文字分の情報を格納することしかできない
4878 \end{itemize}
4879 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
4880 %</ja>
4881 %<*en>
4882 Set a penalty which is inserted automatically after the character <chr\_code>,
4883 to prevent a line ends with this character.
4884 \pTeX\ has following restrictions on \cs{prebreakpenalty} and \cs{postbreakpenalty},
4885 but they don't exist in \LuaTeX-ja:
4886 \begin{itemize}
4887  \item Both \cs{prebreakpenalty} and \cs{postbreakpenalty} cannot be set
4888 for the same character.
4889  \item We can set \cs{prebreakpenalty} and \cs{postbreakpenalty} up to 256~characters.
4890 \end{itemize}
4891 %</en>
4892
4893 \item[\DParam{jatextfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
4894 %<en>[\cs{textfont} in \TeX]
4895 %<ja>[\TeX の \cs{textfont}]
4896 \item[\DParam{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
4897 %<en>[\cs{scriptfont} in \TeX]
4898 %<ja>[\TeX の \cs{scriptfont}]
4899 \item[\DParam{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
4900 %<en>[\cs{scriptscriptfont} in \TeX]
4901 %<ja>[\TeX の \cs{scriptscriptfont}]
4902 \item[\DParam{yjabaselineshift}\,=<dimen>]\
4903 \item[\DParam{yalbaselineshift}\,=<dimen>] [\cs{ybaselineshift}]
4904 \item[\DParam{tjabaselineshift}\,=<dimen>]\
4905 \item[\DParam{talbaselineshift}\,=<dimen>] [\cs{tbaselineshift}]
4906
4907 \item[\DParam{jaxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$]\
4908
4909 %<*en>
4910 Setting whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
4911 The followings are allowed for <mode>:
4912 %</en>
4913 %<*ja>
4914 文字コードが<chr\_code>の\textbf{JAchar}の前/後ろに\Param{xkanjiskip}の
4915 挿入を許すかどうかの設定.
4916 以下の<mode>が許される:
4917 %</ja>
4918 \begin{description}
4919 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
4920 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
4921 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
4922 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
4923 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
4924 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
4925 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
4926 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
4927 \end{description}
4928 %<*en>
4929 This parameter is similar to the \cs{inhibitxspcode} primitive of \pTeX, but not compatible with \cs{inhibitxspcode}.
4930 %</en>
4931 %<*ja>
4932 このパラメータは\pTeX の \cs{inhibitxspcode} プリミティブと似ているが,
4933 互換性はない.
4934 %</ja>
4935 \item[\DParam{alxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$] [\cs{xspcode}]\
4936
4937 %<*en>
4938 Setting whether inserting \Param{xkanjiskip} is allowed before/after a
4939              \textbf{ALchar} whose character code is <chr\_code>.
4940              The followings are allowed for <mode>:
4941 %</en>
4942 %<*ja>
4943 文字コードが<chr\_code>の\textbf{ALchar}の前/後ろに\Param{xkanjiskip}の
4944 挿入を許すかどうかの設定.
4945 以下の<mode>が許される:
4946 %</ja>
4947 \begin{description}
4948 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
4949 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
4950 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
4951 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
4952 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
4953 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
4954 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
4955 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
4956 \end{description}
4957 %<*en>
4958 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
4959 %</en>
4960 %<*ja>
4961 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
4962 これら2つのパラメータは互いの別名となっていることに注意する.
4963 %</ja>
4964
4965 \item[\DParam{autospacing}\,=<bool>] [\cs{autospacing}]
4966 \item[\DParam{autoxspacing}\,=<bool>] [\cs{autoxspacing}]
4967 \item[\DParam{kanjiskip}\,=<skip>$^\ast$] [\cs{kanjiskip}]\
4968
4969 %<*ja>
4970 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
4971 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
4972 しかし,自然長が \cs{maxdimen} の場合は,例外的に和文フォントのJFM側で指定されている
4973 値を採用(こちらはフォントサイズに比例)することになっている.
4974 %</ja>
4975
4976 \item[\DParam{xkanjiskip}\,=<skip>$^\ast$] [\cs{xkanjiskip}]\
4977
4978 %<*ja>
4979 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
4980 \Param{kanjiskip}と同じように,通常ではフォントサイズに比例して変わることはないが,
4981 自然長が \cs{maxdimen} の場合が例外である.
4982 %</ja>
4983
4984
4985 \item[\DParam{differentjfm}\,=<mode>$^\dagger$]\
4986
4987 %<*en>
4988 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
4989 The allowed arguments are the followings:
4990 %</en>
4991 %<*ja>
4992 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
4993 入れるかを指定する.
4994 許される値は以下の通り:
4995 %</ja>
4996 \begin{quote}
4997 \texttt{average},
4998 \texttt{both},
4999 \texttt{large},
5000 \texttt{small},
5001 \texttt{pleft},
5002 \texttt{pright},
5003 \texttt{paverage}
5004 \end{quote}
5005 %<*en>
5006 The default value is \texttt{paverage}. \dots
5007 %</en>
5008 %<*ja>
5009 デフォルト値は \texttt{paverage} である.
5010 各々の値による差異の詳細は\ref{ssec-cluster-wa}節の「『右空白』の算出」を参照してほしい.
5011 %</ja>
5012
5013 \item[\DParam{jacharrange}\,=<ranges>]
5014 \item[\DParam{kansujichar}\,=\{<digit>, <chr\_code>\}$^\ast$] [\cs{kansujichar}]
5015
5016 \item[\DParam{direction}\,=<dir>\ \hbox{\rm (always local)}]\
5017
5018 %<*en>
5019 Assigning to this parameter has the same effect as
5020 \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5021 \cs{dtou}~(if $\hbox{<dir>}=1$) or \cs{utod}~(if $\hbox{<dir>}=11$).
5022 If the argument <dir> is not one of 4,~3, 1~nor~11,
5023 the behavior of this assignment is undefined.
5024 %</en>
5025 %<*ja>
5026 組方向を変更する \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5027 \cs{dtou}~(if $\hbox{<dir>}=1$), \cs{utod}~(if $\hbox{<dir>}=11$) と同じ役割を持つ.
5028 利用可能な状況もこれら4命令と同一である.引数<dir>が4,~3, 1,~11のいずれでも無いときの
5029 動作は未定義である.
5030 %</ja>
5031
5032 \end{cslist}
5033
5034
5035 \subsection{\cs{ltjgetparameter}}
5036 \label{ssec-getpar}
5037 %<*en>
5038 \cs{ltjgetparameter} is a control sequence for acquiring parameters. It
5039 always takes a parameter name as first argument.
5040 %</en>
5041 %<*ja>
5042 \cs{ltjgetparameter} はパラメータの値を取得するための命令であり,
5043 常にパラメータの名前を第一引数にとる.
5044 %</ja>
5045 \begin{LTXexample}
5046 \ltjgetparameter{differentjfm},
5047 \ltjgetparameter{autospacing},
5048 \ltjgetparameter{kanjiskip},
5049 \ltjgetparameter{prebreakpenalty}{`)}.
5050 \end{LTXexample}
5051
5052 %<*en>
5053 \emph{The return value of\/ \cs{ltjgetparameter} is
5054 always a string}, which is outputted by \texttt{tex.write()}.
5055 Hence any character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
5056 12~(other), while the space has 10~(space).
5057 %</en>
5058 %<*ja>
5059 \emph{\cs{ltjgetparameter} の戻り値は常に文字列である.}
5060 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
5061 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
5062 一方,空白のカテゴリーコードは10~(space)である.
5063 %</ja>
5064
5065 \begin{itemize}
5066 \item
5067 %<*en>
5068 If first argument is one of the
5069 following, no  additional argument is needed.
5070 %</en>
5071 %<*ja>
5072 第1引数が次のいずれかの場合には,追加の引数は必要ない.
5073 %</ja>
5074 \begin{quote}
5075 \sffamily
5076 jcharwidowpenalty, yjabaselineshift, yalbaselineshift, autospacing, autoxspacing,\\
5077 kanjiskip, xkanjiskip, differentjfm, direction
5078 \end{quote}
5079 %<*en>
5080 Note that \verb+\ltjgetparameter{autospacing}+~and~\verb+\ltjgetparameter{autoxspacing}+
5081 returns 1 or 0, not
5082 \texttt{true}~nor~\texttt{false}.
5083 %</en>
5084 %<*ja>
5085 \verb+\ltjgetparameter{autospacing}+ と \verb+\ltjgetparameter{autoxspacing}+ は,
5086 \texttt{true}や\texttt{false}を返すの\emph{ではなく},
5087 1か0のいずれかを返すことに注意,
5088 %</ja>
5089
5090 \item
5091 %<*en>
5092 If first argument is one of the
5093 following, an additional argument---a character code, for example---is needed.
5094 %</en>
5095 %<*ja>
5096 第1引数が次のいずれかの場合には,さらに文字コードを第2引数としてとる.
5097 %</ja>
5098 \begin{quote}
5099 \sffamily
5100 kcatcode, prebreakpenalty, postbreakpenalty, jaxspmode, alxspmode
5101 \end{quote}
5102 %<*en>
5103 \verb+\ltjgetparameter{jaxspmode}{...}+~and~\verb+\ltjgetparameter{alxspmode}{...}+
5104 returns 0,~1, 2,~or~3, instead of \texttt{preonly} etc.
5105 %</en>
5106 %<*ja>
5107 \verb+\ltjgetparameter{jaxspmode}{...}+ や \verb+\ltjgetparameter{alxspmode}{...}+\
5108 は,\texttt{preonly} などといった文字列ではなく,0から3までの値を返す.
5109 %</ja>
5110
5111 \item
5112 %<*en>
5113 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ returns \texttt{0}
5114 if ``characters which belong to the character range~<range> are \textbf{JAchar}'',
5115 \texttt{1} if ``\dots~are \textbf{ALchar}''.
5116 Although there is no character range~$-1$, specifying $-1$ to <range> does not cause an
5117       error (returns 1).
5118 %</en>
5119 %<*ja>
5120 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ は,<range>が\textbf{JAchar}達の
5121 範囲ならば0を,そうでなければ1を返す.「$-1$番の文字範囲」は存在しないが,<range>に$-1$を
5122 指定してもエラーは発生しない(1を返す).
5123 %</ja>
5124
5125 \item
5126 %<*en>
5127 For an integer~<digit> between 0~and~9,
5128      \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ returns the character code
5129 of the result of \cs{kansuji}<digit>.
5130 %</en>
5131 %<*ja>
5132 0--9の数<digit>に対して,
5133 \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ は,\cs{kansuji}<digit>で出力され
5134      る文字の文字コードを返す.
5135 %</ja>
5136
5137 \item
5138 %<*en>
5139 \verb+\ltjgetparameter{adjustdir}+ returns a integer which represents
5140 the direction of the surrounding vertical list.
5141 As \Param{direction}, the return value 1 means \emph{down-to-up} direction,
5142 3 means \emph{tate} direction (vertical typesetting),
5143 and 4 means \emph{yoko} direction (horizontal typesetting).
5144 %</en>
5145 %<*ja>
5146 \verb+\ltjgetparameter{adjustdir}+ は,周囲のvboxの組方向(言い換えれば,
5147 \cs{vadjust} で用いられる組方向)を表す数値を返す.
5148 \Param{direction}と同様に,1は \cs{dtou} 方向を,
5149 3は縦組みを,4は横組みを表す.
5150 %</ja>
5151
5152 \item
5153 %<*en>
5154 For an integer~<reg\_num> between 0~and~65535,
5155 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ returns the direction of
5156 \cs{box}<reg\_num>. If this box register is void, the returned value is zero.
5157 %</en>
5158 %<*ja>
5159 0--65535の数<reg\_num>に対して,
5160 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ は,\cs{box}<reg\_num>に
5161 格納されているボックスの組方向を表す.もしこのレジスタが空の場合は,0が返される.
5162 %</ja>
5163
5164 \item
5165 %<*en>
5166 The following parameter names \emph{cannot be specified} in \cs{ltjgetparameter}.
5167 %</en>
5168 %<*ja>
5169 次のパラメータ名を \cs{ltjgetparameter} に指定することはできない.
5170 %</ja>
5171 \begin{quote}
5172 \sffamily
5173 jatextfont, jascriptfont, jascriptscriptfont, jacharrange
5174 \end{quote}
5175
5176 \item
5177 %<*en>
5178 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ returns
5179 the range number which <chr\_code> belongs to
5180 (although there is no parameter named ``chartorange'').
5181
5182 If <chr\_code> is between 0 and 127, this <chr\_code> does not belong to
5183 any character range. In this case,
5184       \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+
5185 returns $-1$.
5186
5187 Hence, one can know whether <chr\_code> is \textbf{JAchar} or not
5188 by the following:
5189 %</en>
5190 %<*ja>
5191 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ によって
5192 <chr\_code>の属する文字範囲の番号を知ることができる.
5193
5194 <chr\_code>に0--127の値を指定した場合(このとき,<chr\_code>が属する
5195 文字範囲は存在しない)は$-1$が返る.
5196
5197 そのため,<chr\_code>が\textbf{JAchar}か\textbf{ALchar}かは
5198 次で知ることができる:
5199 %</ja>
5200 \begin{quote}
5201 \ttfamily \verb+\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{+%
5202   <chr\_code>\verb+}}+\\\null\hfill\verb+% 0 if JAchar, 1 if ALchar+
5203 \end{quote}
5204
5205 %<*en>
5206 \item Because the returned value is string, the following conditionals do not work
5207 if \Param{kanjiskip} (or~\Param{xkanjiskip}) has the stretch part or the shrink part.
5208 \begin{lstlisting}
5209 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5210 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5211 \end{lstlisting}
5212 The correct way is using a temporary register.
5213 \begin{lstlisting}
5214 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5215 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5216 \end{lstlisting}
5217 %</en>
5218 %<*ja>
5219 \item 返り値が文字列であることから,\Param{kanjiskip}や\Param{xkanjiskip}を直接
5220 \ \cs{ifdim} を使って比較することは望ましくない.伸び量や縮み量を持っている時には,
5221 次はエラーを発生させる:
5222 \begin{lstlisting}
5223 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5224 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5225 \end{lstlisting}
5226 レジスタに一旦代入するのが良い:
5227 \begin{lstlisting}
5228 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5229 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5230 \end{lstlisting}
5231 %</ja>
5232
5233 \end{itemize}
5234
5235 %<*ja>
5236 \subsection{\cs{ltjsetparameter} の代替}
5237 原則として各種内部パラメータの設定には \cs{ltjsetparameter} もしくは
5238 \ \cs{ltjglobalsetparameter}\ を用いることになるが,
5239 \cs{ltjsetparameter} の実行には時間がかかるという難点があり,
5240 \LuaTeX-ja の内部ではより高速に実行できる別の形式を用いている.
5241 \emph{本節は一般利用者むけの内容ではない.}
5242
5243 \paragraph{\Param{kanjiskip}, \Param{xkanjiskip} の設定}
5244 \pLaTeXe 新ドキュメントクラスでは,
5245 \begin{lstlisting}
5246 \def\@setfontsize#1#2#3{%
5247   ...
5248   \kanjiskip=0zw plus .1zw minus .01zw
5249   \ifdim\xkanjiskip>\z@
5250     \if@slide \xkanjiskip=0.1em \else
5251       \xkanjiskip=0.25em plus 0.15em minus 0.06em
5252     \fi
5253   \fi}
5254 \end{lstlisting}
5255 と,フォントサイズを変更するごとに \cs{kanjiskip}, \cs{xkanjiskip} を変更している.
5256 この \cs{@setfontsize} は文書の中で多数回実行されるので.
5257 \LuaTeX-ja 用に素直に書き換えた
5258 \begin{lstlisting}
5259   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
5260   \@tempskipa=\ltjgetparameter{xkanjiskip}
5261   \ifdim\@tempskipa>\z@
5262     \if@slide 
5263       \ltjsetparameter{xkanjiskip=0.1em}
5264     \else
5265       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
5266     \fi
5267   \fi
5268 \end{lstlisting}
5269 としたのではタイプセットが遅くなってしまう.
5270 そこで,\cs{ltjsetparameter} の中で
5271 \begin{itemize}
5272 \item \cs{globaldefs} の値を読み取る \cs{ltj@setpar@global}
5273 \item \Param{kanjiskip} の設定を行う \cs{ltjsetkanjiskip}
5274 \item \Param{xkanjiskip} の設定を行う \cs{ltjsetxkanjiskip}
5275 \end{itemize}
5276 を独立させ,\Pkg{ltjsclasses}では,
5277 \begin{lstlisting}
5278   \ltj@setpar@global
5279   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
5280   \@tempskipa=\ltjgetparameter{xkanjiskip}
5281   \ifdim\@tempskipa>\z@
5282     \if@slide 
5283       \ltjsetxkanjiskip{0.1em}
5284     \else
5285       \ltjsetxkanjiskip{0.25em plus 0.15em minus 0.06em}
5286     \fi
5287   \fi
5288 \end{lstlisting}
5289 としている.
5290 \cs{ltj@setpar@global}を直前に実行せず,単独で
5291 \cs{ltjsetkanjiskip}, \cs{ltjsetxkanjiskip}を実行することは想定されていないので注意.
5292
5293
5294
5295 \paragraph{ベースライン補正量の設定}
5296 \pLaTeX の\Pkg{ascmac}パッケージでは,縦組の欧文ベースライン補正量の一時待避・復帰処理に
5297 \ \cs{@saveybaselineshift}\ という寸法レジスタを用い
5298 \begin{lstlisting}
5299 \@savetbaselineshift\tbaselineshift\tbaselineshift\z@
5300 ...
5301 \tbaselineshift\@savetbaselineshift
5302 \end{lstlisting}
5303 という処理を行っている.
5304
5305 これを\LuaTeX-ja 用に \cs{ltjsetparameter} を使って書き直すと,
5306 \begin{lstlisting}
5307 \@savetbaselineshift\ltjgetparameter{talbaselineshift}
5308 \ltjsetparameter{talbaselineshift=\z@}
5309 ...
5310 \ltjsetparameter{talbaselineshift=\@savetbaselineshift}
5311 \end{lstlisting}
5312 となる.
5313
5314 さて,縦組の欧文ベースライン補正量\Param{talbaselineshift}は,
5315 実際には \cs{ltj@tablshift} という属性レジスタに格納されている
5316 (\ref{sec-para}\nobreak 節参照).属性レジスタは長さではなく整数値を格納する\footnote{%
5317   従って,\texttt{\textbackslash @savetbaselineshift=\textbackslash ltj@tablshift}\ 
5318   のように記述することはできない.属性レジスタを \cs{tbaselineshift} という名称にしなかっ
5319   たのはそのためである.
5320 }ものであり,\cs{ltj@tablshift} は補正量を sp 単位で保持することから,
5321 上記のコードと同じ内容をより速い以下のコードで実現することができる.
5322 \begin{lstlisting}
5323 \@savetbaselineshift\ltj@tablshift sp%
5324 \ltj@tablshift\z@
5325 ...
5326 \ltj@tablshift\@savetbaselineshift
5327 \end{lstlisting}
5328 この手法は \Pkg{ascmac} パッケージの\LuaTeX-ja対応パッチ \Pkg{lltjp-tascmac.sty} で
5329 実際に用いられている.\Pkg{lltjp-tascmac.sty} は自動的に読み込まれるので,
5330 ユーザは何も気にせず普通に \Pkg{ascmac} パッケージを \cs{usepackage} で読みこめば良い.
5331 %</ja>
5332
5333
5334 %<en>\section{Other Commands for plain \TeX\ and \LaTeXe}
5335 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
5336 %<en>\subsection{Commands for Compatibility with \pTeX}
5337 %<ja>\subsection{\pTeX 互換用命令}
5338
5339 %<*en>
5340 The following commands are implemented for compatibility with \pTeX.
5341 Note that the former five commands don't support JIS~X~0213, but only JIS~X~0208.
5342 The last \cs{kansuji} converts an integer into its Chinese numerals.
5343 %</en>
5344 %<*ja>
5345 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
5346 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
5347 %</ja>
5348 \begin{center}
5349 \cs{kuten}, \cs{jis}, \cs{euc}, \cs{sjis}, \cs{jis}, \cs{kansuji}
5350 \end{center}
5351 %<*en>
5352 These six commands takes an internal integer, and returns a \emph{string}.
5353 %</en>
5354 %<*ja>
5355 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
5356 %</ja>
5357 \begin{LTXexample}
5358 \newcount\hoge
5359 \hoge="2423 %"
5360 \the\hoge, \kansuji\hoge\\
5361 \jis\hoge, \char\jis\hoge\\
5362 \kansuji1701
5363 \end{LTXexample}
5364
5365 %<*en>
5366 To change characters of Chinese numerals for each digit, set \Param{kansujichar} parameter:
5367 \begin{LTXexample}
5368 \ltjsetparameter{kansujichar={1,`壹}}
5369 \ltjsetparameter{kansujichar={7,`漆}}
5370 \ltjsetparameter{kansujichar={0,`零}}
5371 \kansuji1701
5372 \end{LTXexample}
5373 %</en>
5374
5375
5376 \subsection{\cs{inhibitglue}}
5377 %<*en>
5378 \cs{inhibitglue} suppresses the insertion of \textbf{JAglue}.
5379 The following is an example, using a special JFM that there will be a glue between
5380 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
5381 %</en>
5382 %<*ja>
5383 \cs{inhibitglue} は\textbf{JAglue}の挿入を抑制する.
5384 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
5385 ある.
5386 %</ja>
5387
5388 \begin{LTXexample}[width=0.4\textwidth]
5389 \jfont\g=file:KozMinPr6N-Regular.otf:jfm=test \g
5390 \fbox{\hbox{あウあ\inhibitglue ウ}}
5391 \inhibitglue\par\noindent あ1
5392 \par\inhibitglue\noindent あ2
5393 \par\noindent\inhibitglue あ3
5394 \par\hrule\noindent あoff\inhibitglue ice
5395 \end{LTXexample}
5396
5397 %<*en>
5398 With the help of this example, we remark the specification of \cs{inhibitglue}:
5399 %</en>
5400 %<*ja>
5401 この例を援用して,\cs{inhibitglue} の仕様について述べる.
5402 %</ja>
5403 \begin{itemize}
5404 %<*en>
5405 \item The call of \cs{inhibitglue} in the (internal) vertical mode is
5406       simply ignored.
5407 %</en>
5408 %<*ja>
5409 \item \emph{\cs{inhibitglue} の垂直モード中での呼び出しは意味を持たない}\footnote{%
5410   この点は\TeX~Live~2014での\pTeX における \cs{inhibitglue} の仕様変更と同じである.
5411 }.
5412 4行目の入力で有効にならないのは,\cs{inhibitglue} の時点では垂直モードであり,
5413 \cs{noindent} の時点で水平モードになるからである.
5414 %</ja>
5415
5416 %<*en>
5417 \item The call of \cs{inhibitglue} in the (restricted) horizontal
5418       mode is only effective on the spot; does not get over boundary of
5419       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
5420       kernings, as shown in the last line of above example.
5421 %</en>
5422 %<*ja>
5423 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
5424   有効であり,段落の境界を乗り越えない.
5425   さらに,\cs{inhibitglue} は上の例の最終行のように(欧文における)リガチャとカーニングを
5426   打ち消す.これは,\cs{inhibitglue} が内部的には「現在のリスト中にwhatsitノードを
5427   追加する」ことを行なっているからである.
5428 %</ja>
5429
5430 %<*en>
5431 \item The call of \cs{inhibitglue} in math mode is just ignored.
5432 %</en>
5433 %<*ja>
5434 \item \cs{inhibitglue} を数式モード中で呼び出した場合はただ無視される.
5435 %</ja>
5436
5437 %<*ja>
5438 \item \LaTeX で\LuaTeX-ja を使用する場合は,
5439 \cs{inhibitglue} の代わりとして \verb+\<+ を使うことができる.
5440 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
5441 注意すること.
5442 %</ja>
5443 \end{itemize}
5444
5445
5446 \subsection{\cs{ltjdeclarealtfont}}
5447 \label{ssec-altfont}
5448 %<*en>
5449 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
5450 This \cs{ltjdeclarealtfont} uses in the following form:
5451 \begin{quote}
5452 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5453 \end{quote}
5454 where  <base\_font\_cs>~and~<alt\_font\_cs> are defined by \cs{jfont}.
5455 Its meaning is
5456 \begin{quote}
5457 If the current Japanese font is <base\_font\_cs>, characters which belong to <range>
5458 is typeset by another Japanese font <alt\_font\_cs>, instead of <base\_font\_cs>.
5459 \end{quote}
5460
5461 <range> is a comma-separated list of character codes, but also accepts negative integers:
5462 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
5463 by <base\_font\_cs>. Note that characters which do not exist in <alt\_font\_cs> are
5464 ignored.
5465
5466 For example, if \cs{hoge} uses \texttt{jfm-ujis.lua}, the standard JFM of \LuaTeX-ja,
5467 then
5468 \begin{lstlisting}
5469 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5470 \end{lstlisting}
5471 does
5472 \begin{quote}
5473 If the current Japanese font is \cs{hoge}, \texttt{U+3000}--\texttt{U+30FF}
5474 and characters in class~1 (ideographic opening brackets)
5475 are typeset by \cs{piyo}.
5476 \end{quote}
5477 %</en>
5478 %<*ja>
5479 \cs{jfont} の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
5480 使用出来る「実際のフォント」は1つである.
5481 しかし,\cs{ltjdeclarealtfont} を用いると,この原則から外れることができる.
5482
5483 \cs{ltjdeclarealtfont} は以下の書式で使用する:
5484 \begin{quote}
5485 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5486 \end{quote}
5487 これは「現在の和文フォント」が<base\_font\_cs>であるとき,
5488 <range>に属する文字は<alt\_font\_cs>を用いて組版される,という意味である.
5489 \begin{itemize}
5490  \item <base\_font\_cs>, <alt\_font\_cs>は
5491 \cs{jfont} によって定義された和文フォントである.
5492  \item <range>は文字コードの範囲を表すコンマ区切りのリストであるが,
5493    例外として負数$-n$は「<base\_font\_cs>のJFMの文字クラス$n$に属する全ての文字」
5494    を意味する.
5495
5496 <range>中に<alt\_font\_cs>中に実際には存在しない文字が指定された場合は,
5497 その文字に対する設定は無視される.
5498 \end{itemize}
5499
5500 例えば,\cs{hoge} のJFMが\LuaTeX-ja標準の
5501 \ \texttt{jfm-ujis.lua} であった場合,
5502 \begin{lstlisting}
5503 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5504 \end{lstlisting}
5505 は「\cs{hoge} を利用しているとき,
5506 \texttt{U+3000}--\texttt{U+30FF}と
5507 文字クラス1(開き括弧類)中の文字だけは \cs{piyo} を用いる」
5508 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
5509 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
5510 マクロの都合による.
5511 %</ja>
5512
5513
5514
5515 %<en>\section{Commands for \LaTeXe}
5516 %<ja>\section{\LaTeXe 用の命令}
5517
5518 %<en>\subsection{Patch for NFSS2}
5519 %<ja>\subsection{NFSS2へのパッチ}
5520 \label{ssec-nfsspat}
5521
5522 %<*en>
5523 Japanese patch for NFSS2 in \LuaTeX-ja
5524 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
5525 We will describe
5526 commands which are not described in Subsection~\ref{ssec-chgfnt}.
5527 %</en>
5528 %<*ja>
5529 \LuaTeX-jaのNFSS2への日本語パッチは
5530 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
5531 和文エンコーディングの管理等をLuaで書きなおしたものである.
5532 ここでは\ref{ssec-chgfnt}節で述べていなかった命令について
5533 記述しておく.
5534 %</ja>
5535
5536 \begin{cslist}%
5537 \item[\normalfont\bfseries %
5538 %<ja>追加の長さ変数達
5539 %<en>additonal dimensions
5540 ]
5541 %<*en>
5542 Like \pLaTeXe, \LuaTeX-ja defines the following dimensions
5543 for information of current Japanese font:
5544 %</en>
5545 %<*ja>
5546 \pLaTeXe と同様に,\LuaTeX-jaは「現在の和文フォントの情報」を格納する長さ変数
5547 %</ja>
5548 \begin{quote}
5549  \cs{cht}~(height), \cs{cdp}~(depth), \cs{cHT}~(sum of former two),\\
5550  \cs{cwd}~(width), \cs{cvs}~(lineskip), \cs{chs}~(equals to \cs{cwd})
5551 \end{quote}
5552 %<en>and its \cs{normalsize} version:
5553 %<ja>と,その \cs{normalsize} 版である
5554 \begin{quote}
5555  \cs{Cht}~(height), \cs{Cdp}~(depth),
5556  \cs{Cwd}~(width), \\\cs{Cvs}~(equals to \cs{baselineskip}),
5557  \cs{Chs}~(equals to \cs{cwd})%
5558 %<en>.
5559 \end{quote}
5560 %<*ja>
5561 を定義している.なお,\cs{cwd} と \cs{zw},また
5562 \cs{cHT} と \cs{zh} は一致しない可能性がある.なぜなら,
5563 \cs{cwd},~\cs{cHT} は「あ」の寸法から決定されるのに対し,
5564 \cs{zw} と \cs{zh} はJFMに指定された値に過ぎないからである.
5565 %</ja>
5566 %<*en>
5567 Note that \cs{cwd}~and~\cs{cHT} may  differ from \cs{zw}~and~\cs{zh}
5568 respectively.
5569 On the one hand the former dimensions are determined from the character ``あ'',
5570 but on the other hand \cs{zw}~and~\cs{zh} are specified by JFM.
5571 %</en>
5572
5573
5574 \item[\cs{DeclareYokoKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5575 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5576 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5577 \item[\cs{DeclareTateKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5578
5579 %<*en>
5580 In NFSS2 under \LuaTeX-ja, distinction between alphabetic font families
5581              and Japanese font families are only made by their
5582              encodings. For example, encodings OT1 and T1 are for
5583              alphabetic font families, and a Japanese font family cannot
5584              have these encodings. These command define a new encoding
5585              scheme for Japanese font families.
5586 %</en>
5587 %<*ja>
5588 \LuaTeX-jaのNFSS2においては,欧文フォントファミリと和文フォントファミリは
5589 そのエンコーディングによってのみ区別される.
5590 例えば,OT1とT1のエンコーディングは欧文フォントファミリに対するものであり,
5591 和文フォントファミリはこれらのエンコーディングを持つことはできない.
5592 これらコマンドは横組用・縦組用和文フォントのための新しいエンコーディングを
5593 それぞれ定義する.
5594 %</ja>
5595
5596 \item[\cs{DeclareKanjiEncodingDefaults}\{<text-settings>\}\{<math-settings>\}]
5597 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5598 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5599 \item[\cs{DeclareKanjiSubstitution}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
5600 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5601 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5602 \item[\cs{DeclareErrorKanjiFont}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
5603
5604 %<*en>
5605 The above 3~commands are just the counterparts for \cs{DeclareFontEncodingDefaults} and~others.
5606 %</en>
5607 %<*ja>
5608 上記3つのコマンドはちょうど \cs{DeclareFontEncodingDefaults} などに対応するものである.
5609 %</ja>
5610
5611 \item[\cs{reDeclareMathAlphabet}\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
5612
5613 % ToDo: en
5614 %<*ja>
5615 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
5616 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>(\cs{mathrm} 等)と,和文数式用フォ
5617              ントファミリ変更の命令<ja-cmd>(\cs{mathmc} 等)の2つを同時に行う命令として
5618              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
5619              <al-cmd>に同じものを指定する,すなわち,<al-cmd>で和文側も変
5620              更させるようにするのが一般的と思われる.
5621
5622 本命令は
5623 \begin{center}\tt
5624 <unified-cmd>\{<arg>\}\quad$\longrightarrow$\quad
5625 (<al-cmd>の1段展開結果)\{<ja-cmd>の1段展開結果)\{<arg>\}\}
5626 \end{center}
5627 と定義を行うので,使用には注意が必要である:
5628 %<en>\vspace{-\medskipamount}
5629 \begin{itemize}
5630 \item <al-cmd>,~<ja-cmd>は既に定義されていなければならない.
5631       \cs{reDeclareMathAlphabet}\\の後に
5632 両命令の内容を再定義しても,<unified-cmd>の内容にそれは反映されない.
5633 \item <al-cmd>,~<ja-cmd>に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
5634 \end{itemize}
5635 %</ja>
5636
5637 \item[\cs{DeclareRelationFont}\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\*
5638   \null\hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
5639 %<*en>
5640 This command sets the ``accompanied'' alphabetic font family (given by the latter 4~arguments)
5641 with respect to a Japanese font family given by the former 4~arguments.
5642 %</en>
5643 %<*ja>
5644 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントファミリに対して,
5645 そのフォントに対応する「従属欧文」のフォントファミリを後半の4引数により与える.
5646 %</ja>
5647 \item[\cs{SetRelationFont}]
5648 %<*en>
5649 This command is almost same as \cs{DeclareRelationFont}, except that this command does a local
5650 assignment, where \cs{DeclareRelationFont} does a global assignment.
5651 %</en>
5652 %<*ja>
5653 このコマンドは \cs{DeclareRelationFont} とローカルな指定であることを除いて
5654 ほとんど同じである(\cs{DeclareRelationFont} はグローバル).
5655 %</ja>
5656
5657 \item[\cs{userelfont}]
5658 %<*en>
5659 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
5660              font family with respect to current Japanese font family,
5661              which was set by
5662              \cs{DeclareRelationFont} or \cs{SetRelationFont}.
5663 Like \cs{fontfamily}, \cs{selectfont} is required to take an effect.
5664 %</en>
5665 %<*ja>
5666 現在の欧文フォントのエンコーディング/ファミリ/…… を,
5667 \cs{DeclareRelationFont} か \cs{SetRelationFont} で指定された
5668 現在の和文フォントファミリに対応する「従属欧文」フォントファミリに変更する.
5669 \cs{fontfamily} のように,有効にするためには \cs{selectfont} が必要である.
5670 %</ja>
5671
5672 \item[\cs{adjustbaseline}]
5673 %<*en>
5674 In \pLaTeXe, \cs{adjustbaseline} sets \cs{tbaselineshift}
5675 to match the vertical center of ``M'' and that of ``あ''  in vertical typesetting:
5676 \[
5677 \text{\cs{tbaselineshift}} \leftarrow
5678 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5679   + d_{\text{あ}} - d_{\text{M}},
5680 \]
5681 where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively.
5682 In \LuaTeX-ja, this \cs{adjustbaseline} does same task.
5683 %</en>
5684 %<*ja>
5685 \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「あ」の中心線を一致させるために,
5686 \cs{tbaselineshift} を設定する役割を持っていた:
5687 \[
5688 \text{\cs{tbaselineshift}} \leftarrow
5689 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5690   + d_{\text{あ}} - d_{\text{M}},
5691 \]
5692 ここで,$h_{a}$,~$d_{a}$はそれぞれ「$a$」の高さ・深さを表す.
5693 \LuaTeX-jaにおいても\cs{adjustbaseline} は同様の処理を行っている.
5694 %</ja>
5695
5696 \item[\cs{fontfamily}\{<family>\}]
5697 %<*en>
5698 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
5699 to <family>. Which family will be changed is determined as follows:
5700 %</en>
5701 %<*ja>
5702 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
5703 和文,\emph{もしくは両方})を<family>に変更する.
5704 どのファミリが変更されるかは以下のようにして決定される:
5705 %</ja>
5706 \begin{itemize}
5707 %<*en>
5708 \item Let current encoding scheme for Japanese fonts be
5709       <ja-enc>. Current Japanese font family will be changed to
5710       <family>, if one of the following two conditions is met:
5711 %</en>
5712 %<*ja>
5713 \item 現在の和文フォントに対するエンコーディングが<ja-enc>であるとしよう.
5714   現在の和文フォントファミリは,以下の2つの条件のうちの1つが満たされているときに
5715   <family>に変更される:
5716 %</ja>
5717 \begin{itemize}
5718 %<*en>
5719 \item The family <family> under the encoding <ja-enc> has been already defined by
5720       \cs{DeclareKanijFamily}.
5721 %</en>
5722 %<*ja>
5723 \item エンコーディング<ja-enc>におけるファミリ<family>が
5724 既に \cs{DeclareKanjiFamily} によって定義されている.
5725 %</ja>
5726 %<*en>
5727 \item A font definition named \texttt{<ja-enc><family>.fd} (the file name is
5728       all lowercase) exists.
5729 %</en>
5730 %<*ja>
5731 \item フォント定義ファイル\texttt{<ja-enc><family>.fd}(ファイル名は全て小文字)が存在する.
5732 %</ja>
5733 \end{itemize}
5734 %<*en>
5735 \item Let current encoding scheme for alphabetic fonts be
5736       <al-enc>. For alphabetic font family, the criterion as above is used.
5737 %</en>
5738 %<*ja>
5739 \item 現在の欧文フォントに対するエンコーディングを<al-enc>とする.
5740   欧文フォントファミリに対しても,上記の基準が用いられる.
5741 %</ja>
5742 %<*en>
5743 \item There is a case which none of the above applies, that is, the font
5744       family named <family> doesn't seem to be defined neither under the
5745       encoding <ja-enc>, nor under <al-enc>.
5746 In this case, the default family for font substitution is used for
5747       alphabetic and Japanese fonts. Note that current encoding will not
5748       be set to <family>, unlike the original implementation in \LaTeX.
5749 %</en>
5750 %<*ja>
5751 \item 上記のいずれもが適用されない,つまり<family>が<ja-enc>と<al-enc>の
5752   どちらでも定義されないような場合がある.
5753   この場合,代替フォントに用いられるデフォルトのフォントファミリが欧文フォントと
5754   和文フォントに用いられる.\LaTeX のオリジナルの実装とは異なり,
5755   現在のエンコーディングは<family>には設定されないことに注意する.
5756 %</ja>
5757 \end{itemize}%
5758 %<en>\vspace{-\medskipamount}
5759
5760
5761 \begin{figure}[!tb]
5762 \begin{LTXexample}[pos=b]
5763 \DeclareKanjiFamily{JY3}{edm}{}
5764 \DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
5765 \DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
5766 \DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
5767 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
5768 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
5769 {\kanjifamily{edm}\selectfont
5770 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
5771 \end{LTXexample}
5772 %<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
5773 %<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
5774 \label{fig:altkanji}
5775 \end{figure}
5776
5777 \item[\cs{DeclareAlternateKanjiFont}\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
5778   \null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
5779 %<*ja>
5780 \ref{ssec-altfont}節の\
5781 \cs{ltjdeclarealtfont} と同様に,前半の4引数の
5782 和文フォント(基底フォント)のうち<range>中の文字を
5783 第5から第8引数の和文フォントを使って組むように指示する.
5784 使用例を図\nobreak\ref{fig:altkanji}に載せた.
5785
5786 \begin{itemize}
5787  \item
5788 \cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
5789              ないといけない(その代わり即時発効)であったが,
5790 \cs{DeclareAlternateKanjiFont} の設定が
5791 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
5792 あるいは(これらを含むが)\cs{selectfont} が実行された時である.
5793  \item
5794 段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
5795 <range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
5796 と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
5797 \end{itemize}%
5798 %</ja>
5799 %<*en>
5800 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}),
5801 characters in <range> of the Japanese font (we say the \emph{base font})
5802 which specified by first 4 arguments are typeset
5803 by the Japanese font which specified by fifth to eighth arguments
5804 (we say the \emph{alternate font}).
5805 An example is shown in Figure~\ref{fig:altkanji}.
5806
5807 \begin{itemize}
5808  \item
5809 In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
5810 But this \cs{DeclareAlternateKanjiFont} is not so.
5811 In other words, \cs{DeclareAlternateKanjiFont} is effective only after
5812 current Japanese font is changed, or only after \cs{selectfont} is executed.
5813  \item \dots
5814 \end{itemize}%
5815 \vspace{-\medskipamount}
5816 %</en>
5817 \end{cslist}
5818
5819 %<*en>
5820 As closing this subsection, we shall introduce an example of
5821 \cs{SetRelationFont} and \cs{userelfont}:
5822 %</en>
5823 %<*ja>
5824 この節の終わりに,\cs{SetRelationFont} と \cs{userelfont} の例を
5825 紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
5826 Avant Garde (OT1/pag/m/n) に変わっていることがわかる.
5827 %</ja>
5828 \begin{LTXexample}[width=0.3\textwidth]
5829 \makeatletter
5830 \SetRelationFont{JY3}{\k@family}{m}{n}{OT1}{pag}{m}{n}
5831   % \k@family: current Japanese font family
5832 \userelfont\selectfont あいうabc
5833 \end{LTXexample}
5834
5835 %<*en>
5836 \section{Addons}
5837 \LuaTeX-ja has several addon packages.
5838 These addons are written as \LaTeX\ packages, but
5839 \Pkg{luatexja-otf} and~\Pkg{luatexja-adjust} can be loaded in plain \LuaTeX\
5840 by \cs{input}.
5841 %</en>
5842 %<*ja>
5843 \section{拡張}
5844 \LuaTeX-jaには(動作には必須ではないが)自由に読み込める拡張が付属している.
5845 これらは\LaTeX のパッケージとして制作しているが,
5846 \Pkg{luatexja-otf}と\Pkg{luatexja-adjust}についてはplain \LuaTeX でも\
5847 \cs{input} で読み込み可能である.
5848 %</ja>
5849 \subsection{\texttt{luatexja-fontspec.sty}}
5850 \label{ssec-fontspec2}
5851 %<*en>
5852 As described in Subsection~\ref{ssec-fontspec}, this optional package
5853 provides the counterparts for several commands defined in the
5854 \Pkg{fontspec} package (requires \Pkg{fontspec}~v2.4).
5855 In addition to OpenType font features in the original \Pkg{fontspec},
5856 the following ``font features'' specifications are allowed for
5857 the commands of Japanese version:
5858 %</en>
5859 %<*ja>
5860 \ref{ssec-fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}
5861 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
5862 \emph{以下に述べる和文版の命令の説明は \Pkg{fontspec}~v2.4 使用時にのみ当てはまる.}
5863
5864 \Pkg{fontspec}パッケージで指定可能な各種font featureに加えて,和文版のコマンドには
5865 以下の``font feature''を指定することができる:
5866 %</ja>
5867
5868
5869 \begin{cslist}
5870 \item[CID=<name>\textrm{, }JFM=<name>\textrm{, }JFM-var=<name>]
5871
5872 %<*en>
5873 These 3 keys correspond to \texttt{cid}, \texttt{jfm} and
5874 \texttt{jfmvar} keys for \cs{jfont}~and~\cs{tfont} respectively.
5875 See Subsections~\ref{ssec-jfont} and \ref{ssec-psft} for details
5876  of \texttt{cid}, \texttt{jfm} and
5877 \texttt{jfmvar} keys.
5878
5879 The \texttt{CID} key is effective only when with \texttt{NoEmbed}
5880 described below. The same JFM cannot be used in both horizontal Japanese fonts and
5881              vertical Japanese fonts, hence the \texttt{JFM} key
5882 will be actually used in \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
5883 %</en>
5884 %<*ja>
5885 これら3つのキーはそれぞれ \cs{jfont},~\cs{tfont}に対する
5886 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
5887 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec-jfont}節
5888              と\ref{ssec-psft}節を参照.
5889
5890 \texttt{CID} キーは下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
5891 また,横組用JFMと縦組用JFMは共用できないため,実際に \texttt{JFM} キーを用いる際は
5892 後に述べる\ \texttt{YokoFeatures} キーや \texttt{TateFeatures}\ の中で用いる
5893 ことになる.
5894 %</ja>
5895
5896 \item[NoEmbed]
5897 %<*en>
5898 By specifying this key, one can use ``name-only'' Japanese font which
5899 will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
5900 %</en>
5901 %<*ja>
5902 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
5903 できる.\ref{ssec-psft}節を参照.
5904 %</ja>
5905
5906 \begin{figure}[!tb]
5907 \begin{LTXexample}
5908 \jfontspec[
5909   YokoFeatures={Color=007F00},
5910   TateFeatures={Color=00007F},
5911   TateFont=KozGoPr6N-Regular
5912 ]{KozMinPr6N-Regular}
5913 \hbox{\yoko 横組のテスト}
5914 \hbox{\tate 縦組のテスト}
5915 \end{LTXexample}
5916 %<ja>\caption{\texttt{TateFeatures} 等の使用例}
5917 %<en>\caption{An example of \texttt{TateFeatures} etc.}
5918 \label{fig:yokotate-fontspec}
5919 \end{figure}
5920
5921
5922 \item[TateFeatures=\{<features>\}\textrm{, }TateFont=<font>]
5923 %<en> ...
5924 %<*ja>
5925 縦組において使用されるフォントや,縦組においてのみ適用されるfeature達を
5926 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
5927 %</ja>
5928
5929 \item[YokoFeatures=\{<features>\}]
5930 %<en> ...
5931 %<*ja>
5932 横組においてのみ適用されるfeature達を
5933 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
5934 %</ja>
5935
5936
5937 \begin{figure}[!tb]
5938 \begin{LTXexample}[pos=b]
5939 \jfontspec[
5940   AltFont={
5941     {Range="4E00-"67FF, Color=007F00},
5942     {Range="6800-"9EFF, Color=0000FF},
5943     {Range="3040-"306F, Font=KozGoPr6N-Regular},
5944   }
5945 ]{KozMinPr6N-Regular}
5946 日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
5947 諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
5948 \end{LTXexample}
5949 %<ja>\caption{\texttt{AltFont} の使用例}
5950 %<en>\caption{An example of \texttt{AltFont}}
5951 \label{fig:altkanji-fontspec}
5952 \end{figure}
5953
5954 \item[AltFont]
5955
5956 %<*en>
5957 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}) and
5958 \cs{DeclareAlternateKanjiFont}~(Subsection~\ref{ssec-nfsspat}),
5959 with this key, one can typeset some Japanese characters
5960 by a different font and/or using different features.
5961 The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
5962 as the following:
5963 %</en>
5964 %<*ja>
5965 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} や,
5966 \ref{ssec-nfsspat}節の \cs{DeclareAlternateKanjiFont} と同様に,
5967 このキーを用いると一部の文字を異なったフォントやfont featureを使って組むことができる.
5968 \texttt{AltFont} キーに指定する値は,次のように二重のコンマ区切りリストである:
5969 %</ja>
5970 \begin{lstlisting}[escapechar=\#]
5971 AltFont = {
5972   ...
5973   { Range=#\LARG range>#, #\LARG features>#},
5974   { Range=#\LARG range>#, Font=#\LARG font~name>#, #\LARG features># },
5975   { Range=#\LARG range>#, Font=#\LARG font~name># },
5976   ...
5977 }
5978 \end{lstlisting}
5979 %<*en>
5980 Each sublist should have the \texttt{Range} key
5981 (sublist which does not contain \texttt{Range} key is simply ignored).
5982 A demonstrarion is shown in Figure~\ref{fig:altkanji-fontspec}.
5983 %</en>
5984 %<*ja>
5985 各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
5986 単純に無視される).指定例は図\ref{fig:altkanji-fontspec}に示した.
5987 %</ja>
5988 \end{cslist}
5989
5990 %<*ja>
5991 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
5992 \texttt{<ja-enc><family>.fd}は全く参照されなくなる.
5993 %</ja>
5994
5995
5996 %<*en>
5997 \paragraph{Remark on \texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} keys}
5998 In \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures} keys,
5999 one cannot specify per-shape settings such as \texttt{BoldFeatures}.
6000 For example,
6001 \begin{lstlisting}
6002 AltFont = {
6003   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6004     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6005 }
6006 \end{lstlisting}
6007 does \emph{not} work. Instead, one have to write
6008 \begin{lstlisting}
6009 UprightFeatures = {
6010   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6011 },
6012 BoldFeatures = {
6013   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6014 }
6015 \end{lstlisting}
6016
6017 On the other hand, \texttt{YokoFeatures}, \texttt{TateFeatures} and  \texttt{TateFont}
6018 keys can be specified in each list in the \texttt{AltFont} key. Also,
6019 one can specify \texttt{AltFont} inside \texttt{YokoFeatures},~\texttt{TateFeatures}.
6020 %</en>
6021 %<*ja>
6022 \paragraph{\texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} 等の制限}
6023 \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures}の各キーは
6024 シェイプ別に指定されるべきものであり,
6025 内部では \texttt{BoldFeatures} などのシェイプ別の指定は行うことが出来ない.
6026 例えば.
6027 \begin{lstlisting}
6028 AltFont = {
6029   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6030     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6031 }
6032 \end{lstlisting}
6033 のように指定することは出来ず,
6034 \begin{lstlisting}
6035 UprightFeatures = {
6036   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6037 },
6038 BoldFeatures = {
6039   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6040 }
6041 \end{lstlisting}
6042 のように指定しなければならない.
6043
6044 一方,\texttt{AltFont} キー内の各リストでは
6045 \ \texttt{YokoFeatures},~\texttt{TateFeatures} 及び \texttt{TateFont} キーを
6046 指定することは可能であり.また\ \texttt{YokoFeatures},~\texttt{TateFeatures} キーの
6047 中身に \texttt{AltFont} を指定することができる.
6048 %</ja>
6049
6050
6051 \subsection{\texttt{luatexja-otf.sty}}
6052 \label{ssec-ltjotf}
6053 %<*en>
6054 This optional package supports typesetting characters in
6055 Adobe-Japan1 character collection
6056 (or other CID character collection, if the font is supported).
6057 The package \Pkg{luatexja-otf} offers the following 2~low-level
6058 commands:
6059 %</en>
6060 %<*ja>
6061 この追加パッケージはAdobe-Japan1(フォント自身が持っていれば,
6062 別のCID文字セットでも可)の文字の出力をサポートする.
6063 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
6064 %</ja>
6065 \begin{cslist}
6066 \item[\cs{CID}\{<number>\}]
6067 %<*en>
6068 Typeset a character whose CID number is <number>.
6069 %</en>
6070 %<*ja>
6071 CID番号が<number>の文字を出力する.
6072 %</ja>
6073
6074 \item[\cs{UTF}\{<hex\_number>\}]
6075 %<*en>
6076 Typeset a character whose character code is <hex\_number> (in hexadecimal).
6077 This command is similar to \verb+\char"+<hex\_number>,\ %"
6078 but please remind remarks below.
6079 %</en>
6080 %<*ja>
6081 文字コードが(16進で)<hex\_number>の文字を出力する.
6082 このコマンドは \verb+\char"+<hex\_number>と似ているが,下の記述に注意すること.%"
6083 %</ja>
6084 \end{cslist}
6085
6086 %<*ja>
6087 このパッケージは,\texttt{ajmacros.sty}(\Pkg{otf}パッケージ付属のマクロ集,井上浩一氏作)から
6088 漢字コードをUTF8にしたり,plain \LuaTeX でも利用可能にするという
6089 修正を加えた \texttt{luatexja-ajmacros.sty} も自動的に読み込む.
6090 そのため,\texttt{ajmacros.sty} マクロ集にある \verb+\aj半角+ などのマクロもそのまま使用可能である.
6091 %</ja>
6092
6093 %<en>\paragraph{Remarks}
6094 %<ja>\paragraph{注意}
6095 %<*en>
6096 Characters by \cs{CID} and \cs{UTF} commands are different from
6097 ordinary characters in the following points:
6098 %</en>
6099 %<*ja>
6100 \cs{CID} と \cs{UTF} コマンドによって出力される文字は
6101 以下の点で通常の文字と異なる:
6102 %</ja>
6103 \begin{itemize}
6104 %<*en>
6105 \item Always treated as \textbf{JAchar}s.
6106 %</en>
6107 %<*ja>
6108 \item 常に\textbf{JAchar}として扱われる.
6109 %</ja>
6110 %<*en>
6111 \item Processing codes for supporting OpenType features (\textit{e.g.},
6112       glyph replacement and kerning) by the \Pkg{luaotfload} package
6113       is not performed to these characters.
6114 %</en>
6115 %<*ja>
6116 \item OpenType feature(例えばグリフ置換やカーニング)をサポートするための
6117   \Pkg{luaotfload}パッケージのコードはこれらの文字には働かない.
6118 %</ja>
6119 \end{itemize}
6120
6121 %<en>\paragraph{Additional syntax of JFM}
6122 %<ja>\paragraph{JFMへの記法の追加}
6123
6124 %<*en>
6125 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
6126 chars} table in JFM now allows a string in the form
6127 \verb+'AJ1-xxx'+, which stands for the character
6128 whose CID number in Adobe-Japan1 is \verb+xxx+.
6129
6130 This extended notation is used in the standard JFM \texttt{jfm-ujis.lua}
6131 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
6132 %</en>
6133 %<*ja>
6134 \Pkg{luatexja-otf}パッケージを読み込むと,
6135 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
6136 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
6137
6138 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
6139 正しく半角幅で組むために利用されている.
6140 %</ja>
6141
6142 %<*en>
6143 \paragraph{IVS support}
6144 Recent fonts support Ideographic Variation Selector (IVS).
6145 It seems that \Pkg{luaotfload} and \Pkg{fontspec} packages do not support
6146 IVS, so we implemented IVS support in \Pkg{luatexja-otf}.
6147 \emph{IVS support is experimental; if you want to enable this, load
6148 \Pkg{luatexja-otf} and execute the following:}
6149 %</en>
6150 %<*ja>
6151 \paragraph{IVSサポート}
6152 最近のOpenTypeフォントやTrueTypeフォントには,
6153 \texttt{U+E0100}--\texttt{U+E01EF}の範囲の「文字」
6154 (漢字用異体字セレクタ)を後置することによって
6155 字形を指定する仕組み(IVS)が含まれている.
6156 執筆時点の2013年12月では,\Pkg{luaotfload}や\Pkg{fontspec}パッケージ類は
6157 IVSに対応してはいないようである.これらのパッケージで対応してくれるのが理想的だが,
6158 それまでのつなぎとして,\Pkg{luatexja-otf}パッケージ内にIVS対応を仕込んでおいた.
6159
6160 \medskip
6161
6162 \emph{IVS対応は試験的なものである.
6163 有効にするには,\Pkg{luatexja-otf}パッケージを読み込んだ上で以下の命令を実行する%
6164 \footnote{この命令を2回以上実行しても意味がない.}:}
6165 %</ja>
6166 \begin{lstlisting}
6167 \directlua{luatexja.otf.enable_ivs()}
6168 \end{lstlisting}
6169 %<ja> すると,上の命令を実行した箇所以降では,以下のようにIVSによる字形指定が有効となる.
6170 %<en> After executing the command above, you can use IVS like the following:
6171 \begin{LTXexample}
6172 \Large
6173 \jfontspec{KozMinPr6N-Regular}
6174 奈良県葛󠄀城市と,東京都葛󠄁飾区.\\
6175 こんにちは,渡
6176 邉󠄀邉󠄁邉󠄂邉󠄃邉󠄄
6177 邉󠄅邉󠄆邉󠄇邉󠄈邉󠄉
6178 邉󠄊邉󠄋邉󠄌邉󠄍邉󠄎
6179 さん.
6180 \end{LTXexample}
6181 %<*ja>
6182 左上側の入力においては,漢字用異体字セレクタを明示するため,
6183 例えばVariation~Selector~18 (\texttt{U+E0101})を\IVSB{18}のように表記している.
6184 %</ja>
6185 \medskip
6186
6187 %<*en>
6188 Specifying glyph variants by IVS precedes glyph replacement by font features.
6189 For example, only ``葛'' in ``葛西'' is changed by font features
6190 \texttt{jp78}~or~\texttt{jp90}, which does not followed by any variation selector.
6191 %</en>
6192 %<*ja>
6193 また,IVSによる字形指定は,font featureによるそれに優先されることとした.
6194 下の例において,\texttt{jp78}, \texttt{jp90} 指定で字形が変化した文字は
6195 異体字セレクタが続いていない「葛西」中の「葛」のみである.
6196 %</ja>
6197 \begin{LTXexample}
6198  \def\TEST#1{%
6199    {\jfontspec[#1]{KozMinPr6N-Regular}%
6200    葛󠄀城市,葛󠄁飾区,葛西}\\}
6201  指定なし:\TEST{}
6202  \texttt{jp78}:\TEST{CJKShape=JIS1978}
6203  \texttt{jp90}:\TEST{CJKShape=JIS1990}
6204 \end{LTXexample}
6205
6206 %<*ja>
6207 現状では,\TeX 側のインターフェースとなる \Pkg{luatexja-otf.sty} は一切変更していない
6208 ので,ZRさんによる\Pkg{PXipamjm}パッケージ%
6209 \footnote{\url{https://github.com/zr-tex8r/PXipamjm}. 説明は彼のブログ記事
6210 「pxipamjm パッケージの説明書のような何か(\url{http://d.hatena.ne.jp/zrbabbler/20131221})」
6211 にある.}
6212 にあるような気の利いた命令はまだない.
6213 異体字の一覧表示を行いたい場合は,gitリポジトリ内の \texttt{test/test19-ivs.tex} 中にある
6214 Lua・\TeX コードが参考になるだろう.
6215 %</ja>
6216
6217
6218 \subsection{\texttt{luatexja-adjust.sty}}
6219 \label{ssec-adj}
6220 \begin{figure}[t]
6221 \def\sq{%
6222   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6223    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6224   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6225 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6226   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6227   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6228 \newbox\gridbox
6229 \def\outbox#1{{\Large%
6230   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
6231   \setbox\gridbox=\hbox to 20\zw{\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb}%
6232   \hbox{\textcolor{cyan}{\copy\gridbox}\hskip-20\zw%
6233   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
6234 }}
6235
6236 {\centering
6237 \begin{tabular}{lc}
6238 \toprule
6239 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
6240 without priority&%
6241 \ltjdisableadjust
6242 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
6243 \ltjenableadjust\\
6244 with priority&%
6245 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
6246 %<en>\ltjdisableadjust
6247 \\
6248 \bottomrule
6249 \end{tabular}\par}
6250 \smallskip
6251
6252 Note: the value of
6253 \Param{kanjiskip} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
6254 for making the difference obvious.
6255 %<ja>\caption{行長調整}\label{fig-adj}
6256 %<en>\caption{Line adjustment}\label{fig-adj}
6257 \end{figure}
6258
6259
6260 %<*en>
6261 (see Japanese version of this manual)
6262 %</en>
6263 %<*ja>
6264 \pTeX では,行長調整において優先度の概念が存在しなかったため,図
6265 \ref{fig-adj}上段における半角分の半端は,図\ref{fig-adj}中段のように,鍵
6266 括弧周辺の空白と和文間空白(\Param{kanjiskip})の両方によって負担される.し
6267 かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
6268 ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
6269 文字はベタ組で組まれる(図\ref{fig-adj}下段)ことになっている.この追加
6270 パッケージは\cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
6271 の行長調整を提供する.詳細な仕様については\ref{sec-adjspec}章を参照してほしい.
6272 \begin{itemize}
6273  \item 優先度付き行長調整は,段落を行分割した後に個々の行について行われるものである.
6274 そのため,行分割の位置は変化することはない.
6275
6276 また,\verb+\hbox to ... {...}+ のような「幅が指定されたhbox」では無効である.
6277  \item 優先度付き行長調整を行うと,和文処理グルーの自然長は変化しないが,伸び量や縮み量は
6278 一般に変化する.そのため,既に組まれた段落を \cs{unhbox} などを利用して組み直す処理を
6279 行う場合には注意が必要である.
6280 \end{itemize}
6281
6282
6283 \Pkg{luatexja-adjust} は,以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
6284
6285 \begin{cslist}
6286 \item[\cs{ltjdisableadjust}]
6287 優先順位付きの行長調整を無効化する.
6288
6289 \item[\cs{ltjenableadjust}]
6290 優先順位付きの行長調整を有効化する.
6291
6292 \item[\textsf{adjust}\,=<bool>] \cs{ltjsetparameter} で指定可能な追加パラメータであり,
6293 <bool>が\textit{true}なら \cs{ltjenableadjust} を,
6294 そうでなければ \cs{ltjdisableadjust} を実行する.
6295 \end{cslist}
6296 %</ja>
6297
6298 \subsection{\texttt{luatexja-ruby.sty}}
6299 %<*en>
6300 This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
6301 using callbacks of \LuaTeX-ja.
6302 There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
6303 (Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
6304 %</en>
6305 %<*ja>
6306 この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
6307 前後の文字種に応じた前後への自動進入や,
6308 行頭形・行中形・行末形の自動的な使い分けが特徴である.
6309
6310 ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
6311 使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
6312 この節では簡単な使用方法のみ述べる.
6313 %</ja>
6314
6315 \begin{description}
6316 %<*en>
6317  \item[Group-ruby]
6318 By default, ruby characters (the second argument of \cs{ruby})
6319 are attached to base characters (the first argument), as one object.
6320 This type of ruby is called \emph{group-ruby}.
6321 %</en>
6322 %<*ja>
6323  \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
6324 第2引数にルビを記述する.
6325 %</ja>
6326 \begin{LTXexample}[width=0.3\textwidth]
6327 東西線\ruby{妙典}{みようでん}駅は……\\
6328 東西線の\ruby{妙典}{みようでん}駅は……\\
6329 東西線の\ruby{妙典}{みようでん}という駅……\\
6330 東西線\ruby{葛西}{かさい}駅は……
6331 \end{LTXexample}
6332 %<*en>
6333 As the above example, ruby hangover is allowed on the Hiragana before/after
6334 its base characters.
6335 %</en>
6336 %<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
6337
6338 %<*en>
6339 \item[Mono-ruby]
6340 To attach ruby characters to each base characters (\emph{mono-ruby}),
6341 one should use \cs{ruby} multiple times:
6342 %</en>
6343 %<*ja>
6344  \item[モノルビ] 親文字を1文字にするとモノルビとなる.
6345 2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
6346 その数だけ \cs{ruby} を書く必要がある.
6347 %</ja>
6348 \begin{LTXexample}[width=0.3\textwidth]
6349 東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
6350 \end{LTXexample}
6351
6352 %<*en>
6353  \item[Jukugo-ruby]
6354 Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
6355 %</en>
6356 %<*ja>
6357  \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
6358 複数グループのルビは熟語ルビとして組まれる.
6359 \cite{x4051}にあるように,
6360 どのグループでも「親文字」が対応するルビ以上の長さの場合は
6361 各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
6362 \cite{jlreq}で規定されている組み方とは異なるので注意.
6363 %</ja>
6364 \begin{LTXexample}
6365 \ruby{妙|典}{みよう|でん}\
6366 \ruby{葛|西}{か|さい}\
6367 \ruby{神楽|坂}{かぐら|ざか}
6368 \end{LTXexample}
6369 %<*en>
6370 If there are multiple groups in one \cs{ruby} call,
6371 A linebreak between two groups is allowed.
6372 %</en>
6373 %<ja> 複数ルビではグループとグループの間で改行が可能である.
6374 \begin{LTXexample}[width=0.3\textwidth]
6375 \vbox{\hsize=6\zw\noindent
6376   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6377   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6378   \hbox to   3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6379 }
6380 \end{LTXexample}
6381 \end{description}
6382
6383 %<*en>
6384 If the width of ruby characters are longer than that of base characters,
6385 \cs{ruby} automatically selects the appropriate form
6386 among the line-head form, the line-middle form, and the line-end form.
6387 %</en>
6388 %<*ja>
6389 また,ルビ文字のほうが親文字よりも長い場合は,自動的に
6390 行頭形・行中形・行末形のいずれか適切なものを選択する.
6391 %</ja>
6392 \begin{LTXexample}[width=0.3\textwidth]
6393 \vbox{\hsize=8\zw\noindent
6394 \null\kern3\zw ……を\ruby{承}{うけたまわ}る
6395      \kern1\zw ……を\ruby{承}{うけたまわ}る\\
6396 \null\kern5\zw ……を\ruby{承}{うけたまわ}る
6397 }
6398 \end{LTXexample}
6399
6400
6401 %<*ja>
6402 \subsection{\texttt{lltjext.sty}}
6403 \pLaTeX では縦組用の拡張として \Pkg{plext} パッケージが用意されていたが,
6404 それを\LuaTeX-ja用に書きなおしたものが本追加パッケージ \Pkg{lltjext} である.
6405
6406 従来の \Pkg{plext} パッケージとの違いは,
6407 {\catcode`\<=12
6408 \begin{itemize}
6409  \item 組方向オプション \texttt{<y>}(横組),\texttt{<t>}(縦組),
6410 \texttt{<z>}\ の他に\ \texttt{<d>}(dtou方向),\texttt{<u>}(utod方向)を追加した.
6411 \texttt{<z>} と \texttt{<u>} の違いは,\texttt{<z>} が(\Pkg{plext} パッケージと同様に)
6412 周囲の組方向が縦組のときにしか意味を持たない
6413        のに対し,\texttt{<u>} にはそのような制限がないことである.
6414
6415  \item \Pkg{plext} パッケージでは,表組(\texttt{tabular} 環境,\texttt{align} 環境等)や
6416 \texttt{minipage} 環境,\cs{parbox} 命令において,
6417 垂直位置指定 \texttt{[t]},~\texttt{[b]} の挙動が非読み込み時と微妙に変わることがあった.
6418
6419 \Pkg{lltjext} パッケージでは,垂直位置指定が\LaTeXe と同様の挙動(以下に示す)に
6420 なるように修正した.
6421 \begin{itemize}
6422  \item \texttt{[t]} オプション指定時は,ボックスのベースラインが中身の1行目のベースライン
6423        (1行目の上に罫線などが来た時は,ボックスの上端)に一致するように配置する.
6424  \item \texttt{[b]} オプション指定時は,ボックスのベースラインが中身の最終行のベースライン
6425        (中身の最後が罫線などの時は,ボックスの下端)に一致するように配置する.
6426  \item それ以外のときは,ボックスの中央が「数式の軸」に一致するように配置する.
6427 \end{itemize}
6428
6429  \item 連数字用命令 \cs{rensuji} における位置合わせオプション \texttt{[l]}, \texttt{[c]},
6430        \texttt{[r]} の挙動を若干変更した.
6431
6432 \end{itemize}
6433 }
6434 %</ja>
6435 %<*en>
6436 \subsection{\texttt{lltjext.sty}}
6437 \pLaTeX\ supplies additional macros for vertical writing in the \Pkg{plext} package.
6438 The \Pkg{lltjext} package which we want to describe here is the \LuaTeX-ja
6439 counterpart of the \Pkg{plext} package.
6440 %</en>
6441
6442 %<*ja>
6443 念の為,本 \Pkg{lltjext} パッケージで追加・変更している命令の一覧を載せておく.
6444 \begin{cslist}
6445 \item[tabular\textrm{, }array\textrm{, }minipage環境]
6446 これらの環境は,
6447 \begin{lstlisting}
6448 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6449 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6450 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6451 \end{lstlisting}
6452 のように,組方向オプション \texttt{\<dir\>} が拡張されている.
6453 既に述べたように,組方向オプションに指定できる値は以下の5つであり,
6454 それ以外を指定した時や無指定時は周囲の組方向と同じ組方向になる.
6455 \begin{description}
6456  \item[y] 横組(\cs{yoko})
6457  \item[t] 縦組(\cs{tate})
6458  \item[z] 周囲が縦組の時はutod方向,それ以外はそのまま
6459  \item[d] dtou方向
6460  \item[u] utod方向
6461 \end{description}
6462 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6463 \cs{parbox} 命令も同様に,組方向の指定ができるように拡張されている.
6464
6465 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6466 組方向<dir>で<contents>の中身をLRモードで組む命令である.
6467 <width>が正の値であるときは,ボックス全体の幅がその値となる.
6468 その際,中身は<pos>の値に従い,左寄せ(\texttt{l}),右揃え(\texttt{r}),
6469 中央揃え(それ以外)される.
6470 \item[picture環境]
6471 図表作成に用いる \texttt{picture} 環境も,
6472 \begin{lstlisting}
6473 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
6474   ...
6475 \end{picture}
6476 \end{lstlisting}
6477 と組方向が指定できるように拡張されている.
6478 $x$成分の増加方向は字送り方向,$y$成分の増加方向は行送り方向の\emph{反対方向}となる.
6479 \Pkg{plext} パッケージと同様に
6480 内部ではベースライン補正(\Param{yalbaselineshift}パラメータなど)の影響を受けないように,
6481 \cs{put},~\cs{line}, \cs{vector}, \cs{dashbox}, \cs{oval},~\cs{circle}も
6482 ベースライン補正を受けないように再定義されている.
6483
6484 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6485
6486 \item[\cs{Kanji}\{<counter\_name>\}]
6487
6488 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6489                      }\cs{boutenchar}]
6490
6491 \item[参照番号]
6492 \end{cslist}
6493 %</ja>
6494 %<*en>
6495 \begin{cslist}
6496 \item[tabular\textrm{, }array\textrm{, }minipage\textrm{ environments}]
6497 These environments are extended by \texttt{\<dir\>}, which specifies the direction,
6498 as follows:
6499 \begin{lstlisting}
6500 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6501 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6502 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6503 \end{lstlisting}
6504 This option permits one of the following five values. If none of them is specified,
6505 the direction inside the environment is same as that outside the enviromnent.
6506 \begin{description}
6507  \item[y] \emph{yoko} direction (horizontal writing)
6508  \item[t] \emph{tate} direction (vertical writing)
6509  \item[z] \emph{utod} direction if direction outside the env.\ is \emph{tate}.
6510  \item[d] \emph{dtou} direction
6511  \item[u] \emph{utod} direction
6512 \end{description}
6513 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6514 \cs{parbox} command is also extended by \texttt{\<dir\>}.
6515
6516 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6517 This commands typeset <contents> in LR-mode, in <dir> direction.
6518 If <width> is positive, the width of the box becomes this <width>.
6519 In this case, <contents> will be aligned \dots
6520
6521 \item[picture\textrm{environment}]
6522
6523 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6524
6525 \item[\cs{Kanji}\{<counter\_name>\}]
6526
6527 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6528                      }\cs{boutenchar}]
6529
6530 \item[参照番号]
6531 \end{cslist}
6532 %</en>
6533
6534
6535
6536 %<en>\part{Implementations}
6537 %<ja>\part{実装}
6538 \label{part-imp}
6539 %<en>\section{Storing Parameters}
6540 %<ja>\section{パラメータの保持}
6541 \label{sec-para}
6542 %<en>\subsection{Used Dimensions, Attributes and Whatsit Nodes}
6543 %<ja>\subsection{\LuaTeX-jaで用いられるレジスタとwhatsitノード}
6544
6545 %<*en>
6546 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
6547 %</en>
6548 %<*ja>
6549 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
6550 リストである.
6551 %</ja>
6552 \begin{list}{}{%
6553 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
6554 \def\dim#1{\item[\textbackslash #1\ \textrm{(dimension)}]}
6555 \def\cnt#1{\item[\textbackslash #1\ \textrm{(counter)}]}
6556 \def\attr#1{\item[\textbackslash #1\ \textrm{(attribute)}]}
6557 }
6558
6559 \dim{jQ}
6560 %<*en>
6561 \cs{jQ} is equal to
6562                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
6563                         a unit used in Japanese phototypesetting.
6564 So one should not change the value of this dimension.
6565 %</en>
6566 %<*ja>
6567 \cs{jQ} は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
6568 (「級」とも書かれる)に等しい.したがって,
6569 この寸法レジスタの値を変更してはならない.
6570 %</ja>
6571
6572 \dim{jH}
6573 %<*en>
6574 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
6575                          used in Japanese phototypesetting.
6576 This \cs{jH} is the same \cs{dimen} register as \cs{jQ}.
6577 %</en>
6578 %<*ja>
6579 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
6580 等しい.この \cs{jH} は \cs{jQ} と同じ寸法レジスタを指す.
6581 %</ja>
6582
6583 \dim{ltj@zw}
6584 %<*en>
6585 A temporal register for the ``full-width'' of current Japanese font.
6586 The command \cs{zw} sets this register to the correct value, and
6587 ``return'' this register itself.
6588 %</en>
6589 %<*ja>
6590 現在の和文フォントの「全角幅」を保持する一時レジスタ.
6591 \cs{zw} 命令は,このレジスタを適切な値に設定した後,
6592 「このレジスタ自体を返す」.
6593 %</ja>
6594
6595 \dim{ltj@zh}
6596 %<*en>
6597 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
6598 The command \cs{zh} sets this register to the correct value, and
6599 ``return'' this register itself.
6600 %</en>
6601 %<*ja>
6602 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
6603 \cs{zh} 命令は,このレジスタを適切な値に設定した後,
6604 「このレジスタ自体を返す」.
6605 %</ja>
6606
6607 \attr{jfam}
6608 %<*en>
6609 Current number of Japanese font family for math formulas.
6610 %</en>
6611 %<*ja>
6612 数式用の和文フォントファミリの現在の番号.
6613 %</ja>
6614
6615 \attr{ltj@curjfnt}
6616 %<*en>
6617 The font index of current Japanese font for horizontal direction.
6618 %</en>
6619 %<*ja>
6620 現在の横組用和文フォントのフォント番号.
6621 %</ja>
6622
6623 \attr{ltj@curtfnt}
6624 %<*en>
6625 The font index of current Japanese font for vertical direction.
6626 %</en>
6627 %<*ja>
6628 現在の縦組用和文フォントのフォント番号.
6629 %</ja>
6630
6631 \attr{ltj@charclass}
6632 %<*en>
6633 The character class of Japanese \textit{glyph\_node}.
6634 %</en>
6635 %<*ja>
6636 和文文字の\textit{glyph\_node}の文字クラス.
6637 %</ja>
6638
6639 \attr{ltj@yablshift}
6640 %<*en>
6641 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6642 %</en>
6643 %<*ja>
6644 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
6645 %</ja>
6646
6647 \attr{ltj@ykblshift}
6648 %<*en>
6649 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6650 %</en>
6651 %<*ja>
6652 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
6653 %</ja>
6654
6655 \attr{ltj@tablshift}
6656 \attr{ltj@tkblshift}
6657
6658 \attr{ltj@autospc}
6659 %<*en>
6660 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
6661 %</en>
6662 %<*ja>
6663 そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
6664 %</ja>
6665
6666 \attr{ltj@autoxspc}
6667 %<*en>
6668 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
6669 %</en>
6670 %<*ja>
6671 そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
6672 %</ja>
6673
6674 \attr{ltj@icflag}
6675 %<*en>
6676 An attribute for distinguishing ``kinds'' of a node. One of the following value is
6677 assigned to this attribute:
6678 %</en>
6679 %<*ja>
6680 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
6681 %</ja>
6682 \begin{description}
6683 \item[\textit{italic} (1)]
6684 %<*en>
6685 Kerns from italic correction (\verb+\/+), or from kerning information of a Japanese font.
6686 These kerns are ``ignored'' in the insertion process of \textbf{JAglue},
6687 unlike explicit \cs{kern}.
6688 %</en>
6689 %<*ja>
6690 イタリック補正(\verb+\/+)によるカーン,
6691 または \Pkg{luaotfload} によって挿入されたフォントのカーニング情報由来のカーン.
6692 これらのカーンは通常の \cs{kern} とは異なり,
6693 \textbf{JAglue}の挿入処理においては透過する.
6694 %</ja>
6695
6696 \item[\textit{packed} (2)]
6697
6698 \item[\textit{kinsoku} (3)]
6699 %<*en>
6700 Penalties inserted for the word-wrapping process (\emph{kinsoku shori}) of Japanese characters.
6701 %</en>
6702 %<ja>禁則処理のために挿入されたペナルティ.
6703 \item[\mathversion{bold}$(\textit{from\_jfm}-2)$--$(\textit{from\_jfm}+2)$~(4--8)]
6704 %<en>Glues/kerns from JFM.
6705 %<ja>JFM由来のグルー/カーン.
6706 \item[\textit{kanji\_skip}~(9), \textit{kanji\_skip\_jfm}~(10)]
6707 %<en>Glues from \Param{kanjiskip}.
6708 %<ja>和文間空白\Param{kanjiskip}を表すグルー.
6709 \item[\textit{xkanji\_skip}~(11), \textit{xkanji\_skip\_jfm}~(12)]
6710 %<en>Glues from \Param{xkanjiskip}.
6711 %<ja>和欧文間空白\Param{xkanjiskip}を表すグルー.
6712 \item[\textit{processed} (13)]
6713 %<en>Nodes which is already processed by \ldots.
6714 %<ja>\LuaTeX-ja の内部処理によって既に処理されたノード.
6715 \item[\textit{ic\_processed} (14)]
6716 %<*en>
6717 Glues from an italic correction, but already processed in the insertion process of \textbf{JAglue}s.
6718 %</en>
6719 %<ja>イタリック補正に由来するグルーであって,既に \textbf{JAglue} 挿入処理にかかったもの.
6720 \item[\textit{boxbdd} (15)]
6721 %<en>Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
6722 %<ja>hboxか段落の最初か最後に挿入されたグルー/カーン.
6723 \end{description}
6724
6725 %<*ja>
6726 また,挿入処理の結果であるリストの最初のノードでは,\verb+\ltj@icflag+ の値に
6727 \textit{processed\_begin\_flag}~(128)が追加される.これによって,\cs{unhbox} が
6728 連続した場合でも「ボックスの境界」が識別できるようになっている.
6729 %</ja>
6730
6731 \attr{ltj@kcat\,$i$}
6732 %<*en>
6733 Where $i$~is a natural number which is less than~7.
6734 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
6735 %</en>
6736 %<*ja>
6737 $i$は7より小さい自然数.
6738 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
6739 扱われるかを示すビットベクトルを格納する.
6740 %</ja>
6741
6742 \attr{ltj@dir}
6743 %<*ja>
6744 \textit{direction}~whatsit(後述)において組方向を示すために,あるいは\textit{dir\_box}の
6745                          組方向を用いる.\textit{direction}~whatsitにおいては値は
6746 \begin{quote}
6747  \textit{dir\_dtou} (1), \textit{dir\_tate} (3),
6748  \textit{dir\_yoko} (4), \textit{dir\_utod} (11)
6749 \end{quote}
6750 のいずれかであり,\textit{dir\_box}ではこれらに次を加えた値をとる(\ref{sec-dir-imp}章参照).
6751 %</ja>
6752 \begin{description}
6753 \item[\textit{dir\_node\_auto} (128)]
6754 %<ja> 異なる組方向に配置するために自動的に作られたボックス.
6755 \item[\textit{dir\_node\_manual} (256)]
6756 %<ja> \cs{ltjsetwd} によって「ボックスの本来の組方向とは異なる組方向での寸法」を
6757 %<ja> 設定したときに,それを記録するためのボックス.
6758 \end{description}
6759 %<ja> \TeX 側から見える値,つまり \verb+\the\ltj@dir+ の値は常に0である.
6760
6761 \end{list}
6762
6763 %<*en>
6764 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
6765 internal processing. All those nodes except \emph{direction} whatsits
6766 store a natural number (hence its \texttt{type} is 100).
6767 \emph{direction} whatsits store a node list, hence its \texttt{type} is 110.
6768 Their \texttt{user\_id} (used for distinguish user-defined whatsits)
6769 are allocated by \texttt{luatexbase.newuserwhatsitid}.
6770 %</en>
6771 %<*ja>
6772 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
6773 \textit{direction} whatsitはノードリストを格納するが,
6774 それ以外のwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
6775 user-defined whatsitを識別するための \texttt{user\_id} は\
6776 \texttt{luatexbase.newuserwhatsitid} により確保されており,
6777 下の見出しは単なる識別用でしかない.
6778 %</ja>
6779 \begin{description}
6780 \item[\textit{inhibitglue}]
6781 %<*en>
6782 Nodes for indicating that \cs{inhibitglue} is
6783            specified. The \texttt{value} field of these nodes doesn't matter.
6784 %</en>
6785 %<*ja>
6786 \cs{inhibitglue} が指定されたことを示すノード.これらのノードの\
6787 \texttt{value} フィールドは意味を持たない.
6788 %</ja>
6789
6790 \item[\textit{stack\_marker}]
6791 %<*en>
6792 Nodes for \LuaTeX-ja's stack system (see the next
6793            subsection). The \texttt{value} field of these nodes is
6794            current group level.
6795 %</en>
6796 %<*ja>
6797 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
6798 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
6799 %</ja>
6800
6801 \item[\textit{char\_by\_cid}]
6802 %<*en>
6803 Nodes for \textbf{JAchar} which the callback process of
6804            \Pkg{luaotfload} won't be applied, and the character code is
6805            stored in the \texttt{value} field. Each node of this type are
6806            converted to a \textit{glyph\_node} \emph{after}
6807            the callback process of luaotfload.
6808 Nodes of this type is used in \cs{CID}, \cs{UTF} and IVS support.
6809 %</en>
6810 %<*ja>
6811 \Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{JAchar}のためのノードで,
6812 \texttt{value} フィールドに文字コードが格納されている.
6813 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
6814 \emph{後で}\textit{glyph\_node}に変換される.
6815 \cs{CID}, \cs{UTF}やIVS対応処理でこの種類のノードが利用されている.
6816 %</ja>
6817
6818 \item[\textit{replace\_vs}]
6819 %<*en>
6820 Similar to \textit{char\_by\_cid} whatsits above.
6821 These nodes are for \textbf{ALchar} which the callback process of
6822            \Pkg{luaotfload} won't be applied.
6823 %</en>
6824 %<*ja>
6825 上の\textit{char\_by\_cid}と同様に,
6826 これらのノードは\Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{ALchar}のた
6827            めものである.
6828 %</ja>
6829
6830 \item[\textit{begin\_par}]
6831 %<*en>
6832 Nodes for indicating beginning of a paragraph.
6833 A paragraph which is started by \cs{item} in list-like environments has a horizontal box
6834 for its label before the actual contents. So \dots
6835 %</en>
6836 %<*ja>
6837 「段落の開始」を意味するノード.
6838 list環境,itemize環境などにおいて,\cs{item} で始まる各項目は……
6839 %</ja>
6840
6841 \item[\textit{direction}]
6842
6843 \end{description}
6844
6845 %<*en>
6846 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
6847 %</en>
6848 %<*ja>
6849 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
6850 %</ja>
6851
6852 %<en>\subsection{Stack System of \LuaTeX-ja}
6853 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
6854 \label{ssec-stack}
6855
6856 %<en>\paragraph{Background}
6857 %<ja>\paragraph{背景}
6858 %<*en>
6859 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
6860 are stored in it. To clarify the reason, imagine the parameter
6861 \Param{kanjiskip} is stored by a skip, and consider the following
6862 source:
6863 %</en>
6864 %<*ja>
6865 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
6866 これを用いて保持されている.その理由を明らかにするために,
6867 \Param{kanjiskip}パラメータがスキップレジスタで保持されているとし,
6868 以下のコードを考えてみよう:
6869 %</ja>
6870 \begin{LTXexample}
6871 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
6872 \setbox0=\hbox{%
6873   \ltjsetparameter{kanjiskip=5pt}ほげほげ}
6874 \box0.ぴよぴよ\par
6875 \end{LTXexample}
6876
6877 %<*en>
6878 As described in Subsection~\ref{ssec-param}, the only effective value of
6879 \Param{kanjiskip} in an hbox is the latest value, so the value of
6880 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
6881 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
6882 known from any callbacks.  In the \texttt{tex/packaging.w}, which is a
6883 file in the source of \LuaTeX, there are the following codes:
6884 %</en>
6885 %<*ja>
6886 \ref{ssec-param}節で述べたように,あるhboxの中で効力を持つ
6887 \Param{kanjiskip}の値は最後に現れた値のみであり,したがってボックス全体に適用される
6888 \Param{kanjiskip}は5\,ptであるべきである.しかし,\LuaTeX の実
6889 装を観察すると,この5\,ptという長さはどのコールバックからも知ることはできないことがわかる.
6890 \LuaTeX のソースファイルの1つ \texttt{tex/packaging.w} の中に,
6891 以下のコードがある:
6892 %</ja>
6893 \begin{lstlisting}[numbers=left,firstnumber=1226]
6894 void package(int c)
6895 {
6896     scaled h;                   /* height of box */
6897     halfword p;                 /* first node in a box */
6898     scaled d;                   /* max depth */
6899     int grp;
6900     grp = cur_group;
6901     d = box_max_depth;
6902     unsave();
6903     save_ptr -= 4;
6904     if (cur_list.mode_field == -hmode) {
6905         cur_box = filtered_hpack(cur_list.head_field,
6906                                  cur_list.tail_field, saved_value(1),
6907                                  saved_level(1), grp, saved_level(2));
6908         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
6909 \end{lstlisting}
6910 %<*en>
6911 Notice that \texttt{unsave()} is executed \emph{before}
6912 \texttt{filtered\_hpack()}, where \texttt{hpack\_filter} callback is
6913 executed) here. So ``5\,pt'' in the above source is orphaned at
6914 \texttt{unsave()}, and hence it can't be accessed from \texttt{hpack\_filter}
6915 callback.
6916 %</en>
6917 %<*ja>
6918 \texttt{unsave()} が \texttt{filtered\_hpack()}(これは \texttt{hpack\_filter} コールバックが
6919 実行されるところである)の\emph{前に}実行されていることに注意する.
6920 したがって,上記ソース中で5\,ptは \texttt{unsave()} のところで捨てられ,
6921 \texttt{hpack\_filter} コールバックからはアクセスすることができない.
6922 %</ja>
6923
6924 %<en>\paragraph{Implementation}
6925 %<ja>\paragraph{解決法}
6926
6927 %<*en>
6928 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
6929 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
6930 %</en>
6931 %<*ja>
6932 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{%
6933 \texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
6934 ベースにしている.
6935 %</ja>
6936
6937 %<*en>
6938 These are two \TeX\ count registers for maintaining information:
6939 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
6940 the \TeX's group level when the last assignment was done.  Parameters
6941 are stored in one big table named \texttt{charprop\_stack\_table}, where
6942 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
6943 a new stack level is created by \cs{ltjsetparameter}, all data of the
6944 previous level is copied.
6945 %</en>
6946 %<*ja>
6947 情報を保持するために,2つの\TeX の整数レジスタを用いている:
6948 \verb+\ltj@@stack+ にスタックレベル,\verb+\ltj@@group@level+ に最後の代入が
6949 なされた時点での\TeX のグループレベルを保持している.
6950 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
6951 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
6952 データを格納している.もし新しいスタックレベルが \cs{ltjsetparameter} によって
6953 生成されたら,前のレベルの全てのデータがコピーされる.
6954 %</ja>
6955
6956 %<*en>
6957 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
6958 another trick. When the stack level is about to be increased, a whatsit
6959 node whose type, subtype and value are 44~(\textit{user\_defined}),
6960 \textit{stack\_marker} and the current group level respectively is appended to the current
6961 list (we refer this node by \textit{stack\_flag}). This enables us to
6962 know whether assignment is done just inside a hbox. Suppose that the
6963 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
6964 group, then:
6965 %</en>
6966 %<*ja>
6967 上の「背景」で述べた問題を解決するために,\LuaTeX-jaでは次の手法を用いる:
6968 スタックレベルが増加するするとき,type, subtype, valueがそれぞれ
6969 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
6970 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
6971 これにより,あるhboxの中で代入がなされたかどうかを知ることが可能
6972 となる.スタックレベルを$s$,そのhbox groupの直後の\TeX のグループレベルを
6973 $t$とすると:
6974 %</ja>
6975 \begin{itemize}
6976 %<*en>
6977 \item If there is no \textit{stack\_flag} node in the list of the contents of the hbox, then
6978       no assignment was occurred inside the hbox. Hence values of
6979       parameters at the end of the hbox are stored in the stack
6980       level~$s$.
6981 %</en>
6982 %<*ja>
6983 \item もしそのhboxの中身を表すリストの中に\textit{stack\_flag}ノードがなければ,
6984   hboxの中では代入は起こらなかったということになる.
6985   したがって,そのhboxの終わりにおけるパラメータの値はスタックレベル$s$に
6986   格納されている.
6987 %</ja>
6988
6989 %<*en>
6990 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
6991       an assignment was occurred just inside the hbox group. Hence
6992       values of parameters at the end of the hbox are stored in the
6993       stack level~$s+1$.
6994 %</en>
6995 %<*ja>
6996 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
6997   hboxの中で代入が起こったことになる.
6998   したがって,hboxの終わりにおけるパラメータの値はスタックレベル$s+1$に
6999   格納されている.
7000 %</ja>
7001
7002 %<*en>
7003 \item If there are \textit{stack\_flag} nodes but all of their values
7004       are more than~$t+1$, then an assignment was occurred in the box,
7005       but it is done in more internal group. Hence values of
7006       parameters at the end of the hbox are stored in the stack
7007       level~$s$.
7008 %</en>
7009 %<*ja>
7010 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
7011   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
7012   起こったということになる.したがって,hboxの終わりでのパラメータの
7013   値はスタックレベル$s$に格納されている.
7014 %</ja>
7015 \end{itemize}
7016
7017 %<*en>
7018 Note that to work this trick correctly, assignments to
7019 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
7020 regardless the value of \cs{globaldefs}.
7021 To solve this problem, we use another trick: the assignment
7022 \hbox{\verb+\directlua{tex.globaldefs=0}+} is always local.
7023 %</en>
7024 %<*ja>
7025 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
7026 代入は \cs{globaldefs} の値によらず常にローカルでなければならないことに注意する.
7027 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
7028 用いることで解決している.
7029 %</ja>
7030
7031 %<*en>
7032 \subsection{Lua Functions of the Stack System}
7033 In this subsection, we will see how a user use \LuaTeX-ja's stack system to
7034 store some data which obeys the grouping of \TeX.
7035 %</en>
7036 %<*ja>
7037 \subsection{スタックシステムで使用される関数}
7038 本節では,ユーザが\LuaTeX-jaのスタックシステムを使用して,
7039 \TeX のグルーピングに従うような
7040 独自のデータを取り扱う方法を述べる.
7041 %</ja>
7042
7043 %<*en>
7044 The following function can be used to store data into a stack:
7045 \begin{lstlisting}
7046 luatexja.stack.set_stack_table(index, <any> data)
7047 \end{lstlisting}
7048 Any values which except \texttt{nil}~and~NaN are usable as \textit{index}.
7049 However, a user should use only negative integers or strings as \textit{index},
7050 since natural numbers are used by \LuaTeX-ja itself.
7051 Also, whether \textit{data} is stored locally or globally
7052 is determined by \texttt{luatexja.isglobal}
7053 (stored globally if and only if \texttt{luatexja.isglobal == 'global'}).
7054 %</en>
7055 %<*ja>
7056 スタックに値を設定するには,以下のLua関数を呼び出せば良い:
7057 \begin{lstlisting}
7058 luatexja.stack.set_stack_table(<any> index, <any> data)
7059 \end{lstlisting}
7060 直感的には,スタックテーブル中のインデックス\textit{index}の値を\textit{data}にする,という意味である.
7061 \textit{index}の値としては \texttt{nil} とNaN以外の任意の値を使えるが,
7062 自然数は\LuaTeX-jaが使用する(将来の拡張用も含む)ので,
7063 ユーザが使用する場合は負の整数値か文字列の値にすることが望ましい.
7064 また,ローカルに設定されるかグローバルに設定されるかは,\texttt{luatexja.isglobal} の値に依存する
7065 (グローバルに設定されるのは,\texttt{luatexja.isglobal == 'global'} であるちょうどその時).
7066 %</ja>
7067
7068 %<*en>
7069 Stored data can be obtained as the return value of
7070 \begin{lstlisting}
7071 luatexja.stack.get_stack_table(index, <any> default, <number> level)
7072 \end{lstlisting}
7073 where \textit{level} is the stack level, which is usually the value of \verb+\ltj@@stack+,
7074 and \textit{default} is the default value which will be returned if no values are stored
7075 in the stack table whose level is \textit{level}.
7076 %</en>
7077 %<*ja>
7078 スタックの値は,
7079 \begin{lstlisting}
7080 luatexja.stack.get_stack_table(<any> index, <any> default, <number> level)
7081 \end{lstlisting}
7082 の戻り値で取得できる.\textit{level}はスタックレベルであり,
7083 通常は \verb+\ltj@@stack+ の値を指定することになるだろう.
7084 \textit{default}はレベル\textit{level}のスタックに値が設定されていなかった場合に
7085 返すデフォルト値である.
7086 %</ja>
7087
7088 \begin{figure}[tb]
7089 \begin{lstlisting}[numbers=left, firstnumber=380]
7090 \protected\def\ltj@setpar@global{%
7091   \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
7092     \else\directlua{luatexja.isglobal=''}\fi
7093 }
7094 \protected\def\ltjsetparameter#1{%
7095   \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
7096 \protected\def\ltjglobalsetparameter#1{%
7097   \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
7098     \else\directlua{luatexja.isglobal='global'}\fi%
7099   \setkeys[ltj]{japaram}{#1}\ignorespaces}
7100 \end{lstlisting}
7101 %<ja>\caption{パラメータ設定命令の定義}
7102 %<en>\caption{Definiton of parameter setting commands}
7103 \label{fig:setpar-def}
7104 \end{figure}
7105
7106 %<*en>
7107 \subsection{Extending Parameters}
7108 Keys for \cs{ltjsetparameter}~and~\cs{ltjgetparameter} can be extended,
7109 as in \Pkg{luatexja-adjust}.
7110 %</en>
7111 %<*ja>
7112 \subsection{パラメータの拡張}
7113 ここでは,\Pkg{luatexja-adjust}で行なっているように,
7114 \cs{ltjsetparameter},~\cs{ltjgetparameter}に指定可能なキーを追加する方法
7115 を述べる.
7116 %</ja>
7117
7118 %<*en>
7119 \paragraph{Setting parameters}
7120 Figure~\ref{fig:setpar-def} shows the ``most outer'' definition of
7121 two commands,
7122 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter}.
7123 Most important part is the last \cs{setkeys},
7124 which is offered by the \Pkg{xkeyval} package.
7125
7126 Hence, to add a key in \cs{ltjsetparameter}, one only have to add a key
7127 whose prefix is \texttt{ltj} and whose family is \texttt{japaram}, as the following.
7128 \begin{lstlisting}
7129 \define@key[ltj]{japaram}{...}{...}
7130 \end{lstlisting}
7131
7132 \cs{ltjsetparameter}~and~\cs{ltjglobalsetparameter} automatically sets
7133 \texttt{luatexja.isglobal}. Its meaning is the following.
7134 \begin{align}
7135  \texttt{luatexja.isglobal} =
7136 \begin{cases}
7137  \texttt{'global'}&\text{global}\\
7138  \texttt{''}&\text{local}
7139 \end{cases}
7140 \end{align}
7141 This is determined not only by command name
7142 (\cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}),
7143 but also by the value of \cs{globaldefs}.
7144 %</en>
7145 %<*ja>
7146 \paragraph{パラメータの設定}
7147 \cs{ltjsetparameter} と,\cs{ltjglobalsetparameter} の定義は図\ref{fig:setpar-def}の
7148 のようになっている.
7149 本質的なのは最後の \cs{setkeys} で,これは\Pkg{xkeyval}パッケージの提供する命令である.
7150
7151 このため,\cs{ltjsetparameter} に指定可能なパラメータを追加するには,
7152 <prefix>を \texttt{ltj},<family>を \texttt{japaram} としたキーを
7153 \begin{lstlisting}
7154 \define@key[ltj]{japaram}{...}{...}
7155 \end{lstlisting}
7156 のように定義すれば良いだけである.
7157 なお,パラメータ指定がグローバルかローカルかどうかを示す \texttt{luatexja.isglobal} が,
7158 \begin{align}
7159  \texttt{luatexja.isglobal} =
7160 \begin{cases}
7161  \texttt{'global'}&\text{パラメータ設定はグローバル}\\
7162  \texttt{''}&\text{パラメータ設定はローカル}
7163 \end{cases}
7164 \end{align}
7165 として自動的にセットされる\footnote{命令が \cs{ltjglobalsetparameter} かどうかだけでは
7166 なく,実行時の \cs{globaldefs} の値にも依存して定まる.}.
7167 %</ja>
7168
7169 %<*en>
7170 \paragraph{Getting parameters}
7171 \cs{ltjgetparameter} is implemented by a Lua script.
7172
7173 For parameters that do not need additional arguments, one only have to
7174 define a function in the table \verb+luatexja.unary_pars+.
7175 For example, with the following function,
7176 \verb+\ltjgetparameter{hoge}+ returns a \emph{string} \texttt{42}.
7177 \begin{lstlisting}[numbers=left]
7178 function luatexja.unary_pars.hoge (t)
7179   return 42
7180 end
7181 \end{lstlisting}
7182 Here the argument of \verb+luatexja.unary_pars.hoge+ is
7183 the stack level of \LuaTeX-ja's stack system (see Subsection~\ref{ssec-stack}).
7184
7185 On the other hand, for parameters that need an additional argument
7186 (this must be an integer), one have to define a function in
7187 \verb+luatexja.binary_pars+ first. For example,
7188 \begin{lstlisting}[numbers=left]
7189 function luatexja.binary_pars.fuga (c, t)
7190   return tostring(c) .. ', ' .. tostring(42)
7191 end
7192 \end{lstlisting}
7193 Here the first argument $t$ is the stack level, as before.
7194 The second argument $c$ is just the second argument of \cs{ltjgetparameter}.
7195
7196 For parameters that need an additional argument, one also have to
7197 execute the \TeX\ code like
7198 \begin{lstlisting}
7199 \ltj@@decl@array@param{fuga}
7200 \end{lstlisting}
7201 to indicate that ``the parameter \texttt{fuga} needs an additional argument''.
7202 %</en>
7203 %<*ja>
7204 \paragraph{パラメータの取得}
7205 一方,\cs{ltjgetparameter} はLuaスクリプトによって実装されている.
7206 値を取得するのに追加引数の要らないパラメータについては,\verb+luatexja.unary_pars+\
7207 内に処理内容を記述した関数を定義すれば良い.例えば,Luaスクリプトで
7208 \begin{lstlisting}[numbers=left]
7209 function luatexja.unary_pars.hoge (t)
7210   return 42
7211 end
7212 \end{lstlisting}
7213 を実行すると,\verb+\ltjgetparameter{hoge}+ は \texttt{42} という\emph{文字列}を返す.
7214 関数 \verb+luatexja.unary_pars.hoge+ の引数$t$は,\ref{ssec-stack}節で述べた
7215 \LuaTeX-jaのスタックシステムにおけるスタックレベルである.
7216 戻り値はいかなる値であっても,最終的には文字列として出力されることに注意.
7217
7218 一方,追加引数(\emph{数値しか許容しない})が必要なパラメータについては,
7219 まずLuaスクリプトで処理内容の本体を記述しておく:
7220 \begin{lstlisting}[numbers=left]
7221 function luatexja.binary_pars.fuga (c, t)
7222   return tostring(c) .. ', ' .. tostring(42)
7223 end
7224 \end{lstlisting}
7225 引数$t$は,先に述べた通りのスタックレベルである.一方,引数$c$は\
7226 \cs{ltjgetparameter} の第2引数を表す数値である.
7227 しかしこれだけでは駄目で,
7228 \begin{lstlisting}
7229 \ltj@@decl@array@param{fuga}
7230 \end{lstlisting}
7231 を実行し,\TeX インターフェース側に
7232 「\verb+\ltjgetparameter{fuga}+ は追加引数が必要」ということを通知する必要がある.
7233 %</ja>
7234
7235 %<en>\section{Linebreak after a Japanese Character}
7236 %<ja>\section{和文文字直後の改行}
7237 \label{sec-lbreak}
7238 %<en>\subsection{Reference: Behavior in \pTeX}
7239 %<ja>\subsection{参考:\pTeX の動作}
7240 %<*en>
7241 In~\pTeX, a line break after a Japanese character doesn't emit a space,
7242 since words are not separated by spaces in Japanese writings. However,
7243 this feature isn't fully implemented in \LuaTeX-ja due to the
7244 specification of callbacks in~\LuaTeX. To clarify the difference between
7245 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
7246 this subsection.
7247
7248 \pTeX's input processor can be described in terms of a finite state
7249 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
7250 internal states are as follows:
7251 \begin{itemize}
7252 \item State~$N$: new line
7253 \item State~$S$: skipping spaces
7254 \item State~$M$: middle of line
7255 \item State~$K$: after a Japanese character
7256 \end{itemize}
7257 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
7258 processor.  State~$K$ is similar to state~$M$, and is entered after
7259 Japanese characters.  The diagram of state transitions are indicated in
7260 Figure~\ref{fig-ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
7261 after ``beginning/ending of a group'' characters.
7262 %</en>
7263
7264 %<*ja>
7265 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
7266 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
7267 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
7268
7269 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
7270 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
7271 以下に述べるような4状態を持っている.
7272
7273 \begin{itemize}
7274 \item State~$N$: 行の開始.
7275 \item State~$S$: 空白読み飛ばし.
7276 \item State~$M$: 行中.
7277 \item State~$K$: 行中(和文文字の後).
7278 \end{itemize}
7279 また,状態遷移は,図\ref{fig-ptexipro}のようになっており,図中の数字は
7280 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
7281 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
7282 じものになる.
7283
7284 この図から分かることは,
7285 \begin{quote}
7286 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
7287 \end{quote}
7288 ということである.
7289 %</ja>
7290
7291 \begin{figure}[!tb]
7292 \let\sp\textvisiblespace\small
7293 \begin{minipage}{.6\textwidth}%
7294 \begin{center}
7295 \unitlength=6.5mm\sf\mathversion{bold}
7296 \begin{tikzpicture}[
7297   ->, auto, shorten >=1pt
7298 ]
7299 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
7300 \node [shape=circle,draw, fill=b_cyan] (newline) at (4,7) {$N$};
7301 \node [shape=circle,draw, fill=b_cyan] (midline) at (4,4) {$M$};
7302 \node [shape=circle,draw, fill=b_cyan] (skipspc) at (8,7) {$S$};
7303 \node [shape=circle,draw, fill=b_pink]  (kanji) at (8,4) {$K$};
7304 \node [shape=rectangle,draw, fill=b_green] (scanacs) at (6,8) {scan a c.s.};
7305 \node (endk) at (8,2.5) {} ;
7306 \node (endm) at (4,2.5) {} ;
7307 \node (ends) at (8,8.5) {} ;
7308 \node (endn) at (4,8.5) {} ;
7309 \begin{scope}[font=\scriptsize]
7310 \path (newline) edge [bend right]    node [left]{G, O} (midline)
7311       (init)    edge                 node {} (newline)
7312       (midline) edge [bend right=10] node {10} (skipspc)
7313       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
7314       (skipspc) edge [loop right]    node {10} (skipspc)
7315       (newline) edge [loop right]    node {10} (newline)
7316       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
7317       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
7318       (midline) edge                 node {5\ [\sp]} (endm)
7319       (midline) edge [loop left]     node {G, O} (midline)
7320       (skipspc) edge                 node [right] {5} (ends)
7321       (newline) edge                 node {5 [\cs{par}]} (endn);
7322 \begin{scope}[red]
7323 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
7324       (midline) edge                 node [below]{J} (kanji)
7325       (kanji)   edge [bend left]     node {O} (midline)
7326       (kanji)   edge                 node {10} (skipspc)
7327       (kanji)   edge [loop right]    node {G, J} (kanji)
7328       (skipspc) edge [bend left]     node {J} (kanji)
7329       (kanji)   edge                 node {5} (endk)
7330 ;
7331 \end{scope}
7332 \end{scope}
7333 \end{tikzpicture}
7334 \end{center}
7335 \end{minipage}%
7336 \begin{minipage}{.4\textwidth}
7337 \begin{description}
7338 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
7339  and ending of group (usually \verb+}+).
7340 \item[\textsf{J}] Japanese characters.
7341 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
7342 \item[\textsf{10}] space (usually \sp).
7343 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
7344 \item[\textsf{[\sp]}, \textsf{[\cs{par}]}]
7345 emits a space, or~\cs{par}.
7346 \end{description}
7347 \end{minipage}
7348 \begin{itemize}
7349 \item We omitted about category codes
7350 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
7351 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
7352 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
7353 the input processor scans a control sequence (\textsf{scan a c.s.}).
7354 These paths are not shown in the above diagram.
7355
7356 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
7357 to State~$M$ (middle of line) sometimes.
7358 \end{itemize}
7359 %<en>\caption{State transitions of \pTeX's input processor}
7360 %<ja>\caption{\pTeX の入力処理部の状態遷移}
7361 \label{fig-ptexipro}
7362 \end{figure}
7363
7364
7365 %<en>\subsection{Behavior in \LuaTeX-ja}
7366 %<ja>\subsection{\LuaTeX-jaの動作}
7367 %<*en>
7368 States in the input processor of \LuaTeX\ is the same as that of \TeX,
7369 and they can't be customized by any callbacks. Hence, we can only use
7370 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
7371 suppress a space by a line break which is after Japanese characters.
7372
7373 However, \verb+token_filter+ callback cannot be used either, since a
7374 character in category code 5~(\textit{end-of-line}) is converted into an space
7375 token \emph{in the input processor}.  So we can use only the
7376 \verb+process_input_buffer+ callback.  This means that suppressing a
7377 space must be done \emph{just before} an input line is read.
7378
7379 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
7380 \begin{quote}
7381 A character \texttt{U+FFFFF} (its category code is set to 14~(\textit{comment}) by
7382 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
7383 process it}, if and only if the following three conditions are satisfied:
7384 \begin{enumerate}
7385 \item The category code of \cs{endlinechar}%
7386 \footnote{Usually, it is $\langle$\textit{return}$\rangle$
7387       (whose character code is 13).} is 5~(\textit{end-of-line}).
7388 \item The category code of \texttt{U+FFFFF} itself is 14~(\textit{comment}).
7389 \item The input line matches the following ``regular expression'':
7390 \[
7391   (\text{any char})^*(\textbf{JAchar})
7392   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7393 \]
7394 \end{enumerate}
7395 \end{quote}
7396
7397 \paragraph{Remark}
7398 The following example shows the major difference from the behavior of \pTeX.
7399 \begin{LTXexample}
7400 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
7401 \ltjsetparameter{autoxspacing=false}
7402 \ltjsetparameter{jacharrange={-6}}xあ
7403 y\ltjsetparameter{jacharrange={+6}}zい
7404 u
7405 \end{LTXexample}
7406 It is not strange that ``あ'' does not printed in the above output.
7407 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because
7408 ``あ'' in line~3 is considered as an \textbf{ALchar}.
7409
7410 Note that there is no space before ``y'' in the output, but
7411 there is a space before ``u''. This follows from following reasons:
7412 \begin{itemize}
7413 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
7414 ``あ'' is considered as an \textbf{JAchar}.
7415 Since  line~3 ends with an \textbf{JAchar},
7416 the comment character \texttt{U+FFFFF} is appended to this line,
7417 and hence the linebreak immediately after this line is ignored.
7418 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
7419 ``い'' is considered as an \textbf{ALchar}.
7420 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
7421 emits a space.
7422 \end{itemize}
7423 %</en>
7424
7425 %<*ja>
7426 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
7427 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
7428 きそうなコールバックとしては,\verb+process_input_buffer+や
7429 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
7430 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
7431 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
7432 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
7433 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
7434
7435 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
7436 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
7437 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
7438
7439 \begin{quote}
7440 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
7441 以下の3条件が満たされている場合,\LuaTeX-jaは\texttt{U+FFFFF}の文字
7442 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
7443 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
7444 \begin{enumerate}
7445 \item \cs{endlinechar}の文字\footnote{普通は,改行文字(文字コード13番)である.}
7446 のカテゴリーコードが5~(\textit{end-of-line})である.
7447 \item \texttt{U+FFFFF}のカテゴリーコードが14~(\textit{comment})である.
7448 \item 入力行は次の「正規表現」にマッチしている:
7449 \[
7450   (\text{any char})^*(\textbf{JAchar})
7451   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7452 \]
7453 \end{enumerate}
7454 \end{quote}
7455
7456 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
7457 \texttt{lstlisting}系環境などの日本語対応マクロを書かなくてすませるためのものである.
7458
7459 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
7460 次のように,和文文字の範囲を変更したちょうどその行においては挙動が異なる:
7461 \begin{LTXexample}
7462 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
7463 \ltjsetparameter{autoxspacing=false}
7464 \ltjsetparameter{jacharrange={-6}}xあ
7465 y\ltjsetparameter{jacharrange={+6}}zい
7466 u
7467 \end{LTXexample}
7468 上ソース中の「あ」は欧文文字扱いであり.
7469 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
7470 よって,出力に「あ」は現れないことは不思議ではない.
7471 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
7472 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
7473 上のように異なる挙動となっているが,それは以下の理由による:
7474 \begin{itemize}
7475 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
7476       「あ」は和文文字扱いである.よって3行目は和文文字で終わることになり,
7477       コメント文字 \texttt{U+FFFFF} が追加される.
7478       よって,直後の改行文字は無視されることになり,空白は入らない.
7479 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
7480       「い」は欧文文字扱いである.よって4行目は欧文文字で終わることになり,
7481       直後の改行文字は空白に置き換わる.
7482 \end{itemize}
7483 このため,トラブルを避けるために,和文文字の範囲を\cs{ltjsetparameter}で編集した場合,
7484 その行はそこで改行するようにした方がいいだろう.
7485 %</ja>
7486
7487 %<*ja>
7488
7489 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
7490 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
7491 \label{sec-jfmglue}
7492 %<en>\subsection{Overview}
7493 %<ja>\subsection{概要}
7494
7495 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
7496 \pTeX では次のような仕様であった:
7497 \begin{itemize}
7498 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
7499 追加する過程で行われる.
7500 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
7501 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
7502 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
7503 \end{itemize}
7504 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
7505 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
7506 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
7507 カーニング処理がノードベースになったことに対応する変更である.
7508
7509 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
7510 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
7511 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
7512 であり,2つのクラスタの間には,ペナルティ,\cs{vadjust},whatsitなど,行組版
7513 には関係しないものがある.
7514
7515
7516 %<en>\subsection{Definition of a Cluster}
7517 %<ja>\subsection{「クラスタ」の定義}
7518
7519 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
7520 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
7521 \begin{defn}
7522 %<*en>
7523 A \emph{cluster} is consecutive nodes in one of the following forms,
7524 with the \textit{id} of it:
7525 %</en>
7526 %<*ja>
7527 \emph{クラスタ}は以下の形のうちのどれかひとつをとるノードのリストである:
7528 %</ja>
7529 \begin{enumerate}
7530 %<*en>
7531 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
7532       nodes come from a hbox which is already packaged, by unpackaging
7533       (\cs{unhbox}).
7534       The \textit{id} of the cluster is \textit{id\_pbox}.
7535 %</en>
7536 %<*ja>
7537 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
7538   これらのノードはある既にパッケージングされたhboxから \cs{unhbox} で
7539   アンパックされたものである.
7540   この場合,クラスタの\textit{id}は\textit{id\_pbox}である.
7541 %</ja>
7542
7543 %<*en>
7544 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
7545       The \textit{id} of the cluster is \textit{id\_math}.
7546 %</en>
7547 %<*ja>
7548 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
7549   この場合,クラスタの\textit{id}は\textit{id\_math}である.
7550 %</ja>
7551
7552 %<*en>
7553 \item A \textit{glyph\_node}~$p$, which represents a \textbf{JAchar}, with nodes which relate with it:
7554 %</en>
7555 %<*ja>
7556 \item \textbf{JAchar}を表す\textit{glyph\_node}~$p$とそれに関係するノード:
7557 %</ja>
7558 \begin{enumerate}
7559 %<*en>
7560 \item[(a)] A kern for the italic correction of~$p$.
7561 %</en>
7562 %<*ja>
7563 \item[(a)] $p$のイタリック補正のためのカーン.
7564 %</ja>
7565
7566 %<*en>
7567 \item[(b)] An accent attached to $p$ by \cs{accent}.
7568 %</en>
7569 %<*ja>
7570 \item[(b)] \cs{accent} による$p$に付随したアクセント.
7571 %</ja>
7572 \end{enumerate}
7573 \[
7574 \overbrace{%
7575  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
7576 \left\{\begin{array}{c}
7577 \Node{glyph}{accent}\\\noalign{\medskip}
7578 \Node{hbox}{accent (shifted vert.)}
7579 \end{array}\right\}\longrightarrow
7580 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(a)}}
7581 \longrightarrow
7582 \Node{glyph}{$p$}\longrightarrow
7583 \overbrace{%
7584 \Node{kern}{italic corr.}}^{\text{(b)}}
7585 \]
7586
7587 %<*en>
7588 In this case, the \textit{id} is \textit{id\_jglyph}.
7589 %</en>
7590 %<*ja>
7591 この場合の\textit{id}は\textit{id\_jglyph}である.
7592 %</ja>
7593
7594 %<*en>
7595 \item A list which begins from a \textit{glyph\_node} which represents a \textbf{ALchar},
7596       and consists of \textbf{ALchar} \textit{glyph\_node}s,
7597       kerns for adjusting accents~(its subtype is 2), kerns for italic corrections and
7598       kerns which are automatically inserted by \LuaTeX~or~luaotfload.
7599       In this case, the \textit{id} is \textit{id\_glyph}.
7600 %</en>
7601 %<*ja>
7602 \item \textbf{ALchar}を表す\textit{glyph\_node},\cs{accent} によるアクセント位置補正用の
7603       カーン(subtypeが2),そしてイタリック補正・カーニングによって挿入されたカーン達が連続
7604       したもの.この場合の\textit{id}は\textit{id\_glyph}である.
7605 %</ja>
7606
7607 %<*en>
7608 \item An box-like node, that is, an hbox, a vbox, a rule (\cs{vrule}) and an \textit{unset\_node}.
7609 The \textit{id} of the cluster is \textit{id\_hlist} if the node is an
7610       hbox which is not shifted vertically, or \textit{id\_box\_like}
7611       otherwise.
7612 %</en>
7613 %<*ja>
7614 \item 水平ボックス(hbox),垂直ボックス,罫線 (\cs{vrule}),
7615   そして\textit{unset\_node}.
7616   クラスタの\textit{id}は垂直に移動していないhboxならば\textit{id\_hlist},
7617   そうでなければ\textit{id\_box\_like}となる.
7618 %</ja>
7619
7620 %<*en>
7621 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
7622 The \textit{id} of the cluster is \textit{id\_glue}, \textit{id\_kern}
7623       and \textit{id\_disc}, respectively.
7624 %</en>
7625 %<*ja>
7626 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そしてdiscretionary break.
7627   その\textit{id} of the clusterはそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
7628   \textit{id\_disc}である.
7629 %</ja>
7630 \end{enumerate}
7631 %<*en>
7632 We use \textit{Np}, \textit{Nq} and \textit{Nr} to denote a cluster.
7633 %</en>
7634 %<*ja>
7635 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
7636 %</ja>
7637 \end{defn}
7638
7639 \paragraph{\textit{id}の意味}
7640 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
7641 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
7642 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
7643 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
7644 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
7645 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
7646
7647 \begin{description}
7648 \item[\textit{id\_jglyph}] 和文文字.\\
7649 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その和文文字を表している
7650 \textit{glyph\_node}そのものである.
7651 \item[\textit{id\_glyph}] 和文文字を表していない\textit{glyph\_node}~$p$.\\
7652 多くの場合,$p$は欧文文字を格納しているが,「ffi」などの合字によって作られた
7653 \textit{glyph\_node}である可能性もある.
7654 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
7655 一方,後者の場合,
7656 \begin{itemize}
7657 \item $\mathit{Np}.\mathit{head}$は,
7658 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
7659 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
7660 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
7661 \end{itemize}
7662 \item[\textit{id\_math}] インライン数式.\\
7663 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
7664 「文字コード$-1$の欧文文字」とおく.
7665 \item[\textit{id\_hlist}] 縦方向にシフトされていないhbox.\\
7666 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
7667 先頭・末尾のノードである.
7668 \medskip
7669 \begin{itemize}
7670 \item 状況によっては,\TeX ソースで言うと
7671 \begin{lstlisting}
7672 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
7673 \end{lstlisting}
7674 のように,$p$の内容が別のhboxで開始・終了している可能性も十分あり得る.そのような場合,
7675 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
7676 \emph{垂直方向にシフトされていない}hboxの
7677 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
7678 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされたhbox,
7679 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
7680 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
7681 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
7682 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
7683 と同様に再帰的に構成要素をたどっていく.
7684 \end{itemize}
7685 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
7686 まとめて1つのクラスタとして取り扱うだけである.
7687 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
7688 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
7689 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
7690 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
7691 全く考慮に入れない.
7692 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
7693 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
7694 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
7695 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
7696 \end{description}
7697
7698 \paragraph{クラスタの別の分類}
7699 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
7700 挿入処理では2つの隣り合ったクラスタの間に
7701 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
7702 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
7703 \begin{description}
7704 \item[和文A] リスト中に直接出現している和文文字.
7705 \textit{id}が\textit{id\_jglyph}であるか,\\
7706 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7707
7708 \item[和文B] リスト中のhboxの中身の先頭として出現した和文文字.和文Aとの違いは,これの前に
7709 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
7710 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7711
7712 \item[欧文] リスト中に直接/hboxの中身として出現している欧文文字.次の3つの場合が該当:
7713 \begin{itemize}
7714 \item \textit{id}が\textit{id\_glyph}である.
7715 \item \textit{id}が\textit{id\_math}である.
7716 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
7717 \end{itemize}
7718 \item[箱] box,またはそれに類似するもの.次の2つが該当:
7719 \begin{itemize}
7720 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
7721 \item \textit{id}が\textit{id\_box\_like}である.
7722 \end{itemize}
7723
7724 \end{description}
7725
7726 \subsection{段落/hboxの先頭や末尾}
7727 \paragraph{先頭部の処理}
7728 まず,段落/hboxの一番最初にあるクラスタ\textit{Np}を探索する.
7729 hboxの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
7730 \begin{itemize}
7731 \item \cs{parindent} 由来のhbox($\mathit{subtype}=3$)
7732 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
7733 \end{itemize}
7734 これは,\cs{parindent}由来のhboxがクラスタを構成しないようにするためである.
7735
7736 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
7737 \begin{enumerate}
7738 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
7739 \item 問題のリストが字下げありの段落(\cs{parindent} 由来のhboxあり)の場合は,
7740 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7741 \item そうでないとき(\verb+noindent+ で開始された段落やhbox)は,
7742 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7743 \end{enumerate}
7744 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
7745 そこで,以下の場合には,$g$の直前に \cs{penalty10000} を挿入する:
7746 \begin{itemize}
7747 \item 問題にしているリストが段落であり,かつ
7748 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
7749 \end{itemize}
7750
7751 \paragraph{末尾の処理}
7752 末尾の処理は,問題のリストが段落のものかhboxのものかによって異なる.
7753 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\
7754 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
7755 \textit{Nq}の直後に挿入するのみである.
7756
7757 一方.前者(段落)の場合は,リストの末尾は常に \cs{penalty10000} と,
7758 \cs{parfillskip} 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
7759 %この \cs{parfillskip} 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
7760 段落の最後の「通常の和文文字${}+{}$句点」が独立した行となるのを防ぐために,
7761 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
7762
7763 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
7764 かつその文字の\Param{kcatcode}が偶数であるような
7765 最後のクラスタの直前にあるものたちである%
7766 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
7767 を約物として考えていることになる.
7768 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
7769
7770 \subsection{概観と典型例:2つの「和文A」の場合}
7771 \label{ssec-cluster-wa}
7772 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
7773 ペナルティ,\cs{vadjust},whatsitなど,行組版には関係しないものがある.模式的に表すと,
7774 \[
7775  \Node{cluster}{\textit{Nq}}\longrightarrow
7776 \overbrace{
7777 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
7778 \longrightarrow \Node{cluster}{\textit{Np}}
7779 \]
7780 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
7781 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
7782 \[
7783  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
7784 \overbrace{
7785 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow
7786 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow
7787 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
7788 \Node{cluster}{\textit{Np}}
7789 \]
7790
7791 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
7792 この場合が全ての場合の基本となる.
7793
7794 \paragraph{「右空白」の算出}
7795 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの和文文字間に入る空白量となる.
7796 \begin{description}
7797 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
7798       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
7799 \begin{enumerate}
7800 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
7801       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
7802 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
7803       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
7804 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
7805 この場合,まず
7806 \[
7807 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
7808 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
7809 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
7810 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
7811 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
7812 }}
7813 \]
7814 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
7815
7816 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する<ratio>の値を$d_b$,~$d_a$とする.
7817 \begin{itemize}
7818 \item
7819 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
7820 \Param{kanjiskip}を採用することとなる.
7821 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,<ratio>の値は0であるかのように扱われる.
7822 \item
7823 \Param{diffrentjfm}の値が \texttt{pleft}, \texttt{pright},
7824       \texttt{paverage} のとき,
7825 <ratio>の指定に従って比例配分を行う.
7826 JFM由来のグルー/カーンは以下の値となる:
7827 \[
7828  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
7829 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
7830 \]
7831 ここで.$f(x,y)$は
7832 \[
7833  f(x,y)=\begin{cases}
7834 x&\text{if\ }\Param{diffrentjfm}=\texttt{pleft};\\
7835 y&\text{if\ }\Param{diffrentjfm}=\texttt{pright};\\
7836 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{paverage};
7837 \end{cases}.
7838 \]
7839 \item
7840 \Param{differentjfm}がそれ以外の値の時は,<ratio>の値は無視され,JFM由来のグルー/カーンは以下の値となる:
7841 \[
7842  f(\textit{gb},\textit{ga})
7843 \]
7844 ここで.$f(x,y)$は
7845 \[
7846  f(x,y)=\begin{cases}
7847 \min(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{small};\\
7848 \max(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{large};\\
7849 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{average};\\
7850 x+y&\text{if\ }\Param{diffrentjfm}=\texttt{both};
7851 \end{cases}.
7852 \]
7853 \end{itemize}
7854 \end{enumerate}
7855
7856 例えば,
7857 \begin{lstlisting}
7858 \jfont\foo=psft:Ryumin-Light:jfm=ujis;-kern
7859 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis;-kern
7860 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo;-kern
7861 \end{lstlisting}
7862 という3フォントを考え,
7863 \[
7864  \overbrace{\Node{glyph}{\cs{ foo}, `あ'}}^{p}
7865 \longrightarrow \overbrace{\Node{glyph}{\cs{bar}, `い'}}^{q}
7866 \longrightarrow \overbrace{\Node{glyph}{\cs{baz}, `う'}}^{r}
7867 \]
7868 という3ノードを考える(それぞれ単独でクラスタをなす).
7869 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
7870 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
7871 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
7872 以下で定めた量「右空白」として採用する.
7873 この段階においては,\cs{inhibitglue} は効力を持たないため,
7874 結果として,2つの和文文字間には常に何らかのグルー/カーンが挿入されることとなる.
7875 \begin{enumerate}
7876 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
7877 \Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
7878 \item ユーザ側から見た\Param{kanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
7879 なければ,\Param{kanjiskip}パラメタの値を持つglueを採用する.
7880 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
7881 どちらか片方のクラスタだけが和文文字(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
7882 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
7883 \end{enumerate}
7884 \end{description}
7885 %\paragraph{「左空白」の算出とそれに伴う補正}
7886 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
7887 %挿入は一切行われない(機能自体削除している).
7888 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
7889 \paragraph{禁則用ペナルティの挿入}
7890 まず,
7891 \[
7892  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
7893 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
7894 \]
7895 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
7896 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
7897 算出では単純な整数の加減算を行う.
7898
7899 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
7900 \begin{description}
7901 \item[P-normal~{[PN]}]
7902 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
7903 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
7904 また,$10000 + (-10000) = 0$としている.
7905
7906 少々困るのは,(a)部分にペナルティが存在していない場合である.
7907 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
7908 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
7909 ということになるが,実際には僅かにこれより複雑である.
7910 \begin{itemize}
7911 \item 「右空白」がカーンであるとき,
7912 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
7913 この場合は$a\neq 0$であってもペナルティの挿入はしない.
7914 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
7915 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
7916 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
7917 %\textit{penalty\_node}を作って挿入する.
7918 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
7919 \end{itemize}
7920 \end{description}
7921
7922 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
7923   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
7924 \begin{table}[t]
7925 %<en>\caption{Summary of JFM glues}
7926 %<ja>\caption{JFM グルーの概要}
7927 \label{tab-jfmglue}
7928 %<en>\medskip
7929 \begin{center}
7930 \small
7931 \begin{tabular}{c|cccccc}
7932 \toprule
7933 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
7934 \sf 和文A&
7935 \gkf{E}{M→K}{PN}&
7936 \gkf{---}{\OA →K}{PN}&
7937 \gkf{---}{\OA →X}{PN}&
7938 \gkf{---}{\OA}{PA}&
7939 \gkf{---}{\OA}{PN}&
7940 \gkf{---}{\OA}{PS}\\
7941 \sf 和文B&
7942 \gkf{E}{\OB→K}{PA}&
7943 \gkf{---}{K}{PS}&
7944 \gkf{---}{X}{PS}\\
7945 \sf 欧文&
7946 \gkf{E}{\OB →X}{PA}&
7947 \gkf{---}{X}{PS}\cr
7948 \sf 箱&\gkf{E}{\OB}{PA}\\
7949 \sf glue&\gkf{E}{\OB}{PN}\\
7950 \sf kern&\gkf{E}{\OB}{PS}\\
7951 \bottomrule
7952 \end{tabular}
7953 \end{center}
7954 \begin{quote}
7955 %<*en>
7956 In the table above, {\small\gkf{E}{M→K}{PN}} means that
7957 %</en>
7958 %<*ja>
7959 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
7960 %</ja>
7961 \begin{enumerate}
7962 %<*en>
7963 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
7964 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
7965 %</en>
7966 %<*ja>
7967 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
7968   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
7969 %</ja>
7970
7971 % %<*en>
7972 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is
7973 %   determined by the method ``\textsf{line-end~[E]}''.
7974 % %</en>
7975 % %<*ja>
7976 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
7977 %   方法で決定される.
7978 % %</ja>
7979
7980 %<*en>
7981 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty
7982   between two clusters for \emph{kinsoku shori}.
7983 %</en>
7984 %<*ja>
7985 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを設定するために「\textsf{P-normal~[PN]}」の方法を採用する.
7986 %</ja>
7987 \end{enumerate}
7988 \end{quote}
7989 \end{table}
7990
7991 \subsection{その他の場合}
7992 本節の内容は表\ref{tab-jfmglue}にまとめてある.
7993
7994 \paragraph{和文Aと欧文の間}
7995 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
7996 \begin{itemize}
7997 \item 「右空白」については,まず以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
7998 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
7999 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
8000 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
8001 \end{itemize}
8002 \begin{description}
8003 \item[Boundary-B~{[\OB]}] 和文文字と「和文でないもの」との間に入る空白を以下によって求め,
8004 未定義でなければそれを「右空白」として採用する.
8005 \textsf{JFM-origin~[M]}の変種と考えて良い.
8006 これによって定まる空白の典型例は,和文の閉じ括弧と欧文文字の間に入る半角アキである.
8007 \begin{enumerate}
8008 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合%
8009 (証としてwhatsitノードが自動挿入される),「右空白」は未定義.
8010 \item そうでなければ,
8011 \textit{Nq}と「文字コードが {\tt'jcharbdd'} の文字」との間に入るグルー/カーンとして定まる.
8012 \end{enumerate}
8013 \item[\Param{xkanjiskip}~{[X]}]
8014 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
8015 以下で定めた量を「右空白」として採用する.
8016 \cs{inhibitglue} は効力を持たない.
8017 \begin{enumerate}
8018 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
8019 \begin{itemize}
8020 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
8021 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
8022 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
8023 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
8024 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
8025 \end{itemize}
8026 \item ユーザ側から見た\Param{xkanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
8027 なければ,\Param{xkanjiskip}パラメタの値を持つglueを採用する.
8028 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
8029 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
8030 \end{enumerate}
8031 \end{description}
8032
8033 \paragraph{欧文と和文Aの間}
8034 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
8035 \textsf{和文A}のクラスタが逆になるので,\textsf{Boundary-A~[\OA]}の部分が変わるだけ.
8036 \begin{itemize}
8037 \item 「右空白」については,まず以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
8038 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
8039 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
8040 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
8041 \end{itemize}
8042 \begin{description}
8043 \item[Boundary-A~{[\OA]}] 「和文でないもの」と和文文字との間に入る空白を以下によって求め,
8044 未定義でなければそれを「右空白」として採用する.
8045 \textsf{JFM-origin~[M]}の変種と考えて良い.
8046 これによって定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
8047 \begin{enumerate}
8048 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),次へ.
8049 \item そうでなければ,
8050 「文字コードが {\tt'jcharbdd'} の文字」と\textit{Np}との間に入るグルー/カーンとして定まる.
8051 \end{enumerate}
8052 \end{description}
8053
8054 \paragraph{和文Aと箱・グルー・カーンの間}
8055 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
8056 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
8057 ペナルティの挿入処理は若干異なったものとなっている.
8058
8059 \begin{itemize}
8060 \item 「右空白」については,既に述べた\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
8061 それが失敗した場合は,「右空白」は挿入されない.
8062 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
8063 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
8064 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
8065 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
8066 \[
8067  a:=(\text{\textit{Nq}の文字に対する\Param{postbreakpenalty}の値}).
8068 \]
8069 \begin{description}
8070 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
8071 (明示的に両クラスタの間に \cs{penalty10000} があった場合を除き)いつも許容される.そのため,
8072 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
8073 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
8074 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
8075 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
8076 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
8077 \end{description}
8078 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
8079 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
8080 \end{itemize}
8081
8082 \begin{description}
8083 \item[P-allow~{[PA]}]
8084 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
8085 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
8086
8087 (a)部分にペナルティが存在していない場合,
8088 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
8089 そのために,以下のいずれかの場合に$a$をもつ\textit{penalty\_node}を作って
8090 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
8091 \begin{itemize}
8092 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
8093 \item $a\neq 0$のときは,「右空白」がグルーであっても\textit{penalty\_node}を作る.
8094 \end{itemize}
8095
8096 \item[P-suppress~{[PS]}]
8097 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
8098 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
8099
8100 (a)部分にペナルティが存在していない場合,
8101 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
8102 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
8103 そのため,「右空白」がglueであれば,その直前に \cs{penalty10000} を挿入する.
8104 \end{description}
8105
8106 \paragraph{箱・グルー・カーンと和文Aの間}
8107 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
8108 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
8109 %が,「左空白」がなくなることにのみ注意.
8110 \begin{itemize}
8111 \item 「右空白」については,既に述べた\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
8112 それが失敗した場合は,「右空白」は挿入されない.
8113 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
8114 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
8115 $\mathit{Nq}.\mathit{tail}$は無意味なので,
8116 \[
8117  a:=(\text{\textit{Np}の文字に対する\Param{prebreakpenalty}の値}).
8118 \]
8119 \begin{description}
8120 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
8121 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
8122 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
8123 \end{description}
8124 \end{itemize}
8125
8126 \paragraph{和文Aと和文Bの違い}
8127 先に述べたように,\textsf{和文B}はhboxの中身の先頭(or 末尾)として出現している
8128 和文文字である.リスト内に直接ノードとして現れている和文文字(\textsf{和文A})との違いは,
8129 \begin{itemize}
8130 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
8131 \textsf{JFM-origin~[M]},\textsf{Boundary-A~[\OA]},\textsf{Boundary-B~[\OB]})の挿入は行われない.
8132 %「左空白」の算出も行われない.
8133 例えば,
8134 \begin{itemize}
8135 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
8136 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
8137 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
8138 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
8139 \end{itemize}
8140 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
8141 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
8142 \textsf{P-suppress~[PS]}が用いられる.
8143 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
8144 \end{itemize}
8145
8146
8147 次が具体例である:
8148 \begin{LTXexample}
8149 あ.\inhibitglue A\\
8150 \hbox{あ.}A\\
8151 あ.A
8152 \end{LTXexample}
8153 \begin{itemize}
8154 \item 1行目の\cs{inhibitglue}は\textsf{Boundary-B~[\OB]}の処理のみを抑止するので,ピリオドと「A」の間には
8155 \Param{xkanjiskip}(四分アキ)が入ることに注意.
8156 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(hboxの中身の末尾として登場しているから)ので,
8157 そもそも\textsf{Boundary-B~[\OB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
8158 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
8159 ピリオドと「A」の間には\textsf{Boundary-B~[\OB]}由来の半角アキが入ることになる.
8160 \end{itemize}
8161 %</ja>
8162
8163 %<*ja>
8164 \section{ベースライン補正の方法}
8165 \subsection{\texttt{yoffset} フィールド}
8166 \Param{yalbaselineshift}等のベースライン補正は,基本的には対象となっている
8167 \textit{glyph\_node}の \texttt{yoffset} フィールドの値を増減することによって
8168 実装されている.なお,\texttt{yoffset} の値は上方向への移動量であるのに対し,
8169 \Param{yalbaselineshift}などは下方向への移動量である.
8170
8171 さて,\texttt{yoffset} の増減によって見かけのグリフ位置は上下に移動するが,
8172 仮想ボディの高さ$h$,深さ$d$については
8173 \begin{description}
8174 \catcode`\<=12\catcode`\>=12
8175  \item[$\texttt{yoffset}\geq 0$のとき] 
8176 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, 
8177 $d = \max(\texttt{depth} - \texttt{yoffset}, 0)$, 
8178  \item[$\texttt{yoffset}<0$のとき] 
8179 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, $d=\texttt{depth}$.
8180 \end{description}
8181 という仕様になっている.つまり,\texttt{yoffset} が負(グリフを下ける)の場合に深さは増加しな
8182 い(表\ref{tab:yoffset_and_im}参照).
8183
8184 \begin{table}[t]
8185 \caption{\texttt{yoffset} and imaginary body}
8186 \label{tab:yoffset_and_im}
8187 \centering\small
8188 \fboxsep0pt
8189 \def\T#1#2{\fcolorbox{blue}{white}{%
8190   \setbox0=\hbox{\LARGE #1%
8191     \directlua{
8192       local p = tex.nest[tex.nest.ptr].tail
8193       p.yoffset = #2 * 65536
8194     }%
8195   }%
8196   \copy0\kern-\wd0\smash{\color{red}\vrule width \wd0 height 0.2pt depth 0.2pt}%
8197 }}
8198 \begin{tabular}{>{\bfseries}lccccc}
8199 \toprule
8200 \texttt{yoffset}&10\,pt&5\,pt&0&$-5$\,pt&$-10$\,pt\\
8201 \midrule
8202 仮想ボディ&\T{y}{10}, \T{H}{10}&\T{y}{5}, \T{H}{5}&\T{y}{0}, \T{H}{0}%
8203 &\T{y}{-5}, \T{H}{-5}&\T{y}{-10}, \T{H}{-10}\\[10pt]
8204 \bottomrule
8205 \end{tabular}
8206 \end{table}
8207
8208 \subsection{\textbf{ALchar}の補正}
8209 上記の問題について,\textbf{ALchar}のベースライン補正では
8210 「正しい深さ」を持った罫線(rule)を補うという対応策をとった.
8211 この罫線による補正は,\textit{id}が\textit{id\_glyph}であるクラスタ単位,
8212 大雑把に言えば音節単位で行われる.
8213 文字列``Typeset''を
8214 \begin{itemize}
8215  \item フォントはLatin Modern Roman (\texttt{lmroman10-regular.otf}) 10\,pt
8216  \item \Param{yalbaselineshift}は5\,pt
8217 \end{itemize}
8218 という状況で組んだ場合を例にとって説明しよう.
8219
8220 \LuaTeX・\Pkg{luaotfload}によるカーニング・ハイフネーションが終わった段階では,
8221
8222
8223
8224 %</ja>
8225
8226 %<en>\section{Patch for the \Pkg{listings} Package}
8227 %<ja>\section{\Pkg{listings} パッケージへの対応}
8228
8229 %<*en>
8230 It is well-known that the \Pkg{listings} package outputs weird results
8231 for Japanese input.
8232 The \Pkg{listings} package makes most of letters active and assigns
8233 output command for each letter~(\cite{listings}).
8234 But Japanese characters are not included in these activated letters.
8235 For \pTeX{} series, there is no method to make Japanese characters active;
8236 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
8237 %</en>
8238 %<*ja>
8239 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
8240 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
8241 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
8242 力命令を割り当てている(\cite{listings}).
8243 しかし,そこでアクティブにする文字の中に,和文文
8244 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
8245 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
8246 %</ja>
8247
8248 %<*en>
8249 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
8250 The callback function inserts the output command (active character \texttt{U+FFFFF})
8251 before each letter above \texttt{U+0080}.
8252 This method can omits the process to make all Japanese characters active
8253 (most of the activated characters are not used in many cases).
8254 %</en>
8255 %<*ja>
8256 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
8257 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
8258 という方法をとっている.出力命令としては,アクティブ文字化した \texttt{U+FFFFF} を用いている.
8259 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
8260 見通しが良い実装になっている.
8261 %</ja>
8262
8263
8264 %<*en>
8265 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
8266 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
8267 %</en>
8268 %<*ja>
8269 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
8270 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
8271 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
8272 意識する必要はない.
8273 %</ja>
8274
8275 %<en>\subsection{Notes}
8276 %<ja>\subsection{注意}
8277 %<*en>
8278 \paragraph{Escaping to \LaTeX}
8279 We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
8280 But it has a drawback; any commands whose name contains a \textbf{JAchar}
8281 cannot be used in any ``escape to \LaTeX''.
8282
8283 Consider the following input:
8284 %</en>
8285 %<*ja>
8286 \paragraph{\LaTeX へのエスケープ}
8287 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
8288 \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
8289 \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
8290 例えば次のような入力を考えよう:
8291 %</ja>
8292 \begin{verbatim*}
8293 \begin{lstlisting}[escapechar=\#]
8294 #\ほげ xぴよ#
8295 \end{lstlisting}
8296 \end{verbatim*}
8297 %<en>The line~2 is transformed by the callback to
8298 %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
8299 \begin{lstlisting}[showspaces, escapechar=\!]
8300 #\!\IVSA FFFFF!ほ!\IVSA FFFFF!げ x!\IVSA FFFFF!ぴ!\IVSA FFFFF!よ#
8301 \end{lstlisting}
8302 %<*en>
8303 before the line is actually processed.
8304 In the escape (between the character ``\verb+#+''),
8305 the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
8306 Hence the control symbol ``\cs{}\IVSA FFFFF'' will be executed,
8307 instead of ``\verb+\ほげ+''.
8308 %</en>
8309 %<*ja>
8310 と変換されてから,実際の処理に回される.
8311 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
8312 \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
8313 結局「\verb+\ほげ+」の代わりに
8314 「\cs{}\IVSA FFFFF」というcontrol symbolが実行されることになる.
8315 %</ja>
8316
8317 %<*ja>
8318 \paragraph{異体字セレクタの扱い}
8319 \texttt{lstlisting} 環境などの内部にある異体字セレクタを扱うため,
8320 \Pkg{lltjp-listings} では \texttt{vsraw} と \texttt{vscmd} という2つのキーを追加した.
8321 しかし,\Pkg{lltjp-listings} が実際に読み込まれるのは \verb+\begin{document}+\
8322 のところであるので,プリアンブル内ではこれらの追加キーは使用できない.
8323
8324 \texttt{vsraw}は,ブール値の値をとるキーであり,標準ではfalseである.
8325 \begin{itemize}
8326  \item trueの場合は,異体字セレクタは「直前の文字に続けて」出力される.
8327 もしもIVSサポート(\ref{ssec-ltjotf}節)が有効になっていた場合は,
8328 以下の例(左側は入力,右側はその出力)のようになる.
8329 \begin{LTXexample}
8330 \begin{lstlisting}[vsraw=true]
8331 葛󠄀城市,葛󠄁飾区,葛西
8332 \end{lstlisting}
8333 \end{LTXexample}
8334 \item falseの場合は,異体字セレクタは適当な命令によって「見える形で」出力される.
8335 どのような形で出力されるかを規定するのが \texttt{vscmd} キーであり,
8336 \Pkg{lltjp-listings} の標準設定では以下の例の右側のように出力される.
8337 \begin{LTXexample}
8338 \begin{lstlisting}[vsraw=false,
8339    vscmd=\ltjlistingsvsstdcmd]
8340 葛󠄀城市,葛󠄁飾区,葛西
8341 \end{lstlisting}
8342 \end{LTXexample}
8343 ちなみに,本ドキュメントでは次のようにしている:
8344 \begin{lstlisting}[numbers=left]
8345 \def\IVSA#1#2#3#4#5{%
8346   \textcolor{blue}{\raisebox{3.5pt}{\tt%
8347     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
8348 }
8349 {\catcode`\%=11
8350   \gdef\IVSB#1{\expandafter\IVSA\directlua{
8351     local cat_str = luatexbase.catcodetables['string']
8352     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
8353 }}}
8354 \lstset{vscmd=\IVSB}
8355 \end{lstlisting}
8356 \end{itemize}
8357 既定の出力命令を復活させたい場合は\ \verb+vsraw=\ltjlistingsvsstdcmd+\
8358 とすれば良い.
8359 %</ja>
8360
8361 %<en>\subsection{Class of Characters}
8362 %<ja>\subsection{文字種}
8363
8364 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
8365 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
8366 \begin{enumerate}
8367 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
8368 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
8369 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
8370 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
8371 %<en>\item Collects \textit{others}.
8372 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
8373 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
8374 %<ja>\item letterが出現したら集めた文字列を出力する.
8375 %<en>\item Turns back to 1.
8376 %<ja>\item 1.に戻る.
8377 \end{enumerate}
8378 %<*en>
8379 By the above process, line breaks inside of an identifier are blocked.
8380 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
8381 for the name of identifiers or not.
8382 %</en>
8383 %<*ja>
8384 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
8385 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
8386 %</ja>
8387
8388 %<*en>
8389 For Japanese characters, line breaks are permitted on both sides
8390 except for brackets, dashes, etc.
8391 Hence the patch \Pkg{lltjp-listings} introduces
8392 a new flag \verb+\lst@ifkanji+, which indicates
8393 whether the previous character is a Japanese character or not.
8394 For illustration, we introduce following classes of characters:
8395 %</en>
8396 %<*ja>
8397 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
8398 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
8399 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
8400 以降,説明のために以下のように文字を分類する:
8401 %</ja>
8402 \begin{center}
8403 \small
8404 \begin{tabular}{lccccc}
8405 \toprule
8406 &Letter&Other&Kanji&Open&Close\\\midrule
8407 \verb+\lst@ifletter+&T&F&T&F&T\\
8408 \verb+\lst@ifkanji+&F&F&T&T&F\\
8409 %<en>Meaning&char in an identifier&other alphabet&%
8410 %<en>most of Japanese char&opening brackets&closing brackets\\
8411 %<ja>意図&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
8412 \bottomrule
8413 \end{tabular}
8414 \end{center}
8415 %<*en>
8416 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
8417 Other according to circumstances.
8418 %</en>
8419 %<*ja>
8420 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
8421 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
8422 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
8423 これは間違いではない.
8424 %</ja>
8425
8426 %<*en>
8427 For example, let us consider the case an Open comes after a Letter.
8428 Since an Open represents Japanese open brackets,
8429 it is preferred to be permitted to insert line break after the Letter.
8430 Therefore, the collected character string is output in this case.
8431 %</en>
8432 %<*ja>
8433 例えば,Letterの直後にOpenが来た場合を考える.
8434 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
8435 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
8436 %</ja>
8437
8438 %<*en>
8439 The following table summarizes $5\times 5=25$ cases:
8440 %</en>
8441 %<*ja>
8442 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
8443 %</ja>
8444 \begin{center}
8445 \small
8446 \begin{tabular}{llccccc}
8447 \toprule
8448 %<*en>
8449 &&\multicolumn{4}{c}{Next}\\\cmidrule(lr){3-7}
8450 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8451 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8452 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8453 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8454 Prev&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8455 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
8456 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8457 %</en>
8458 %<*ja>
8459 &&\multicolumn{4}{c}{後ろ側の文字}\\\cmidrule(lr){3-7}
8460 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8461 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8462 直&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8463 前&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8464 文&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8465 字&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
8466 種&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8467 %</ja>
8468 \bottomrule
8469 \end{tabular}
8470 \end{center}
8471 %<en>In the above table,
8472 %<ja>上の表において,
8473 \begin{itemize}
8474 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
8475 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
8476
8477 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
8478 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
8479 \end{itemize}
8480
8481 %<*en>
8482 Characters above or equal to~\texttt{U+0080} \emph{except Variation Selectors}
8483 are classified into above 5~classes by the following rules:
8484 %</en>
8485 %<*ja>
8486 \texttt{U+0080}以降の\emph{異体字セレクタ以外の}各文字が
8487 Letter, Other, Kanji, Open, Closeのどれに属するかは次によって決まる:
8488 %</ja>
8489 \begin{itemize}
8490 %<en>\item \textbf{ALchar}s above \texttt{U+0080} are classified as Letter.
8491 %<ja>\item (\texttt{U+0080}以降の)\textbf{ALchar}は,すべてLetter扱いである.
8492
8493 %<en>\item \textbf{JAchar}s are classified in the order as follows:
8494 %<ja>\item \textbf{JAchar}については,以下の順序に従って文字種を決める:
8495 \begin{enumerate}
8496 %<en>\item Characters whose \Param{prebreakpenalty} is greater than or equal to 0 are classified as Open.
8497 %<ja>\item \Param{prebreakpenalty}が0以上の文字はOpen扱いである.
8498
8499 %<en>\item Characters whose \Param{postbreakpenalty} is greater than or equal to 0 are classified as Close.
8500 %<ja>\item \Param{postbreakpenalty}が0以上の文字はClose扱いである.
8501
8502 %<en>\item Characters that don't satisfy the above two conditions are classified as Kanji.
8503 %<ja>\item 上の3条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
8504 \end{enumerate}
8505 \end{itemize}
8506
8507 %<*en>
8508 The width of halfwidth kana (\texttt{U+FF61}--\texttt{U+FF9F})
8509 is same as the width of \textbf{ALchar};
8510 the width of the other \textbf{JAchar}s is double the width of \textbf{ALchar}.
8511 %</en>
8512 %<*ja>
8513 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
8514 半角カナは欧文文字1文字分の幅となる.
8515 %</ja>
8516
8517 %<*en>
8518 This classification process is executed every time a character appears in
8519 the \texttt{lstlisting} environment or other environments/commands.
8520 %</en>
8521 %<*ja>
8522 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
8523 %</ja>
8524
8525 %<*ja>
8526 \section{和文の行長補正方法}
8527 \label{sec-adjspec}
8528 \Pkg{luatexja-adjust} で提供される優先順位付きの行長調整の詳細を述
8529 べる.大まかに述べると,次のようになる.
8530 \begin{itemize}
8531 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
8532       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{xkanjiskip},
8533       \Param{kanjiskip},JFMグルー)と
8534       それ以外のグルーの全てで(優先順位なく)負担される.
8535 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
8536       落中の各行ごとに},行末文字の位置を調整したり,優先度付きの行長調整
8537       を実現するためにグルーの伸縮度を調整する.
8538       その処理においては,グルーの自然長と\textbf{JAglue}以外の
8539       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
8540       変更する設計とした.
8541
8542 \Pkg{luatexja-adjust} の作用は,この処理を行うcallbackを追加するだけであり,
8543       この章の残りではcallbackでの処理について解説する.
8544 \end{itemize}
8545
8546 \paragraph{準備:合計伸縮量の計算}
8547 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
8548 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
8549 いう4つの無限大レベル(後ろの方ほど大きい)があり,行の調整に
8550 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている場合は,そ
8551 の行に対しての処理を中止}する.
8552
8553 よって,以降,問題にしている行の行長調整は伸縮度が有限長のグルーを用いて
8554 行われているとして良い.さらに,簡単のため,この行はグルーが広げられている
8555 (自然長で組むと望ましい行長よりの短い)場合しか扱わない.
8556
8557 まず,段落中の行中のグルーを
8558 \begin{itemize}
8559 \item \textbf{JAglue}ではないグルー
8560 \item JFMグルー(優先度\footnote{%
8561   \ref{ssec-jfm-str}節にあるように,
8562   各JFMグルーには$-2$から2までの優先度がついている.}%
8563 別にまとめられる)
8564 \item 和欧文間空白(\Param{xkanjiskip})
8565 \item 和文間空白(\Param{kanjiskip})
8566 \end{itemize}
8567 の$1+1+5+1=8$つに類別し,それぞれの種別ごとに
8568 許容されている伸び量(\texttt{stretch}の値)の合計を計算する.
8569 また,行長と自然長との差を\textit{total}とおく.
8570
8571
8572 \subsection{行末文字の位置調整}
8573 行末が文字クラス$n$の\textbf{JAchar}であった場合,
8574 それを動かすことによって,\textit{total}のうち
8575 \textbf{JAglue}が負担する分を少なくしようとする.
8576 この行末文字の左右の移動可能量は,
8577 JFM中にある文字クラス$n$の定義の
8578 \texttt{end\_stretch},~\texttt{end\_shrink}フィールドに
8579 全角単位の値として記述されている.
8580
8581 例えば,行末文字が句点「。」であり,そこで用いられているJFM中に
8582 \begin{lstlisting}
8583   [2] = {
8584     chars = { '。', ... }, width = 0.5, ...,
8585     end_stretch = 0.5, end_shrink = 0.5,
8586   },
8587 \end{lstlisting}
8588 という指定があった場合,この行末の句点は
8589 \begin{itemize}
8590 \item 通常の\TeX の行分割処理で「半角以上の詰め」が行われていた場合,
8591 この行中の\textbf{JAglue}の負担を軽減するため,
8592 行末の句点を半角だけ右に移動する(ぶら下げ組を行う).
8593 \item 通常の\TeX の行分割処理で「半角以上の空き」が行われていた場合,
8594 逆に行末句点を半角左に移動させる(見た目的に全角取りとなる).
8595 \item 以上のどちらでもない場合,行末句点の位置調整は行わない.
8596 \end{itemize}
8597 となる.
8598
8599 行末文字を移動した場合,その分だけ\textit{total}の値を引いておく.
8600
8601 \subsection{グルーの調整}
8602 \textit{total}の分だけが,行中のグルーの伸び量に応じて負担されることになる.
8603 負担するグルーの優先度は以下の順であり,
8604 できるだけ\Param{kanjiskip}を自然長のままにすることを
8605 試みている.
8606 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
8607  \item \textbf{JAglue}以外のグルー
8608  \item 優先度2のJFMグルー
8609  \item 優先度1のJFMグルー
8610  \item 優先度0のJFMグルー
8611  \item 優先度$-1$のJFMグルー
8612  \item 優先度$-2$のJFMグルー
8613  \item \Param{xkanjiskip}
8614  \item \Param{kanjiskip}
8615 \end{enumerate}
8616 \begin{enumerate}
8617  \item 行末の和文文字を移動したことで$\textit{total}=0$となれば,
8618 調整の必要はなく,行が格納されているhboxの
8619 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
8620 以降,$\textit{total}\neq 0$と仮定する.
8621  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
8622        合計,と称す)よりも小さければ,
8623 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
8624 よって,以下の処理を行う:
8625 \begin{enumerate}
8626 \item 各\textbf{JAglue}の伸び量を0とする.
8627 \item 行が格納されているhboxの
8628 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8629 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8630 \end{enumerate}
8631 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(H)のどこまで負担すれば
8632 \textit{total}以上になるかを計算する.
8633 例えば,
8634 \[\catcode`\<=12
8635  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
8636  \qquad 0\le p<1
8637 \]
8638 であった場合,各グルーは次のように組まれる:
8639 \begin{itemize}
8640  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
8641  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
8642  \item (D)--(H)に属するグルーは自然長のまま.
8643 \end{itemize}
8644 実際には,前に述べた「設計」に従い,次のように処理している:
8645 \begin{enumerate}
8646 \item (C)に属するグルーの伸び量を$p$倍する.
8647 \item (D)--(H)に属するグルーの伸び量を0とする.
8648 \item 行が格納されているhboxの
8649 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8650 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8651 \end{enumerate}
8652 \item \textit{total}が(A)--(H)の伸び量の合計よりも大きい場合,どうしようもないので
8653       \verb+^^;+何もしない.
8654 \end{enumerate}
8655
8656 %</ja>
8657
8658 %<*ja>
8659 \section{IVS対応}
8660 \verb+luatexja.otf.enable_ivs()+ を実行し,IVS対応を有効にした状態では,
8661 \verb+pre_linebreak_filter+ や \verb+hpack_filter+ コールバックには
8662 次の4つが順に実行される状態となっている:
8663 \begin{description}
8664 \item[\tt ltj.do\_ivs] \textit{glyph\_node}~$p$の直後に,異体字セレクタ(を表す\textit{glyph\_node})
8665 が連続した場合に,$p$のフォントに対応したが持つ「異体字情報」に従って出力するグリフを変える.
8666
8667 しかし,単に$p.\textit{char}$を変更するだけでは,後から
8668 font featureの適用(すぐ下)により置換される可能性がある.そのため,
8669 \cs{CID} や \cs{UTF} と同じように,\textit{glyph\_node}~$p$の代わりに
8670 \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを用いている.
8671 \item[(\Pkg{luaotfload} によるfont featureの適用)]
8672 \item[\tt ltj.otf] \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを
8673 きちんと\textit{glyph\_node}に変換する.この処理は,\cs{CID}, \cs{UTF}やIVSによる置換が,
8674 font featureの適用で上書きされてしまうのを防止するためである.
8675 \item[\tt ltj.main\_process] \textbf{JAglue}の挿入処理(\ref{sec-jfmglue}章)と,
8676 JFMの指定に従って各\textbf{JAchar}の「寸法を補正」することを行う.
8677 \end{description}
8678
8679 問題は各フォントの持っているIVS情報をどのように取得するか,である.
8680 \Pkg{luaotfload} はフォント番号<font\_number>の情報を\
8681 \texttt{fonts.hashes.identifiers[<font\_number>]} 以下に格納している.
8682 しかし,OpenTypeフォントのIVS情報は格納されていないようである%
8683 \footnote{TrueTypeフォントに関しては,
8684 \begin{center}
8685 \texttt{fonts.hashes.idenfiers[<font\_number>]%
8686   .resources.variants[<selector>][<base\_char>]}
8687 \end{center}
8688 に,<base\_char>番の文字の後に異体字セレクタ<selector>が続いた場合に
8689 出力すべきグリフが書かれてある.}.
8690 %例えば,小塚明朝Pr6N~Rでは,
8691
8692 一方,\LuaTeX 内部の \texttt{fontloader} の返すテーブルには
8693 OpenTypeフォントでもTrueTypeフォントでもIVS情報が格納されている.
8694 具体的には……
8695
8696 そのため,\LuaTeX-jaのIVS対応においては,\LuaTeX 内部の\
8697 \texttt{fontloader} を直接用いることで,フォントのIVS情報を取得している.
8698 20140114.0以降でキャッシュを用いるようにした要因はここにあり,
8699 \texttt{fontloader} の呼び出しでかなり時間を消費することから,
8700 %%% to_table を使わなくしたことで,メモリ使用量は減った
8701 IVS情報をキャッシュに保存することで2回目以降の実行時間を節約している.
8702
8703
8704 \section{複数フォントの「合成」(未完)}
8705
8706 \section{\LuaTeX-jaにおけるキャッシュ}
8707 \Pkg{luaotfload}パッケージが,各TrueType・OpenTypeフォントの情報を
8708 キャッシュとして保存しているのと同様の方法で,
8709 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
8710 \begin{itemize}
8711  \item 通常,キャッシュは\texttt{\$TEXMFVAR/luatexja/}以下に保存され,
8712 そこから読み込みが行われる.
8713  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua})以外にも,
8714 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
8715 \begin{itemize}
8716  \item \LuaTeX とLuaJIT\TeX ではバイトコードの形式が異なるため,バイナリ形式の
8717 キャッシュは共有できない.\LuaTeX 用のバイナリキャッシュは \texttt{.luc},
8718 LuaJIT\TeX 用のは \texttt{.lub} と拡張子を変えることで対応している.
8719  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
8720 テキスト形式のものよりそちらを優先して読み込む.
8721  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
8722 同時に更新される.
8723 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
8724 \LuaTeX-jaはバイナリキャッシュを作成する.
8725 \end{itemize}
8726 \end{itemize}
8727 %</ja>
8728 %<*en>
8729 \section{Cache Management of \LuaTeX-ja}
8730 \LuaTeX-ja creates some cache files to reduce the loading time.
8731 in a similar way to the \Pkg{luaotfload} package:
8732 \begin{itemize}
8733  \item Cache files are usually stored in (and loaded from)
8734 \texttt{\$TEXMFVAR/luatexja/}.
8735  \item In addition to caches of the text form (the extension is ``\texttt{.lua}''),
8736 caches of the \emph{binary}, precompiled form are supported.
8737 \begin{itemize}
8738  \item We cannot share same binary cache for \LuaTeX\ and LuaJIT\TeX.
8739 Hence we distinguish them by their extension, ``\texttt{.luc}'' for \LuaTeX\
8740 and ``\texttt{.lub}'' for LuaJIT\TeX.
8741  \item In loading a cache, the binary cache precedes
8742 the text form.
8743  \item When \LuaTeX-ja updates a cache \texttt{hoge.lua},
8744 its binary version is also updated.
8745 \end{itemize}
8746 \end{itemize}
8747 %</en>
8748
8749 %<*ja>
8750 \subsection{キャッシュの使用箇所}
8751
8752 \LuaTeX-ja では以下の3種類のキャッシュを使用している:
8753 \begin{cslist}
8754 \item[ltj-cid-auto-adobe-japan1.lua]
8755 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
8756 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
8757 生成には\texttt{UniJIS2004-UTF32-\{H, V\}}, \texttt{Adobe-Japan1-UCS2}という3つの
8758 CMapが必要である.
8759
8760 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
8761 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
8762 キャッシュの名称,必要となるCMapについては表\ref{tab:cid-cache}を参照して欲しい.
8763
8764 \item[extra\_***.lua]
8765 フォント``\texttt{***}''における異体字セレクタの情報,縦組用字形への変換テーブル,そして
8766 縦組時における幅を格納している.構造は以下の通り:
8767 %</ja>
8768 %<*en>
8769 \subsection{Use of Cache}
8770
8771 \LuaTeX-ja uses the following cache:
8772 \begin{cslist}
8773 \item[ltj-cid-auto-adobe-japan1.lua]
8774 The font table of a CID-keyed non-embedded Japanese font.
8775 This is loaded in every run.
8776 It is created from two CMaps, \texttt{UniJIS2004-UTF32-H} and
8777              \texttt{Adobe-Japan1-UCS2},
8778 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
8779
8780 Similar caches are created as Table~\ref{tab:cid-cache},
8781 if you specified \texttt{cid} key in \cs{jfont}
8782 to use other CID-keyed non-embedded fonts for Chinese or Korean,
8783 as in Page~\pageref{para-cid}.
8784
8785 \item[extra\_***.lua]
8786 This file stores the table which stores the following.
8787 \begin{itemize}
8788  \item unicode variants in a font ``\texttt{***}''
8789  \item vertical width of glyphs, if it is not equal to the sum of 
8790 the height of ascender and the depth of descender
8791  \item vertical variants
8792 \end{itemize}
8793 The following is the structure of the that table.
8794 %</en>
8795
8796 \begin{table}[!tb]
8797  \centering\small
8798 \caption{\texttt{cid} key and corresponding files}
8799 \label{tab:cid-cache}
8800 \vspace*{\medskipamount}
8801 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
8802 \toprule
8803 \bf \texttt{cid} key&\bf name of the cache &
8804 \multicolumn{2}{c}{\bf used CMaps}\\
8805 \midrule
8806 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.lua&UniJIS2004-UTF32-H&Adobe-Japan1-UCS2\\
8807 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.lua&UniKS-UTF32-H&Adobe-Korea1-UCS2\\
8808 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.lua&UniGB-UTF32-H&Adobe-GB1-UCS2\\
8809 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.lua&UniCNS-UTF32-H&Adobe-CNS1-UCS2\\
8810 \bottomrule
8811 \end{tabular}
8812 \end{table}
8813
8814 \begin{lstlisting}
8815 return {
8816  {
8817   [10955]={    -- U+2ACB "Subset Of Above Not Equal To"
8818    [65024]=983879, -- <2ACB FE00>
8819    ["vwidth"]=0.98, -- vertical width
8820   },
8821   [37001]={    -- U+9089 "邉"
8822    [0]=37001,  --   <9089 E0100>
8823    991049,     --   <9089 E0101>
8824    ...
8825    ["vert"]=995025, -- vertical variant
8826   },
8827   ...
8828  },
8829  ["chksum"]="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", -- checksum of the fontfile
8830  ["version"]=2, -- version of the cache
8831 }
8832 \end{lstlisting}
8833 %<*ja>
8834 \item[ltj-jisx0208.\{luc|lub\}]
8835 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイナリ化したものである.
8836 これはJIS~X~0208とUnicodeとの変換テーブルであり,
8837 \pTeX との互換目的の文字コード変換命令で用いられる.
8838 %</ja>
8839 %<*en>
8840 \item[ltj-jisx0208.\{luc|lub\}]
8841 The binary version of \texttt{ltj-jisx0208.lua}.
8842 This is the conversion table between JIS~X~0208 and Unicode
8843 which is used in Kanji-code conversion commands for compatibility with \pTeX.
8844 %</en>
8845 \end{cslist}
8846
8847 %<*en>
8848 \subsection{Internal}
8849 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
8850 (\texttt{ltj-base.lua}).
8851 There are three public functions for cache management in \texttt{luatexja.base},
8852 where <filename> stands for the file name \emph{without suffix}:
8853 \begin{cslist}
8854 \item[save\_cache(<filename>, <data>)]
8855 Save a non-nil table <data> into a cache <filename>.
8856 Both the text form <filename>\texttt{.lua} and its binary version
8857 are created or updated.
8858
8859 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
8860
8861 Same as \texttt{save\_cache}, except that only the binary cache is updated.
8862 The third argument <serialized\_data> is not usually given.
8863 But if this is given, it is treated as a string representation of <data>.
8864
8865 \item[load\_cache(<filename>, <outdate>)]
8866 Load the cache <filename>.
8867 <outdate> is a function which takes one argument (the contents of the cache),
8868 and its return value is whether the cache is outdated.
8869
8870 \texttt{load\_cache} first tries to
8871 read the binary cache <filename>\texttt{.\{luc|lub\}}.
8872 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
8873 If the binary cache is not found or
8874 its contents is outdated, \texttt{load\_cache} tries to
8875 read the text form <filename>\texttt{.lua}.
8876 Hence, the return value of \texttt{load\_cache} is non-nil,
8877 if and only if the updated cache is found.
8878 \end{cslist}
8879 %</en>
8880 %<*ja>
8881 \subsection{内部命令}
8882 \LuaTeX-jaにおけるキャッシュ管理は,\texttt{luatexja.base}~(\texttt{ltj-base.lua})に
8883 実装しており,以下の3関数が公開されている.
8884 ここで,<filename>は保存するキャッシュのファイル名を\emph{拡張子なしで}指定する.
8885 \begin{cslist}
8886 \item[save\_cache(<filename>, <data>)]
8887 nilでない<data>をキャッシュ<filename>に保存する.
8888 テキスト形式の<filename>\texttt{.lua}のみならず,
8889 そのバイナリ版も作成/更新される.
8890
8891 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
8892
8893 \texttt{save\_cache}と同様だが,バイナリキャッシュのみが更新される.
8894 第3引数<serialized\_data>が与えられた場合,それを
8895 <data>の文字列化表現として使用する.
8896 そのため,<serialized\_data>は普通は指定しないことになるだろう.
8897
8898 \item[load\_cache(<filename>, <outdate>)]
8899 キャッシュ<filename>を読み込む.
8900 <outdate>は1引数(キャッシュの中身)をとる関数であり,
8901 その戻り値は「キャッシュの更新が必要」かどうかを示すブール値でないといけない.
8902
8903 \texttt{load\_cache}は,まずバイナリキャッシュ<filename>\texttt{.\{luc|lub\}}を
8904 読みこむ.もしその内容が「新しい」,つまり<outdate>の評価結果が \texttt{false} なら
8905 \texttt{load\_cache}はこのバイナリキャッシュの中身を返す.
8906 もしバイナリキャッシュが見つからなかったか,「古すぎる」ならばテキスト版
8907              <filename>\texttt{.lua}を読み込み,その値を返す.
8908
8909 以上より,\texttt{load\_cache}自体がnilでない値を返すのは,ちょうど「新しい」キャッシュが
8910 見つかった場合である.
8911 \end{cslist}
8912 %</ja>
8913
8914
8915 %<*ja>
8916 \section{縦組の実装}
8917 \label{sec-dir-imp}
8918 \ref{sec-direction}章の最初でも述べたように,
8919 \LuaTeX-jaは横組(\texttt{TLT})で組んだボックスを回転させる方式で
8920 縦組を実装している.
8921
8922 \LuaTeX-jaにおける縦組の実装は
8923 \pTeX における実装(\cite{ptexdoc,ptextug})をベースにしている.
8924
8925 \subsection{direction~whatsit}
8926 \textit{direction}~whatsitとは,\textit{direction}という特定の \verb+user_id+ を持つ
8927 whatsitのことであり,以下のタイミングで作られる.
8928 \begin{itemize}
8929  \item 組方向を \cs{tate} 等で変更したとき.
8930  \item \cs{hbox}, \cs{vbox}, \cs{vtop} による明示的なボックスの開始時.\\
8931 \verb+\hbox{}+, \verb+\vbox{}+ といった,
8932 \begin{itemize}
8933  \item \cs{tate} 等によりボックス内部の組方向を変更していない
8934  \item ボックスの中身のリストが空である
8935 \end{itemize}
8936 場合は,\LuaTeX の \verb+hpack_filter+, \verb+vpack_filter+ といった
8937 callbackに処理が回らない.そこで,\LuaTeX-ja では,\cs{everyhbox}, \cs{everyvbox} を利用す
8938        ることで各ボックスの先頭に確実に追加するようにしている\footnote{%
8939   問題は \cs{hbox to 25pt\{\}} という状況である.実際のこのボックスの中身は空でない(少な
8940        くともdirection whatsitがある)ため,何も対策をしなければhpack時にUnderfill警告が発
8941        生してしまうことになる.\LuaTeX-jaではそうならないように「\cs{hbadness},
8942        \cs{vbadness} を一時的に10000に変更し,hpack, vpack後に元の値に戻す」処理を行ってい
8943        る.
8944 }.
8945  \item \cs{vsplit}によってvboxを分割した時の「残り」の先頭.
8946  \item \LuaTeX-ja読み込み前に作成したボックスの寸法を \cs{ltjsetwd} 等によって変更した時.
8947  \item \cs{insert} によるinsertionでは,中身の先頭に\textit{direction}~whatsitは作られず,
8948 その代わりに中身の各ボックス・罫線の直前に作られる\footnote{%
8949  これは,ページ分割の過程でinsertionが分割される時,「現在のページで出力される部分」が空と
8950        なることがあることによる.先頭にwhatsitを置くと,最悪でも「現在のページにwhatsitが
8951        残る」ことになってしまう.}.
8952 \end{itemize}
8953 なお,\verb+\vtop{...}+ の場合は,先頭にdirection whatsitを置くと
8954 ボックスの高さが常に0\,ptになるという問題が発生する.そのため,この場合に限っては
8955 vpack時にdirection whatsitをリストの2番目に移動させている.
8956
8957 direction whatsitはあくまでも組方向処理のための補助的なノードであるので,
8958 \cs{unhbox}, \cs{unhcopy} によってボックスの中身が展開される時には展開直前に削除される.
8959 これは
8960 \begin{lstlisting}
8961  % yoko direction
8962 \setbox0=\hbox{\tate B}
8963 \noindent % 水平モードに入る.この時点でのリストの中身は空
8964 \unhbox0 A
8965 \end{lstlisting}
8966 といった場合に,段落が縦組で組まれたり,あるいは
8967 \begin{lstlisting}
8968 \setbox0=\hbox{}
8969 \leavevmode \hbox{A}\unhbox0
8970 \setbox1=\lastbox % \box1 はどうなる?
8971 \end{lstlisting}
8972 で \cs{box1} が \cs{hbox\{A\}} でなく空になってしまうことを防ぐためである.
8973
8974
8975 \subsection{\textit{dir\_box}}
8976 縦中横など異方向のボックスを配置する場合に,周囲の組方向と大きさを整合させるため,
8977 \LuaTeX-jaでは \verb+\ltj@dir+ が128以降の\textit{hlist\_node}, \textit{vlist\_node}を
8978 用いる.これらは\pTeX における\textit{dir\_node}の役割と同じ果たしており,
8979 この文章中では\textit{dir\_box}と呼称する.
8980
8981 \subsubsection{異方向のボックスの整合}
8982 \textit{dir\_box}の第一の使用目的は,異方向のボックスの大きさを整合させることである.
8983 例えば,
8984 \begin{lstlisting}
8985  % yoko direction
8986 平成\hbox{\tate 26}年
8987 \end{lstlisting}
8988 は段落中で
8989 \[
8990  \xymatrix{
8991    {}\Node{glyph}{`平'}\ar[r]&{}\Node{glyph}{`成'}\ar[r]&
8992    {}\HNode{hlist}{10.00003}{3.02779}{0.0}\ar[r]\ar[d]^{\text{中身}}&{}\Node{glyph}{`年'}\\
8993    &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
8994  }
8995 \]
8996 というリストを作る.その後,この段落が終了したときに,
8997 \LuaTeX-jaの\textbf{JAglue}挿入処理が行われ
8998 \[
8999  \xymatrix{
9000    {}\Node{glyph}{`平'}\ar[r]
9001   &{}\textcolor{blue}{\Node{glue}{\Param{xkanjiskip}}}\ar[r]
9002   &{}\Node{glyph}{`成'}\ar[r]
9003   &{}\textcolor{blue}{\Node{penalty}{0}}
9004     \ar`r[d] `[l] `[ddll] `[dl] [dl]
9005   \\
9006   &&{}\textcolor{red}{\HNode{hlist}{3.02779}{10.00003}{0.0}}\ar[r]\ar[d]^{\text{中身}}
9007   &{}\textcolor{blue}{\Node{penalty}{0}}\ar[r]
9008   &{}\Node{glyph}{`年'}\\
9009   &&{}\HNode{\textit{dir\_box} (\cs{yoko})}{10.00003}{3.02779}{0.0}\ar[d]^{\text{中身}}\\
9010   &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
9011  }
9012 \]
9013 のようになる(青字は\textbf{JAglue},赤字が整合処理のための\textit{dir\_box}である).
9014 \TeX の \cs{showbox} 形式で書けば
9015
9016 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
9017 \catcode`\@=0 @catcode`@\=12
9018 .\tenmin 平
9019 @textcolor{blue}{.\glue 0.0 plus 0.4 minus 0.4}
9020 .\tenmin 成
9021 @textcolor{blue}{.\penalty 0}
9022 @textcolor{red}{.\hbox(10.00003+0.0)x3.02779, direction TLT}
9023 ..\hbox(3.02779+0.0)x10.00003, direction TLT
9024 ...\whatsit4=[]
9025 ...\tenrm 2
9026 ...\tenrm 6
9027 @textcolor{blue}{.\penalty 0}
9028 .\tenmin 年
9029 }\medskip
9030
9031 \noindent である.
9032
9033 なお,\cs{raise},~\cs{lower}, \cs{moveleft},~\cs{moveright} といったボックス移動命令では.
9034 移動を正しく表現するために段落やボックスの途中でも異方向のボックスは\textit{dir\_box}にカ
9035 プセル化している.
9036 例えば
9037 \begin{lstlisting}
9038  % yoko direction
9039 平成\raise1pt\hbox{\tate 26}年\showlists
9040 \end{lstlisting}
9041 は以下のような結果を得る.
9042
9043 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
9044 \catcode`\@=0 @catcode`@\=12
9045 (前略)
9046 \tenrm 平
9047 \tenrm 成
9048 @textcolor{red}{\hbox(10.00003+0.0)x3.02779, shifted -1.0, direction TLT}
9049 .\hbox(3.02779+0.0)x10.00003, direction TLT
9050 ..\whatsit4=[]
9051 ..\tenrm 2
9052 ..\tenrm 6
9053 \tenrm 年
9054 }\medskip
9055
9056 また,メインの垂直リストに異方向のボックスが追加される場合にも同様に即座に
9057 \textit{dir\_box}にカプセル化している.ページ分割のタイミングを正
9058 しく\TeX が判断するためである.
9059 \cs{lastbox} によるボックスの取得では,\textit{dir\_box}は削除される.
9060
9061 \subsubsection{異方向のボックス寸法の格納}
9062 第二の使用目的は,現在の組方向がボックス本来の組方向とは異なる状況で,
9063 \cs{ltjsetwd} によってボックス寸法を設定されたことを記録することである.
9064
9065 例えば
9066 \begin{lstlisting}[numbers=left]
9067 \setbox0=\hbox{\vrule width 10pt height 5pt depth 2pt}
9068 \setbox1=\hbox{\tate\ltjsetwd0=20pt}
9069 \wd0=9pt
9070 \setbox1=\hbox{\dtou\ltjsetwd0=20pt}
9071 \setbox0=\hbox{\dtou a\box0}
9072 \end{lstlisting}
9073 というコードを考える.1行目で \cs{box0} には横組の
9074 幅10\,pt,高さ5\,pt,深さ2\,ptのボックスが代入される.
9075 よって,
9076 \begin{itemize}
9077  \item 縦組下では \cs{box0} は幅7\,pt,高さ・深さ5\,ptのボックスとして扱われる.
9078  \item \cs{dtou} 下では \cs{box0} は幅7\,pt,高さ10\,pt,深さ0\,ptのボックスとして扱われる.
9079 \end{itemize}
9080 このとき,\cs{box0} の\emph{中身}は
9081 \[
9082  \xymatrix{
9083    {}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
9084  }
9085 \]
9086 である.
9087
9088 さて,2行目で縦組時の \cs{box0} の幅が20\,ptに設定される.この情報が
9089 direction~whatsit内部のノードリストに,\textit{dir\_box}として格納される:
9090 \[
9091  \xymatrix{
9092    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
9093    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}}
9094  }
9095 \]
9096
9097 次に,3行目では横組時の,つまり \cs{box0} 本来の組方向での深さが9\,ptに変更される.
9098 このとき,\cs{box0} は
9099 \begin{itemize}
9100  \item 縦組下では寸法代入が既に行われているので,2行目で作成された\textit{dir\_box}の通り
9101        に幅20\,pt,高さ・深さ5\,ptのボックスとして扱われる.
9102  \item \cs{dtou} 下ではまだ寸法代入が行われていないので,
9103 \cs{box0} の寸法変更に追従し,幅7\,pt,高さ9\,pt,深さ0\,ptのボックスとして扱われる.
9104 \end{itemize}
9105
9106 4行目では \cs{dtou} 下での\cs{box0} の幅が20\,ptに設定されるので,2行目と同じように
9107 \[
9108  \xymatrix{
9109    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
9110    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[r]&
9111    {}\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}
9112  }
9113 \]
9114 と\textit{dir\_box}が作成される.
9115
9116 このように寸法代入によってつくられた\textit{dir\_box}は,前節の整合過程のときに再利用され
9117 る.上記の例でいえば,5行目を実行した後の \cs{box0} の内容は
9118 \[
9119  \xymatrix{
9120    {}\Node{whatsit}{\cs{dtou}}\ar[r]&
9121    {}\Node{glyph}{`a'}\ar[r]&
9122    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[d]_{\text{中身}}\\
9123    &&{}\HNode{hlist}{9.0}{5.0}{2.0}\ar[d]_{\text{中身}}\\
9124    &&{}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
9125  }
9126 \]
9127 のようになる.
9128 %</ja>
9129
9130 \newpage
9131 \begin{thebibliography}{99}
9132   \addcontentsline{toc}{section}{\refname}
9133 \bibitem{texbytopic}
9134 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
9135 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
9136 \bibitem{uptex} Takuji Tanaka. \newblock
9137 upTeX---Unicode version of pTeX with CJK extensions,
9138 TUG 2013, October 2013.
9139 %<ja>\newblock
9140 %<en>\\\null\hfill
9141 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
9142 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert.
9143 %<en>\newblock
9144 %<ja>\\\null\hfill
9145 \url{http://mytexpert.sourceforge.jp/index.php?Listings}
9146 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
9147 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
9148 \url{http://www.w3.org/TR/jlreq/}%
9149 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
9150 \bibitem{min10} 乙部厳己.min10フォントについて.\\\null\hfill
9151 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
9152 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard). JIS~X~4051,
9153 日本語文書の組版方法(Formatting rules for Japanese documents), 1993, 1995, 2004.
9154 \bibitem{ptexdoc} 濱野尚人,田村明史,倉沢良一.\TeX の出版への応用—縦組み機能の組み込み—.
9155 \\\null\hfill\texttt{.../texmf-dist/doc/ptex/base/ptexdoc.pdf}
9156 \bibitem{ptextug} Hisato Hamano. \newblock
9157 \textit{Vertical Typesetting with \TeX}, TUGBoat~\textbf{11}(3), 346--352, 1990.
9158 \bibitem{pdfstd} International Organization for Standardization. \newblock
9159 ISO 32000-1:2008, \textit{Document management -- Portable document format -- Part 1: PDF
9160       1.7}, 2008. \newblock
9161 \\\null\hfill
9162 \url{http://www.iso.org/iso/iso\_catalogue/catalogue_tc/catalogue\_detail.htm?csnumber=51502}
9163 \end{thebibliography}
9164
9165 \end{document}
9166 %</!showexpl>
9167 %<*showexpl>
9168 %%
9169 %% config file for showexpl.sty
9170 %%
9171 %% Copyright The LuaTeX-ja project team, 2012
9172 %%
9173 \ProvidesFile{showexpl.cfg}
9174   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
9175 \lstset{}
9176 \def\SX@Info{}
9177 \endinput
9178 %</*showexpl>