OSDN Git Service

target release date: 2019-01-07 (documentation: WIP)
[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 \IfFileExists{luatex85.sty}{\RequirePackage{luatex85}}{}
12
13 %<en>\documentclass[a4paper,titlepage]{article}
14 %<ja>\documentclass[a4paper,10ptj,titlepage]{ltjsarticle}
15
16 %%%%%%%%
17 \makeatletter
18 %%%%%%%%
19 \def\pgfsysdriver{pgfsys-pdftex.def}
20 \directlua{if jit then jit.on() end}
21 \usepackage{metalogo,amsmath,array,tikz,pict2e,multienum,float}
22 \usepackage{booktabs,multicol,luatexja-ruby}
23 \usepackage[all]{xy}
24 \usepackage{lltjext,alltt,comment}
25
26 %%%%%%%% Lua GC
27 \patchcmd\@outputpage{\stepcounter{page}}{%
28   \directlua{%
29         if jit then
30       local k = collectgarbage("count")
31       if k>900000 then 
32         collectgarbage("collect")
33         texio.write_nl("term and log", "GC: ", math.floor(k), math.floor(collectgarbage("count")))
34       end
35         end
36   }%
37   \stepcounter{page}%
38 }{}{}
39
40 %%%%%%%% fonts
41 \usepackage{luatexja-otf}
42 \usepackage[no-math]{fontspec}
43 \setmainfont[Ligatures=TeX]{Linux Libertine O}
44 \setmonofont[Scale=MatchLowercase, ItalicFont=lmmono10-italic.otf,
45   BoldFont=lmmonolt10-bold.otf, BoldItalicFont=lmmonolt10-boldoblique.otf
46 ]{lmmono10-regular.otf}
47 \setsansfont[Scale=MatchLowercase,Ligatures=TeX]{Linux Biolinum O}
48 \usepackage[match]{luatexja-fontspec}
49 \usepackage[kozuka-pr6n]{luatexja-preset}
50 \usepackage{unicode-math}
51 \setmonojfont{KozGoPr6N-Regular.otf}
52 \setmathfont[Scale=MatchLowercase]{XITSMath}
53
54 \setLaTeXa{\scshape a}
55 %<*ja>
56 \def\emph#1{\textbf{\textgt{#1}}}
57 \def\headfont{\normalfont\bfseries\gtfamily}\normalsize
58 %</ja>
59 %<*en>
60 \frenchspacing\sloppy
61 \usepackage[margin=25mm,lmargin=30mm,rmargin=30mm,footskip=6mm]{geometry}
62 \usepackage{luatexja-adjust}\ltjdisableadjust
63 \parskip=\smallskipamount
64 \makeatletter
65 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
66     {3.25ex \@plus1ex \@minus.2ex}%
67     {-1em}%
68     {\normalfont\normalsize\bfseries\raisebox{.2ex}{$\mdlgblksquare\mkern1mu$}}}
69 %</en>
70 %<*ja>
71 \usepackage[textwidth=44\zw, lines=41, footskip=6mm]{geometry}
72 \usepackage{luatexja-adjust}%\ltjdisableadjust
73 \advance\leftmargini-1\zw\advance\leftmarginii-1\zw
74 %</ja>
75 %<en>\long\def\fakefn#1#2{\par\noindent{\footnotesize\hbox to1.8em{\hss#1}#2\par}}
76 %<*ja>
77 \long\def\fakefn#1#2{%
78   \par{\footnotesize\advance\leftskip 3\zw\parindent1\zw\noindent
79   \llap{#1\hskip.3\zw}#2\par}}
80 %</ja>
81 %%%%%%%% listings
82
83 %%%%%%%% IVS
84
85 \def\IVS#1{\char\numexpr "E0100+#1\relax}%"
86 \def\IVSA#1#2#3#4#5{%
87   \textcolor{blue}{\raisebox{3.5pt}{\tt%
88     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
89 }
90 {\catcode`\%=11
91   \gdef\IVSB#1{\expandafter\IVSA\directlua{
92     local cat_str = luatexbase.catcodetables['string']
93     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
94 }}}
95
96 \usepackage{listings,showexpl,enumitem}
97 \lstset{
98   basicstyle=\ttfamily\small, pos=r, breaklines=true,
99   numbers=none, rframe={}, basewidth=0.5em, numberstyle=\tiny, numbersep=0.5em,
100   explpreset={numberstyle=\tiny, numbers=left, numbersep=1em, columns=fixed}
101 }
102 % Suppress output from showexpl to stdout.
103 \makeatletter
104 \let\SX@Info\relax
105
106 %%%%%%%% colors
107 %% modified from http://jfly.iam.u-tokyo.ac.jp/colorset/
108 \usepackage{transparent}
109 \definecolor{red}{rgb}{1, 0.16, 0}
110 \definecolor{blue}{rgb}{0, 0.25, 1}
111 \definecolor{gray}{rgb}{.50, .53, .56}
112 \definecolor{green}{rgb}{.21, .63, .42}
113 \definecolor{cyan}{rgb}{0.40, .80, 1}
114 \definecolor{b_gray}{rgb}{0.78, 0.78, 0.80}
115 \definecolor{b_pink}{rgb}{1, 0.82, 0.82}
116 \definecolor{b_green}{rgb}{.53, .91, .69}
117 \definecolor{b_cyan}{rgb}{0.70, .92, 98}
118
119 %%%%%%%% hyperref
120 \usepackage{hyperref,bookmark}
121 %<*en>
122 \title{The \LuaTeX-ja package}
123 \author{The \LuaTeX-ja project team}
124 \date{\LuaTeXjaversion~(\today)}
125 %</en>
126 %<*ja>
127 \title{\LuaTeX-jaパッケージ}
128 \author{\LuaTeX-jaプロジェクトチーム}
129 \date{\LuaTeXjaversion(\today)}
130 %</ja>
131 \hypersetup{%
132         unicode,
133         colorlinks,
134         allbordercolors=1 1 1,
135         allcolors=blue,
136 %<*en>
137         pdfauthor={The LuaTeX-ja project team},
138         pdftitle={The LuaTeX-ja package}
139 %</en>
140 %<*ja>
141         pdfauthor={LuaTeX-jaプロジェクトチーム},
142         pdftitle={LuaTeX-jaパッケージ}
143 %</ja>
144 }
145 %<*ja>
146 \def\HyRef@autoref#1#2{%
147   \begingroup
148     \Hy@safe@activestrue
149     \expandafter\HyRef@autosetref\csname r@#2\endcsname{#2}{#1}%
150   \endgroup\ltjalchar"200C %" 欧文ゴースト
151 }
152 \def\figureautorefname{図}
153 \def\tableautorefname{表}
154 %</ja>
155
156 %%%%%%%% definition env.
157 \usepackage{amsthm}
158 \theoremstyle{definition}
159 %<en>\newtheorem{defn}{Definition}
160 %<ja>\newtheorem{defn}{定義}
161
162 %%%%%%%% logo
163 \usepackage{metalogo}
164 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
165 \DeclareRobustCommand\LuaTeX{Lua\TeX}
166 \DeclareRobustCommand\pdfTeX{pdf\TeX}
167 \DeclareRobustCommand\pTeX{p\kern-.15em\TeX}
168 \DeclareRobustCommand\upTeX{up\kern-.15em\TeX}
169 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
170 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
171 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\pTeX}
172
173 %%%%%%%% other macros
174 \newlist{cslist}{description}{2}
175 \setlist[cslist]{%
176     style=nextline,font=\mdseries\ttfamily,
177     before*=\def\<{\char`\<}\def\>{\char`\>}\def\{{\char`\{}\def\}{\char`\}},
178     topsep=\medskipamount,
179 %<ja> leftmargin=2\zw,
180 %<en> leftmargin=2em,
181 }
182
183 \def\labelenumii{(\arabic{enumii})}
184 \long\def\@makecaption#1#2{%
185   \vskip\abovecaptionskip
186   \sbox\@tempboxa{{\small #1. #2}}%
187   \ifdim \wd\@tempboxa >\hsize
188     {\small #1. #2}\par
189   \else
190     \global \@minipagefalse
191     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
192   \fi
193   \vskip\belowcaptionskip}
194
195 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
196 \def\cs#1{\texttt{\upshape
197   \texorpdfstring{\textbackslash\hbox{\ltjsetparameter{autoxspacing=false}#1}}{\textbackslash#1}}}
198 \ltjsetparameter{alxspmode={`\\,allow}}
199 %%%%%%%%
200 \makeatother
201 %%%%%%%%
202
203 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
204   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}\strut#2\cr}}}}}\,}
205 \def\HNode#1#2#3#4{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
206   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}%
207   width:\hfill\ #2\cr height:\hfill\ #3\cr depth:\hfill\ #4\cr
208   }}}}}\,}
209
210 \makeatletter
211 \def\myghost{\ifmmode\else\ltjalchar"200C \fi}
212 \def\Param#1{\texorpdfstring{\@Param{#1}}{#1}} % parameter name
213 \protected\def\@Param#1{\myghost\hyperlink{fld:#1}{\underline{\smash{\textsf{#1}}}}\myghost}
214 \protected\def\DParam#1{\myghost\hypertarget{fld:#1}{\underline{\smash{\textsf{#1}}}}\myghost} % parameter name (definition)
215 \def\Pkg#1{\texorpdfstring{\textsf{#1}}{#1}} % packages/classes
216 \ltjsetparameter{alxspmode={"200C,allow}}
217
218 \begin{document}
219 \lstset{
220   vscmd=\IVSB
221 }
222
223 \catcode`\<=13
224 \def<#1>{{\normalfont\rm\itshape$\langle$#1\/$\rangle$}}
225 \let\LARG=<
226 \maketitle
227
228 \tableofcontents
229 \bigskip
230
231 %<*en>
232 \textbf{This documentation is far from complete. It may have many
233 grammatical (and contextual) errors.} Also, several parts
234 are written in Japanese only.
235 %</en>
236 %<*ja>
237 \emph{\large 本ドキュメントはまだまだ未完成です.}
238 %</ja>
239
240 \clearpage
241 %<en>\part{User's manual}
242 %<ja>\part{ユーザーズマニュアル}
243
244 %<en>\section{Introduction}
245 %<ja>\section{はじめに}
246
247
248 %<*en>
249 The \LuaTeX-ja package is a macro package for typesetting high-quality
250 Japanese documents when using \LuaTeX.
251 %</en>
252 %<*ja>
253 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
254 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
255 %</ja>
256 %<en>\subsection{Backgrounds}
257 %<ja>\subsection{背景}
258
259 %<*en>
260 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
261 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
262 extension of \TeX: so it can produce high-quality Japanese documents
263 without using very complicated macros. But this point is a mixed
264 blessing: \pTeX\ is left behind from other extensions of \TeX,
265 especially \eTeX\ and \pdfTeX, and from changes about
266 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
267 %</en>
268 %<*ja>
269 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
270 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
271 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
272 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
273 もなってしまった.\pTeX という(組版的に)満足なものがあったため,海外で
274 行われている数々の\TeX の拡張――例えば\eTeX や\pdfTeX ――や,TrueType,
275 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
276 を怠ってしまったのだ.
277 %</ja>
278
279 %<*en>
280 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
281 of \pTeX) and \epTeX\ (merging of \pTeX\ and
282 \eTeX\ extension), have developed to fill those gaps to some
283 extent, but gaps still exist.
284 %</en>
285 %<*ja>
286 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
287 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
288 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
289 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
290 るようになった.だが,\pdfTeX 拡張(PDF直接出力やmicro-typesetting)を
291 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
292 る.
293 %</ja>
294
295 %<*en>
296 However, the appearance of \LuaTeX\ changed the whole situation. With
297 using Lua ``callbacks'', users can customize the internal processing of
298 \LuaTeX. So there is no need to modify sources of engines to
299 support Japanese typesetting: to do this, we only have to write Lua
300 scripts for appropriate callbacks.
301 %</en>
302 %<*ja>
303 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
304 ``callback''を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
305 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
306 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
307 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
308 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
309 が始まったパッケージである.
310 %</ja>
311
312 %<en>\subsection{Major changes from \pTeX}
313 %<ja>\subsection{\pTeX からの主な変更点}
314 \label{ssec:chgptex}
315
316 %<*en>
317 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
318 target of development was to implement features of \pTeX. However,
319 implementing all feature of \pTeX\ is impossible,
320 since all process of \LuaTeX-ja must be implemented only by Lua and \TeX\ macros.
321 Hence \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
322 specifications/behaviors of \pTeX\ were not adopted}.
323 %</en>
324 %<*ja>
325 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
326 能をLuaコードにより実装することであった.しかし,(\pTeX はエンジン拡張であったのに対し)
327 \LuaTeX-jaはLuaコードと\TeX マクロを用いて全てを実装していなければならないため,\pTeX
328 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
329 ているような状況も発見された.そのため,\emph{\LuaTeX-jaは,もはや
330 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
331 れば,そこは積極的に改める.}
332 %</ja>
333
334 %<*en>
335 The followings are major changes from \pTeX.
336 For more detailed information, see Part~\ref{part-imp} or other sections of this manual.
337 %</en>
338 %<*ja>
339 以下は \pTeX からの主な変更点である.
340 より詳細については第\ref{part-imp}部など本文書の残りを参照.
341 %</ja>
342
343 %<*en>
344 \paragraph{Command names} \pTeX\ addes several primitives, such as \cs{kanjiskip},
345 \cs{prebreakpenalty},~and \cs{ifydir}. They can be used as follows:
346 %</en>
347 %<*ja>
348 \paragraph{命令の名称} 例えば\pTeX で追加された次のようなプリミティブ
349 %</ja>
350 \begin{verbatim}
351 \kanjiskip=10pt  \dimen0=kanjiskip
352 \tbaselineshift=0.1zw
353 \dimen0=\tbaselineshift
354 \prebreakpenalty`ぁ=100
355 \ifydir ... \fi
356 \end{verbatim}
357 %<en> However, we cannot use them under \LuaTeX-ja.
358 %<en> Instead of them, we have to write as the following.
359 %<ja> は\LuaTeX-jaには存在しない.\LuaTeX-jaでは以下のように記述することになる.
360 \begin{verbatim}
361 \ltjsetparameter{kanjiskip=10pt}  \dimen0=\ltjgetparameter{kanjiskip}
362 \ltjsetparameter{talbaselineshift=0.1\zw}
363 \dimen0=\ltjgetparameter{talbaselineshift}
364 \ltjsetparameter{prebreakpenalty={`ぁ,100}}
365 \ifnum\ltjgetparemeter{direction}=4 ... \fi
366 \end{verbatim}
367 %<*en>
368 Note that \pTeX\ adds new two useful units, namely \texttt{zw}~and~\texttt{zh}.
369 As shown above, they are changed by \cs{zw}~and~\cs{zh} respectively, in \LuaTeX-ja.
370 %</en>
371 %<*ja>
372 特に注意してほしいのは,\pTeX で追加された \texttt{zw} と \texttt{zh} という単位は
373 \LuaTeX-ja では使用できず,\cs{zw}, \cs{zh} と制御綴の形にしないといけないという点である.
374 %</ja>
375
376 %<*en>
377 \paragraph{Linebreak after a Japanese character}
378 In \pTeX, a line break after Japanese character is ignored (and
379       doesn't yield a space), since line breaks (in source files) are
380       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
381       doesn't have this feature completely, because of a specification
382       of \LuaTeX. For the detail, see Section~\ref{sec-lbreak}.
383 %</en>
384 %<*ja>
385 \paragraph{和文文字直後の改行}
386 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
387       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
388       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
389       詳しくは\ref{sec-lbreak}章を参照.
390 %</ja>
391
392 %<*en>
393 \paragraph{Spaces related to Japanese characters}
394 The insertion process of glues/kerns between two Japanese
395       characters and between a Japanese character and other characters
396       (we refer glues/kerns of both kinds as \textbf{JAglue}) is rewritten from
397       scratch.
398 %</en>
399 %<*ja>
400 \paragraph{和文関連の空白}
401 2つの和文文字の間や,和文文字と欧文文字の間に入るグルー/カーン
402       (両者をあわせて\textbf{JAglue}と呼ぶ)の挿入処理が0から書き直されている.
403 %</ja>
404
405 \begin{itemize}
406 %<*en>
407 \item As \LuaTeX's internal ligature handling is \emph{node-based}
408       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
409       insertion process of \textbf{JAglue} is now \emph{node-based}.
410 %</en>
411 %<*ja>
412 \item \LuaTeX の内部での合字の扱いは「ノード」を単位として行われるようになっている(例えば,
413       \verb+of{}fice+ で合字は抑制されない).それに合わせ,\textbf{JAglue}の挿入処理も
414       ノード単位で実行される.
415 %</ja>
416
417 %<*en>
418 \item Furthermore, nodes between two characters which have no effects in
419       line break (\textit{e.g.}, \cs{special} node) and kerns from
420       italic correction are ignored in the insertion process.
421 %</en>
422 %<*ja>
423 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \cs{special} ノード)や,
424   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
425 %</ja>
426
427 %<*en>
428 \item \emph{Caution: due to above two points, many methods which did for the
429       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
430       effective anymore.} In concrete terms, the following two methods are not effective anymore:
431 %</en>
432 %<*ja>
433 \item \emph{注意:上の2つの変更により,従来\textbf{JAglue}の挿入処理を分断するのに
434       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
435 %</ja>
436 \begin{lstlisting}
437 ちょ{}っと    ちょ\/っと
438 \end{lstlisting}
439 %<*en>
440       If you want to do so, please put an empty horizontal box (hbox) between it instead:
441 %</en>
442 %<*ja>
443       もし同じことをやりたければ,空の水平ボックス(hbox)を間に挟めばよい:
444 %</ja>
445 \begin{lstlisting}
446 ちょ\hbox{}っと
447 \end{lstlisting}
448
449 %<*en>
450 \item In the process, two Japanese fonts which only differ in their ``real''
451       fonts are identified.
452 %</en>
453 %<*ja>
454 \item 処理中では,2つの和文フォントは,実フォントが異なるだけの場合には同一視
455       される.
456 %</ja>
457 \end{itemize}
458
459 %<*en>
460 \paragraph{Directions}
461 From version~20150420.0, \LuaTeX-ja supports vertical writing.
462 We implement this feature by using callbacks of \LuaTeX; so it must \emph{not} be confused
463 with $\Omega$-style direction support of \LuaTeX\ itself.
464 Due to implementation, the dimension returned by \cs{wd},~\cs{ht}, or~\cs{dp} depends
465 on the content of the register \emph{only}. This is major difference with \pTeX.
466 %</en>
467 %<*ja>
468 \paragraph{組方向}
469 バージョン20150420.0からは,不安定ながらも\LuaTeX-ja における縦組みをサポートしている.
470 なお,\LuaTeX 本体も$\Omega$流の組方向をサポートしているが,それとは全くの別物であること
471 に注意してほしい.
472 特に,異なった組方向のボックスを扱う場合には
473 \cs{wd}, \cs{ht}, \cs{dp}等の仕様が\pTeX と異なるので注意.詳細は第\ref{sec-direction}章を参照.
474 %</ja>
475
476 %<*en>
477 \paragraph{\cs{discretionary}}
478 Japanese characters in discretionary break (\cs{discretionary}) is not supported.
479 %</en>
480 %<*ja>
481 \paragraph{\cs{discretionary}}
482  \cs{discretionary} 内に直接和文文字を記述することは,\pTeX においても想定されていなかった
483  感があるが.\LuaTeX-jaにおいても想定していない.和文文字をどう
484       しても使いたい場合は \cs{hbox} で括ること.
485 %</ja>
486
487 %<*en>
488 \paragraph{Greek and Cyrillic letters, and ISO~8859-1 symbols}
489 By default, \LuaTeX-ja uses Japanese fonts to typeset Greek and Cyrillic letters,
490       To change this behavior,
491       put \verb!\ltjsetparameter{jacharrange={-2,-3}}! in the preamble.
492       For the detailed description, see Subsection~\ref{ssec:setrange}.
493
494 From version~20150906.0, characters which belongs both ISO~8859-1 and JIS~X~0208,
495 such as \P~and~\S, are now typeset in alphabetic fonts.
496 If you are using \LaTeXe\ prior to 2017/01/01, these characters are not typeset correctly
497 without the \cs{fontspec} (and~\Pkg{luatexja-fontspec}) package.
498 %</en>
499 %<*ja>
500 \paragraph{ギリシャ文字・キリル文字とISO~8859-1の記号}
501 標準では,\LuaTeX-jaはギリシャ文字やキリル文字を和文フォントを使っ
502       て組む.ギリシャ語などを本格的に組むなどこの状況が望ましくない場合,
503       プリアンブルに
504 \begin{lstlisting}
505  \ltjsetparameter{jacharrange={-2,-3}}
506 \end{lstlisting}
507       を入れると
508       上記種類の文字は欧文フォントを用いて組まれるようになる.
509       詳しい説明は\ref{ssec:setrange}節を参照してほしい.
510
511 また,\P,~\S といったISO~8859-1の上位領域とJIS~X~0208の共通部分の文字は
512       バージョン20150906.0から標準で欧文扱いとなった.\LaTeXe\ 2017/01/01以降では
513 標準でTUエンコーディングのLatin Modernフォントが使われるので,
514 特に何もせずソース中にそのまま記述してもこれらの文字が出力される
515 \footnote{\LaTeXe\ 2017/01/01より前では,ソース中に直接記述しても
516   \Pkg{fontspec}パッケージ(および\Pkg{luatexja-fontspec}パッケージ)非読み込みの状態では出力されない.}.
517 和文扱いで出力するには \verb+\ltjjachar`§+ のように \cs{ltjjachar} 命令
518 を使えばよい.
519 %</ja>
520
521 %<en>\subsection{Notations}
522 %<ja>\subsection{用語と記法}
523
524 %<*en>
525 In this document, the following terms and notations are used:
526 %</en>
527 %<*ja>
528 本ドキュメントでは,以下の用語と記法を用いる:
529 %</ja>
530 \begin{itemize}
531 %<*en>
532 \item Characters are classified into following two types.
533       Note that the classification can be customized by a user
534       (see Subsection~\ref{ssec:setrange}).
535 %</en>
536 %<*ja>
537 \item 文字は次の2種類に分けられる.この類別は固定されているものではなく,ユーザが後から変更可能である
538       (\ref{ssec:setrange}節を参照).
539 %</ja>
540 \begin{itemize}
541 %<*en>
542 \item \textbf{JAchar}: standing for characters which is used in Japanese typesetting,
543       such as Hiragana,~Katakana, Kanji, and~other Japanese punctuation marks.
544 %</en>
545 %<*ja>
546 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった
547       日本語組版に使われる文字のことを指す.
548 %</ja>
549
550 %<en>\item \textbf{ALchar}: standing for all other characters like latin alphabets.
551 %<ja>\item \textbf{ALchar}: ラテンアルファベットを始めとする,その他全ての文字を指す.
552 \end{itemize}
553
554 %<*en>
555 We say \emph{alphabetic fonts} for fonts used in \textbf{ALchar},
556 and \emph{Japanese fonts} for fonts used in \textbf{JAchar}.
557 %</en>
558 %<*ja>
559 そして,\textbf{ALchar}の出力に用いられるフォントを\emph{欧文フォント}と呼び,
560 \textbf{JAchar}の出力に用いられるフォントを\emph{和文フォント}と呼ぶ.
561 %</ja>
562 %<*en>
563 \item A word in a sans-serif font with underline (like \Param{prebreakpenalty})
564       means an internal parameter for Japanese typesetting, and it
565       is used as a key in \cs{ltjsetparameter} command.
566 %</en>
567 %<*ja>
568 \item 下線つきローマン体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
569       パラメータを表し,これらは \cs{ltjsetparameter} 命令のキーとして
570       用いられる.
571 %</ja>
572 %<*en>
573 \item A word in a sens-serif font without underline (like \Pkg{fontspec})
574       means a package or a class of \LaTeX.
575 %</en>
576 %<*ja>
577 \item 下線なしサンセリフ体の語(例:\Pkg{fontspec})は\LaTeX の
578       パッケージやクラスを表す.
579 %</ja>
580 %<*en>
581 \item In this document, natural numbers start from~zero.
582   $\omega$ denotes the set of all natural numbers which can be used in \TeX.
583 %</en>
584 %<*ja>
585 \item 本ドキュメントでは,自然数は0から始まる.(\TeX で扱える)自然数全体の集合は$\omega$と表記する.
586 %</ja>
587 \end{itemize}
588
589 %<en>\subsection{About the project}
590 %<ja>\subsection{プロジェクトについて}
591
592 %<en>\paragraph{Project Wiki} Project Wiki is under construction.
593 %<ja>\paragraph{プロジェクトWiki} プロジェクトWikiは構築中である.
594 %<*en>
595 \begin{itemize}
596 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
597 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
598 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28zh%29} (Chinese)
599 \end{itemize}
600 %</en>
601 %<*ja>
602 \begin{itemize}
603 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
604 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
605 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28zh%29}(中国語)
606 \end{itemize}
607 %</ja>
608
609 %<en>This project is hosted by OSDN.
610 %<ja>本プロジェクトはOSDNのサービスを用いて運営されている.
611
612 %<en>\paragraph{Members}\
613 %<ja>\clearpage\paragraph{開発メンバー}\
614
615 %<*en>
616 \begin{multienumerate}
617 \def\labelenumi{$\bullet$}
618 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
619 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
620 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
621 \end{multienumerate}
622 %</en>
623 %<*ja>
624 \begin{multienumerate}
625 \def\labelenumi{$\bullet$}
626 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
627 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
628 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
629 \end{multienumerate}
630 %</ja>
631
632 % \paragraph{Acknowledgments} -- 挿入するならここ
633
634 %<en>\clearpage
635 %<en>\section{Getting Started}
636 %<ja>\section{使い方}
637 %<en>\subsection{Installation}
638 %<ja>\subsection{インストール}
639
640 %<en>The following packages are needed for the \LuaTeX-ja\ package.
641 %<ja>\LuaTeX-jaパッケージの動作には次のパッケージ類が必要である.
642 \begin{itemize}
643 \item \LuaTeX\ 1.0.0 (or later)
644 \item \Pkg{luaotfload} v2.6 (or later)
645 \item \Pkg{adobemapping} (Adobe cmap and pdfmapping files)
646 \item \Pkg{etoolbox}, \Pkg{everysel} (if you want to use \LuaTeX-ja with \LaTeXe)
647 \item \Pkg{ltxcmds}, \Pkg{pdftexcmds}, \Pkg{filehook}, \Pkg{atbegshi}
648 \item \Pkg{fontspec} v2.5c (or later)
649 %<en>\item \emph{IPAex fonts} (\url{http://ipafont.ipa.go.jp/})
650 %<ja>\item \emph{IPAexフォント(\url{http://ipafont.ipa.go.jp/})}
651 \end{itemize}
652 %<en>In summary, \LuaTeX-ja version 20180825.0 (or~later) no longer supports \TeX~Live~2016.
653 %<*ja>
654 要約すると,バージョン20180825.0以降の\LuaTeX-jaは\TeX~Live~2016以前では動作しない\footnote{%
655   もっとも,自分で\LuaTeX のバイナリをSubversionリポジトリからビルドしていれば話は別である.
656 }.
657 %</ja>
658
659 %<*en>
660 Now \LuaTeX-ja is available from
661 CTAN (in the \texttt{macros/luatex/generic/luatexja} directory), and
662 the following distributions:
663   \begin{itemize}
664   \item MiK\TeX\ (in \texttt{luatexja.tar.lzma}); see the next subsection
665   \item \TeX\ Live (in \texttt{texmf-dist/tex/luatex/luatexja})
666   \item W32\TeX\ (in \texttt{luatexja.tar.xz})
667   \end{itemize}
668 IPAex fonts are also available in these distributions.
669 %</en>
670 %<*ja>
671 現在,\LuaTeX-jaはCTAN (\texttt{macros/luatex/generic/luatexja})に収録されている他,
672 以下のディストリビューションにも収録されている:
673   \begin{itemize}
674   \item MiK\TeX\ (\texttt{luatexja.tar.lzma})
675   \item \TeX\ Live (\texttt{texmf-dist/tex/luatex/luatexja})
676   \item W32\TeX\ (\texttt{luatexja.tar.xz})
677   \end{itemize}
678 これらのディストリビューションはIPAexフォントも収録している.
679 W32\TeX においてはIPAexフォントは \texttt{luatexja.tar.xz} 内にある.
680 %</ja>
681
682 %<en>\paragraph{Manual installation}
683 %<ja>\paragraph{手動インストール方法}
684
685 \begin{enumerate}
686 %<*en>
687 \item Download the source, by one of the following method.
688       At the present, \LuaTeX-ja has no \emph{stable} release.
689
690 \begin{itemize}
691 \item Clone the Git repository:
692 \begin{lstlisting}
693 $ git clone git://git.osdn.jp/gitroot/luatex-ja/luatexja.git
694 \end{lstlisting}
695 \item Download the \texttt{tar.gz} archive of HEAD in the \texttt{master} branch from
696 \begin{flushleft}
697 \url{http://git.osdn.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
698 \end{flushleft}
699 \end{itemize}
700
701 Note that the \texttt{master} branch, and hence the archive in CTAN, are not updated frequently;
702 the forefront of development is not the \texttt{master} branch.
703 %</en>
704 %<*ja>
705 \item ソースを以下のいずれかの方法で取得する.現在公開されているのはあくまでも
706       開発版であって,安定版でないことに注意.
707
708 \begin{itemize}
709 \item Gitリポジトリをクローンする:
710 \begin{lstlisting}
711 $ git clone git://git.osdn.jp/gitroot/luatex-ja/luatexja.git
712 \end{lstlisting}
713 \item \texttt{master} ブランチのスナップショット(\texttt{tar.gz} 形式)をダウンロードする.
714 \begin{flushleft}
715 \url{http://git.osdn.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
716 \end{flushleft}
717 \end{itemize}
718 \texttt{master} ブランチ(従って,CTAN内のアーカイブも)はたまにしか更新されないことに注意.
719 主な開発は\texttt{master}の外で行われ,比較的まとまってきたらそれを \texttt{master} に
720 反映させることにしている.
721 %</ja>
722
723 %<*en>
724 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
725 But only the contents in \texttt{src/} are needed to work \LuaTeX-ja.
726 %</en>
727 %<*ja>
728 \item 「Gitリポジトリをクローン」以外の方法でアーカイブを取得したならば,それを展開する.
729       \texttt{src/} をはじめとしたいくつかのディレクトリができるが,
730       動作には \texttt{src/} 以下の内容だけで十分.
731 %</ja>
732
733 %<*en>
734 \item If you downloaded this package from CTAN, you have to run following commands
735     to generate classes
736     and \texttt{ltj-kinsoku.lua} (the file which stores default ``\textit{kinsoku}'' parameters):
737 %</en>
738 %<*ja>
739 \item もしCTANから本パッケージを取得したのであれば,日本語用クラスファイルや
740 標準の禁則処理用パラメータを
741 格納した \texttt{ltj-kinsoku.lua} を生成するために,
742 以下を実行する必要がある:
743 %</ja>
744 \begin{lstlisting}
745 $ cd src
746 $ lualatex ltjclasses.ins
747 $ lualatex ltjsclasses.ins
748 $ lualatex ltjltxdoc.ins
749 $ luatex   ltj-kinsoku_make.tex
750 \end{lstlisting}
751 %<*en>
752 \emph{Do not forget The last line (processing \texttt{ltj-kinsoku\_make.tex})}.
753 \texttt{*.\{dtx,ins\}} and \texttt{ltj-kinsoku\_make.tex} used here are not needed in regular use.
754 %</en>
755 %<*ja>
756 \emph{最後の \texttt{ltj-kinsoku\_make.tex} の実行を忘れないように注意}.
757 ここで使用した \texttt{*.\{dtx,ins\}} と \texttt{ltj-kinsoku\_make.tex} は
758 通常の使用にあたっては必要ない.
759 %</ja>
760
761
762
763 %<*en>
764 \item Copy all the contents of \texttt{src/} into one of your \texttt{TEXMF} tree.
765       \texttt{TEXMF/tex/luatex/luatexja/} is an example location.
766       If you cloned entire Git repository, making a symbolic link of \texttt{src/}
767       instead copying is also good.
768 %</en>
769 %<*ja>
770 \item \texttt{src} の中身を自分の \texttt{TEXMF} ツリーにコピーする.
771       場所の例としては,例えば
772 \begin{quote}
773  \texttt{TEXMF/tex/luatex/luatexja/}
774 \end{quote}
775       がある.
776       シンボリックリンクが利用できる環境で,かつリポジトリを直接取得したのであれば,
777       (更新を容易にするために)コピーではなくリンクを貼ることを勧める.
778 %</ja>
779 %<*en>
780 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
781 %</en>
782 %<*ja>
783 \item 必要があれば,\texttt{mktexlsr} を実行する.
784 %</ja>
785 \end{enumerate}
786
787 %<*en>
788 \subsection{Cautions}
789 For changes from \pTeX, see Subsection~\ref{ssec:chgptex}.
790 %</en>
791 %<*ja>
792 \subsection{注意点}
793 \pTeX からの変更点として,\ref{ssec:chgptex}節も熟読するのが望ましい.
794 ここでは一般的な注意点を述べる.
795 %</ja>
796 \begin{itemize}
797 %<*en>
798 \item The encoding of your source file must be UTF-8. Other
799       encodings, such as EUC-JP or Shift-JIS, are not supported.
800 %</en>
801 %<*ja>
802 \item 原稿のソースファイルの文字コードはUTF-8固定である.
803       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
804 %</ja>
805 %<*en>
806 \item \LuaTeX-ja is very slower than \pTeX.
807   Generally speaking, LuaJIT\TeX\ processes \LuaTeX-ja
808   about 30\% faster than \LuaTeX, but not always%
809   \footnote{%
810     LuaJIT has several limitations such as 1\,GB~(or~2\,GB) memory limitation.
811         So typesetting a large source by LuaJIT\TeX may cause an ``out of memory'' error,
812         or failure of loading/saving font cache of \Pkg{luaotfload}.
813   }.
814 %</en>
815 %<*ja>
816 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
817 コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
818 LuaJIT\TeX を用いると\LuaTeX のだいたい1.3倍の速度で動くようであるが,
819 IPA mj明朝などの大きいフォントを用いた場合には\LuaTeX よりも遅くなることもある
820   \footnote{%
821     LuaJITは1\,GB(あるいは2\,GB)のメモリ制限など,いくつかの制限事項があることが知られている.そのため,
822     大きいソースファイルをLuaJIT\TeX でタイプセットするとLuaの側で``out of memory''エラーが発生してしまう.
823     本ドキュメントのように,「各ページごとにLuaで使っているメモリ容量をチェックし,
824     必要なら\texttt{collectgarbage("collect")}でガベージコレクタを実行」すると
825     状況が多少改善されるかもしれない.
826         また,LuaJIT\TeX でIPA mj明朝などの「大きい」フォントを利用した場合はフォントキャッシュの保存に失敗し,
827         毎回フォントを読み込まなければならず結果的に時間がかかることがある.
828   }.
829 %</ja>
830
831 \item%
832 %<*en>
833 \textbf{(Outdated) note for MiK\TeX\ users}\quad
834 \LuaTeX-ja requires that several CMap files%
835 \footnote{\texttt{UniJIS2004-UTF32-\{H,V\}} and \texttt{Adobe-Japan1-UCS2}.}
836 must be found from \LuaTeX.
837 Strictly speaking, those CMaps are needed
838 only in the first run of \LuaTeX-ja after installing or updating.
839 But it seems that MiK\TeX\ does not satisfy this condition,
840 so you will encounter an error like the following:
841 %</en>
842 %<*ja>
843 \LuaTeX-jaが動作するためには,\emph{導入・更新後の初回起動時に}
844 \texttt{UniJIS2004-UTF32-\{H,V\}}, \texttt{Adobe-Japan1-UCS2}という3つのCMapが
845 \LuaTeX によって見つけられることが必要である.
846 しかし古いバージョンのMiK\TeX ではそのようになっていないので,次のエラーが発生するだろう:
847 %</ja>
848 \begin{lstlisting}
849 ! LuaTeX error ...iles (x86)/MiKTeX 2.9/tex/luatex/luatexja/ltj-rmlgbm.lua
850 bad argument #1 to 'open' (string expected, got nil)
851 \end{lstlisting}
852
853 %<*en>
854 If so, please execute a batch file which is written on
855 \href{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{ the Project Wiki (English)}.
856 This batch file creates a temporary directory, copy CMaps in it,
857 run a test file which loads \LuaTeX-ja in this directory,
858 and finally delete the temporary directory.
859 %</en>
860 %<*ja>
861 そのような場合には,
862 \href{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{%
863   プロジェクトWiki英語版トップページ}中に書かれているバッチファイルを
864 実行して欲しい.このバッチファイルは,作業用ディレクトリにCMap達を
865 コピーし,その中で\LuaTeX-jaの初回起動を行い,作業用ディレクトリを消す作業をしている.
866 %</ja>
867
868 \end{itemize}
869
870 %<en>\subsection{Using in plain \TeX}
871 %<ja>\subsection{plain \TeX で使う}
872 \label{ssec:plain}
873
874 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
875 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
876 \begin{lstlisting}
877 \input luatexja.sty
878 \end{lstlisting}
879 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
880 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
881
882 \begin{itemize}
883 %<*en>
884 \item The following 12~Japanese fonts are preloaded:
885 \begin{center}\small
886 \begin{tabular}{cccccc}
887 \toprule
888 \textbf{direction}&
889 \textbf{classification}&\textbf{font name}&\bfseries ``10\,pt''&\bfseries ``7\,pt''&\bfseries ``5\,pt''\\\midrule
890 \smash{\raisebox{-1ex}{\emph{yoko} (horizontal)}}&
891 \emph{mincho}&IPAex Mincho&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
892 &\emph{gothic}&IPAex Gothic&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
893 \midrule
894 \smash{\raisebox{-1ex}{\emph{tate} (vertical)}}&
895 \emph{mincho}&IPAex Mincho&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
896 &\emph{gothic}&IPAex Gothic&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
897 \bottomrule
898 \end{tabular}
899 \end{center}
900 %</en>
901 %<*ja>
902 \item 以下の12個の和文フォントが定義される:
903 \begin{center}\small
904 \begin{tabular}{cccccc}
905 \toprule
906 \emph{組方向}&\emph{字体}&\emph{フォント名}&\bfseries``10\,pt''&\bfseries``7\,pt''&\bfseries``5\,pt''\\\midrule
907 \smash{\raisebox{-1ex}{横組}}&
908 明朝体&IPAex明朝&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
909 &ゴシック体&IPAexゴシック&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
910 \midrule
911 \smash{\raisebox{-1ex}{縦組}}&
912 明朝体&IPAex明朝&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
913 &ゴシック体&IPAexゴシック&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
914 \bottomrule
915 \end{tabular}
916 \end{center}
917 %</ja>
918 \begin{itemize}
919 %<*en>
920 \item With \texttt{luatexja.cfg}, one can use other fonts
921 as ``default'' Japanese fonts (Subsection~\ref{ssec:cfg}).
922 %</en>
923 %<*ja>
924 \item \texttt{luatexja.cfg} を用いることによって,標準和文フォントを
925 IPAexフォントから別のフォントに置き換えることができる.\ref{ssec:cfg}節を参照.
926 %</ja>
927
928 %<*en>
929 \item A character in an alphabetic font is generally smaller than a
930       Japanese font in the same size. So actual size specification of
931       these Japanese fonts is in fact smaller than that of alphabetic
932       fonts, namely scaled by 0.962216.
933 %</en>
934 %<*ja>
935 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
936       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
937       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
938       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
939 %</ja>
940 \end{itemize}
941
942 %<*en>
943 \item The amount of glue that are inserted between a \textbf{JAchar} and
944       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
945 %</en>
946 %<*ja>
947 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{xkanjiskip})の
948       量は次のように設定されている:
949 %</ja>
950 \[
951  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
952  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
953 \]
954 \end{itemize}
955
956 %<en>\subsection{Using in \LaTeX}
957 %<ja>\subsection{\LaTeX で使う}
958 \label{ssec:ltx}
959
960 %<*en>
961 Using in \LaTeXe\ is basically same. To set up the minimal environment
962 for Japanese, you only have to load \texttt{luatexja.sty}:
963 %</en>
964 %<*ja>
965 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
966 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
967 %</ja>
968 \begin{lstlisting}
969 \usepackage{luatexja}
970 \end{lstlisting}
971 %<*en>
972 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
973 plfonts.dtx} and \texttt{pldefs.ltx}).
974 %</en>
975 %<*ja>
976 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
977 なされる.
978 %</ja>
979
980 \begin{itemize}
981 %<*en>
982 \item Font encodings for Japanese fonts are \texttt{JY3}~(for horizontal direction) and
983 \texttt{JT3}~(for vertical direction).
984 %</en>
985 %<*ja>
986 \item 和文フォントのエンコーディングとしては,横組用には \texttt{JY3},縦組用には\
987 \texttt{JT3}が用いられる.
988 %</ja>
989
990 %<*en>
991 \item Traditionally, Japanese documents use only two families: \emph{mincho}~(明朝体) and
992  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
993       is used in the headings or for emphasis.
994 \begin{center}\small
995 \begin{tabular}{lllc}
996 \toprule
997 \textbf{classification}&&&\textbf{commands}\\\midrule
998 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
999 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
1000 \bottomrule
1001 \end{tabular}
1002 \end{center}
1003 \item
1004 By default, the following fonts are used for these two families.
1005 \begin{center}\small
1006 \begin{tabular}{ccccc}
1007 \toprule
1008 \textbf{classification}&\textbf{family}&\cs{mdseries}&\cs{bfseries}&\textbf{scale}\\\midrule
1009 \emph{mincho} (明朝体)&\tt mc&IPAex Mincho&IPAex Gothic&0.962216\\
1010 \emph{gothic} (\textgt{ゴシック体})&\tt gt&IPAex Gothic&IPAex Gothic&0.962216\\
1011 \bottomrule
1012 \end{tabular}
1013 \end{center}
1014 \item Note that the bold series (series \texttt{bx}~or~\texttt{b}) in both family
1015      are same as the medium series of gothic family.
1016      There is no italic nor slanted shape for these \texttt{mc}~and~\texttt{gt}.
1017 %</en>
1018 %<*ja>
1019 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる:
1020 \begin{center}\small
1021 \begin{tabular}{cllc}
1022 \toprule
1023 \emph{字体}&&&\emph{ファミリ名}\\\midrule
1024 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
1025 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
1026 \bottomrule
1027 \end{tabular}
1028 \end{center}
1029   \newpage
1030 \item 標準では,次のフォントが用いられる:
1031 \begin{center}\small
1032 \begin{tabular}{ccccc}
1033 \toprule
1034 \emph{字体}&\emph{ファミリ}&\cs{mdseries}&\cs{bfseries}&\emph{スケール}\\\midrule
1035 明朝体&\tt mc&IPAex明朝&IPAexゴシック&0.962216\\
1036 ゴシック体&\tt gt&IPAexゴシック&IPAexゴシック&0.962216\\
1037 \bottomrule
1038 \end{tabular}
1039 \end{center}
1040
1041 明朝・ゴシックどちらのファミリにおいても,太字(\cs{bfseries})のフォントは
1042 ゴシック体中字(\cs{gtfamily}\cs{mdseries})で使われるフォントと同じであることに注意.
1043 また,どちらのファミリでもイタリック体・スラント体は定義されない.
1044
1045  \item 和文の太字を表すシリーズ名は,(元々のComputer Modernが
1046   太字に\texttt{bx}を用いていたことから)伝統的に\texttt{bx}~(Bold Extended)が使われてきた.
1047   しかし,太字にシリーズ\texttt{b}を使うフォントも増えてきたため,
1048   バージョン20180616.0以降では和文の太字として\texttt{bx},~\texttt{b}の両方を扱えるようにした.
1049 %</ja>
1050
1051 %<*en>
1052  \item From version~20181102.0, one can specifies \texttt{disablejfam} option at
1053   loading \LuaTeX-ja. This option prevents loading a patch for \LaTeX, which are
1054   needed to support Japanese characters in math mode.
1055
1056   Without \texttt{disablejfam} option, one can typeset Japanese characters in
1057   math mode as~\verb+$あ$+ (see Page~\pageref{para:jachar_in_math}) as before.
1058   Japanese characters in math mode are typeset by the font family \texttt{mc}.
1059 %</en>
1060 %<*ja>
1061  \item バージョン20181102.0以降では,\texttt{disablejfam}オプションを\LuaTeX-ja読み込み時に
1062   指定できるようになった.このオプションは,数式モード中に直に和文文字を書けるようにするための
1063   \LaTeX へのパッチを読み込まない.
1064
1065   \texttt{disablejfam}のない状況では,以前と同様に和文文字を数式モード中に
1066   直に書くことができる(但し\autoref{para:jachar_in_math}ページの記述も参照).
1067   その際には明朝体(\texttt{mc})で出力される.
1068 %</ja>
1069 %<*en>
1070  \item \cs{jttdefault}%
1071   \footnote{%
1072         When \Pkg{ltjsclasses} classes are used, or
1073         \Pkg{luatexja-fontspec} (or \Pkg{luatexja-preset}) is loaded with \texttt{match} option,
1074         \cs{ttfamily} changes the current Japanese font amily to \cs{jttdefault}.
1075         These classes and packages also redefine \cs{jttdefault} to
1076         \cs{gtdefault} (\emph{gothic}~family).
1077   } specifies the Japanese font family in \cs{verb}~or~\texttt{verbatim} environment.
1078   The default value of \cs{jttdefault} is \cs{mcdefault}, so the mincho family is used.
1079 %</en>
1080 %<*ja>
1081  \item \cs{verb} や \texttt{verbatim} 環境中の和文文字に使われる和文フォントファミリは
1082   \ \cs{jttdefault} で指定する%
1083   \footnote{%
1084         \Pkg{ltjsclasses}を使用したり,あるいは \texttt{match} オプションを指定して\Pkg{luatexja-fontspec}%
1085         や\Pkg{luatexja-preset}パッケージを読み込んだときは,単なる \cs{ttfamily} によっても和文フォントが
1086         \ \cs{jttdefault}\ に変更される.また,これらのクラスファイルやパッケージは
1087         \ \cs{jttdefault}\ を \cs{gtdefault}(ゴシック体)に再定義する.
1088   }.標準値は \cs{mcdefault},つまり明朝体として用いるのと
1089   同じフォントファミリである.
1090 %</ja>
1091
1092 %<*en>
1093 \item If you use the \Pkg{beamer} class with the default font theme (which uses sans serif
1094       fonts) and with \LuaTeX-ja, you might want to change default Japanese fonts to
1095       the gothic family. The following line  changes  the default Japanese font family
1096       to it:
1097 %</en>
1098 %<*ja>
1099 \item \Pkg{beamer}クラスを既定のフォント設定で使う場合,既定欧文フォントがサンセリフなの
1100       で,既定和文フォントもゴシック体にしたいと思うかもしれない.その場合はプリアンブルに
1101 次を書けばよい:
1102 %</ja>
1103 \begin{lstlisting}
1104  \renewcommand{\kanjifamilydefault}{\gtdefault}
1105 \end{lstlisting}
1106
1107 %<*ja>
1108 \item \pLaTeX と同様に,\texttt{mc},~\texttt{gt}両ファミリには「従属欧文」書体が定義されている.
1109   これらは\cs{userelfont}を\cs{selectfont}(や,その他の「実際に」
1110   フォントを変更する命令)の前で実行することにより使うことができる.
1111
1112   \pLaTeX では標準の欧文フォントはOT1エンコーディングのComputer Modern Roman (\texttt{cmr})%
1113   であったが,2017年以降の\LuaLaTeX ではTUエンコーディングのlatin Modern Roman (\texttt{lmr})%
1114   に変更されている.そのため,前段落で述べた「従属欧文」も,Latin Modern Romanに設定している.
1115 %</ja>
1116
1117 \end{itemize}
1118
1119 %<*en>
1120 However, above settings are not sufficient for Japanese-based
1121 documents. To typeset Japanese-based documents, you are better to use
1122 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
1123 the present, we have the counterparts of \Pkg{jclasses} (standard
1124 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
1125 Okumura), namely, \Pkg{ltjclasses}\footnote{%
1126   \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls},
1127   \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls}.
1128   The latter \texttt{ltjt*.cls} are for vertically written Japanese documents.
1129 } and \Pkg{ltjsclasses}\footnote{%
1130   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls}, \texttt{ltjsreport.cls},~\texttt{ltjskiyou.cls}.}.
1131
1132 Original \Pkg{jsclasses} use \cs{mag}~primitive to set the main document font size.
1133 However, \LuaTeX\ beta-0.87.0~or~later does not support \cs{mag} in PDF~output,
1134 so \Pkg{ltjsclasses} uses the \texttt{nomag*} option\footnote{Same effect as 
1135   the \Pkg{BXjscls} classes (by Takayuki Yato) and \Pkg{jsclasses}.
1136   However, these classes uses only \TeX\ code, but \Pkg{ltjsclasses} uses Lua code.}
1137  by default to set the main font size. If this causes some unexpected behavior, specify
1138 \texttt{nomag} option in \cs{documentclass}.
1139 %</en>
1140 %<*ja>
1141 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
1142 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
1143 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
1144 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}%
1145 (奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,
1146 \Pkg{ltjclasses}\footnote{%
1147   横組用は \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls} であり,
1148   縦組用は \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls} である.
1149 },
1150 \Pkg{ltjsclasses}\footnote{%
1151   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls}, \texttt{ltjsreport.cls},~\texttt{ltjskiyou.cls}.}%
1152 がそれぞれ用意されている.
1153
1154 元々の\Pkg{jsclasses}では本文のフォントサイズを設定するのに\cs{mag}プリミティブが使われていたが,
1155 \LuaTeX~beta-0.87.0以降ではPDF出力時の\cs{mag}のサポートが廃止された.
1156 そのため,\Pkg{ltjsclasses}では\texttt{nomag*}オプション
1157 \footnote{\Pkg{jsclasses}や,八登崇之氏による\Pkg{BXjscls}クラスにおける同名のオプションと
1158   同じ.上記クラスは\TeX コードのみで実装しているが,\Pkg{ltjsclasses}ではLuaコードも用いている.}が標準で
1159 有効になっており,これを使って本文フォントサイズの設定を行っている.
1160 しかし,この\texttt{nomag*}オプションでは(20180121.0版より前の版において\Pkg{unicode-math}パッケージ使用時に
1161 起きたように)予想外の意図しない現象に遭遇する危険がある.そのような場合は
1162 \cs{documentclass}において\texttt{nomag}オプションを指定してほしい.
1163 %</ja>
1164
1165 %<*ja>
1166 \paragraph{脚注とボトムフロートの出力順序}
1167 オリジナルの\LaTeX では脚注はボトムフロートの上に出力され,また\cs{raggedbottom}命令でページの高さが不揃いであることを許した場合には
1168 脚注の下端の垂直位置もページに応じて変わるようになっている.
1169 一方,日本語の組版では脚注はボトムフロートの下に来るのが一般的であるので,
1170 \pLaTeX ではそのように変更されており,
1171 さらに\cs{raggedbottom}命令を実行した後でも脚注は常にページの下端に固定されるようになっている.
1172
1173 \LuaTeX-jaでは「欧文クラスの中にちょっとだけ日本語を入れる」という利用も考慮し,
1174 脚注とボトムフロートの順序,及び\cs{raggedbottom}時の脚注の垂直位置は\LaTeX 通りとした.
1175 これらを制御するには以下の手段がある:
1176 \begin{itemize}
1177  \item \pLaTeX のように,脚注をボトムフロートの下に組む場合には
1178   \Pkg{stfloats}パッケージを利用して
1179   \begin{lstlisting}
1180     \usepackage{stfloats}\fnbelowfloat
1181   \end{lstlisting}
1182   とする.この状況から「脚注をボトムフロートの上に組む」という\LaTeX の標準の挙動に戻したければ,
1183   \Pkg{stfloats}パッケージの\cs{fnunderfloat}命令を使用する.
1184   \item \cs{raggedbottom}時の脚注の垂直位置は,\cs{iffnfixbottom}という真偽値で制御する.
1185   \begin{description}
1186     \item[偽(\cs{fnfixbottomfalse})の場合] \LaTeX 標準と同じく,本文と脚注の間の空白は\cs{skip}\cs{footins}のみ.
1187     従って脚注の垂直位置はページにより変動する.
1188     \item[真(\cs{fnfixbottomtrue})の場合] \pLaTeX や\Pkg{footmisc}パッケージを\texttt{bottom}オプションで
1189     読み込んだ場合のように,脚注は常にページの下端に固定される.
1190   \end{description}
1191 \item ただし,\LuaTeX-jaが提供する「互換クラス」(\Pkg{ltjclasses}, \Pkg{ltjsclasses})では,
1192   \pLaTeX と合わせるために以下のようにしている:
1193   \begin{itemize}
1194     \item \cs{fnfixbottomtrue}が自動的に実行される
1195     \item \Pkg{stfloats}パッケージが\LuaTeX から参照できる場所にあった場合は
1196     自動的に読み込み,\cs{fnbelowfloat}を実行する.
1197   \end{itemize}
1198 \end{itemize}
1199 なお,\Pkg{stfloats}パッケージを使う代わりに,
1200 \Pkg{footmisc}パッケージを \texttt{bottom}オプションを指定して読み込む
1201 という「解決法」もある.
1202 %</ja>
1203 %%% ↑は英訳しない
1204
1205 %<*en>
1206 \paragraph{\Pkg{geometry} package and classes for vertical writing}
1207 It is well-known that the \Pkg{geometry} package produces the following error, when classes for
1208 vertical writing is used:
1209 %</en>
1210 %<*ja>
1211 \paragraph{縦組での\Pkg{geometry}パッケージ}
1212 \pLaTeX の縦組用標準クラスファイルでは\Pkg{geometry}パッケージを利用することは出来ず,
1213 %</ja>
1214 \begin{lstlisting}
1215 ! Incompatible direction list can't be unboxed.
1216 \@begindvi ->\unvbox \@begindvibox
1217                                    \global \let \@begindvi \@empty
1218 \end{lstlisting}
1219 %<*en>
1220 Now, \LuaTeX-ja automatically applies the patch \Pkg{lltjp-geometry} to the
1221 \Pkg{geometry} package, when the direction of the document is \emph{tate} (vertical
1222 writing).
1223 This patch \Pkg{lltjp-geometry} also can be used in \pLaTeX; for the detail, please refer
1224 \url{lltjp-geometry.pdf}~(Japanese).
1225 %</en>
1226 %<*ja>
1227 というようなエラーが発生することが知られている.
1228 \LuaTeX-jaでは, \texttt{ltjtarticle.cls} といった縦組クラスの下でも
1229 \Pkg{geometry}パッケージが利用できるようにパッチ\Pkg{lltjp-geometry}パッケージを自動的に当てている.
1230
1231 なお,\Pkg{lltjp-geometry}パッケージは\pTeX 系列でも明示的に読み込むことによって
1232 使用可能である.詳細や注意事項は \url{lltjp-geometry.pdf} を参照のこと.
1233 %</ja>
1234
1235
1236 %<en>\section{Changing Fonts}
1237 %<ja>\section{フォントの変更}
1238
1239 \subsection{plain \TeX~and~\LaTeXe}
1240 \label{ssec:chgfnt}
1241
1242 \paragraph{plain \TeX}
1243 %<*en>
1244 To change Japanese fonts in plain \TeX, you must use the command
1245 \cs{jfont}~and~\cs{tfont}. So please see Subsection~\ref{ssec:jfont}.
1246 %</en>
1247 %<*ja>
1248 plain \TeX で和文フォントを変更するためには,
1249 \pTeX のように \cs{jfont} 命令や \cs{tfont} 命令を直接用いる.
1250 \ref{ssec:jfont}節を参照.
1251 %</ja>
1252
1253 \paragraph{\LaTeXe\ (NFSS2)}
1254 %<*en>
1255 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
1256 %</en>
1257 %<*ja>
1258 \LaTeX で用いる際には,\pLaTeXe\ (\texttt{plfonts.dtx})用のフォント選択機構の大部分を流用している.
1259 %</ja>
1260 \begin{itemize}
1261 %<*en>
1262 \item Commands \cs{fontfamily}, \cs{fontseries}, and \cs{fontshape} can be used to change
1263       attributes of Japanese fonts.
1264 %</en>
1265 %<*ja>
1266 \item 和文フォントの属性を変更するには,\cs{fontfamily}, \cs{fontseries}, \cs{fontshape} を使用する.
1267       もちろん,それらを実際に反映させるには手動で \cs{selectfont} を実行する必要がある.
1268 %</ja>
1269
1270 %<*en>
1271 \begin{center}\small
1272 \begin{tabular}{cccccc}
1273 \toprule
1274 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
1275 alphabetic fonts
1276 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1277 &\cs{useroman}\\
1278 Japanese fonts
1279 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1280 &\cs{usekanji}\\
1281 both&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1282 auto select&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1283 \bottomrule
1284 \end{tabular}
1285 \end{center}
1286 %</en>
1287 %<*ja>
1288 \begin{center}\small
1289 \begin{tabular}{cccccc}
1290 \toprule
1291 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェープ}&\emph{選択}\\\midrule
1292 欧文
1293 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1294 &\cs{useroman}\\
1295 和文
1296 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1297 &\cs{usekanji}\\
1298 両方&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1299 自動選択&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1300 \bottomrule
1301 \end{tabular}
1302 \end{center}
1303 %</ja>
1304
1305 %<*en>
1306       \verb+\fontencoding{+<encoding>\verb+}+ changes the encoding of alphabetic fonts
1307       or Japanese fonts depending on the argument. For example,
1308       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
1309       \texttt{JY3}, and \verb+\fontencoding{T1}+ changes the encoding of
1310       alphabetic fonts to \texttt{T1}.
1311       \cs{fontfamily} also changes the current Japanese font family,
1312       the current alphabetic font family, \emph{or both}.
1313       For the detail, see Subsection~\ref{ssec:nfsspat}.
1314 %</en>
1315 %<*ja>
1316       ここで,\verb+\fontencoding{+<encoding>\verb+}+ は,引数により和文側か欧文
1317       側かのどちらかのエンコーディングを変更する.例えば,
1318       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1319       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1320       \texttt{T1}へと変更する.\cs{fontfamily} も引数により和文側,欧文
1321       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1322       \ref{ssec:nfsspat}節を参照すること.
1323 %</ja>
1324
1325 %<*en>
1326 \item For defining a Japanese font family, use
1327       \cs{DeclareKanjiFamily} instead of
1328       \cs{DeclareFontFamily}. (In previous version of \LuaTeX-ja,
1329       using \cs{DeclareFontFamily} didn't cause any problem. But this no longer applies
1330       the current version.)
1331 \item Defining a Japanese font shape can be done by usual \cs{DeclareFontShape}:
1332 %</en>
1333 %<*ja>
1334 \item 和文フォントファミリの定義には \cs{DeclareFontFamily} の
1335       代わりに \cs{DeclareKanjiFamily} を用いる.以前の
1336       実装では \cs{DeclareFontFamily} を用いても問題は生じなかったが,現在の実装では
1337       そうはいかない.
1338 \item 和文フォントのシェイプを定義するには,通常の \cs{DeclareFontShape} を使えば良い:
1339 %</ja>
1340 \begin{lstlisting}
1341 \DeclareFontShape{JY3}{mc}{bx}{n}{<-> s*KozMinPr6N-Bold:jfm=ujis;-kern}{}
1342     % Kozuka Mincho Pr6N Bold
1343 \end{lstlisting}
1344 %<*ja>
1345 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1346 \ref{ssec:altfont}節の \cs{ltjdeclarealtfont} と,その\LaTeX 版の\
1347 \cs{DeclareAlternateKanjiFont}(\ref{ssec:nfsspat}節)を参照せよ.
1348 %</ja>
1349
1350 \end{itemize}
1351
1352 %<*en>
1353 \paragraph{Japanese characters in math mode}
1354 \label{para:jachar_in_math}
1355
1356 Since \pTeX\ supports Japanese characters in math mode, there are
1357 sources like the following:
1358 %</en>
1359 %<*ja>
1360 \paragraph{数式モード中の和文文字}
1361 \label{para:jachar_in_math}
1362   
1363 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1364 以下のようなソースが見られた:
1365 %</ja>
1366
1367 \begin{LTXexample}
1368 $f_{高温}$~($f_{\text{high temperature}}$).
1369 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1370 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1371 \end{LTXexample}
1372 %<*en>
1373 We (the project members of \LuaTeX-ja) think that using
1374 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1375 In this point of view,
1376 %</en>
1377 %<*ja>
1378 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1379 ときのみ許されると考えている.
1380 この観点から,
1381 %</ja>
1382
1383 \begin{itemize}
1384 %<*en>
1385 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1386 ``よって'' is used as a conjunction.
1387 %</en>
1388 %<*ja>
1389 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1390       して,「よって」が接続詞として用いられているからである.
1391 %</ja>
1392 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1393 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1394 \end{itemize}
1395 %<en>Hence, in our opinion, the above input should be corrected as:
1396 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1397 \begin{LTXexample}
1398 $f_{\text{高温}}$~%
1399 ($f_{\text{high temperature}}$).
1400 \[ y=(x-1)^2+2\quad
1401   \mathrel{\mbox{よって}}\quad y>0 \]
1402 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1403 \end{LTXexample}
1404
1405 %<*en>
1406 We also believe that using Japanese characters as identifiers is rare,
1407 hence we don't describe how to change Japanese fonts in math mode in
1408 this chapter. For the method, please see Subsection~\ref{ssec:math}.
1409
1410 {\emshape When \LuaTeX-ja is loaded with \texttt{disablejfam}~option,
1411   one cannot write Japanese characters in math mode as~\verb+$素$+.
1412   At that case, one have to use \cs{mbox} (or~\cs{text} in the \Pkg{amsmath} package).
1413 }
1414 %</en>
1415 %<*ja>
1416 なお\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1417 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1418 記述しない.この方法については\ref{ssec:math}節を参照のこと.
1419
1420 {\gtfamily\bfseries
1421   既に記述した通り,\texttt{disablejfam}オプションを指定して\LuaTeX-jaを読み込んだ場合は,
1422   \verb+$素$+ のように直接和文文字を数式モード中に記述することはできなくなる.
1423   \cs{mbox},あるいは\Pkg{amsmath}パッケージの提供する\cs{text}命令などを使うことになる.
1424 }
1425 %</ja>
1426
1427
1428
1429 %<en>\subsection{\Pkg{luatexja-fontspec} package}
1430 %<ja>\subsection{\Pkg{luatexja-fontspec}パッケージ}
1431 \label{ssec:fontspec}
1432 %<*en>
1433 To use the functionality of the \Pkg{fontspec} package to Japanese fonts,
1434 it is needed to load the \Pkg{luatexja-fontspec} package in the preamble, as follows:
1435 \begin{quote}
1436 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1437 \end{quote}
1438 This \Pkg{luatexja-fontspec} package
1439 automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1440 packages, if needed.
1441 %</en>
1442 %<*ja>
1443 \Pkg{fontspec}パッケージは,\LuaTeX・\XeTeX において
1444 TrueType・OpenTypeフォントを容易に扱うためのパッケージであり,このパッケージを読み込んでお
1445 けばUnicodeによる各種記号の直接入力もできるようになる.
1446 \LuaTeX-jaでは和文と欧文を区別しているため,\Pkg{fontspec}パッケージの機能は欧文フォントに
1447 対してのみ有効なものとなっている.
1448
1449 \LuaTeX-ja上において,\Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場
1450 合は\Pkg{luatexja-fontspec}パッケージを読み込む:
1451 \begin{quote}
1452 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1453 \end{quote}
1454 このパッケージは自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1455 %</ja>
1456
1457 %<*en>
1458 In the \Pkg{luatexja-fontspec} package, several commands are defined as
1459 counterparts of original commands in the \Pkg{fontspec} package
1460 (see \autoref{tab:ltj_fntspc}):
1461 %</en>
1462 %<*ja>
1463 \Pkg{luatexja-fontspec}パッケージでは,\autoref{tab:ltj_fntspc}の
1464 「和文」行に示した命令を\Pkg{fontspec}パッケージの元のコマンド(「欧文」行)
1465 に対応するものとして定義している:
1466 %</ja>
1467 %<*en>
1468 \begin{table}
1469 \caption{Commands of \Pkg{luatexja-fontspec}}\label{tab:ltj_fntspc}
1470 \medskip
1471 {\centering\small
1472 \begin{tabular}{cllll}
1473 \toprule
1474 Japanese fonts
1475 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}$^*$\\
1476 alphabetic fonts
1477 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1478 \midrule
1479 Japanese fonts
1480 &\cs{newjfontfamily}&\cs{renewjfontfamily}$^{**}$&\cs{setjfontfamily}$^{**}$\\
1481 alphabetic fonts
1482 &\cs{newfontfamily}&\cs{renewfontfamily}$^{**}$&\cs{setfontfamily}$^{**}$\\
1483 \midrule
1484 Japanese fonts
1485 &\cs{newjfontface}&\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1486 alphabetic fonts
1487 &\cs{newfontface}&\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1488 \bottomrule
1489 \end{tabular}\par}
1490 \medskip
1491 \fakefn{$^*$}{%
1492   \cs{setmonojfont} is defined if and only if \texttt{match} option is specified.}
1493 \fakefn{$^{**}$}{%
1494   \cs{renewfontfamily}~and~\cs{setfontfamily} are new commands
1495   in \Pkg{fontspec}~v2.6h (2018/7/30).
1496   Hence, \Pkg{luatexja-fontspec} define \cs{renewjfontfamily}~and~\cs{setjfontfamily}
1497   only when \Pkg{fontspec}~v2.6h (or later) is used.
1498 }
1499 \end{table}
1500 %</en>
1501 %<*ja>
1502 \begin{table}
1503 \caption{\Pkg{luatexja-fontspec}で定義される命令}\label{tab:ltj_fntspc}
1504 \medskip
1505 {\centering\small
1506 \begin{tabular}{cllll}
1507 \toprule
1508 和文
1509 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}$^*$\\
1510 欧文
1511 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1512 \midrule
1513 和文
1514 &\cs{newjfontfamily}&\cs{renewjfontfamily}$^{**}$&\cs{setjfontfamily}$^{**}$\\
1515 欧文
1516 &\cs{newfontfamily}&\cs{renewfontfamily}$^{**}$&\cs{setfontfamily}$^{**}$\\
1517 \midrule
1518 和文
1519 &\cs{newjfontface}&\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1520 欧文
1521 &\cs{newfontface}&\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1522 \bottomrule
1523 \end{tabular}\par}
1524
1525 \medskip
1526 \fakefn{$^*$}{\cs{setmonojfont} は \texttt{match} オプションが
1527 指定された時のみ定義される.}
1528 \fakefn{$^{**}$}{%
1529   \cs{renewfontfamily} と \cs{setfontfamily} は
1530   \Pkg{fontspec}~v2.6h (2018/7/30)で新たに追加された命令である.
1531   そのため,\Pkg{luatexja-fontspec}が \cs{renewjfontfamily} と \cs{setjfontfamily} を
1532   定義するのはv2.6h以降の\Pkg{fontspec}を使用した時のみになっている.
1533 }
1534
1535 \end{table}
1536 %</ja>
1537
1538 %<en> The package option of \Pkg{luatexja-fontspec} are the followings:
1539 %<ja> \Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである:
1540 \begin{cslist}
1541  \item[match]
1542 %<*en>
1543 If this option is specified, usual family-changing commands such as
1544 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
1545
1546 Note that \emph{\cs{setmonojfont} is defined
1547 if and only if this \texttt{\textup{match}} option is specified}.
1548 %</en>
1549
1550 %<*ja>
1551 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
1552 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
1553 欧文フォントだけでなく和文フォントも変更するようになる.
1554
1555 \emph{なお,\cs{setmonojfont} はこの \texttt{match} オプションが
1556 指定された時のみ定義される.}この命令は標準の「タイプライタ体に対応する和文フォント」を指定する.
1557 %</ja>
1558
1559  \item[pass=<opts>]
1560 %<en> \emph{(Obsoleted)}\ Specify options <opts> which will be passed to the \Pkg{fontspec} package.
1561 %<ja> \Pkg{fontspec} パッケージに渡すオプション <opts> を指定する.本オプションは時代遅れである.
1562
1563 \item[scale=<float>]
1564 %<*en>
1565 Override the ratio of the font size of Japanese fonts to that of alphabetic fonts.
1566 The default value is determined as follows:
1567   \begin{itemize}
1568     \item The value of \cs{Cjascale} is used, if this control sequence is already defined.
1569     \item It is calculated automatically from the current Japanese font at the loading of the
1570     package, if \cs{Cjascale} is not defined.
1571   \end{itemize}
1572 \cs{Cjascale} is defined in \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
1573 %</en>
1574 %<*ja>
1575 欧文に対する和文の比率を手動で上書きするときに使用する.
1576 標準では
1577 \begin{itemize}
1578   \item \cs{Cjascale}が定義されている場合
1579   \footnote{\LuaTeX-ja が用意しているクラスファイル(\Pkg{ltjclasses},~\Pkg{ltjsclasses})を
1580   使う場合はこちらに当てはまる.}は,それを用いる.
1581   \item \cs{Cjascale}が未定義の場合は,\Pkg{luatexja-fontspec}読み込み時の和文フォントから自動計算される.
1582 \end{itemize}
1583 %</ja>
1584 \end{cslist}
1585
1586 %<*en>
1587 All other options listed above are simply passed to the \Pkg{fontspec} package.
1588 This means that two lines below are equivalent, for example.
1589 %</en>
1590 %<*ja>
1591 上記にないオプションは全て \Pkg{fontspec} パッケージに渡される.
1592 例えば,下の2行は同じ意味になる:
1593 %</ja>
1594 \begin{lstlisting}
1595 \usepackage[no-math]{fontspec}\usepackage{luatexja-fontspec}
1596 \usepackage[no-math]{luatexja-fontspec}
1597 \end{lstlisting}
1598
1599
1600 %<*en>
1601 The reason that \cs{setmonojfont} is not defined by default is that
1602 it is popular for Japanese fonts that nearly all Japanese glyphs have same
1603 widths.  Also note that kerning information in a font is not used
1604 (that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands.
1605 This is because of the compatibility with previous versions of \LuaTeX-ja
1606 (see \ref{para-kern}).
1607
1608 Below is an example of \cs{jfontspec}.
1609 %</en>
1610 %<*ja>
1611 標準で \cs{setmonojfont} コマンドが定義されないのは,
1612 和文フォントではほぼ全ての和文文字のグリフが等幅であるのが伝統的であったことによる.
1613 また,これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
1614 言い換えれば \texttt{kern} featureは標準では無効化となっている.
1615 これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
1616
1617 以下に\cs{jfontspec}の使用例を示す.
1618 %</ja>
1619
1620 \begin{LTXexample}[width=0.4\textwidth]
1621 \jfontspec[CJKShape=NLC]{KozMinPr6N-Regular}
1622 JIS~X~0213:2004→辻\par
1623 \jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular}
1624 JIS~X~0208:1990→辻
1625 \end{LTXexample}
1626
1627 %<en>\subsection{Presets of Japanese fonts}
1628 %<ja>\subsection{和文フォントのプリセット設定}
1629 \label{ssec:preset-abst}
1630
1631 %<*en>
1632 With \Pkg{luatexja-preset} package, 
1633 one use one of ``preset'' to simplify Japanese font setting.
1634 For details of package options, and those of each presets, please see Subsecion~\ref{ssec:preset}.
1635 The following presets are defined:
1636 %</en>
1637 %<*ja>
1638 よく使われている和文フォント設定を一行で指定できるようにしたのが
1639 \Pkg{luatexja-preset}パッケージである.オプションや各プリセットの詳細については
1640 \ref{ssec:preset}節を参照して欲しい.
1641 現時点では以下のプリセットが定義されている:
1642 %</ja>
1643 \begin{quote}
1644   \ttfamily
1645   \hyphenchar\font=-1 \exhyphenchar=-1
1646   hiragino-pro, hiragino-pron, ipa, ipa-hg, ipaex, ipaex-hg,
1647   kozuka-pr6, kozuka-pr6n, kozuka-pro, moga-mobo, moga-mobo-ex,
1648   morisawa-pr6n, morisawa-pro, ms, ms-hg, noembed, noto-otc, noto-otf,
1649   sourcehan, sourcehan-jp, ume, yu-osx, yu-win, yu-win10
1650 \end{quote}
1651
1652 %<ja> 例えば,本ドキュメントでは\Pkg{luatexja-preset}パッケージを
1653 %<en> For example, this document loads \Pkg{luatexja-preset} package by
1654 \begin{lstlisting}
1655 \usepackage[kozuka-pr6n]{luatexja-preset}
1656 \end{lstlisting}
1657 %<ja>として読み込み,小塚書体(Pr6N)を使うことを指定している.
1658 %<en> which means that Kozuka~Pr6N fonts will be used in this document.
1659
1660
1661 %<*en>
1662 \subsection{\cs{CID}, \cs{UTF}, and macros in \Pkg{japanese-otf} package}
1663 Under \pLaTeX, \Pkg{japanese-otf} package (developed by Shuzaburo Saito) is
1664 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1665 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1666 supports some of functions in the \Pkg{japanese-otf} package,
1667 as an external package \Pkg{luatexja-otf}.
1668 %</en>
1669 %<*ja>
1670 \subsection{\cs{CID}, \cs{UTF}と\Pkg{otf}パッケージのマクロ}
1671 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1672 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1673 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1674 一部を(\Pkg{luatexja-otf}という別のパッケージとして)実装した.
1675 %</ja>
1676
1677 \begin{LTXexample}
1678 \jfontspec{KozMinPr6N-Regular.otf}
1679 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
1680
1681 \CID{7652}飾区の\CID{13706}野家,
1682 \CID{1481}城市,葛西駅,
1683 高崎と\CID{8705}\UTF{FA11}
1684
1685 \aj半角{はんかくカタカナ}
1686 \end{LTXexample}
1687
1688 %<*ja>
1689 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1690 \begin{cslist}
1691 \item[deluxe] 明朝体・ゴシック体各3ウェイトと,丸ゴシック体を扱えるようになる.
1692 \item[expert] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も
1693 \ \cs{rubyfamily}\ によって扱えるようになる.
1694 \item[bold] ゴシック体を標準で太いウェイトのものに設定する.
1695 \end{cslist}
1696 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1697 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1698 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1699
1700 これら3オプションについては,
1701 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1702 あるいは対応する内容を\ref{ssec:chgfnt}節,\ref{ssec:nfsspat}節 (NFSS2) や
1703 \ref{ssec:fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1704 %</ja>
1705
1706 %<en>\subsection{Changing default Japanese fonts}
1707 %<ja>\subsection{標準和文フォントの変更}
1708 \label{ssec:cfg}
1709 %<*en>
1710 If \texttt{luatexja.cfg} can be seen from \LuaTeX, \LuaTeX-ja automatically reads it.
1711 The main use of \texttt{luatexja.cfg} is for changing default Japanese fonts,
1712 when IPAex fonts cannot be installed in \TeX~system.
1713 One should not overuse this \texttt{luatexja.cfg}; fonts which will be used in
1714 a document should be specified in its source.
1715
1716 For example,
1717 \begin{lstlisting}
1718 \def\ltj@stdmcfont{IPAMincho}
1719 \def\ltj@stdgtfont{IPAGothic}
1720 \end{lstlisting}
1721 makes that IPA~Mincho and IPA~Gothic will be used as default Japanese fonts, instead of
1722 IPAex~Mincho and IPAex~Gothic.
1723
1724 For another example, the following two lines makes that
1725 non-embedded fonts Ryumin-Light~and~GothicBBB-Medium as default Japanese fonts
1726 (as the earlier version of \LuaTeX-ja):
1727 \begin{lstlisting}
1728 \def\ltj@stdmcfont{psft:Ryumin-Light}
1729 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1730 \end{lstlisting}
1731 %</en>
1732 %<*ja>
1733 \LuaTeX から見える位置に \texttt{luatexja.cfg} があれば,\LuaTeX-jaはそれを読み込む.
1734 このファイルを用いるとplain~\TeX, \LaTeXe における標準和文フォントを
1735 IPAex明朝・IPAexゴシックから変更することができる.
1736 しかし,基本的には\emph{文章中で用いるフォントは(例えば \Pkg{luatexja-preset} などで)
1737 文書ソース内で指定するべき}であり,この \texttt{luatexja.cfg} は,
1738 「IPAexフォントがインストールできない」など,IPAexフォントが使用できない場合にのみ
1739 応急処置的に用いるべきである.
1740
1741 例えば
1742 \begin{lstlisting}
1743 \def\ltj@stdmcfont{IPAMincho}
1744 \def\ltj@stdgtfont{IPAGothic}
1745 \end{lstlisting}
1746 と記述しておけば,標準和文フォントがIPA明朝・IPAゴシックへと変
1747 更される.
1748
1749
1750 なお,20140906.0以前のバージョンのように,
1751 Ryumin-Light, GothicBBB-Mediumという名前の非埋込フォントを用いる場合は
1752 \begin{lstlisting}
1753 \def\ltj@stdmcfont{psft:Ryumin-Light}
1754 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1755 \end{lstlisting}
1756 と記述すればよい.
1757 %</ja>
1758
1759
1760 %<en>\section{Changing Internal Parameters}
1761 %<ja>\section{パラメータの変更}
1762
1763 %<*en>
1764 There are many internal parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1765 most of them are not stored as internal register of \TeX, but as an
1766 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1767 parameters, you have to use commands \cs{ltjsetparameter} and
1768 \cs{ltjgetparameter}.
1769 %</en>
1770 %<*ja>
1771 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1772 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1773 これらのパラメータを設定・取得するためには \cs{ltjsetparameter} と \cs{ltjgetparameter} を
1774 用いる.
1775 %</ja>
1776
1777 %<en>\subsection{Range of \textbf{JAchar}s}
1778 %<ja>\subsection{\textbf{JAchar}の範囲}
1779 \label{ssec:setrange}
1780
1781 %<*en>
1782 \LuaTeX-ja divides the Unicode codespace \texttt{U+0080}--\texttt{U+10FFFF}
1783 into \emph{character ranges},
1784 numbered 1 to 217. The grouping can be (globally) customized by \cs{ltjdefcharrange}.
1785 The next line adds whole characters in Supplementary Ideographic Plane
1786 and the character ``漢'' to the character range~100.
1787 %</en>
1788 %<*ja>
1789 \LuaTeX-jaは,Unicodeの \texttt{U+0080}--\texttt{U+10FFFF} の空間を
1790 1番から217番までの\emph{文字範囲}に分割している.
1791 区分けは \cs{ltjdefcharrange} を用いることで(グローバルに)変更することができ,
1792 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1793 %</ja>
1794 \begin{lstlisting}
1795 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1796 \end{lstlisting}
1797
1798 %<*en>
1799 A character can belong to only one character range.
1800 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
1801 and if one executes the above line, then SIP will belong to the range~100 and be
1802 removed from the range~4.
1803 %</en>
1804 %<*ja>
1805 各文字はただ一つの文字範囲に所属することができる.
1806 例えば,SIP内の文字は全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1807 属しているが,上記の指定を行えばSIP内の文字は100番に属すようになり,4番からは除かれる.
1808 %</ja>
1809
1810 %<*en>
1811 The distinction between \textbf{ALchar} and \textbf{JAchar} is performed by character ranges.
1812 This can be edited by setting the \textsf{jacharrange} parameter.
1813 For example, the code below is just the default setting of \LuaTeX-ja, and
1814 it sets
1815 \begin{itemize}
1816  \item a character which belongs character ranges 1,~4, 5, and~8 is \textbf{ALchar},
1817  \item a character which belongs character ranges 2,~3, 6, and~7 is \textbf{JAchar}.
1818 \end{itemize}
1819 %</en>
1820 %<*ja>
1821 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1822 これは\textsf{jacharrange}パラメータによって編集できる.
1823 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1824 \begin{itemize}
1825  \item 1番,4番,5番,8番の文字範囲に属する文字は\textbf{ALchar}.
1826  \item 2番,3番,6番,7番の文字範囲に属する文字は\textbf{JAchar}.
1827 \end{itemize}
1828 %</ja>
1829 \begin{lstlisting}
1830 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, -8}}
1831 \end{lstlisting}
1832 %<*en>
1833 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
1834 Negative integer $-n$ in the list means that ``each character in the range~$n$ is an
1835 \textbf{ALchar}'',
1836 and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
1837 %</en>
1838 %<*ja>
1839 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
1840 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
1841 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
1842 %</ja>
1843
1844 %<*en>
1845 Note that characters \texttt{U+0000}--\texttt{U+007F} are always treated as an
1846 \textbf{ALchar} (this cannot be customized).
1847 %</en>
1848 %<*ja>
1849 なお,\texttt{U+0000}--\texttt{U+007F} は常に\textbf{ALchar}として扱われる(利用者が変更す
1850 ることは出来ない).
1851 %</ja>
1852
1853 %<*en>
1854 \paragraph{Default character ranges}
1855 \LuaTeX-ja predefines eight character ranges for convenience. They are
1856 determined from the following data:
1857 %</en>
1858 %<*ja>
1859 \paragraph{文字範囲の初期値}
1860 \LuaTeX-jaでは8つの文字範囲を予め定義しており,
1861 これらは以下のデータに基づいて決定している.
1862 %</ja>
1863 \begin{itemize}
1864 %<en>\item Blocks in Unicode~6.0.
1865 %<ja>\item Unicode~6.0のブロック.
1866 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
1867 %<ja>\item Adobe-Japan1-6のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
1868 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
1869 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
1870 \end{itemize}
1871
1872 %<*en>
1873 Now we describe these eight ranges. The superscript ``J'' or ``A'' after the
1874 number shows whether each character in the range is treated as
1875 \textbf{JAchar}s or not by default. These settings are similar to the
1876 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
1877 Any characters equal to or above \texttt{U+0080} which does not belong to
1878 these eight ranges belongs to the character range~217.
1879 %</en>
1880 %<*ja>
1881 以下ではこれら8つの文字範囲について記述する.添字のアルファベット「J」「A」
1882 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの初期設定は
1883 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものであるが,
1884 8ビットフォント使用時のトラブルを防ぐために \texttt{U+0080}--\texttt{U+00FF} の文字は全部
1885 \textbf{ALchar}としている.
1886 なお,\texttt{U+0080} 以降でこれら8つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
1887 %</ja>
1888 \begin{description}
1889 %<*en>
1890
1891 \item[Range~8${}^{\text{A}}$] The intersection of the upper half of ISO~8859-1
1892          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
1893          consists of the following characters:
1894 %</en>
1895 %<*ja>
1896 \item[範囲8${}^{\text{A}}$] ISO~8859-1の上位領域(ラテン1補助)と
1897                              JIS~X~0208の共通部分.この文字範囲は
1898                              以下の文字で構成される:
1899 %</ja>
1900 \begin{multicols}{2}
1901 \begin{itemize}
1902 \def\ch#1#2{\item \char"#1\ (\texttt{U+00#1}, #2)}%"
1903 \ch{A7}{Section Sign}
1904 \ch{A8}{Diaeresis}
1905 \ch{B0}{Degree sign}
1906 \ch{B1}{Plus-minus sign}
1907 \ch{B4}{Spacing acute}
1908 \ch{B6}{Paragraph sign}
1909 \ch{D7}{Multiplication sign}
1910 \ch{F7}{Division Sign}
1911 \end{itemize}
1912 \end{multicols}
1913
1914 %<*en>
1915 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
1916 This range consists of the following Unicode ranges, \emph{except characters in the range~8 above}:
1917 %</en>
1918 %<*ja>
1919 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-6との共通部分があるもの.
1920                              この範囲は以下のUnicodeのブロックのうち
1921                              \emph{範囲8を除いた}部分で構成されている:
1922 %</ja>
1923 \begin{multicols}{2}
1924 \begin{itemize}
1925 \item \texttt{U+0080}--\texttt{U+00FF}: Latin-1 Supplement
1926 \item \texttt{U+0100}--\texttt{U+017F}: Latin Extended-A
1927 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
1928 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
1929 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
1930 %<en>\par\
1931 \item \texttt{U+0300}--\texttt{U+036F}: \\*\null\hfill Combining Diacritical Marks
1932 \item \texttt{U+1E00}--\texttt{U+1EFF}: \\*\null\hfill Latin Extended Additional
1933 %<ja>\par\
1934 \end{itemize}
1935 \end{multicols}
1936 %<*en>
1937 \item[Range~2${}^{\text{\kern.1emJ}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1938            fonts) has some of these characters.
1939 %</en>
1940 %<*ja>
1941 \item[範囲2${}^{\text{\kern.1emJ}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
1942                              和文フォント)には,これらの文字の一部が含まれている.
1943 %</ja>
1944 \begin{multicols}{2}
1945 \begin{itemize}
1946 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
1947 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
1948 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
1949 \\\
1950 \end{itemize}
1951 \end{multicols}
1952 %<*en>
1953 \item[Range~3${}^{\text{\kern.1emJ}}$] Punctuations and Miscellaneous symbols. The block list is
1954            indicated in \autoref{tab:rng3}.
1955 %</en>
1956 %<*ja>
1957 \item[範囲3${}^{\text{\kern.1emJ}}$] 句読点と記号類.ブロックのリストは\autoref{tab:rng3}%
1958                              に示してある.
1959 %</ja>
1960 \begin{table}[!tb]
1961 %<en>\caption{Unicode blocks in predefined character range~3.}\medskip
1962 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
1963 \label{tab:rng3}
1964 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1965 \centering\small
1966 \begin{tabular}{llll}
1967 "2000--"206F&General Punctuation&
1968 "2070--"209F&Superscripts and Subscripts\\
1969 "20A0--"20CF&Currency Symbols&
1970 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1971 "2100--"214F&Letterlike Symbols&
1972 "2150--"218F&Number Forms\\
1973 "2190--"21FF&Arrows&
1974 "2200--"22FF&Mathematical Operators\\
1975 "2300--"23FF&Miscellaneous Technical&
1976 "2400--"243F&Control Pictures\\
1977 "2500--"257F&Box Drawing&
1978 "2580--"259F&Block Elements\\
1979 "25A0--"25FF&Geometric Shapes&
1980 "2600--"26FF&Miscellaneous Symbols\\
1981 "2700--"27BF&Dingbats&
1982 "2900--"297F&Supplemental Arrows-B\\
1983 "2980--"29FF&Misc.\ Mathematical Symbols-B&
1984 "2B00--"2BFF&Miscellaneous Symbols and Arrows
1985 \end{tabular}
1986 \end{table}
1987 %<*en>
1988 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1989            of almost all Unicode blocks which are not in other
1990            predefined ranges. Hence, instead of showing the block list,
1991            we put the definition of this range itself:
1992 %</en>
1993 %<*ja>
1994 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
1995                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
1996                              で構成されている.したがって,ブロックのリストを示す
1997                              代わりに,範囲の定義そのものを示す:
1998 %</ja>
1999 \begin{lstlisting}
2000 \ltjdefcharrange{4}{%
2001    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
2002   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F,
2003   "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese
2004 \end{lstlisting}
2005 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
2006 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
2007 %<en>\item[Range~6${}^{\text{\kern.1emJ}}$] Characters used in Japanese. The block list is indicated in \autoref{tab:rng6}.
2008 %<ja>\item[範囲6${}^{\text{\kern.1emJ}}$] 日本語で用いられる文字.ブロックのリストは\autoref{tab:rng6}に示す.
2009 \begin{table}[!tb]
2010 %<en>\caption{Unicode blocks in predefined character range~6.}\medskip
2011 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
2012 \label{tab:rng6}
2013 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2014 \centering\small
2015 \begin{tabular}{llll}
2016 "2460--"24FF&Enclosed Alphanumerics&
2017 "2E80--"2EFF&CJK Radicals Supplement\\
2018 "3000--"303F&CJK Symbols and Punctuation&
2019 "3040--"309F&Hiragana\\
2020 "30A0--"30FF&Katakana&
2021 "3190--"319F&Kanbun\\
2022 "31F0--"31FF&Katakana Phonetic Extensions&
2023 "3200--"32FF&Enclosed CJK Letters and Months\\
2024 "3300--"33FF&CJK Compatibility&
2025 "3400--"4DBF&CJK Unified Ideographs Extension A\\
2026 "4E00--"9FFF&CJK Unified Ideographs&
2027 "F900--"FAFF&CJK Compatibility Ideographs\\
2028 "FE10--"FE1F&Vertical Forms&
2029 "FE30--"FE4F&CJK Compatibility Forms\\
2030 "FE50--"FE6F&Small Form Variants&
2031 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)\\
2032 "{E0}100--"{E0}1EF&Variation Selectors Supplement
2033 \end{tabular}
2034 \end{table}
2035 %<*en>
2036 \item[Range~7${}^{\text{\kern.1emJ}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
2037 The block list is indicated in \autoref{tab:rng7}.
2038 %</en>
2039 %<*ja>
2040 \item[範囲7${}^{\text{\kern.1emJ}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-6に
2041                             含まれていないもの.
2042                             ブロックのリストは\autoref{tab:rng7}に示す.
2043 %</ja>
2044 \begin{table}[!tb]
2045 %<en>\caption{Unicode blocks in predefined character range~7.}\medskip
2046 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
2047 \label{tab:rng7}
2048 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2049 \centering\small
2050 \begin{tabular}{llll}
2051 "1100--"11FF&Hangul Jamo&
2052 "2F00--"2FDF&Kangxi Radicals\\
2053 "2FF0--"2FFF&Ideographic Description Characters&
2054 "3100--"312F&Bopomofo\\
2055 "3130--"318F&Hangul Compatibility Jamo&
2056 "31A0--"31BF&Bopomofo Extended\\
2057 "31C0--"31EF&CJK Strokes&
2058 "A000--"A48F&Yi Syllables\\
2059 "A490--"A4CF&Yi Radicals&
2060 "A830--"A83F&Common Indic Number Forms\\
2061 "AC00--"D7AF&Hangul Syllables&
2062 "D7B0--"D7FF&Hangul Jamo Extended-B
2063 \end{tabular}
2064 \end{table}
2065 \end{description}
2066
2067 %<*en>
2068 \paragraph{Notes on \texttt{U+0080}--\texttt{U+00FF}}
2069 You should treat characters in \\texttt{U+0080}--\texttt{U+00FF} as \textbf{ALchar},
2070 when you use traditional 8-bit fonts, such as the \Pkg{marvosym} package.
2071
2072 For example, \cs{Frowny} which is provided by the \Pkg{marvosym} package has
2073 the same codepoint as \S\ (\text{U+00A7}).
2074 Hence, as previous versions of \LuaTeX-ja, if these characters are treated as
2075 \text{JAchar}s, then \cs{Frowny} produces ``\ltjjachar`§'' (in a Japanese font).
2076
2077 To avoid such situations, the default setting of \LuaTeX-ja is changed in version~20150906.0
2078 so that all characters \texttt{U+0080}--\texttt{U+00FF} are treated as \textbf{ALchar}.
2079
2080 If you want to output a character as \textbf{ALchar} and \textbf{JAchar} regardless the range
2081 setting, you can use \cs{ltjalchar} and \cs{ltjjachar} respectively, as the following example.
2082 \begin{LTXexample}[width=0.3\textwidth]
2083 \gtfamily\large % default, ALchar, JAchar
2084 ¶, \ltjalchar`¶, \ltjjachar`¶\\   % default: ALchar
2085 α, \ltjalchar`α, \ltjjachar`α  % default: JAchar
2086 \end{LTXexample}
2087 %</en>
2088 %<*ja>
2089 \paragraph{\texttt{U+0080}--\texttt{U+00FF}についての注意}
2090 \LuaTeX-jaで,\Pkg{marvosym}パッケージ等,Unicodeフォントでなく
2091 伝統的な8ビットフォントを用いる場合には注意が必要である.
2092
2093 例えば,\Pkg{marvosym}パッケージの提供する \cs{Frowny} も,符号位置は167,つまりUnicodeにおける
2094 \S\ (\text{U+00A7}) と同じ符号位置にある.
2095 即ち,以前のバージョンのように,「前節の文字範囲8内の文字は\textbf{JAchar}」という設定で
2096 あったとすると,上記の \cs{Frowny} は和文フォントで「\ltjjachar`§」を出力することになる.
2097
2098 このような事態を避けるために,バージョン20150906.0からは \texttt{U+0080}--\texttt{U+00FF} の範囲の
2099 文字は全て\textbf{ALchar}となるように初期設定を変更している.
2100
2101 なお,文字範囲の設定に関わらず1つの文字を\textbf{ALchar}, \textbf{JAchar}で出力したい場合には,
2102 以下の例のようにそれぞれ \cs{ltjalchar},~\cs{ltjjachar} に該当文字の文字コードを渡せばよい.
2103 \begin{LTXexample}[width=0.3\textwidth]
2104 \gtfamily\large % default, ALchar, JAchar
2105 ¶, \ltjalchar`¶, \ltjjachar`¶\\   % default: ALchar
2106 α, \ltjalchar`α, \ltjjachar`α  % default: JAchar
2107 \end{LTXexample}
2108 %</ja>
2109
2110
2111 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
2112 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
2113 \label{subs-kskip}
2114
2115 %<en>\textbf{JAglue} is divided into the following three categories:
2116 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
2117 \begin{itemize}
2118 %<*en>
2119 \item Glues/kerns specified in JFM. If \cs{inhibitglue} is issued
2120       around a \textbf{JAchar}, this glue will not be inserted at the
2121       place.
2122 %</en>
2123 %<*ja>
2124 \item JFMで指定されたグルー/カーン.もし \cs{inhibitglue} が\textbf{JAchar}の周りで
2125       発行されていれば,このグルーは挿入されない.
2126 %</ja>
2127 %<*en>
2128 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
2129       kanjiskip}).
2130 %</en>
2131 %<*ja>
2132 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{kanjiskip}).
2133 %</ja>
2134 %<*en>
2135 \item The default glue which inserted between a \textbf{JAchar} and an
2136       \textbf{ALchar} (\Param{xkanjiskip}).
2137 %</en>
2138 %<*ja>
2139 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{xkanjiskip}).
2140 %</ja>
2141 \end{itemize}
2142 %<*en>
2143 The value (a skip) of \Param{kanjiskip} or
2144 \Param{xkanjiskip} can be changed as the following.
2145 Note that only their values \emph{at the end of a paragraph or a hbox are
2146 adopted in the whole paragraph or the whole hbox.
2147 }
2148 %</en>
2149 %<*ja>
2150 \Param{kanjiskip}や\Param{xkanjiskip}の値
2151 は以下のようにして変更可能である.
2152 %</ja>
2153 \begin{lstlisting}
2154 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
2155                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
2156 \end{lstlisting}
2157 %<*en>
2158 Here \cs{zw} is a internal dimension
2159 which stores fullwidth of the current Japanese font.
2160 This \cs{zw} can be used as the unit \texttt{zw} in \pTeX.
2161
2162 The value of these parameter can be get by \cs{ltjgetparameter}.
2163 Note that the result by \cs{ltjgetparameter} is \emph{not} the internal quantities,
2164 but \emph{a string} (hence \cs{the} cannot be prefixed).
2165 %</en>
2166 %<*ja>
2167 ここで,\cs{zw} は現在の和文フォントの全角幅を表す長さであり,
2168 \pTeX における長さ単位 \texttt{zw} と同じように使用できる.
2169
2170 これらのパラメータの値は以下のように取得できる.
2171 戻り値は内部値ではなく\emph{文字列}である(\cs{the} は前置できない)ことに注意してほしい:
2172 %</ja>
2173 \begin{LTXexample}
2174 kanjiskip: \ltjgetparameter{kanjiskip},\\
2175 xkanjiskip: \ltjgetparameter{xkanjiskip}
2176 \end{LTXexample}
2177
2178 %<*en>
2179 It may occur that JFM contains the data of ``ideal width of
2180 \Param{kanjiskip}''
2181 and/or ``ideal width of \Param{xkanjiskip}''.
2182 To use these data from JFM, set the value of \Param{kanjiskip} or
2183 \Param{xkanjiskip} to \cs{maxdimen}
2184 (these ``ideal width'' cannot be retrived by \cs{ltjgetparameter}).
2185 %</en>
2186 %<*ja>
2187 JFMは「望ましい\Param{kanjiskip}の値」や
2188 「望ましい\Param{xkanjiskip}の値」を持っていることがある.
2189 これらのデータを使うためには,\Param{kanjiskip}や%
2190 \Param{xkanjiskip}の値を \cs{maxdimen} の値に設定すればよいが,
2191 \cs{ltjgetparameter} によって取得することはできないので注意が必要である.
2192 %</ja>
2193
2194 %<en>\subsection{Insertion setting of \Param{xkanjiskip}}
2195 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
2196
2197 %<*en>
2198 It is not desirable that \Param{xkanjiskip} is inserted into every
2199 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
2200 \Param{xkanjiskip} should not be inserted after opening parenthesis
2201 (\textit{e.g.}, compare ``(あ'' and ``(\hskip\ltjgetparameter{xkanjiskip}あ'').
2202 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
2203 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
2204 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
2205 %</en>
2206 %<*ja>
2207 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
2208 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
2209 後には挿入されるべきではない(「(あ」と「(\hskip\ltjgetparameter{xkanjiskip}あ」を
2210 比べてみよ).
2211 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
2212 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
2213 \Param{alxspmode}をそれぞれ変えることで制御することができる.
2214 %</ja>
2215 \begin{LTXexample}
2216 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
2217 pあq い!う
2218 \end{LTXexample}
2219
2220 %<*en>
2221 The second argument \texttt{preonly} means that the insertion of
2222 \Param{xkanjiskip} is allowed before this character, but not after.
2223 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{inhibit}.
2224 %</en>
2225 %<*ja>
2226 2つ目の引数の \texttt{preonly}は「\Param{xkanjiskip}の挿入はこの文字の
2227 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
2228 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
2229 %</ja>
2230
2231 %<*en>
2232 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
2233 on the current version. Therefore, line~1 in the code above can be rewritten
2234 as follows:
2235 %</en>
2236 %<*ja>
2237 なお,現行の
2238 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
2239 上のコードの1行目を次のように変えても同じことになる:
2240 %</ja>
2241 \begin{lstlisting}
2242 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
2243 \end{lstlisting}
2244 %<*en>
2245 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec:param}).
2246 %</en>
2247 %<*ja>
2248 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec:param}節を参照).
2249 %</ja>
2250
2251 %<*en>
2252 If you want to enable/disable all insertions of \Param{kanjiskip} and
2253 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
2254 parameters to \texttt{true}/\texttt{false}, respectively.
2255 %</en>
2256 %<*ja>
2257 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
2258 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2259 \texttt{true}/\texttt{false}に設定すればよい.
2260 %</ja>
2261
2262 %<en>\subsection{Shifting the baseline}
2263 %<ja>\subsection{ベースラインの移動}
2264 %<*en>
2265 To make a match between a Japanese font and an alphabetic font, sometimes
2266 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2267 by setting \cs{ybaselineshift} (or \cs{tbaselineshift}) to a non-zero length (the
2268 baseline of \textbf{ALchar} is shifted below). However, for documents
2269 whose main language is not Japanese, it is good to shift the baseline of
2270 Japanese fonts, but not that of alphabetic fonts.
2271 Because of this, \LuaTeX-ja can independently set the shifting amount
2272 of the baseline of alphabetic fonts and that of Japanese fonts.
2273 \begin{center}
2274  \small
2275 \begin{tabular}{>{\bfseries}lcc}
2276 \toprule
2277 &\bfseries Horizontal writing (\emph{yoko} direction) etc.
2278 &\bfseries Vertical writing(\emph{tate} direction)\\
2279 \midrule
2280 Alphabetic fonts&\Param{yalbaselineshift}
2281      parameter&\Param{talbaselineshift} parameter\\
2282 Japanese fonts&\Param{yjabaselineshift}
2283      parameter&\Param{tjabaselineshift} parameter\\
2284 \bottomrule
2285 \end{tabular}
2286 \end{center}
2287 %</en>
2288 %<*ja>
2289 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2290 必要になる.\pTeX ではこれは \cs{ybaselineshift}(または\cs{tbaselineshift})を設定することで
2291 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2292 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2293 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2294 と和文フォントのベースラインのシフト量を独立に設定できるようになっている.
2295 \begin{center}
2296  \small
2297 \begin{tabular}{>{\bfseries}lcc}
2298 \toprule
2299 &\bfseries 横組など&\bfseries 縦組\\
2300 \midrule
2301 欧文フォントのシフト量&\Param{yalbaselineshift}
2302      parameter&\Param{talbaselineshift} parameter\\
2303 和文フォントのシフト量&\Param{yjabaselineshift}
2304      parameter&\Param{tjabaselineshift} parameter\\
2305 \bottomrule
2306 \end{tabular}
2307 \end{center}
2308 %</ja>
2309
2310 %<*en>
2311 Here the horizontal line in the below example is the baseline of a line.
2312 %</en>
2313 %<*ja>
2314 下の例において引かれている水平線がベースラインである.
2315 %</ja>
2316 \begin{LTXexample}
2317 \vrule width 150pt height 0.2pt depth 0.2pt \hskip-120pt
2318 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2319 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2320 \end{LTXexample}
2321
2322 %<*en>
2323 There is an interesting side-effect: characters in different size can be
2324 vertically aligned center in a line, by setting two parameters appropriately.
2325 The following is an example (beware the value is not well tuned):
2326 %</en>
2327 %<*ja>
2328 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2329 異なる文字を中心線に揃えることができる.
2330 以下は一つの例である(値はあまり調整されていないことに注意):
2331 %</ja>
2332 \begin{LTXexample}[width=0.4\textwidth]
2333 \vrule width 150pt height4.417pt depth-4.217pt%
2334 \kern-150pt
2335 \large xyz漢字
2336 {\scriptsize
2337   \ltjsetparameter{yjabaselineshift=-1.757pt,
2338     yalbaselineshift=-1.757pt}
2339   漢字xyzあいう
2340 }あいうabc
2341 \end{LTXexample}
2342
2343 %<*en>
2344 Note that setting positive \Param{yalbaselineshift}~or~\Param{talbaselineshift}
2345 parameters does not increase the depth of one-letter \emph{syllable} $p$ of \textbf{Alchar}, if
2346 its left-protrusion~(\cs{lpcode}) and right-protrusion~(\cs{rpcode}) are both non-zero.
2347 This is because
2348 \begin{itemize}
2349 \item These two parameters are implemented by setting \texttt{yoffset} field of a
2350 glyph node, and this does not increase the depth of the glyph.
2351 \item To cope with the above situation, \LuaTeX-ja automatically supplies
2352 a rule in every syllable.
2353 \item However, we cannot use this ``supplying a rule'' method if a syllable comprises just
2354       one letter whose \cs{lpcode}~and~\cs{rpcode} are both non-zero.
2355 \end{itemize}
2356
2357 This problem does not apply for \Param{yjabaselineshift}~nor~\Param{tjabaselineshift},
2358 becuse a \emph{JAchar} is encapsulated by a horizontal box if needed.
2359 %</en>
2360 %<*ja>
2361 なお,以下の場合には1文字の\textbf{ALchar}からなる「音節」の深さは増加しないことに注意.
2362 \begin{itemize}
2363  \item \Param{yalbaselineshift},~\Param{talbaselineshift}パラメータが正になっている.
2364  \item 「音節」を構成する唯一の文字$p$の
2365 左余白への突出量(\cs{lpcode}),右余白への突出量(\cs{rpcode})がどちらも非零である.
2366 \end{itemize}
2367 \emph{JAchar}は必要に応じて1文字ずつボックスにカプセル化されるため,
2368 \Param{yjabaselineshift},~\Param{tjabaselineshift}パラメータについてはこのような問題は起こらない.
2369 %</ja>
2370
2371 %<*ja>
2372 \paragraph{数式における挙動:\pTeX との違い}
2373 \textbf{ALchar}のベースラインを補正する\Param{yalbaselineshift}, \Param{talbaselineshift}パラメータは
2374 ほぼ\pTeX における \cs{ybaselineshift}, \cs{tbaselineshift} に対応しているものであるが,
2375 数式中の挙動は異なっているので注意が必要である.
2376 例えば,\autoref{tab:math_bsa}のように,数式中に明示的に現れた \cs{hbox},~\cs{vbox} は,横組において
2377 \begin{itemize}
2378  \item 2015年以前の\pTeX では,ボックス全体が \cs{ybaselineshift} だとシフトされるので,
2379  \autoref{tab:math_bsa}中の``い''のように,ボックス中の和文文字は
2380  \ \cs{ybaselineshift} だけシフトされ,一方,``for all''のように,
2381  ボックス内の欧文文字は2重にシフトされることになる.
2382  \item 一方,\LuaTeX-jaではそのようなことはおこらず,
2383  数式中に明示的に現れた \cs{hbox},~\cs{vbox} はシフトしない.そのため,
2384  \autoref{tab:math_bsa}中の``い''も``for all''も,それぞれ本文中に
2385  書かれたときと同じ上下位置に組まれる.
2386
2387  なお,\TeX~Live~2016以降の\pTeX では改修がなされ,\LuaTeX-jaと
2388  近い挙動になるようにしているが,数式中に直に書かれた``あ''のベースラインについては
2389  まだ違いが見られる.
2390 \end{itemize}
2391
2392 なお,バージョン20170401.0以降の\LuaTeX-jaでは,\cs{vcenter} によるボックスには
2393 全体が\Param{yalbaselineshift}, \Param{talbaselineshift} パラメータが反映されるようにしている.
2394 その方が結果が自然であることによる変更なのだが,結果的に\cs{vcenter} については\pTeX と同じ挙動となった.
2395
2396 \begin{table}
2397 \small\centering
2398 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2399 \label{tab:math_bsa}
2400 \newdimen\origbaselineskip
2401 \origbaselineskip=\baselineskip
2402 \begin{tabular}{lp{30\zw}}
2403 \toprule
2404 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2405 \begin{lstlisting}
2406 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2407 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2408 \end{lstlisting}\\
2409 \noalign{\vskip-\origbaselineskip}
2410 \midrule
2411 \emph{\pTeX~(--2015)}&
2412 {\ltjsetparameter{yalbaselineshift=10pt}%
2413 数式abc: $\lower10pt\hbox{あ}a\lower10pt\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2414 $\Phi\vdash F(x)\ \lower10pt\hbox{for all}\ x\in A$
2415 \par}\\\noalign{\vskip-\origbaselineskip}\midrule
2416 \emph{\pTeX~(2016--)}&
2417 {\ltjsetparameter{yalbaselineshift=10pt}%
2418 数式abc: $\lower10pt\hbox{あ}a\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2419 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2420 \par}\\\noalign{\vskip-\origbaselineskip}\midrule
2421 \emph{\LuaTeX-ja}&
2422 {\ltjsetparameter{yalbaselineshift=10pt}%
2423 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2424 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2425 \par}\\
2426 \noalign{\vskip-\origbaselineskip}
2427 \bottomrule
2428 \end{tabular}
2429 \end{table}
2430 %</ja>
2431
2432 %<*en>
2433 \subsection{\emph{kinsoku} parameters and OpenType features}
2434 Among parameters which related to Japanese word-wrapping process (\emph{kinsoku shori}),
2435 \begin{quote}
2436  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2437  \Param{postbreakpenalty}~and~\Param{kcatcode}
2438 \end{quote}
2439 are stored by each character codes.
2440
2441 OpenType font features are ignored in these parameters.
2442 For example, a fullwidth katakana ``ア'' on line~10 in the below input is replaced to
2443 its halfwidth variant ``ア'', by \verb+hwid+ feature.
2444 However, the penalty inserted after it is 10 which is the \Param{postbreakpenalty} of
2445 ``ア'', not 20.
2446 %</en>
2447 %<*ja>
2448 \subsection{禁則処理関連パラメータとOpenTypeのfont feature}
2449 禁則処理や \Param{kanjiskip}, \Param{xkanjiskip} の挿入に関連したパラメータのうち
2450 \begin{quote}
2451  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2452  \Param{postbreakpenalty}, \Param{kcatcode}
2453 \end{quote}
2454 は,文字コードごとに設定する量である.
2455
2456 \Pkg{fontspec}パッケージを使う(\ref{ssec:fontspec}節)場合など,
2457 各種のOpenType featureを適用することもあると思うが,前段落に述べたパラメータ類は,
2458 \emph{OpenType featureの適用前の文字コードによって適用される.}
2459 例えば,以下の例において10行目の「ア」は,\verb+hwid+ featureの適用により半角カタカナの「ア」
2460 に置き換わる.しかし,その直後に挿入される \Param{postbreakpenalty}は,置換前の「ア」に対する値10である.
2461 %</ja>
2462
2463 \begin{LTXexample}[width=0.2\textwidth]
2464 \ltjsetparameter{postbreakpenalty={`ア, 10}}
2465 \ltjsetparameter{postbreakpenalty={`ア, 20}}
2466
2467 \newcommand\showpostpena[1]{%
2468   \leavevmode\setbox0=\hbox{#1\hbox{}}%
2469   \unhbox0\setbox0=\lastbox\the\lastpenalty}
2470
2471 \showpostpena{ア},
2472 \showpostpena{ア},
2473 {\addjfontfeatures{CharacterWidth=Half}\showpostpena{ア}}
2474 \end{LTXexample}
2475
2476 \clearpage
2477 %<en>\part{Reference}
2478 %<ja>\part{リファレンス}
2479 \label{part-ref}
2480 \suppressfloats[t]
2481 %<*ja>
2482 \section{\LuaTeX-jaにおける \cs{catcode}}
2483 \label{sec-catcode}
2484 \subsection{予備知識:\pTeX と\upTeX における \cs{kcatcode}}
2485 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2486 は \cs{kcatcode} の値によって決定されるのであった.
2487 詳細は\autoref{tab:kcat}を参照されたい.
2488 %</ja>
2489 %<*en>
2490 \section{\cs{catcode} in \LuaTeX-ja}
2491 \label{sec-catcode}
2492 \subsection{Preliminaries: \cs{kcatcode} in \pTeX\ and \upTeX}
2493 In \pTeX~and~\upTeX, the value of \cs{kcatcode} determines
2494 whether a Japanese character can be used in a control word.
2495 For the detail, see \autoref{tab:kcat}.
2496 %</en>
2497
2498 \begin{table}[t]
2499 \small
2500 \caption{\cs{kcatcode} in \upTeX}
2501 \label{tab:kcat}
2502 %<en>\medskip
2503
2504 \noindent\hfill
2505 \begin{tabular}{ccccc}
2506 \toprule
2507 \bfseries \cs{kcatcode}&
2508 %<*en>
2509 \bfseries meaning&
2510 \bfseries control word&
2511 \bfseries widow penalty&
2512 \bfseries linebreak\\
2513 %</en>
2514 %<*ja>
2515 \bfseries 意図&
2516 \bfseries 制御綴中に使用&
2517 \bfseries 文字ウィドウ処理&
2518 \bfseries 直後での改行\\
2519 %</ja>
2520 \midrule
2521 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2522 16&kanji&Y&Y&ignored\\
2523 17&kana&Y&Y&ignored\\
2524 18&other&N&N&ignored\\
2525 19&hangul&Y&Y&space\\
2526 \bottomrule
2527 \end{tabular}\hfill\null
2528
2529 \medskip
2530
2531 %<*ja>
2532 文字ウィドウ処理:「漢字が一文字だけ次の行に行くのを防ぐ」
2533 \cs{jcharwidowpenalty} が,
2534 その文字の直前に挿入されうるか否か,を示す.
2535 %</ja>
2536 \end{table}
2537
2538 %<*en>
2539 \cs{kcatcode} can be set by a row of JIS~X~0208 in \pTeX,
2540 and generally by a Unicode block\footnote{%
2541   \upTeX\ divides \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)
2542   into three subblocks, and \cs{kcatcode} can be set by a subblock.
2543 }
2544 in \upTeX. So characters which can be used in a control word
2545 slightly differ between \pTeX~and~\upTeX.
2546 %</en>
2547 %<*ja>
2548 \pTeX では \cs{kcatcode} はJIS~X~0208の区単位,
2549 \upTeX では概ねUnicodeブロック単位\footnote{%
2550   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2551   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2552   それぞれ別々に \cs{kcatcode} が指定できるようになっている.
2553 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2554 制御綴内で使用可能な文字が微妙に異なっている.
2555 %</ja>
2556
2557 %<*en>
2558 \subsection{Case of \LuaTeX-ja}
2559 The role of \cs{kcatcode} in \pTeX~and~\upTeX\ can be
2560 divided into the following four kinds,
2561 and \LuaTeX-ja can control these four kinds separately:
2562 \begin{itemize}
2563  \item
2564 \emph{Distinction between \textbf{JAchar} or \textbf{ALchar}}
2565 is controlled by the character range, see Subsection~\ref{ssec:setrange}.
2566  \item
2567 \emph{Whether the character can be used in a control word}
2568 is controlled by setting \cs{catcode} to 11~(enabled) or 12~(disabled), as usual.
2569  \item
2570 \emph{Whether \Param{jcharwidowpenalty} can be inserted before the character}
2571 is controlled by the lowermost bit of the \Param{kcatcode} parameter.
2572  \item
2573 \emph{Linebreak after a \textbf{JAchar}} does not produce a space.
2574 \end{itemize}
2575 %</en>
2576 %<*ja>
2577 \subsection{\LuaTeX-jaの場合}
2578 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \cs{kcatcode} の役割を
2579 分割している:
2580 \begin{description}
2581  \item[欧文/和文の区別 (\upTeX)]
2582 \cs{ltjdefcharrange} と\textsf{jacharrange}パラメータ(\ref{ssec:setrange}節)
2583  \item[制御綴中に使用可か]
2584 \LuaTeX 自身の \cs{catcode} でよい
2585  \item[\Param{jcharwidowpenalty}が挿入可か]
2586 \Param{kcatcode}パラメータの最下位ビット
2587  \item[直後の改行]
2588 日本語しか想定していないので,\textbf{JAchar}直後の改行で半角スペースが挿入されることはない.
2589 \end{description}
2590 %</ja>
2591
2592 %<*en>
2593 Default setting of \cs{catcode} of Unicode characters are located in
2594 \begin{description}
2595  \item[plain \LuaTeX] \texttt{luatex-unicode-letters.tex}, which is based on \texttt{unicode-letters.tex}
2596 (for \XeTeX).
2597  \item[\LuaLaTeX] now included in \LaTeX\ kernel  as~\texttt{unicode-letters.def}.
2598 \end{description}
2599 However, the default setting of \cs{catcode} differs
2600 between \XeTeX\ and \LuaTeX, by the following reasons:
2601 \begin{itemize}
2602  \item (plain format) \texttt{luatex-unicode-letters.tex} is based on old \texttt{unicode-letters.tex}.
2603  \item The latter half of \texttt{unicode-letters.tex}~and~\texttt{unicode-letters.def}
2604 sets\cs{catcode} of several characters to 11, via setting \cs{XeTeXcharclass}.
2605 However, this latter half does not exist (plain case), or not executed (\LaTeX~case) in \LuaTeX.
2606 \end{itemize}
2607 In other words,
2608 \begin{description}
2609 \item[plain \LuaTeX]
2610 Kanji nor kana characters cannot be used in
2611 a control word, in the default setting of plain \LuaTeX.
2612 \item[\LuaLaTeX]
2613 In recent (2015-10-01 or later) \LuaLaTeX, Kanji and kana characters in a control word is supported (these catcode are 11),
2614 but not fullwidth alphanumerics and several other characters.
2615 \end{description}
2616
2617 This would be inconvenient for \pTeX~users to shifting to \LuaTeX-ja,
2618 since several control words containing Kanji or other fullwidth characters, such as
2619 \verb+\西暦+~or~\verb+\1年目西暦+ are used in \pTeX.
2620 Hence, \LuaTeX-ja have a counterpart of \texttt{unicode-letters.tex}
2621 for \LuaTeX, \emph{to match the \cs{catcode} setting with that of \XeTeX.}
2622 %</en>
2623 %<*ja>
2624 ネイティブにUnicode全部の文字を扱える\XeTeX や\LuaTeX では,
2625 文字が制御綴内で使用できるかは通常の欧文文字と同じく\cs{catcode}%
2626 で指定することとなる.plain \XeTeX における\cs{catcode}の初期設定は%
2627 \texttt{unicode-letters.tex}中に記述されており,plain \LuaTeX ではそれを
2628 元にした\texttt{luatex-unicode-letters.tex}を用いている.
2629 \LaTeX では\cs{catcode}の設定はカーネルに\texttt{unicode-letters.def}として統合され.
2630 このファイルを\XeLaTeX, \LuaLaTeX の両方が用いている.
2631
2632 だが,\XeTeX における\cs{catcode}の初期設定と
2633 \LuaTeX におけるそれは一致していない:
2634 \begin{itemize}
2635  \item \texttt{luatex-unicode-letters.tex} の元になった
2636   \texttt{unicode-letters.tex}が古い
2637  \item \texttt{unicode-letters.tex} 後半部や\texttt{unicode-letters.def}後半部では
2638 \cs{XeTeXcharclass}の設定を行なっており,
2639 それによって漢字や仮名,および全角英数字の\cs{catcode}が11に設定されている.
2640 しかし,\texttt{luatex-unicode-letters.tex}ではこの「後半部」が
2641 まるごと省略されており,また\LuaLaTeX でも\texttt{unicode-letters.def}後半部は実行されな
2642        い.
2643 \end{itemize}
2644 言い換えると,
2645 \begin{description}
2646  \item[plain \LuaTeX]  漢字や仮名を制御綴内に
2647 使用することはできない.
2648  \item[\LuaLaTeX] 最近の(2015-10-01以降の)
2649 \LuaLaTeX では漢字や仮名を制御綴内に
2650 使用することが可能になったが,全角英数字は相変わらず使用できない,
2651 \end{description}
2652 これでは\pTeX で使用できた\verb+\1年目西暦+\footnote{科研費\LaTeX で使用されているそうです.}などが使えないこととなり,
2653 \LuaTeX-jaへの移行で手間が生じる.そのため,\LuaTeX-jaでは
2654 \texttt{unicode-letters.tex}の後半部にあたる内容を自前でパッチし,
2655 結果として\emph{\XeTeX における初期設定と同じになるようにしている.}
2656 %</ja>
2657
2658 \begin{table}
2659  \centering\small
2660 %<en>\caption{Difference of the set of non-kanji JIS~X~0208 characters which can be used in a control word}
2661 %<ja>\caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2662 %<en>\medskip
2663 \label{tab:kcat-diff}
2664 \def\D#1#2#3#4{%
2665   {\fboxsep0pt\fcolorbox{cyan}{white}%
2666   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2667 \leavevmode\hbox to 0pt{\hss\begin{tabular}{cccccc}
2668 \toprule
2669 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2670 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2671 \midrule
2672 %\D 3000&1&1&N&N&Y\\
2673 \D 30FB&1&6&N&Y&N\\
2674 \D 309B&1&11&N&Y&N\\
2675 \D 309C&1&12&N&Y&N\\
2676 \D FF40&1&14&N&N&Y\\
2677 \D FF3E&1&16&N&N&Y\\
2678 \D FFE3&1&17&N&N&Y\\
2679 \D FF3F&1&18&N&N&Y\\
2680 %\D 30FD&1&19&N&Y&Y\\
2681 %\D 30FE&1&20&N&Y&Y\\
2682 %\D 309D&1&21&N&Y&Y\\
2683 %\D 309E&1&22&N&Y&Y\\
2684 \D 3003&1&23&N&N&Y\\
2685 \D 4EDD&1&24&N&Y&Y\\
2686 \D 3005&1&25&N&N&Y\\
2687 \D 3006&1&26&N&N&Y\\
2688 \D 3007&1&27&N&N&Y\\
2689 \D 30FC&1&28&N&Y&Y\\
2690 \D FF0F&1&31&N&N&Y\\
2691 \D FF3C&1&32&N&N&Y\\
2692 \bottomrule
2693 \end{tabular}\qquad
2694 \begin{tabular}{cccccc}
2695 \toprule
2696 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2697 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2698 \midrule
2699 \D FF5C&1&35&N&N&Y\\
2700 \D FF0B&1&60&N&N&Y\\
2701 \D FF1D&1&65&N&N&Y\\
2702 \D FF1C&1&67&N&N&Y\\
2703 \D FF1E&1&68&N&N&Y\\
2704 \D FF03&1&84&N&N&Y\\
2705 \D FF06&1&85&N&N&Y\\
2706 \D FF0A&1&86&N&N&Y\\
2707 \D FF20&1&87&N&N&Y\\
2708 \D 3012&2&9&N&N&Y\\
2709 \D 3013&2&14&N&N&Y\\
2710 \D FFE2&2&44&N&N&Y\\
2711 \D 212B&2&82&N&N&Y\\
2712 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Greek letters (row 6)}&Y&N&Y\\
2713 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Cyrillic letters (row 7)}&N&N&Y\\
2714 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&Y&N&Y\\
2715 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&N&N&Y\\
2716 \bottomrule
2717 \end{tabular}\hss}\par
2718 \end{table}
2719
2720 %<*en>
2721 \subsection{Non-kanji characters in a control word}
2722 Because the engine differ, so non-kanji JIS~X~0208 characters
2723 which can be used in a control word differ in \pTeX, in \upTeX,~and~in \LuaTeX-ja.
2724 \autoref{tab:kcat-diff} shows the difference.
2725 Except for four characters ``・'',~``゛'', ``゜'',~``゠'',
2726 \LuaTeX-ja admits more characters in a control word than \upTeX.
2727
2728 Difference becomes larger, if we consider
2729 non-kanji JIS~X~0213 characters.
2730 For the detail, see \url{https://github.com/h-kitagawa/kct}.
2731 %</en>
2732 %<*ja>
2733 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2734
2735 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2736 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2737 異なっているところだけを載せると,\autoref{tab:kcat-diff}のようになる.
2738 「・」「゛」「゜」「゠」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2739 制御綴に使用可能になっている.
2740
2741 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2742 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\
2743 \texttt{kct-out.pdf} などを参照すること.
2744 %</ja>
2745
2746
2747 %<*en>
2748 \section{Directions}
2749 \LuaTeX\ supports four $\Omega$-style directions: \texttt{TLT},~\texttt{TRT}, \texttt{RTT}
2750 and \texttt{LTL}.
2751 However, neither directions are not well-suited for typesetting Japanese vertically, hence we
2752 implemented vertical writing by rotating \texttt{TLT}-box by 90~degrees.
2753 %</en>
2754 %<*ja>
2755 \section{縦組}
2756 \label{sec-direction}
2757 \LuaTeX 本体でも,$\Omega$・$\aleph$由来の機能として,複数の組方向をサポートしている.
2758 しかし,\LuaTeX がサポートするのは \texttt{TLT},~\texttt{TRT}, \texttt{RTT},~\texttt{LTL}\
2759 のみであり,日本語の縦組に使うのは望ましくない\footnote{%
2760 和文文字だけならば \texttt{RTT} を使えばなんとかなると思うが,
2761 欧文文字が入ってきた場合はうまくいかず,\texttt{RTR} という組方向が必要になる.
2762 }.そのため,\LuaTeX-jaでは横組(\texttt{TLT})で組んだボックスを回転させる方式で
2763 縦組を実装した.
2764 %</ja>
2765
2766 %<ja>\subsection{サポートする組方向}
2767 \begin{table}[t]
2768 %<ja>\caption{\LuaTeX-ja のサポートする組方向}
2769 %<en>\caption{Directions supported by \LuaTeX-ja}
2770 %<en>\medskip
2771 \label{tab-dir}
2772 \centering\small
2773 \def\obox#1{%
2774   \setbox0=\hbox{\yoko\hbox{#1%
2775   \large\ltjsetparameter{talbaselineshift=0pt}%
2776   \vrule height 25pt width 0.4pt depth 15pt\kern-.2pt%
2777   \raise25pt\hbox to 0pt{\hss\composite{*r^@{>>}}\hss}%
2778   \raise-15pt\hbox to 0pt{\hss\composite{*l^@{>|}}\hss}\kern.2pt%
2779   \vrule height.2pt depth.2pt width 60pt\hbox to 0pt{\hss\composite{*d^@{>}}\hss}\kern-60pt
2780   \hbox to 60pt{\,銀は、Ag\hss}}}%
2781   \raise\dimexpr 0.5\ltjgetdp0-0.5\ltjgetht0\box0%
2782 }
2783 %<*ja>
2784 \begin{tabular}{>{\bfseries}lcccc}
2785 \toprule
2786 &横組&縦組 &「dtou方向」&「utod方向」\\
2787 \midrule
2788 命令&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2789 字送り方向&水平右向き(→)&垂直下向き(↓)&垂直上向き(↑)&垂直下向き(↓)\\
2790 行送り方向&垂直下向き(↓)&水平左向き(←)&水平右向き(→)&水平左向き(←)\\
2791 使用する和文フォント&横組用(\cs{jfont})&縦組用(\cs{tfont})&
2792 \multicolumn{2}{c}{%
2793   横組用(\cs{jfont})の$90^\circ$回転}\\[\smallskipamount]
2794 組版例\null $^*$ &\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2795 \noalign{\medskip}
2796 \bottomrule
2797 \end{tabular}
2798
2799 \medskip\raggedright
2800 \def\R#1{%
2801   \raise0.38\zw\hbox{%
2802     \vrule height.2pt  depth.2pt width2\zw%
2803     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2804   }%
2805 }
2806 $^*$\ 幅(width),高さ(height),深さ(depth)の増加方向を,
2807 それぞれ「\R{>}」,「\R{>>}」,「\R{>|}」で表している.
2808 \raggedright
2809 %</ja>
2810
2811 %<*en>
2812 \begin{tabular}{>{\bfseries}lcccc}
2813 \toprule
2814 &horizontal (\emph{yoko}~direction)&vertical (\emph{tate}~direction)&%
2815   \emph{dtou} direction&\emph{utod} direction\\
2816 \midrule
2817 Commands&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2818 Beginning of the page&Top&Right&Left&Right\\
2819 Beginning of the line&Left&Top&Bottom&Top\\
2820 Used Japanese font&horizontal (\cs{jfont})&vertical (\cs{tfont})&
2821 \multicolumn{2}{c}{%
2822   horizontal ($90^\circ$ rotated)}\\[\smallskipamount]
2823 Example&\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2824 \noalign{\medskip}
2825 (Notation used in $\Omega$)&TLT&RTR, RTT&LBL&RTR\\
2826 \bottomrule
2827 \end{tabular}
2828
2829 \medskip\raggedright
2830 \def\R#1{%
2831   \raise0.38\zw\hbox{%
2832     \vrule height.2pt  depth.2pt width2\zw%
2833     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2834   }%
2835 }
2836 \raggedright
2837 %</en>
2838 \end{table}
2839
2840 %<*en>
2841 \LuaTeX-ja supports four directions, as shown in \autoref{tab-dir}.
2842 The second column (\emph{yoko} direction) is just horizontal writing,
2843 and the third column (\emph{tate} direction) is vertical writing.
2844 The fourth column (\emph{dtou} direction) is actually a hidden feature of \pTeX.
2845 We implemented this for debugging purpose.
2846 The fifth column (\emph{utod} direction) corresponds the ``\texttt{tate (math) direction}'' of \pTeX.
2847
2848 Directions can be changed by \cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod},
2849 only when the current list is null.
2850 These commands cannot be executed in unrestricted horizontal modes, nor math modes.
2851 The direction of a math formula is changed to
2852 \emph{utod}, when the direction outside the math formula is \emph{tate} (vertical writing).
2853 %</en>
2854
2855 %<*ja>
2856 \LuaTeX-jaがサポートする組方向は\autoref{tab-dir}に示す4つである.
2857 4列目の \cs{dtou} は聞き慣れない命令だと思うが,
2858 実は\pTeX に同名の命令が(ドキュメントには書かれていないが)存在する.
2859 Down-TO-Upの意味なのだろう.\cs{dtou} を使用する機会はないだろうが,
2860 \LuaTeX-jaではデバッグ用に実装している.
2861 5列目の \cs{utod} は,\pTeX で言う「縦数式ディレクション」に相当するものである.
2862
2863 組方向は,\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod} をそれぞれ使用することで,
2864 現在作成中のリストやボックスが空の時にのみ変更可能である.
2865 ただし,現在のモードが非制限水平モードや(文中,別行立て問わず)数式モードであるときには
2866 組方向を変更することは出来ない.
2867 また,縦組中の数式内のボックスは\pTeX と同じように組方向が \cs{utod} となる.
2868
2869 なお,\LaTeX の下で\LuaTeX-jaを使用する場合,組方向変更命令には
2870 「新たな組方向下での和文フォントを必要なら読み込み(・選択する)」という
2871 処理が付け加えられている(\ref{ssec:ltx-jfm}節参照).
2872 %</ja>
2873
2874 %<*en>
2875 \subsection{Boxes in different direction}
2876
2877 As in \pTeX, one can use boxes of different direction in one document.
2878 The below is an example.
2879 \begin{LTXexample}
2880 ここは横組%     yoko
2881 \hbox{\tate %   tate
2882   \hbox{縦組}%  tate
2883   の中に
2884   \hbox{\yoko 横組の内容}% yoko
2885   を挿入する
2886 }
2887 また横組に戻る% yoko
2888 \end{LTXexample}
2889
2890 \autoref{tab-diffdir} shows how a box is arranged when
2891 the direction  inside the box and that outside the box differ.
2892 %</en>
2893 %<*ja>
2894 \subsection{異方向のボックス}
2895
2896 縦組の中に「42」などの2桁以上の算用数字を横組で組むなど,
2897 異なる組方向を混在させることがしばしば行われる.
2898 組方向の混在も\pTeX と同じようにできる:
2899 \begin{LTXexample}
2900 ここは横組%     yoko
2901 \hbox{\tate %   tate
2902   \hbox{縦組}%  tate
2903   の中に
2904   \hbox{\yoko 横組の内容}% yoko
2905   を挿入する
2906 }
2907 また横組に戻る% yoko
2908 \end{LTXexample}
2909
2910 異なる組方向のボックスを配置した場合にどう組まれるかの仕様も,\pTeX を
2911 踏襲している.\autoref{tab-diffdir}に示す.
2912 %</ja>
2913
2914 \begin{table}[t]
2915 %<ja>\caption{異方向のボックスの配置}
2916 %<en>\caption{Boxes in different direction}
2917 %<en>\medskip
2918 \label{tab-diffdir}
2919  \centering\small\unitlength3mm
2920  \def\TATEeg{%
2921    \hbox{\smash{\begin{picture}(0,0)(-2,0)
2922      \thicklines
2923      \polyline(-2,0)(-2,-7)(5,-7)(5,0)
2924      \put(0,0){\circle*{0.3}}
2925      \put(2.5,-4){\makebox(0,0){\hbox{\tate\bfseries \emph{tate}/\emph{utod}}}}
2926      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
2927      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
2928      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
2929    \end{picture}}}%
2930  }
2931  \def\DTOUeg{%
2932    \hbox{\smash{\begin{picture}(0,0)(-5,0)
2933      \thicklines
2934      \polyline(-5,0)(-5,7)(2,7)(2,0)
2935      \put(0,0){\circle*{0.3}}
2936      \put(-2.5,4){\makebox(0,0){\hbox{\dtou\bfseries \emph{dtou}}}}
2937      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
2938      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
2939      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
2940    \end{picture}}}%
2941  }
2942  \def\YOKOeg{%
2943    \hbox{\smash{\begin{picture}(0,0)
2944      \thicklines
2945      \polyline(0,5)(7,5)(7,-2)(0,-2)
2946      \put(4,2.5){\makebox(0,0){\hbox{\yoko\bfseries \emph{yoko}}}}
2947      \put(0,0){\circle*{0.3}}
2948      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
2949      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
2950      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
2951    \end{picture}}}%
2952  }
2953 \begin{tabular}{ccc}
2954 \toprule
2955 %<ja>\emph{横組中に配置}&\emph{縦組中に配置}&%
2956 %<ja>\emph{組方向 \cs{dtou} 中に配置}\\
2957 %<en>\textbf{typeset in \emph{yoko} direction}
2958 %<en>&\textbf{typeset in \emph{tate} or \emph{utod} direction}
2959 %<en>&\textbf{typeset in \emph{dtou} direction}\\
2960 \midrule
2961  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2962    \put(0,0){\line(1,0){3.8}}
2963    \put(4,7){\TATEeg}
2964    \put(11.2,0){\line(1,0){3.8}}
2965 %
2966    \put(2,7){\line(1,0){1.8}}
2967    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
2968    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
2969    \put(3,-2){\vector(0,1){2}}
2970    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
2971 %
2972    \put(4,7.2){\line(0,1){1.8}}
2973    \put(11,7.2){\line(0,1){1.8}}
2974    \put(6,8){\vector(-1,0){2}}
2975    \put(9,8){\vector(1,0){2}}
2976    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
2977 %
2978  \end{picture}\vspace{-\baselineskip}
2979    \begin{align*}
2980    W_{\mathrm{Y}} &= h_{\mathrm{T}}+d_{\mathrm{T}},\\
2981    H_{\mathrm{Y}} &= w_{\mathrm{T}},\\
2982    D_{\mathrm{Y}} &=0\,\mathrm{pt}
2983    \end{align*}%
2984  }&
2985  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2986    \put(7.5,-0.2){\line(0,-1){2.8}}
2987    \put(4,2){\YOKOeg}
2988    \put(7.5, 7.2){\line(0,1){3.8}}
2989 %
2990    \put(2,7){\line(1,0){1.8}}
2991    \put(2,0){\line(1,0){1.8}}
2992    \put(3,5){\vector(0,1){2}}
2993    \put(3,2){\vector(0,-1){2}}
2994    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
2995 %
2996    \put(4,7.2){\line(0,1){1.8}}
2997    \put(11,7.2){\line(0,1){1.8}}
2998    \put(8,8){\vector(-1,0){0.5}\vector(1,0){3}}
2999    \put(7,8){\vector(-1,0){3}\vector(1,0){0.5}}
3000    \put(9.25,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3001    \put(5.75,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3002 %
3003  \end{picture}\vspace{-\baselineskip}
3004    \begin{align*}
3005    W_{\mathrm{T}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3006    H_{\mathrm{T}} &= w_{\mathrm{Y}}/2,\\
3007    D_{\mathrm{T}} &= w_{\mathrm{Y}}/2
3008    \end{align*}%
3009  }&
3010  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3011    \put(11,-0.2){\line(0,-1){2.8}}
3012    \put(4,2){\YOKOeg}
3013    \put(11, 7.2){\line(0,1){3.8}}
3014 %
3015    \put(2,7){\line(1,0){1.8}}
3016    \put(2,0){\line(1,0){1.8}}
3017    \put(3,5){\vector(0,1){2}}
3018    \put(3,2){\vector(0,-1){2}}
3019    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3020 %
3021    \put(4,7.2){\line(0,1){1.8}}
3022    \put(11,7.2){\line(0,1){1.8}}
3023    \put(7.5,8){\vector(-1,0){3.5}\vector(1,0){3.5}}
3024    \put(13,8){\vector(-1,0){2}}
3025    \put(7.5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3026    \put(12,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3027 %
3028  \end{picture}\vspace{-\baselineskip}
3029    \begin{align*}
3030    W_{\mathrm{D}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3031    H_{\mathrm{D}} &= w_{\mathrm{Y}},\\
3032    D_{\mathrm{D}} &= 0\,\mathrm{pt}
3033    \end{align*}%
3034  }%
3035 \\\midrule
3036  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3037    \put(0,0){\line(1,0){3.8}}
3038    \put(4,0){\DTOUeg}
3039    \put(11.2,0){\line(1,0){3.8}}
3040 %
3041    \put(2,7){\line(1,0){1.8}}
3042    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
3043    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
3044    \put(3,-2){\vector(0,1){2}}
3045    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
3046 %
3047    \put(4,7.2){\line(0,1){1.8}}
3048    \put(11,7.2){\line(0,1){1.8}}
3049    \put(6,8){\vector(-1,0){2}}
3050    \put(9,8){\vector(1,0){2}}
3051    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3052 %
3053  \end{picture}\vspace{-\baselineskip}
3054    \begin{align*}
3055    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3056    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
3057    D_{\mathrm{Y}} &= 0\,\mathrm{pt}
3058    \end{align*}%
3059  }&
3060  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3061    \put(9,-0.2){\line(0,-1){2.8}}
3062    \put(4,0){\DTOUeg}
3063    \put(9, 7.2){\line(0,1){3.8}}
3064 %
3065    \put(2,7){\line(1,0){1.8}}
3066    \put(2,0){\line(1,0){1.8}}
3067    \put(3,5){\vector(0,1){2}}
3068    \put(3,2){\vector(0,-1){2}}
3069    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3070 %
3071    \put(4,7.2){\line(0,1){1.8}}
3072    \put(11,7.2){\line(0,1){1.8}}
3073    \put(6.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3074    \put(10,8){\vector(-1,0){1}\vector(1,0){1}}
3075    \put(10,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3076    \put(6.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3077 %
3078  \end{picture}\vspace{-\baselineskip}
3079    \begin{align*}
3080    W_{\mathrm{T}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3081    H_{\mathrm{T}} &= d_{\mathrm{D}},\\
3082    D_{\mathrm{T}} &= h_{\mathrm{D}}
3083    \end{align*}%
3084  }&
3085  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3086    \put(6,-0.2){\line(0,-1){2.8}}
3087    \put(4,7){\TATEeg}
3088    \put(6, 7.2){\line(0,1){3.8}}
3089 %
3090    \put(2,7){\line(1,0){1.8}}
3091    \put(2,0){\line(1,0){1.8}}
3092    \put(3,5){\vector(0,1){2}}
3093    \put(3,2){\vector(0,-1){2}}
3094    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3095 %
3096    \put(4,7.2){\line(0,1){1.8}}
3097    \put(11,7.2){\line(0,1){1.8}}
3098    \put(5,8){\vector(-1,0){1}\vector(1,0){1}}
3099    \put(8.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3100    \put(5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3101    \put(8.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3102 %
3103  \end{picture}\vspace{-\baselineskip}
3104    \begin{align*}
3105    W_{\mathrm{D}} &= w_{\mathrm{T}},\\
3106    H_{\mathrm{D}} &= d_{\mathrm{T}},\\
3107    D_{\mathrm{D}} &= h_{\mathrm{T}}
3108    \end{align*}%
3109  }\\
3110 \bottomrule
3111 \end{tabular}
3112 \end{table}
3113
3114
3115
3116 %<*en>
3117 \paragraph{\cs{wd} and direction}
3118 In \pTeX, \cs{wd},~\cs{ht},~\cs{dp} means the dimensions of a box register
3119 \emph{with respact to the current direction}.
3120 This means that the value of \cs{wd0} etc.\ might differ when the current direction is
3121 different, even if \cs{box0} stores the same box.
3122 However, this no longer applies in \LuaTeX-ja.
3123
3124 \begin{LTXexample}
3125 % yoko direction
3126 \setbox0=\hbox to 20pt{foo}
3127 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3128 \wd0=100pt
3129 \the\wd0,~\hbox{\tate \the\wd0}
3130 \end{LTXexample}
3131
3132 To access box dimensions \emph{with respect to current direction},
3133 one have to use the following commands instead of \cs{wd} wtc.
3134 \begin{cslist}
3135
3136  \item[\cs{ltjgetwd}<num>\textrm{, }\cs{ltjgetht}<num>\textrm{, }%
3137   \cs{ltjgetdp}<num>]
3138 These commands return \emph{an internal dimension} of \cs{box<num>} with respect to
3139 the current direction. One can use these in \cs{dimexpr} primitive, as the followings.
3140 \begin{lstlisting}
3141 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3142 \end{lstlisting}
3143 The following is an example.
3144 \begin{LTXexample}[width=0.3\textwidth]
3145 \parindent0pt
3146 \setbox32767=\hbox{\yoko よこぐみ}
3147 \fboxsep=0mm\fbox{\copy32767}
3148 \vbox{\hsize=20mm
3149 \yoko YOKO \the\ltjgetwd32767, \\
3150   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3151 \vbox{\hsize=20mm\raggedleft
3152 \tate TATE \the\ltjgetwd32767, \\
3153   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3154 \vbox{\hsize=20mm\raggedleft
3155 \dtou DTOU \the\ltjgetwd32767, \\
3156   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3157 \end{LTXexample}
3158
3159  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3160   \cs{ltjsetdp}<num>=<dimen>]
3161 These commands set the dimension of \cs{box<num>}. One does not need
3162         to group the argument <num>; four calls of \cs{ltjsetwd} below have the same meaning.
3163 \begin{lstlisting}
3164 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3165 \end{lstlisting}
3166
3167 \end{cslist}
3168 %</en>
3169 %<*ja>
3170 \paragraph{\cs{wd} 達と組方向}
3171 ボックスレジスタ \cs{box}<num> にセットされているボックスの幅・高さ・深さの取得や
3172 変更にはそれぞれ \cs{wd},~\cs{ht},~\cs{dp} プリミティブを用いるのであった.
3173 \pTeX ではこれらのプリミティブは,「現在の組方向におけるボックスの寸法」を指すもので,
3174 同じボックスに対しても現在の組方向によって返る値は異なるもであった.
3175
3176 \LuaTeX-jaにおいては状況が異なり,\cs{wd},~\cs{ht},~\cs{dp} が返す値は
3177 現在の組方向には依存しない.下の例のように,横組のボックスが格納されていれば
3178 \cs{wd}等は常に「横組におけるボックスの寸法」を意味する.
3179
3180 \begin{LTXexample}
3181 % yoko direction
3182 \setbox0=\hbox to 20pt{foo}
3183 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3184 \wd0=100pt
3185 \the\wd0,~\hbox{\tate \the\wd0}
3186 \end{LTXexample}
3187
3188 \pTeX のように現在の組方向に応じたボックスの寸法の取得・設定を行うには,
3189 代わりに次の命令を使用する.
3190
3191 \begin{cslist}
3192
3193  \item[\cs{ltjgetwd}<num>\textrm{, }\cs{ltjgetht}<num>\textrm{, }%
3194   \cs{ltjgetdp}<num>]
3195 現在の組方向に応じたボックスの寸法の取得を行う.結果は内部長さであるため,
3196 \begin{lstlisting}
3197 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3198 \end{lstlisting}
3199 のように \cs{wd}<num> の代わりとして扱うことができる.
3200 使用例は以下の通りである.
3201 \begin{LTXexample}[width=0.3\textwidth]
3202 \parindent0pt
3203 \setbox32767=\hbox{\yoko よこぐみ}
3204 \fboxsep=0mm\fbox{\copy32767}
3205 \vbox{\hsize=20mm
3206 \yoko YOKO \the\ltjgetwd32767, \\
3207   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3208 \vbox{\hsize=20mm\raggedleft
3209 \tate TATE \the\ltjgetwd32767, \\
3210   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3211 \vbox{\hsize=20mm\raggedleft
3212 \dtou DTOU \the\ltjgetwd32767, \\
3213   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3214 \end{LTXexample}
3215
3216  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3217   \cs{ltjsetdp}<num>=<dimen>]
3218 現在の組方向に応じたボックスの寸法の設定を行う.\cs{afterassignment} を2回利用して
3219 実装しているので,次の4通りは全て同じ意味である.
3220 \begin{lstlisting}
3221 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3222 \end{lstlisting}
3223
3224 設定値は「横組」「縦組及びutod方向」「dtou方向」
3225 の3種ごとに独立して記録される.参考として,Gitリポジトリ内の
3226               \verb+test/test55-boxdim_diffdir.{tex,pdf}+ を挙げておく.
3227
3228 \end{cslist}
3229 %</ja>
3230
3231 %<*en>
3232 \subsection{Getting current direction}
3233 The \Param{direction} parameter returns the current direction, and
3234 the \Param{boxdir} parameter (with the argument <num>)
3235 returns the direction of a box register \cs{box}<num>.
3236 The returned value of these parameters are a \emph{string}:
3237 \begin{center}
3238 \small
3239 \begin{tabular}{>{\bfseries}lccccc}
3240 \toprule
3241 Direction&\emph{yoko}&\emph{tate}&\emph{dtou}&\emph{utod}&(empty)\\
3242 \midrule
3243 Returned value&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3244 \bottomrule
3245 \end{tabular}
3246 \end{center}
3247 \begin{LTXexample}[width=0.3\textwidth]
3248 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3249 \hbox{\yoko \DIR}, \hbox{\tate\DIR},
3250 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3251 \hbox{\tate$\hbox{tate math: \DIR}$}
3252
3253 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3254 \end{LTXexample}
3255 %</en>
3256 %<*ja>
3257 \subsection{組方向の取得}
3258 「現在の組方向」や「<num>番のボックスの組方向」は,
3259 \pTeX では \cs{ifydir} や \cs{ifybox}<num> といった条件判断文を使って
3260 判断することができた.
3261 しかし,\LuaTeX-jaはあくまでも\TeX マクロとLuaコードで
3262 記述されており,それでは新たな条件判断命令を作るのは難しい.
3263
3264 \LuaTeX-jaでは,\Param{direction}パラメータで現在の組方向を,
3265 \Param{boxdir}パラメータ(と追加の引数<num>)によって
3266 \cs{box}<num>の組方向をそれぞれ取得できるようにした.
3267 戻り値は文字列である:
3268 \begin{center}
3269 \small
3270 \begin{tabular}{>{\bfseries}lccccc}
3271 \toprule
3272 組方向&\emph{横組}&\emph{tate縦組}&\emph{dtou方向}&\emph{utod方向}&(未割り当て)\\
3273 \midrule
3274 戻り値&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3275 \bottomrule
3276 \end{tabular}
3277 \end{center}
3278
3279 \begin{LTXexample}[width=0.3\textwidth]
3280 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3281 \hbox{\yoko\DIR}, \hbox{\tate\DIR},
3282 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3283 \hbox{\tate$\hbox{tate math: \DIR}$}
3284
3285 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3286 \end{LTXexample}
3287
3288 これらを用いれば,例えば
3289 \pTeX の \cs{ifydir},~\cs{ifybox200} と同等の条件判断を
3290 \begin{lstlisting}
3291 \ifnum\ltjgetparameter{direction}=4
3292 \ifnum\ltjgetparameter{boxdir}{200}=4
3293 \end{lstlisting}
3294 のように行うことができる.
3295 \cs{iftdir} は少々面倒であるが,8で割った余りが3であるか否かを判断すれば良いから
3296 \begin{lstlisting}
3297 \ifnum\numexpr
3298   \ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8=3
3299 \end{lstlisting}
3300 とすればよい.
3301 %</ja>
3302
3303 %<*en>
3304 \subsection{Overridden box primitives}
3305 To cope with multiple directions, the following primitives are
3306 overridden by \LuaTeX-ja, using~\verb+\protected\def+.
3307 \begin{cslist}[style=standard]
3308  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3309  \item[\cs{vadjust}\{<material>\}]
3310  \item[\cs{insert}<number>\{<material>\}]
3311  \item[\cs{lastbox}]
3312  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3313  \item[\cs{vcenter}]
3314 \end{cslist}
3315 %</en>
3316 %<*ja>
3317 \subsection{プリミティブの再定義}
3318 異なる組方向に対応するために,以下に挙げるプリミティブは
3319 \LuaTeX-jaによる前処理もしくは後処理が行われるように
3320 \ \verb+\protected\def+ により再定義してある.
3321
3322 \begin{cslist}
3323  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3324  ボックスの組方向が現在のリストと異なる場合は事前にエラーメッセージを出力する.
3325  \pTeX と異なり,エラーを無視して無理矢理 \cs{unhbox}, \cs{unvbox} を
3326  続行させることもできるが,その場合の組版結果は保証しない.
3327  \item[\cs{vadjust}\{<material>\}] 一旦プリミティブ本来の挙動を行う.その後,<material>の組方向が
3328  周囲の垂直リストの組方向と一致しない場合にエラーを出力し,
3329  該当の \cs{vadjust} を無効にする.
3330  \item[\cs{insert}<number>\{<material>\}]
3331  一旦プリミティブ本来の挙動を行い,その後<material>内の各ボックス・罫線の直前に組方向を示
3332               すdirection whatsitを挿入する.
3333  \item[\cs{lastbox}] ボックスの「中身」を現在の組方向に合わせるためのノード
3334               (\textit{dir\_box}という)を必要ならば除去し,
3335  正しく「中身」のボックスが返されるように前処理をする.
3336  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3337  一方,こちらでは必要に応じて\textit{dir\_box}を作成する前処理を追加している.
3338 \end{cslist}
3339 %</ja>
3340
3341 %<en>\section{Font Metric and Japanese Font}
3342 %<ja>\section{フォントメトリックと和文フォント}
3343 %<en>\subsection{\cs{jfont}}
3344 %<ja>\subsection{\cs{jfont} 命令}
3345 \label{ssec:jfont}
3346
3347 %<*en>
3348 To load a font as a Japanese font (for horizontal direction), you must use the
3349 \cs{jfont} instead of~\cs{font}, while
3350 \cs{jfont} admits the same syntax used in~\cs{font}.
3351 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
3352 so TrueType/OpenType fonts with features can be used for Japanese fonts:
3353 %</en>
3354 %<*ja>
3355 フォントを(横組用)和文フォントとして読み込むためには,\cs{jfont} を
3356 \ \cs{font} プリミティブの代わりに用いる.
3357 \cs{jfont} の文法は \cs{font} と同じである.
3358 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
3359 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
3360 ことができる:
3361 %</ja>
3362 \begin{LTXexample}[width=0.3\textwidth]
3363 \jfont\tradgt={file:KozMinPr6N-Regular.otf:script=latn;%
3364   +trad;-kern;jfm=ujis} at 14pt
3365 \tradgt 当/体/医/区
3366 \end{LTXexample}
3367
3368 %<*en>
3369 Note that the defined control sequence
3370 (\cs{tradgt} in the example above) using \cs{jfont} is not a
3371 \textit{font\_def} token,  but a macro.
3372 Hence the input like \verb+\fontname\tradgt+
3373 causes a error.  We denote control sequences which are defined in
3374 \cs{jfont} by <jfont\_cs>.
3375 %</en>
3376 %<*ja>
3377 なお,\cs{jfont} で定義された制御綴(上の例だと \cs{tradgt})
3378 は\textit{font\_def}トークンではなくマクロである.従って,\verb+\fontname\tradgt+ のような
3379 入力はエラーとなる.以下では \cs{jfont} で定義された
3380 制御綴を<jfont\_cs>で表す.
3381 %</ja>
3382
3383 \paragraph{JFM}
3384 %<*en>
3385 a JFM has measurements of characters and
3386 glues/kerns that are automatically inserted for Japanese
3387 typesetting. The structure of JFM will be described in the next
3388 subsection. At the calling of \cs{jfont}, you must specify
3389 which JFM will be used for this font by the following keys:
3390 %</en>
3391 %<*ja>
3392 JFMは文字と和文組版で自動的に挿入される
3393 グルー/カーンの寸法情報を持っている.JFMの構造は次の節で述べる.
3394 \cs{jfont} 命令の呼び出しの際には,どのJFMを用いるのかを以下のキーで
3395 指定する必要がある:
3396 %</ja>
3397
3398
3399 \begin{table}[t]
3400 %<en>\caption{Differences between horizontal JFMs shipped with \LuaTeX-ja}
3401 %<ja>\caption{\LuaTeX-ja に同梱されている横組用JFMの違い}
3402 %<en>\medskip
3403 \label{tab-difjfm}
3404 \ltjsetparameter{jacharrange={+3}}
3405 \centering\small
3406 \def\r#1#2{%
3407   \hbox{\Large\vrule
3408   \parbox[b]{7\zw}{%
3409     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3410     ◆◆◆◆◆◆◆
3411     ある日モモちゃんがお使いで迷子になって泣きました.
3412   }\vrule}}
3413 \def\s#1#2{%
3414   \Large
3415   \parbox[b]{7\zw}{%
3416     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3417     ちょっと!何
3418   }}
3419 \def\t#1#2#3{\hbox to 0pt{\hss%
3420   \setbox0=\hbox{\addjfontfeatures{YokoFeatures={JFM=#1}}\huge #3}%
3421   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3422   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3423   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3424   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3425   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3426 {\Large\tabcolsep0pt
3427 \begin{tabular}{m{8\zw}m{8\zw}m{8\zw}}
3428 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{jis}{black}&
3429 \leavevmode\hbox to 0pt{\r{jis}{black}\hss}\r{min}{red}&
3430 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{min}{red}\\
3431 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{jis}{black}&
3432 \leavevmode\hbox to 0pt{\s{jis}{black}\hss}\s{min}{red}&
3433 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{min}{red}\\
3434 \leavevmode\qquad\t{ujis}{blue}{漢}\t{jis}{black}{漢}\qquad
3435            \t{ujis}{blue}{っ}\t{jis}{black}{っ}&
3436 \leavevmode\qquad\t{jis}{black}{漢}\t{min}{red}{漢}\qquad
3437            \t{jis}{black}{っ}\t{min}{red}{っ}&
3438 \leavevmode\qquad\t{ujis}{blue}{漢}\t{min}{red}{漢}\qquad
3439            \t{ujis}{blue}{っ}\t{min}{red}{っ}\\
3440 \end{tabular}\par}
3441
3442 (\textcolor{blue}{Blue: \texttt{jfm-ujis.lua}},
3443 \textcolor{black}{Black: \texttt{jfm-jis.lua}},
3444 \textcolor{red}{Red: \texttt{jfm-min.lua}})
3445 \ltjsetparameter{jacharrange={-3}}
3446 \end{table}
3447
3448 \begin{cslist}
3449 \item[jfm=<name>]
3450 %<*en>
3451 Specify the name of (horizontal) JFM.
3452 If specified JFM has not been loaded, \LuaTeX-ja search and load
3453 a file named \texttt{jfm-<name>.lua}.
3454
3455 The following horizontal JFMs are shipped with \LuaTeX-ja:
3456 %</en>
3457 %<*ja>
3458 用いる(横組用)JFMの名前を指定する.もし以前に指定されたJFMが読み込まれていなければ,
3459 \texttt{jfm-<name>.lua}を読み込む.以下の横組用JFMが\LuaTeX-jaには同梱されている:
3460 %</ja>
3461 \begin{description}
3462 %<*en>
3463 \item[\tt jfm-ujis.lua] A standard horizontal JFM in \LuaTeX-ja. This JFM is
3464   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
3465   is used in \upTeX. When you use the \Pkg{luatexja-otf} package, you should use this JFM.
3466 %</en>
3467 %<*ja>
3468 \item[\tt jfm-ujis.lua] \LuaTeX-jaの標準JFMである.このJFMは\upTeX で
3469   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
3470   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
3471 %</ja>
3472 %<*en>
3473 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, ``JIS font
3474   metric'' which is widely used in \pTeX. A major difference between
3475   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
3476   most characters under \texttt{jfm-ujis.lua} are square-shaped,
3477   while that under \texttt{jfm-jis.lua} are horizontal
3478   rectangles.
3479 %</en>
3480 %<*ja>
3481 \item[\tt jfm-jis.lua] \pTeX で広く用いられている「JISフォントメトリック」
3482   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua} とこの
3483   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
3484   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状であることと,
3485   \texttt{jfm-ujis.lua} では「?」「!」の直後に半角空白が挿入されることである.
3486 %</ja>
3487 %<*en>
3488 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
3489   of the default Japanese font metric shipped with \pTeX.
3490 %</en>
3491 %<*ja>
3492 \item[\tt jfm-min.lua] \pTeX に同梱されているデフォルトの和文用TFM
3493 (\verb+min10.tfm+)に相当し,行末で文字が揃うようにするために「っ」など一部の文字幅が変わっ
3494            ている.\verb+min10.tfm+ については\cite{min10}が詳しい.
3495 %</ja>
3496 \end{description}
3497 %<*en>
3498 The difference among these three~JFMs is  shown in \autoref{tab-difjfm}.
3499 %</en>
3500 %<*ja>
3501 これら3つのJFMの違いは\autoref{tab-difjfm}に示した.表中の文例の一部には,
3502 \cite{min10}の図3,~4のものを用いた.
3503 %</ja>
3504
3505 \begin{figure}
3506 \begin{LTXexample}[width=0.3\textwidth]
3507 \ltjsetparameter{differentjfm=both}
3508 \jfont\F=file:KozMinPr6N-Regular.otf:jfm=ujis
3509 \jfont\G=file:KozGoPr6N-Medium.otf:jfm=ujis
3510 \jfont\H=file:KozGoPr6N-Medium.otf:jfm=ujis;jfmvar=hoge
3511 \F ){\G 【】}( % halfwidth space
3512    ){\H 『』}( % fullwidth space
3513
3514 ほげ,{\G 「ほげ」}(ほげ)\par
3515 ほげ,{\H 「ほげ」}(ほげ)% pTeX-like
3516
3517 \ltjsetparameter{differentjfm=paverage}
3518 \end{LTXexample}
3519 \caption{Example of \texttt{jfmvar} key}
3520 \label{fig:jfmvar}
3521 \end{figure}
3522
3523 %<*en>
3524 \item[jfmvar=<string>]
3525 Sometimes there is a need that \ldots.
3526 %</en>
3527 %<*ja>
3528 \item[jfmvar=<string>]
3529 標準では,JFMとサイズが同じで,
3530   実フォントだけが異なる2つの和文フォントは「区別されない」.例えば
3531 \autoref{fig:jfmvar}において,最初の「)」と「【」の実フォントは異なるが,
3532 JFMもサイズも同じなので,普通に「)【」と入力した時と同じように半角空きとなる.
3533
3534 しかし,JFMとサイズが同じであっても,\texttt{jfmvar} キーの異なる
3535 2つの和文フォント,例えば\autoref{fig:jfmvar}で言う \cs{F} と \cs{H},
3536 は「区別される」.異なる和文フォントに異なる \texttt{jfmvar} キーを割り当て,
3537 かつ\Param{differentjfm}パラメータを \texttt{both} に設定すれば,
3538 \pTeX と似た状況で組版されることになる.
3539 %</ja>
3540 \end{cslist}
3541
3542 \begin{figure}
3543 \begin{LTXexample}[pos=t]
3544 \newcommand\test{\vrule ダイナミックダイクマ\vrule\\}
3545 \jfont\KMFW = KozMinPr6N-Regular:jfm=prop;-kern at 17pt
3546 \jfont\KMFK = KozMinPr6N-Regular:jfm=prop at 17pt % kern is activated
3547 \jfont\KMPW = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;-kern at 17pt
3548 \jfont\KMPK = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;+kern at 17pt
3549 \begin{multicols}{2}
3550 \ltjsetparameter{kanjiskip=0pt}
3551 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3552
3553 \ltjsetparameter{kanjiskip=3pt}
3554 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3555 \end{multicols}
3556 \end{LTXexample}
3557 \caption{Kerning information and \Param{kanjiskip}}
3558 \label{fig:kern-jfm}
3559 \end{figure}
3560
3561 %<en>\paragraph{Using kerning information in a font}
3562 %<ja>\paragraph{ペアカーニング情報の使用}
3563 \label{para-kern}
3564 %<*en>
3565 Some fonts have information for inter-glyph spacing.
3566 \LuaTeX-ja 20140324.0 or later treats kerning spaces like an italic correction;
3567 any glue and/or kern from the JFM and a kerning space can coexist.
3568 See \autoref{fig:kern-jfm} for detail.
3569
3570 Note that in \cs{setmainjfont} etc.\ which are provided by \Pkg{luatexja-fontspec}
3571 package, kerning option is set \emph{off} (\texttt{Kerning=Off}) by default,
3572 because of the compatibility with previous versions of \LuaTeX-ja.
3573 %</en>
3574 %<*ja>
3575 いくつかのフォントはグリフ間のスペースについての情報を持っている.
3576 このカーニング情報は以前の\LuaTeX-ja とはあまり相性が良くなかったが,
3577 バージョン20140324.0以降ではカーニングによる空白はイタリック補正と同様に扱うことになっている.
3578 つまり,カーニング由来の空白とJFM由来のグルー・カーンは同時に入りうる.
3579 \autoref{fig:kern-jfm}を参照.
3580 \begin{itemize}
3581  \item \emph{\cs{jfont} や,
3582 NFSS2用の命令(\ref{ssec:chgfnt}節,\ref{ssec:nfsspat}節)における指定では
3583 カーニング情報は標準で使用する}ことになっているようである.
3584 言い換えれば,カーニング情報を使用しない設定にするには,面倒でも
3585 \begin{lstlisting}
3586 \jfont\hoge=KozMinPr6N-Regular:jfm=ujis;-kern at 3.5mm
3587 \DeclareFontShape{JY3}{fuga}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern}{}
3588 \end{lstlisting}
3589 のように,\texttt{-kern} という指定を自分で追加しなければいけない.
3590  \item
3591 一方,\emph{\Pkg{luatexja-fontspec} の提供する \cs{setmainjfont}\
3592 などの命令の標準設定ではカーニング情報は使用しない}(\texttt{Kerning=Off})
3593 ことになっている.これは以前のバージョンの\LuaTeX-jaとの互換性のためである.
3594 \end{itemize}
3595 %</ja>
3596
3597 %<*ja>
3598 \paragraph{\texttt{extend}と\texttt{slant}}
3599 OpenType font featureと見かけ上同じような形式で指定できるものに,
3600 \begin{description}
3601 \item[\texttt{extend=}<extend>] 横方向に<extend>倍拡大する.
3602 \item[\texttt{slant=}<slant>] <slant>に指定された割合だけ傾ける.
3603 \end{description}
3604 の2つがある.
3605 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
3606 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
3607 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
3608 正しくない:
3609 %</ja>
3610 %<*en>
3611 \paragraph{\texttt{extend} and \texttt{slant}}
3612 The following setting can be specified as OpenType font features:
3613 \begin{cslist}[style=standard]
3614 \item[\texttt{extend=}<extend>] expand the font horizontally by <extend>.
3615 \item[\texttt{slant=}<slant>] slant the font.
3616 \end{cslist}
3617 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
3618 settings; you have to write new JFMs on purpose.
3619 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
3620 letter-spacing and the width of italic correction are not correct:
3621 %</en>
3622 \begin{LTXexample}[width=0.3\textwidth]
3623 \jfont\E=KozMinPr6N-Regular:extend=1.5;jfm=ujis;-kern
3624 \E あいうえお
3625
3626 \jfont\S=KozMinPr6N-Regular:slant=1;jfm=ujis;-kern
3627 \S あいう\/ABC
3628 \end{LTXexample}
3629
3630 %<*ja>
3631 \paragraph{\texttt{ltjksp} 指定}
3632 \label{pg:ltjksp}
3633 \LuaTeX-ja標準では,
3634 JFM中における \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
3635 \texttt{kanjiskip\_shrink}キー(\pageref{pg:ksp_nat}ページ)の使用によって,
3636 「JFM由来のグルーの他に,\Param{kanjiskip}の自然長/伸び量/縮み量の一部が
3637 同じ場所に挿入される」という状況が起こりうる.
3638 この機能を無効化し,バージョン20150922.0以前と同じような組版を得るためには
3639 他のOpenType機能と同じように\ \texttt{-ltjksp}\ 指定を行えば良い.
3640 \begin{LTXexample}[width=16\zw]
3641 \leavevmode
3642 \ltjsetparameter{kanjiskip=0pt plus 3\zw}
3643 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
3644
3645 \jfont\G=file:KozMinPr6N-Regular.otf%
3646   :jfm=ujis;-ltjksp at 9.2487pt
3647 \G\leavevmode%
3648 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
3649 \end{LTXexample}
3650 なお,
3651 \begin{lstlisting}
3652  \jfont\G=file:KozMinPr6N-Regular.otf:jfm=ujis;-ltjksp;+ltjksp at 9.2487pt
3653 \end{lstlisting}
3654 のように \texttt{+ltjksp} 指定を行った場合は,\texttt{kanjiskip\_natural} など
3655 3キーは再び有効化される.\texttt{-ltjksp}, \texttt{+ltjksp} を複数回指定した場合は,
3656 最後に指定したものが有効となる.
3657 %</ja>
3658 %<*en>
3659 \paragraph{\texttt{ltjksp}}
3660 \label{pg:ltjksp}
3661 \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
3662 \texttt{kanjiskip\_shrink} keys (Page~\pageref{pg:ksp_nat}) makes tha
3663 \LuaTeX-ja inserts not only a glue which is specified by a JFM, and also
3664 the natural width/stretch part/shrink part of \Param{kanjiskip}.
3665
3666 This functionality is disabled by \texttt{-ltjksp} specification.
3667 \begin{LTXexample}[width=16\zw]
3668 \leavevmode
3669 \ltjsetparameter{kanjiskip=0pt plus 3\zw}
3670 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
3671
3672 \jfont\G=file:KozMinPr6N-Regular.otf%
3673   :jfm=ujis;-ltjksp at 9.2487pt
3674 \G\leavevmode%
3675 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
3676 \end{LTXexample}
3677 %</en>
3678
3679
3680
3681
3682 %<en>\subsection{\cs{tfont}}
3683 %<ja>\subsection{\cs{tfont} 命令}
3684
3685
3686 \begin{comment}
3687   {\catcode`\<=12\catcode`\>=12
3688 \begin{table}[t]
3689 %<en>\caption{Differences between vertical JFMs shipped with \LuaTeX-ja}
3690 %<ja>\caption{\LuaTeX-ja に同梱されている縦組用 JFM の違い}
3691 %<en>\medskip
3692 \label{tab-difjfm-tate}
3693 \ltjsetparameter{jacharrange={+3}}
3694 \small
3695 \def\r#1#2{%
3696   \hbox{\tate\Large\vrule
3697   \parbox{7\zw}{%
3698     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3699     ◆◆◆◆◆◆◆
3700     ある日モモちゃんが「お使い」で迷子になって泣きました。
3701   }\vrule}}
3702 \def\s#1#2{%
3703   \hbox{\tate\Large
3704   \parbox{7\zw}{%
3705     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3706     ちょっと!何
3707   }}}
3708 \def\t#1#2#3{\hbox to 0pt{\hss%
3709   \setbox0=\hbox{\addjfontfeatures{TateFeatures={JFM=#1}}\huge #3}%
3710   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3711   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3712   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3713   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3714   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3715
3716 \begin{minipage}{.7\textwidth}
3717 \centering
3718 \leavevmode\hbox to 0pt{\r{ujisv}{blue}\hss}\r{tmin}{red}\quad
3719 \leavevmode\hbox to 0pt{\s{ujisv}{blue}\hss}\s{tmin}{red}\quad
3720 \raise4\zw\hbox{\tate\Large\t{ujisv}{black}{漢}\t{tmin}{red}{漢}\qquad
3721            \t{ujisv}{black}{っ}\t{tmin}{red}{っ}}
3722 \end{minipage}%
3723 \begin{minipage}{.3\textwidth}
3724 \textcolor{blue}{Blue: \texttt{jfm-ujisv.lua}}\\
3725 \textcolor{red}{Red: \texttt{jfm-tmin.lua}}
3726 \end{minipage}
3727 \ltjsetparameter{jacharrange={-3}}
3728 \end{table}
3729 }
3730 \end{comment}
3731
3732 %<*en>
3733 \cs{tfont} loads a font as a Japanese font for vertical direction.
3734 This command admits the same syntax used in \cs{font}~and~\cs{jfont}.
3735 A font defined by~\cs{tfont} differs the following points from that by~\cs{jfont}:
3736 \begin{itemize}
3737  \item OpenType Feature~\texttt{vrt2}%
3738   \footnote{If the font does not define \texttt{vrt2} feature,
3739         use \texttt{vert} instead.} is automatically activated,
3740   unless \texttt{vert}~and//or~\texttt{vrt2} are explicitly activated
3741   or deactivated (as the second line in the example below).
3742 \begin{lstlisting}
3743 \tfont\S=file:KozMinPr6N-Regular.otf:jfm=ujisv % vrt2 is automatically activated
3744 \tfont\T=file:KozMinPr6N-Regular.otf:jfm=ujisv;-vert % vert and vrt2 are not activated
3745 \tfont\U=file:ipaexm.ttf:jfm=ujisv
3746     % vert is automatically activated, since this font does not have vrt2
3747 \end{lstlisting}
3748  \item Sometimes \texttt{vert} and/or \texttt{vrt2} are not activated
3749  while one specified activation of these feature.
3750  This is because the font does not define these features in current combination of
3751  script~tag and language~system~identifier.
3752
3753  In this situation, \LuaTeX-ja performs all replacements which is defined in~\texttt{vert}
3754  feature for \emph{some} scripts for \emph{some} languages.
3755  \item Furthermore, a glyph is automatically rotated 90~degrees,
3756   if it is not replaced by \texttt{vert} feature for \emph{any} script
3757   for \emph{any} language, and if it is marked as `r''~or~``Tr'' in UAX~\#50.
3758  \item One have to specify the name of vertical JFM in  \texttt{jfm=<name>}.
3759 \LuaTeX-ja ships following vertical JFMs:
3760 \begin{description}
3761 \item[\tt jfm-ujisv.lua] A standard vertical JFM in \LuaTeX-ja. This JFM is
3762   based on \verb+upnmlminr-v.tfm+, a metric for UTF/OTF package that
3763   is used in \upTeX.
3764 \item[\tt jfm-tmin.lua] A counterpart for \verb+tmin10.tfm+, which is one
3765   of the default Japanese font metric shipped with \pTeX.
3766 \end{description}
3767 \end{itemize}
3768 %</en>
3769 %<*ja>
3770 \cs{tfont} はフォントを縦組用の和文フォントとして読み込む命令であり,
3771 \cs{tfont} の文法は \cs{jfont} と同じである.
3772 \cs{tfont} で定義された縦組用和文フォントは,
3773 以下の点が \cs{jfont} による横組用和文フォントとは異なる:
3774 \begin{itemize}
3775  \item 明示的に \texttt{vert}, \texttt{vrt2}(のいずれか)の
3776   有効・無効を指定した場合を除き,自動的に OpenType feature~\texttt{vrt2} の有効化が
3777   指定されたものとみなされる
3778  \footnote{もしフォントが\texttt{vrt2}を定義していなかった場合,代わりに
3779  \texttt{vert}を用いる.}.
3780 \begin{lstlisting}
3781 \tfont\S=file:KozMinPr6N-Regular.otf:jfm=ujisv % vrt2 is automatically activated
3782 \tfont\T=file:KozMinPr6N-Regular.otf:jfm=ujisv;-vert % vert and vrt2 are not activated
3783 \tfont\U=file:ipaexm.ttf:jfm=ujisv
3784     % vert is automatically activated, since this font does not have vrt2
3785 \end{lstlisting}
3786  \item \texttt{vert}, \texttt{vrt2} の少なくとも一つの有効を指定した場合にも関わらず,
3787   script tagとlanguage system identifierの値の組み合わせによって
3788   実際には有効にならなかった場合,\LuaTeX-jaは
3789  \begin{quote}
3790    どれかのscript,~languageで定義されている\texttt{vert}による
3791    (単一グリフから単一グリフへの)置換を全部適用する
3792  \end{quote}
3793   という挙動を取る\footnote{%
3794   例えば,Windows~7に付属しているSimHeiでは,\texttt{vert}はScriptが\texttt{hani},
3795   Languageが\texttt{CHN}という状況でのみ定義されている.しかし,\Pkg{luaotfload}では
3796   このscript,~languageの組み合わせを指定することはできないので,
3797   \Pkg{luaotfload}そのままでは\texttt{vert}を適用させることはできない.
3798  }.
3799  \item さらに,「いかなるscript,~languageでも\texttt{vert}により置換されない」グリフ
3800   のうち,UAX~\#50で``r''もしくは``Tr''と指定されているものは90度自動回転させる.
3801  \item \ref{ssec:math}節で述べる,数式中の和文フォントには縦組用和文フォントは指定できない.
3802  \item \texttt{jfm=<name>}\ の部分には縦組用JFMを指定する.
3803 以下の縦組用JFMが\LuaTeX-jaには同梱されている.%おり,違いを\autoref{tab-difjfm-tate}に示した.
3804 \begin{description}
3805 \item[\tt jfm-ujisv.lua] \LuaTeX-jaの標準縦組用JFMである.このJFMは\upTeX で
3806   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-v.tfm+ を
3807   元にしている.
3808 \item[\tt jfm-tmin.lua] \pTeX に同梱されているデフォルトの和文用縦組TFM
3809   である \verb+tmin10.tfm+ に相当し,\texttt{min10.tfm} と同様に
3810   「っ」など一部の文字幅が狭められている.
3811 \end{description}
3812 \end{itemize}
3813
3814 なお,\pTeX では,\cs{font},~\cs{jfont},~\cs{tfont}のどれでも欧文フォント・横組用和文フォン
3815 ト・縦組用和文フォントの定義が可能であったが,\LuaTeX-jaではそうでないので注意.
3816 %</ja>
3817
3818 %<en>\subsection{Prefix \texttt{psft}}
3819 %<ja>\subsection{\texttt{psft}プリフィックス}
3820 \label{ssec:psft}
3821 %<*en>
3822 Besides ``\texttt{file:}''\ and ``\texttt{name:}''\ prefixes which
3823 are introduced in the \Pkg{luaotfload} package,
3824 \LuaTeX-ja adds ``\texttt{psft:}''\ prefix in \cs{jfont} (and~\cs{font}),
3825 to specify a ``name-only'' Japanese font which
3826 will not be embedded to PDF.
3827 Note that these non-embedded fonts under current \LuaTeX\ has Identity-H encoding,
3828 and this violates the standard ISO32000-1:2008~(\cite{pdfstd}).
3829
3830 \emph{OpenType font features, such as ``{\tt +jp90}'',
3831 have no meaning in name-only fonts using ``{\tt psft:}''\ prefix,
3832 because we can't expect what fonts are actually used by the PDF reader.}
3833 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
3834 with \texttt{psft} prefix, because they are only simple linear transformations.
3835 %</en>
3836 %<*ja>
3837 \Pkg{luaotfload}で使用可能になった
3838 \texttt{file:}\ と \texttt{name:}\ のプリフィックスに加えて,
3839 \cs{jfont}(と \cs{font} プリミティブ)では
3840 \texttt{psft:}プリフィックスを用いることができる.
3841 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
3842 和文フォントを指定することができる.
3843 なお,現行の\LuaTeX で非埋め込みフォントを作成するとPDF内でのエンコーディングが
3844 Identity-Hとなり,PDFの標準規格ISO32000-1:2008~(\cite{pdfstd})に非準拠になってしまう
3845 ので注意してほしい.
3846
3847 \emph{\texttt{psft} プリフィックスの下では
3848 \texttt{+jp90} などのOpenType font featureの効力はない.
3849 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
3850 表示に用いられるか予測できないからである.}\
3851 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
3852 \texttt{psft} プリフィックスでも使用可能である.
3853 %</ja>
3854
3855 %<en>\paragraph{\texttt{cid} key}
3856 %<ja>\paragraph{\texttt{cid}キー}
3857 \label{para-cid}
3858
3859 %<*en>
3860 The default font defined by using \texttt{psft:} prefix is for Japanese typesetting;
3861 it is Adobe-Japan1-6 CID-keyed font.
3862 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
3863 for Chinese or Korean typesetting.
3864 %</en>
3865 %<*ja>
3866 標準で\texttt{psft:}プリフィックスで定義されるフォントは日本語用のもので
3867 あり,Adobe-Japan1-6のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
3868 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
3869 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
3870
3871 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
3872 %</ja>
3873 \begin{lstlisting}[numbers=left]
3874 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-6;jfm=jis}     % Japanese
3875 \jfont\testD={psft:Ryumin-Light:jfm=jis}                        % default value is Adobe-Japan1-6
3876 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-6;jfm=jis} % Traditional Chinese
3877 \jfont\testG={psft:SimSun:cid=Adobe-GB1-5;jfm=jis}              % Simplified Chinese
3878 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}           % Korean
3879 \end{lstlisting}
3880 %<*en>
3881 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
3882 as JFM for Chinese and Korean fonts.
3883 %</en>
3884 %<*ja>
3885 上のコードでは中国語・韓国語用フォントに対してもJFMに
3886 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
3887 %</ja>
3888
3889 %<*en>
3890 At present, \LuaTeX-ja supports only 4 values written in the sample code above.
3891 Specifying other values, e.g.,
3892 %</en>
3893 %<*ja>
3894 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた4つの値しかサポートしていない.
3895 %</ja>
3896 \begin{lstlisting}
3897 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
3898 \end{lstlisting}
3899 %<*en>
3900 produces the following error:
3901 %</en>
3902 %<*ja>
3903 のようにそれら以外の値を指定すると,エラーが発生する:
3904 %</ja>
3905 \begin{lstlisting}[numbers=left]
3906 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
3907
3908 See the luatexja package documentation for explanation.
3909 Type  H <return>  for immediate help.
3910 <to be read again>
3911                    \par
3912 l.78
3913
3914 ? h
3915 I couldn't find any non-embedded font information for the CID
3916 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
3917 Please contact the LuaTeX-ja project team.
3918 ?
3919 \end{lstlisting}
3920
3921 %<en>\subsection{Structure of a JFM file}
3922 %<ja>\subsection{JFMファイルの構造}
3923 \label{ssec:jfm-str}
3924 %<en>A JFM file is a Lua script which has only one function call:
3925 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
3926 \begin{lstlisting}
3927 luatexja.jfont.define_jfm { ... }
3928 \end{lstlisting}
3929 %<*en>
3930 Real data are stored in the table which indicated above by
3931 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
3932 structure of this table.  Note that all lengths in a JFM file are
3933 floating-point numbers in design-size unit.
3934 %</en>
3935 %<*ja>
3936 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
3937 以下ではこのテーブルの構造について記す.
3938 なお,JFMファイル中の長さは全てdesign-sizeを単位とする浮動小数点数であることに
3939 注意する.
3940 %</ja>
3941
3942 \begin{cslist}[style=standard]
3943
3944 \item[version=<version>]
3945 %<en>(optional, default value is~1)
3946 %<ja>(任意,既定値は1)
3947
3948 %<*en>
3949 The version JFM. Currently 1,~2,~and,~3 are supported
3950 %</en>
3951 %<*ja>
3952 JFMのバージョン.1,~2,~3がサポートされる.
3953 %</ja>
3954   
3955 \item[dir=<direction>]
3956 %<en>(required)
3957 %<ja>(必須)
3958
3959 %<*en>
3960 The direction of JFM. \texttt{'yoko'}~(horizontal)
3961 or \texttt{'tate'}~(vertical) are supported.
3962 %</en>
3963 %<*ja>
3964 JFMの書字方向.\texttt{'yoko'}(横組)と \texttt{'tate'}(縦組)がサポートされる.
3965 %</ja>
3966
3967 \item[zw=<length>]
3968 %<en>(required)
3969 %<ja>(必須)
3970
3971 %<en>The amount of the length of the ``full-width''.
3972 %<*ja>
3973 「全角幅」の長さ.この量が \cs{zw} の長さとなる.\pTeX では
3974 「全角幅」\texttt{1zw} は「文字クラス0の文字」の幅と決められていたが,
3975 \LuaTeX-jaではここで指定する.
3976 %</ja>
3977
3978 \item[zh=<length>]
3979 %<en>(required)
3980 %<ja>(必須)
3981
3982 %<en>The amount of the ``full-height'' (height + depth).
3983 %<*ja>
3984 「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
3985 \pTeX では 「全角高さ」\texttt{1zh} は「文字クラス0の文字」の高さと深さの和と決められていたが,
3986 \LuaTeX-jaではここで指定する.
3987 %</ja>
3988
3989 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}]
3990 %<en>(optional)
3991 %<ja>(任意)
3992
3993 %<*en>
3994 This field specifies the ``ideal'' amount of \Param{kanjiskip}. As noted
3995              in Subsection~\ref{subs-kskip}, if the parameter
3996              \Param{kanjiskip} is \cs{maxdimen}, the value specified
3997              in this field is actually used (if this field is not specified in
3998              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
3999              fields are in design-size unit too.
4000 %</en>
4001 %<*ja>
4002 理想的な\Param{kanjiskip}の量を指定する.\ref{subs-kskip}節で述べたように,
4003 もし\Param{kanjiskip}が \cs{maxdimen} の値ならば,このフィールドで指定された
4004 値が実際には用いられる(指定なしは0\,ptとして扱われる).<stretch>と<shrink>のフィールドもdesign-size
4005 が単位であることに注意せよ.
4006 %</ja>
4007
4008 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}]
4009 %<en>(optional)
4010 %<ja>(任意)
4011
4012 %<*en>
4013 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
4014              amount of \Param{xkanjiskip}.
4015 %</en>
4016 %<*ja>
4017 \texttt{kanjiskip}フィールドと同様に,\Param{xkanjiskip}の理想的な量を
4018 指定する.
4019 %</ja>
4020 \end{cslist}
4021
4022 %<*en>
4023 \paragraph{Character classes}
4024 Besides from above fields, a JFM file have several sub-tables those
4025 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
4026 information of \emph{character class}~$i$. At least, the character class~0 is
4027 always present, so each JFM file must have a sub-table whose index is
4028 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
4029 the following fields:
4030 %</en>
4031 %<*ja>
4032 \paragraph{文字クラス}
4033 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
4034 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
4035 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
4036 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
4037 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
4038 %</ja>
4039
4040 \begin{cslist}[style=standard]
4041 \item[chars=\{<character>, ...\}]
4042 %<en>(required except character class~0)
4043 %<ja>(文字クラス0を除いて必須)
4044
4045 %<*en>
4046 This field is a list of characters which are in this character
4047              type~$i$. This field is optional if $i=0$, since all
4048              \textbf{JAchar} which do not belong  any character classes other
4049              than 0 are in the character class 0
4050              (hence, the character class~0 contains most of
4051              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
4052 \begin{itemize}
4053 \item a Unicode code point
4054 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
4055 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
4056 \item several ``imaginary'' characters (We will describe these later.)
4057 \end{itemize}
4058 %</en>
4059 %<*ja>
4060 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
4061 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
4062 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
4063 \begin{itemize}
4064 \item Unicode におけるコード番号
4065 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
4066 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
4067 \item いくつかの「仮想的な文字」(後に説明する)
4068 \end{itemize}
4069 %</ja>
4070
4071 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]
4072 %<en>(required)
4073 %<ja>(必須)
4074
4075 %<*en>
4076 \begin{table}[t]
4077  \centering
4078 \begin{tabular}{llr}
4079 \toprule
4080 Direction of JFM&\textbf{\texttt{'yoko'} (horizontal)}&\multicolumn{1}{l}{\textbf{\texttt{'tate'} (vertical)}}\\
4081 \midrule
4082 \texttt{width} field&\multicolumn{2}{c}{the width of the ``real'' glyph}\\
4083 \texttt{height} field&the height of the ``real'' glyph&0.0\\
4084 \texttt{depth} field&the depth of the ``real'' glyph&0.0\\
4085 \midrule
4086 \texttt{italic} field&\multicolumn{2}{c}{0.0}\\
4087 \bottomrule
4088 \end{tabular}
4089 \caption{Default values of \texttt{width} field and other fields}
4090 \label{tab-wid}
4091 \end{table}
4092 Specify the width of characters in character class~$i$, the height, the depth and
4093 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
4094 as values of these fields. The default values are shown in \autoref{tab-wid}.
4095 %</en>
4096 %<*ja>
4097 \begin{table}[t]
4098  \centering
4099 \begin{tabular}{llr}
4100 \toprule
4101 JFM書字方向&\emph{\texttt{'yoko'}(横組)}&\multicolumn{1}{l}{\emph{\texttt{'tate'}(縦組)}}\\
4102 \midrule
4103 \texttt{width}&\multicolumn{2}{c}{「実際のグリフ」の幅}\\
4104 \texttt{height}&「実際のグリフ」の高さ&0.0\\
4105 \texttt{depth}&「実際のグリフ」の深さ&0.0\\
4106 \midrule
4107 \texttt{italic}&\multicolumn{2}{c}{0.0}\\
4108 \bottomrule
4109 \end{tabular}
4110 \caption{\texttt{width} フィールド等の標準値}
4111 \label{tab-wid}
4112 \end{table}
4113 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
4114 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
4115 値であるものとして扱われる.省略時や,数でない値を指定した時には表\nobreak\ref{tab-wid}に
4116              示されている値を用いる.例えば,横組用JFMで \texttt{width} フィールドには数値以外の値を指
4117              定した場合,文字の幅はその「実際の」グリフの幅となる.OpenTypeの \texttt{prop} featureと併用
4118              すれば,これによってプロポーショナル組を行うことができる.
4119 %</ja>
4120
4121 \item[left=<length>, down=<length>, align=<align>]\
4122
4123 %<*en>
4124 These fields are for adjusting the position of the ``real'' glyph. Legal
4125              values of \texttt{align} field are \texttt{'left'},
4126              \texttt{'middle'}, and \texttt{'right'}. If one of these
4127              3~fields are omitted, \texttt{left} and \texttt{down} are
4128              treated as~0, and \texttt{align} field is treated as
4129              \texttt{'left'}.
4130 The effects of these 3~fields are indicated in
4131 \autoref{fig:pos}~and~\autoref{fig:pos-tate}.
4132 %</en>
4133 %<*ja>
4134 これらのフィールドは実際のグリフの位置を調整するためにある.
4135 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
4136 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
4137 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
4138 \ \texttt{'left'} であるものとして扱われる.
4139 これら3つのフィールドの意味については\autoref{fig:pos}(横組用和文フォント),
4140 \autoref{fig:pos-tate}(縦組用和文フォント)で説明する.
4141 %</ja>
4142
4143 %<*en>
4144 In most cases, \texttt{left} and \texttt{down} fields are~0, while
4145 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
4146 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
4147 when the current character class is the class for opening delimiters'.
4148 %</en>
4149 %<*ja>
4150 多くの場合,\texttt{left}と\texttt{down}は0である一方,
4151 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
4152 珍しいことではない.
4153 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
4154 文字クラスが開き括弧類であるときに実際必要である.
4155 %</ja>
4156
4157 \begin{figure}[!tb]
4158 \begin{minipage}{0.4\textwidth}%
4159 \begin{center}\unitlength=10pt\small
4160 \begin{picture}(15,12)(-1,-4)
4161 \color{b_gray}% jfm
4162 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
4163
4164 \color{b_pink}% step1
4165 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4166
4167 \color{red}% real glyph
4168 \thicklines
4169 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4170 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
4171 \put(-1,5.5){\line(1,0){6}}
4172 \put(-1,-4){\line(1,0){6}}
4173
4174 \color{b_green}% real glyph
4175 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4176
4177 \color{black}% jfm
4178 \thicklines
4179 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
4180 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
4181 \put(0,8){\line(1,0){12}}
4182 \put(0,-3){\line(1,0){12}}
4183 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
4184 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
4185 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
4186
4187 \color{green}% step1
4188 \thicklines
4189 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4190 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
4191 \put(3,7){\line(1,0){6}}
4192 \put(3,-2.5){\line(1,0){6}}
4193 \newsavebox{\eqdist}
4194 \savebox{\eqdist}(0,0)[b]{%
4195   \thinlines
4196   \put(-0.08,0.2){\line(0,-1){0.4}}%
4197   \put(0.08,0.2){\line(0,-1){0.4}}}
4198 \put(1.5,0){\usebox{\eqdist}}
4199 \put(10.5,0){\usebox{\eqdist}}
4200
4201 \color{blue}% shifted
4202 \thicklines
4203 \put(3,-1.5){\vector(-1,0){4}}
4204 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
4205 \put(3,0){\vector(0,-1){1.5}}
4206 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
4207 \end{picture}
4208 \end{center}
4209 \end{minipage}%
4210 \begin{minipage}{0.6\textwidth}%
4211 %<*en>
4212 Consider a  Japanese character node which belongs to
4213 a character class whose the \texttt{align}
4214 field is \texttt{'middle'}.
4215 %</en>
4216 %<*ja>
4217 \texttt{align}フィールドの値が \texttt{'middle'} であるような文字クラスに属する
4218 和文文字ノードを考えよう.
4219 %</ja>
4220 \begin{itemize}
4221 \item
4222 %<*en>
4223 The black rectangle is the imaginary body of the node.
4224 Its width, height, and depth are specified by JFM.
4225 %</en>
4226 %<*ja>
4227 黒色の長方形はノードの枠であり,
4228 その幅,高さ,深さはJFMによって指定されている.
4229 %</ja>
4230 \item
4231 %<*en>
4232 Since the \texttt{align} field is \texttt{'middle'},
4233 the ``real'' glyph is centered horizontally (the green rectangle) first.
4234 %</en>
4235 %<*ja>
4236 \texttt{align}フィールドは \texttt{'middle'} なので,
4237 実際のグリフの位置はまず水平方向に中央揃えしたものとなる(緑色の長方形).
4238 %</ja>
4239 \item
4240 %<*en>
4241 Furthermore, the glyph is shifted according to values of fields
4242       \texttt{left} and \texttt{down}. The ultimate position of the real
4243       glyph is indicated by the red rectangle.
4244 %</en>
4245 %<*ja>
4246 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
4247 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
4248 %</ja>
4249 \end{itemize}
4250 \end{minipage}
4251 \medskip
4252
4253 \caption{%
4254 %<en>The position of the real glyph (horizontal Japanese fonts)
4255 %<ja>横組和文フォントにおける「実際の」グリフの位置
4256 }
4257 \label{fig:pos}
4258 \end{figure}
4259 \begin{figure}[!tb]
4260 \begin{minipage}{0.4\textwidth}%
4261 \begin{center}\unitlength=10pt\small
4262 \begin{picture}(15,12)(-6,0)
4263 \color{b_gray}% jfm
4264 \put(-6,0){\vrule width 12\unitlength height 11\unitlength}
4265
4266 \color{b_pink}% real glyph
4267 \put(-6.5,5.5){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4268
4269 \color{red}% real glyph
4270 \thicklines
4271 \put(-6.5,5.5){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4272 \put( 1.5,5.5){\line(0,1){6}\line(0,-1){3}}
4273 \put(-6.5,11.5){\line(1,0){8}}
4274 \put(-6.5,2.5){\line(1,0){8}}
4275
4276 \color{b_green}% step1
4277 \put(-4,3){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4278
4279 \color{black}% jfm
4280 \thicklines
4281 \put(0,11){\vector(1,0){6}\vector(-1,0){6}\vector(0,-1){11}}
4282 \put(0,0){\line(1,0){6}\line(-1,0){6}}
4283 \put(-6,0){\line(0,1){11}}
4284 \put( 6,0){\line(0,1){11}}
4285 \put( 3,10.8){\makebox(0,0)[t]{\texttt{height}}}
4286 \put(-3,10.8){\makebox(0,0)[t]{\texttt{depth}}}
4287 \put(0.2,5.5){\makebox(0,0)[l]{\texttt{width}}}
4288
4289 \color{green}% step1
4290 \thicklines
4291 \put(-4,3){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4292 \put( 4,3){\line(0,1){6}\line(0,-1){3}}
4293 \put(-4,9){\line(1,0){8}}
4294 \put(-4,0){\line(1,0){8}}
4295 \savebox{\eqdist}(0,0)[b]{%
4296   \thinlines
4297   \put(-0.08,0.2){\line(0,-1){0.4}}%
4298   \put(0.08,0.2){\line(0,-1){0.4}}}
4299 \put(2,9){\usebox{\eqdist}}
4300 \put(-2,9){\usebox{\eqdist}}
4301
4302
4303 \color{blue}% shifted
4304 \thicklines
4305 \put(-4,3){\vector(0,1){2.5}}
4306 \put(-3.8,4.25){\makebox(0,0)[l]{\texttt{left}}}
4307 \put(-4,5.5){\vector(-1,0){2.5}}
4308 \put(-5.,5.7){\makebox(0,0)[b]{\texttt{down}}}
4309 \end{picture}
4310 \end{center}
4311 \end{minipage}%
4312 \begin{minipage}{0.6\textwidth}%
4313 %<*en>
4314 (\dots)
4315 %</en>
4316 %<*ja>
4317 \texttt{align}フィールドの値が \texttt{'right'} であるような文字クラスに属する
4318 和文文字を考えよう.
4319 \begin{itemize}
4320 \item
4321 実際のグリフの「垂直位置」は,まずベースラインが文字の物理的な左右方向の中央を通る
4322 位置となる.
4323 \item
4324 また,この場合 \texttt{align} フィールドは \texttt{'right'} なので,
4325 「水平位置」は字送り方向に「右寄せ」したものとなる(緑色の長方形).
4326 \item
4327 その後さらに \texttt{left} と \texttt{down} の値に従ってシフトされる
4328 のは横組用和文フォントと変わらない.
4329 \end{itemize}
4330 %</ja>
4331 \end{minipage}
4332 \medskip
4333
4334 \caption{%
4335 %<en>The position of the real glyph (vertical Japanese fonts)
4336 %<ja>縦組和文フォントにおける「実際の」グリフの位置
4337 }
4338 \label{fig:pos-tate}
4339 \end{figure}
4340
4341 \item[kern={\{[$j$]=<kern>, [$j'$]=\{<kern>, [ratio=<ratio>]\}, ...\}}]
4342 \nopagebreak
4343 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>, [ratio=<ratio>, ...]\}, ...\}}]\leavevmode
4344 %<*ja>
4345
4346 文字クラス$i$の文字と$j$の文字の間に挿入されるカーンやグルーの量を指定する.
4347
4348 <ratio>は,グルーの自然長のうちどれだけの割合が「後の文字」由来かを示す量で,
4349 $0$から$+1$の実数値をとる.省略時の値は$0.5$である.
4350 このフィールドの値は\Param{differentjfm}の値が
4351 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
4352
4353 例えば,\cite{x4051}では,句点と中点の間には,
4354 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
4355 \begin{itemize}
4356 \item <width>には$0.5+0.25=0.75$を指定する.
4357 \item <ratio>には$0.25/(0.5+0.25)=1/3$を指定する.
4358 \end{itemize}
4359 %</ja>
4360 %<*en>
4361 \
4362
4363 Specifies the amount of kern or glue which will be inserted
4364 between characters in character class~$i$ and those in character class~$j$.
4365
4366 <ratio> specifies how much the glue is originated in the ``right'' character.
4367 It is a real number between 0 and 1, and treated as 0.5 if omitted. For example,
4368 The width of a glue between an ideographic full stop ``。''
4369 and a fullwidth middle dot ``・'' is three-fourth of fullwidth,
4370 namely halfwidth from the ideographic full stop, and
4371 quarter-width from the fullwidth middle dot.  In this case,
4372 we specify <ratio> to $0.25/(0.5+0.25)=1/3$.
4373 %</en>
4374
4375 %<*ja>
4376 グルーの指定においては,上記に加えて各 \texttt{[$j$]} の各サブテーブル内に
4377 次のキーを指定できる,
4378 \begin{cslist}[style=standard]
4379 \item[priority=<priority>]
4380              \Pkg{luatexja-adjust}による優先順位付き
4381              行長調整(\ref{ssec:adj}節)において,このグルーの優先度を指定する.許される値は以下の通り:
4382   \begin{description}
4383     \item[バージョン1] $-4$から$+3$の間の整数
4384     \item[バージョン2以降] $-4$から$+3$の間の整数の2つ組\texttt{\{<stretch>, <shrink>\}}か,
4385     または$-4$から$+3$の間の整数.<stretch>, <shrink>はそれぞれこのグルーが伸びるときの優先度,縮むときの
4386     優先度であり,単に整数$i$が指定された場合は\texttt{\{$i$, $i$\}}であると解釈される.
4387   \end{description}
4388   ここで指定する値は,大きい値ほど「先に伸ばされる」「先に縮ませる」ことを意味しており,省略時の値
4389              は0である.範囲外の値が指定されたときの動作は未定義である.
4390 \item[kanjiskip\_natural=<num>\textrm{, }%
4391   kanjiskip\_stretch=<num>\textrm{, }kanjiskip\_shrink=<num>]\leavevmode
4392   \label{pg:ksp_nat}
4393
4394 JFMによって本来挿入されるグルーの他に
4395 \Param{kanjiskip}分の空白を自然長(\texttt{kanjiskip\_natural}),伸び量(\texttt{kanjiskip\_stretch}),
4396 縮み量(\texttt{kanjiskip\_shrink})ごとに挿入する\footnote{本来\Param{xkanjiskip}が挿入される場所においては
4397              \Param{xkanjiskip}分の空白を自然長・伸び量・縮み量ごとに.追加できる.}%
4398 ための指定である.いずれも省略された場合のデフォルト値は0(追加しない)である.
4399
4400 例えば,\LuaTeX-jaの横組標準JFMの \texttt{jfm-ujis.lua} では,
4401 \begin{itemize}
4402  \item 通常の文字「あ」と開き括弧類の間に入るグルーは,自然長・縮み量半角,伸び量0のグルー
4403 となっているが,さらに\Param{kanjiskip}の伸び量に \texttt{kanjiskip\_stretch}(ここでは1)を掛け
4404        た分だけ伸びることが許される.
4405  \item 同様に,閉じ括弧類(全角コンマ「,」も含む)と通常の文字「う」「え」の間にも
4406 自然長・縮み量半角,伸び量0のグルー
4407 となっているが,さらに\Param{kanjiskip}の伸び量に \texttt{kanjiskip\_stretch}(ここでは1)を掛け
4408        た分だけ伸びることが許される.
4409  \item 一方,開き括弧類と通常の文字の間,また通常の文字と閉じ括弧類の間は
4410   自然長・縮み量・伸び量0のグルーだが,\Param{kanjiskip}の縮み量に
4411   \texttt{kanjiskip\_shrink}(ここでは1)を掛けた分だけ縮むことが許される.
4412 \end{itemize}
4413 となっている.従って,以下のような組版結果を得る.
4414
4415 \medskip
4416 \begin{LTXexample}[width=16\zw]
4417 \leavevmode
4418 \ltjsetparameter{kanjiskip=0pt plus 3\zw}
4419 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
4420
4421 \vrule\hbox{あ「い」う,えお}\vrule\par
4422 \ltjsetparameter{kanjiskip=0pt minus \zw}
4423 \vrule\hbox to 6.5\zw{あ「い」う,えお}\vrule
4424 \end{LTXexample}
4425
4426 \end{cslist}
4427 %</ja>
4428 %<*en>
4429 In case of glue, one can specify following additional keys in each \texttt{[$j$]}
4430              subtable:
4431 \begin{cslist}[style=standard]
4432 \item[priority=<priority>]
4433 An integer in $[-4,3]$ (treated as 0 if omitted), or
4434 a pair of these integers \texttt{\{<stretch>, <shrink>\}} (version 2~or~later).
4435 This is
4436 used only in line adjustment with priority by \Pkg{luatexja-adjust}
4437 (see Subsection~\ref{ssec:adj}). Higher value means the glue is easy to stretch,
4438 and is also easy to shrink. 
4439 \item[kanjiskip\_natural=<num>\textrm{, }%
4440   kanjiskip\_stretch=<num>\textrm{, }kanjiskip\_shrink=<num>]\leavevmode
4441
4442 These keys specifies the amount of the natural width of \Param{kanjiskip}
4443 (the stretch/shrink part, respectively) which will be inserted
4444 in addition to the original JFM glue. Default values of them are all 0.
4445
4446 As an example, in \texttt{jfm-ujis.lua}, the standard JFM in horizontal writing, we have
4447 \begin{itemize}
4448  \item Between an ordinal letter ``あ'' and an ideographic opening bracket, we have
4449 a glue whose natural part and shrink part are both half-width, while its stretch part is
4450        zero. However, this glue also can be stretched
4451        as much as the stretch part of \Param{kanjiskip} times the value of
4452        \texttt{kanjiskip\_stretch} key (1 in this case).
4453  \item Between an ideographic closeing brackets (the ideographic comma ``,''
4454        is included) and an ordinal letter, we have the same glue.
4455        Again, this glue also can be stretched
4456        as much as the stretch part of \Param{kanjiskip} times the value of
4457        \texttt{kanjiskip\_stretch} key (1 in this case).
4458  \item Between an ideographic opening bracket and an ordinal letter
4459   and between an ordinal letter and an ideographic closing bracket,
4460   we have a glue whose natural part and stretch part are both zero, while its shrink part as much as
4461   the shrink part of \Param{kanjiskip}.
4462 \end{itemize}
4463 Hence we have the following result:
4464
4465 \medskip
4466 \begin{LTXexample}[width=16\zw]
4467 \leavevmode
4468 \ltjsetparameter{kanjiskip=0pt plus 3\zw}
4469 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
4470
4471 \vrule\hbox{あ「い」う,えお}\vrule\par
4472 \ltjsetparameter{kanjiskip=0pt minus \zw}
4473 \vrule\hbox to 6.5\zw{あ「い」う,えお}\vrule
4474 \end{LTXexample}
4475
4476 \end{cslist}
4477 %</en>
4478   
4479 \item[end\_stretch=<kern>, end\_shrink=<kern>]
4480 %<*ja>
4481 (任意,バージョン1のみ)
4482
4483 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
4484              末に来た時に,行長を詰める調整・伸ばす調整のた
4485              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
4486 %</ja>
4487 %<*en>
4488 (optional, version~1 only)
4489 %</en>
4490
4491   \item[end\_adjust=\{<kern>, <kern>, ...\}]
4492 %<*ja>
4493 (任意,バージョン2以降)
4494
4495 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が
4496   行末に来た時に,この文字と行末の間には指定された値のいずれかの大きさのカーンが
4497   挿入される(\autoref{ssec:adj}参照).
4498
4499 バージョン1における
4500 \begin{lstlisting}[escapechar=\$]
4501     end_stretch = $a$, end_shrink = $b$
4502 \end{lstlisting}
4503 という指定は,バージョン2以降では次の指定と同じになる.
4504 \begin{lstlisting}[escapechar=\$]
4505     end_adjust = {$-b$, 0.0, $a$}
4506 \end{lstlisting}
4507 もし真ん中の \texttt{0.0} がない場合は,$a$か$-b$かいずれかのカーンが常に行末に追加される.
4508 %</ja>
4509 %<*en>
4510 (optional, version~2 or~later)
4511 %</en>
4512
4513 \end{cslist}
4514
4515 %<*ja>
4516 \paragraph{文字クラスの決定}
4517 文字からその文字の属する文字クラスを算出する過程について,
4518 次の内容を含んだ \texttt{jfm-test.lua} を用いて説明する.
4519 %</ja>
4520 %<*en>
4521 \paragraph{Character to character classes}
4522 We explain how the character class of a character is determined,
4523 using  \texttt{jfm-test.lua} which contains the following:
4524 %</en>
4525 \begin{lstlisting}
4526    [0] = {
4527       chars = { '漢' },
4528       align = 'left', left = 0.0, down = 0.0,
4529       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
4530    },
4531    [2000] = {
4532       chars = { '。', 'ヒ' },
4533       align = 'left', left = 0.0, down = 0.0,
4534       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
4535    },
4536 \end{lstlisting}
4537 %<ja>ここで,次のような入力とその実行結果を考える:
4538 %<en>Now consider the following input/output:
4539 \begin{LTXexample}[width=0.3\textwidth]
4540 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+hwid
4541 \setbox0\hbox{\a ヒ漢}
4542 \the\wd0
4543 \end{LTXexample}
4544 %<*en>
4545 Now we look why the above source outputs 15\,pt.
4546 \begin{enumerate}
4547 \item The character ``ヒ'' is converted to its half width  form ``ヒ'' by \verb+hwid+ feature.
4548 \item According to the JFM, the character class of ``ヒ'' is 2000, hence its width is halfwidth.
4549 \item The character class of ``漢'' is zero,  hence its width is fullwidth.
4550 \item Hence the width of \cs{hbox} equals to 15\,pt.
4551 \end{enumerate}
4552 This example shows that the character class of a character is generally determined \emph{after
4553 applying font features by \Pkg{luaotfload}}.
4554 %</en>
4555 %<*ja>
4556 上記の出力結果が,15\,ptとなっているのは理由によるものである:
4557 \begin{enumerate}
4558 \item \verb+hwid+ featureによって「ヒ」が半角幅のグリフ「ヒ」と置き換わる(\Pkg{luaotfload} による処理).
4559 \item JFMによれば,この「ヒ」のグリフの文字クラスは2000である.
4560 \item 以上により文字クラス2000とみなされるため,結果として「ヒ」の幅は半角だと認識される.
4561 \end{enumerate}
4562 この例は,\emph{文字クラスの決定はfont featureの適用によるグリフ置換の結果に基づく}ことを
4563 示している.
4564 %</ja>
4565
4566 %<*en>
4567 However, if the class determined by the glyph after application of features is zero,
4568 \LuaTeX-ja adopts the class determined by the glyph \emph{before} application of features.
4569 The following input is an example.
4570 %</en>
4571 %<*ja>
4572 但し,JFMによって決まる置換後のグリフの文字クラスが0である場合は,置換前の文字クラスを採用する.
4573 %</ja>
4574 \begin{LTXexample}[width=0.3\textwidth]
4575 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+vert
4576 \a 漢。\inhibitglue 漢
4577 \end{LTXexample}
4578 %<*en>
4579 Here, the character class of the ideographic full stop ``。''~(\texttt{U+3002}) is determined
4580 as follows:
4581 \begin{enumerate}
4582 \item As the case of ``ヒ'', the ideographic full stop ``。'' is converted to its vertical
4583       form ``\char"FE12''~(\texttt{U+FE12}) by \verb+vert+ feature.%"
4584 \item The character class of ``\char"FE12'', according to the JFM  is \emph{zero}.
4585 \item However, \LuaTeX-ja remembers that this ``\char"FE12'' is obtained from ``。'' by
4586       font features. The character class of ``。'' is \emph{non-zero value}, namely, 2000.
4587 \item Hence the ideographic full stop ``。'' in above belongs the character class~2000.
4588 \end{enumerate}
4589 %</en>
4590 %<*ja>
4591 ここで,句点「。」(\texttt{U+3002})の文字クラスは,以下のようにして決まる.
4592 \begin{enumerate}
4593 \item \Pkg{luaotfload} によって縦組用句点のグリフに置き換わる.
4594 \item 置換後のグリフは \texttt{U+FE12} であり,JFMに従えば文字クラスは\emph{0}と判定される.
4595 \item この場合,置換前の横組用句点のグリフによって文字クラスを判定する.
4596 \item 結果として,上の出力例中の句点の文字クラスは2000となる.
4597 \end{enumerate}
4598 %</ja>
4599
4600
4601 %<ja>\paragraph{仮想的な文字}
4602 %<en>\paragraph{Imaginary characters}
4603 %<*en>
4604 As described before, you can specify several \emph{imaginary characters} in
4605 \texttt{chars} field. The most of these characters are regarded as the
4606 characters of class 0 in \pTeX.
4607 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
4608 The following is the list of imaginary characters:
4609 %</en>
4610 %<*ja>
4611 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
4612 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
4613 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
4614 い組版調整ができるようになっている.以下でその一覧を述べる:
4615 %</ja>
4616
4617 \begin{cslist}
4618 %%\item['diffmet']
4619 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
4620 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
4621
4622 \item['boxbdd']
4623 %<en>The beginning/ending of a hbox, and the beginning of a noindented (i.e., began by \cs{noindent}) paragraph.
4624 %<ja>hboxの先頭と末尾,及びインデントされていない(\cs{noindent} で開始された)段落の先頭を表す.
4625
4626 \item['parbdd']
4627 %<en>The beginning of an (indented) paragraph.
4628 %<ja>通常の(\cs{noindent} で開始されていない)段落の先頭.
4629
4630 \item['jcharbdd']
4631 %<en>A boundary between \textbf{JAchar} and anything else.
4632 %<*ja>
4633 \textbf{JAchar}と「その他のもの」との境界.
4634
4635 バージョン2以前では\textbf{ALchar},箱,罫線(rule),glue,~kernなどいろいろなものと\textbf{JAchar}の境界に対して
4636 本特殊文字が用いられていたが,
4637 バージョン3以降では\ \texttt{'jcharbdd'}, \texttt{'alchar'}, \texttt{'nox\_alchar'},
4638 \texttt{'glue'} と細分化され,
4639 \texttt{'jcharbdd'} は主に\textbf{JAchar}とボックスや罫線(rule)との境界に使われるようになった.
4640 %</ja>
4641   
4642 \item['alchar', 'nox\_alchar']
4643 %<*en>
4644 (version 3~or~later) A boundary between \textbf{JAchar} and \textbf{ALchar}.
4645 %</en>
4646 %<*ja>
4647 (バージョン3以降)\textbf{JAchar}と\textbf{ALchar}との境界.
4648 \textbf{JAchar}と\textbf{ALchar}の間に\Param{xkanjiskip}が入ることが可能な場合は
4649 \ \texttt{'alchar'}\ が,そうでない場合は\ \texttt{'nox\_alchar'}\ が用いられる
4650 (この区別は\textbf{ALchar}側の\Param{alxspmode}の値によってのみ行われる).
4651 %</ja>
4652
4653 \item['glue']
4654 %<en>(version 3~or~later) A boundary between \textbf{JAchar}, and, a glue or kern.
4655 %<ja>(バージョン3以降)\textbf{JAchar}とglue,kernとの境界.
4656
4657 \item[$-1$]
4658 %<en>The left/right boundary of an inline math formula.
4659 %<ja>行中数式と地の文との境界.
4660 \end{cslist}
4661
4662 %<en>\paragraph{Porting JFM from \pTeX}
4663 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
4664
4665 % ToDo: English version.
4666
4667 %<*en>
4668 See Japanese version of this manual.
4669 %</en>
4670
4671 %<*ja>
4672 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
4673 \begin{itemize}
4674 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
4675 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
4676       トメトリック等を移植する場合は,次のようにするべきである:
4677 \begin{itemize}
4678 \item JFM中の全ての数値を$1/0.962216$倍しておく.
4679 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
4680       \LaTeX でのフォント宣言なら,例えば次のように:
4681 \begin{lstlisting}
4682 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
4683 \end{lstlisting}
4684 \end{itemize}
4685 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
4686       (JFM中に単に書かなければよい).
4687 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
4688       文字クラスに関してはグルー/カーンの設定はしない.
4689
4690 これは,\pTeX では,
4691       hboxの先頭・末尾とインデントされていない(\cs{noindent} で開始さ
4692       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
4693 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
4694
4695 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
4696       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
4697       は,段落の最初に手動で \cs{inhibitglue} を追加するか,あるいは
4698       \ \cs{everypar} のハックを行い,それを自動化させるしかなかった.
4699
4700 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
4701 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
4702 \texttt{'parbdd'}を入れれば全角下がりとなる.
4703
4704 \begin{LTXexample}[width=0.4\textwidth]
4705 \jfont\g=KozMinPr6N-Regular:jfm=test \g
4706 \parindent1\zw\noindent{}◆◆◆◆◆
4707 \par 「◆◆←二分下がり
4708 \par 【◆◆←全角下がり
4709 \par 〔◆◆←全角二分下がり
4710 \end{LTXexample}
4711 \end{itemize}
4712
4713 但し,\cs{everypar} を利用している場合にはこの仕組みは正しく動かない.
4714 そのような例としては箇条書き中の \cs{item} で始まる段落があり,\Pkg{ltjsclasses}では
4715 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
4716 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
4717 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
4718 %</ja>
4719
4720
4721 %<en>\subsection{Math font family}
4722 %<ja>\subsection{数式フォントファミリ}
4723 \label{ssec:math}
4724
4725 %<*en>
4726 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
4727 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
4728 an external package is needed to support this in plain \TeX\ and
4729 \LaTeX.}, and each family has three fonts:
4730 \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}.
4731 %</en>
4732 %<*ja>
4733 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
4734   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
4735   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
4736   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
4737 \cs{textfont}, \cs{scriptfont} そして \cs{scriptscriptfont} である.
4738 %</ja>
4739
4740 %<*en>
4741 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
4742 \autoref{tab-math} shows counterparts to \TeX's primitives for math
4743 font families. There is no relation between the value of
4744 \cs{fam} and that of \cs{jfam}; with appropriate settings,
4745 you can set both \cs{fam} and \cs{jfam} to the same value.
4746 Here <jfont\_cs> in the argument of \Param{jatextfont} etc.\ is
4747 a control sequence which is defined by \cs{jfont}, i.e.,
4748 a \emph{horizontal} Japanese font.
4749 %</en>
4750 %<*ja>
4751 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
4752 \autoref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
4753 ものを示している.\cs{fam} と \cs{jfam} の値の間には関係はなく,
4754 適切な設定の下では \cs{fam} と \cs{jfam} の両方に同じ値を設定することができる.
4755 \Param{jatextfont} 他の第2引数<jfont\_cs>は,\cs{jfont} で定義された
4756 \emph{横組用}和文フォントである.\cs{tfont} で定義された
4757 \emph{縦組用}和文フォントを指定することは想定していない.
4758 %</ja>
4759
4760 \begin{table}[!tb]
4761 %<en>\caption{Commands for Japanese math fonts}
4762 %<ja>\caption{和文数式フォントに対する命令}
4763 \label{tab-math}
4764 %<en>\medskip
4765 \centering
4766 \def\{{\char`\{}\def\}{\char`\}}\small
4767 \begin{tabular}{ll}
4768 \toprule
4769 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
4770 %<ja>\bf 和文フォント&\bf 欧文フォント\\
4771 \midrule
4772 \cs{jfam}${}\in [0,256)$&\cs{fam}\\
4773 \tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{textfont}<fam>=<font\_cs>\\
4774 \tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptfont}<fam>=<font\_cs>\\
4775 \tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptscriptfont}<fam>=<font\_cs>\\
4776 \bottomrule
4777 \end{tabular}
4778 \end{table}
4779
4780 %<en>\subsection{Callbacks}
4781 %<ja>\subsection{コールバック}
4782
4783 %<*en>
4784 \LuaTeX-ja also has several callbacks. These callbacks can
4785 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
4786 %</en>
4787 %<*ja>
4788 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
4789 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
4790 関数などを用いることでアクセスすることができる.
4791 %</ja>
4792 \begin{description}[font=\bfseries, style=nextline]
4793 %<en>\item[\texttt{luatexja.load\_jfm} callback]
4794 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
4795 %<*en>
4796 With this callback you can overwrite JFMs.
4797 This callback is called when a new JFM is loaded.
4798 %</en>
4799 %<*ja>
4800 このコールバックを用いることでJFMを上書きすることができる.
4801 このコールバックは新しいJFMが読み込まれるときに呼び出される.
4802 %</ja>
4803
4804 \begin{lstlisting}[numbers=left]
4805 function (<table> jfm_info, <string> jfm_name)
4806   return <table> new_jfm_info
4807 end
4808 \end{lstlisting}
4809
4810 %<*en>
4811 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
4812 this argument has \texttt{chars} field which contains character codes
4813              whose character class is not~0.
4814 %</en>
4815 %<*ja>
4816 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
4817 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
4818 %</ja>
4819
4820 %<*en>
4821 An example of this callback is the \texttt{ltjarticle} class, with
4822              forcefully assigning character class~0 to \texttt{'parbdd'}
4823              in the JFM \texttt{jfm-min.lua}.
4824 %</en>
4825 %<*ja>
4826 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
4827 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
4828 %</ja>
4829
4830 %<en>\item[\texttt{luatexja.define\_jfont} callback]
4831 %<ja>\item[\texttt{luatexja.define\_jfont}コールバック]
4832 %<*en>
4833 This callback and the next callback form a pair, and you can assign characters
4834  which do not have fixed code points in Unicode to non-zero character classes.
4835 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
4836 %</en>
4837 %<*ja>
4838 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
4839 番号を持たない文字を非零の文字クラスに割り当てることができる.
4840 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
4841 %</ja>
4842
4843 \begin{lstlisting}[numbers=left]
4844 function (<table> jfont_info, <number> font_number)
4845   return <table> new_jfont_info
4846 end
4847 \end{lstlisting}
4848 %<*en>
4849 \verb+jfont_info+ has the following fields,
4850 \emph{which may not overwritten by a user}:
4851 \begin{description}
4852 \item[\texttt{size}]
4853 The font size specified at \cs{jfont} in scaled points ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$).
4854 \item[\texttt{zw}, \texttt{zh}, \texttt{kanjiskip}, \texttt{xkanjiskip}]
4855 These are scaled value of those specified by the JFM, by the font size.
4856 \item[\texttt{jfm}]
4857 The internal number of the JFM.
4858 \item[\texttt{var}]
4859 The value of \texttt{jfmvar}~key, which is specified at \cs{jfont}.
4860 The default value is the empty string.
4861 \item[\texttt{chars}]
4862 The mapping table from character codes to its character classes.\\
4863 The specification \texttt{[i].chars=\{<character>, ...\}} in the JFM will be  stored in this
4864            field as \texttt{chars=\{[<character>]=\,$i$, ...\}}.
4865 \item[\texttt{char\_type}]
4866 For $i\in\omega$, \texttt{char\_type[$i$]} is information of characters whose class is
4867            $i$, and has the following fields:
4868 \begin{itemize}
4869  \item \texttt{width},~\texttt{height}, \texttt{depth},
4870   \texttt{italic}, \texttt{down},~\texttt{left}\ are just
4871        scaled value of those specified by the JFM, by the font size.
4872  \item \texttt{align} is a number which is determined from \texttt{align}~field in the JFM:
4873 \[
4874  \begin{cases}
4875   0&\text{\texttt{'left'} (default)}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4876  \end{cases}
4877 \]
4878 \end{itemize}
4879 For $i$,~$j\in \omega$, \texttt{char\_type[$i$][$j$]} stores a kern or a glue which will be inserted
4880 between character class~$i$ and class~$j$.
4881 \end{description}
4882 %</en>
4883 %<*ja>
4884 \verb+jfont_info+ は最低限以下のフィールドを持つが,これらを書き換えてはならない:
4885 \begin{cslist}
4886 \item[size]
4887 実際に使われるフォントサイズ(sp単位).$1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$.
4888 \item[zw\textrm{, }zh\textrm{, }kanjiskip\textrm{, }xkanjiskip]
4889 JFMファイルで指定されているそれぞれの値をフォントサイズに合わせてスケーリングしたものを
4890 sp単位で格納している.
4891 \item[jfm]
4892 利用されているJFMを識別するための番号.
4893 \item[var]
4894 \cs{jfont},~\cs{tfont} で指定された \texttt{jfmvar} キーの値(未指定のときは空文字列).
4895 \item[chars]
4896 文字コードから文字クラスへの対応が記述されたテーブル.\\
4897 JFM内の \texttt{[i].chars=\{<character>, ...\}} という指定は\
4898 \texttt{chars=\{[<character>]=\,$i$, ...\}} という形式に変換されている.
4899 \item[char\_type]
4900 $i\in\omega$に対して,\texttt{char\_type[$i$]} は文字クラス$i$の文字の寸法を格納しており,
4901 以下のフィールドを持つ.
4902 \begin{itemize}
4903  \item \texttt{width},~\texttt{height}, \texttt{depth},
4904   \texttt{italic}, \texttt{down},~\texttt{left}\ は
4905 JFMで指定されているそれぞれの値をスケーリングしたものである.
4906  \item \texttt{align} はJFMで指定されている値によって,
4907 \[
4908  \begin{cases}
4909   0&\text{\texttt{'left'}や省略時}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4910  \end{cases}
4911 \]
4912 のいずれかの値をとる.
4913 \end{itemize}
4914 $i$,~$j\in \omega$に対して,\texttt{char\_type[$i$][$j$]} は
4915 文字クラス$i$の文字と$j$の文字の間に挿入されるグルーやカーンを格納している.
4916 \begin{itemize}
4917   \item 間に入るものがカーンであれば,この値は\
4918 \texttt{[$j$]=\{[1]=<kern\_node>, ratio=<ratio>\}} であり,
4919 <kern\_node>はカーンを表すノードそのものである\footnote{%
4920 バージョン20150420.0以降ではノードのアクセス手法にdirect access
4921       modelを用いている.そのため,例えば\LuaTeX\ beta-0.78.2では,単なる自然数のようにし
4922       か見えないことに注意.
4923 }.
4924   \item グルーであれば,この値は以下のキーを持つテーブルである.
4925   \begin{description}
4926     \item[\texttt{width}, \texttt{stretch}, \texttt{shrink}]
4927     グルーのそれぞれ自然長,伸び量,縮み量をsp単位で表したもの.
4928     \item[\texttt{priority}] バ(ージョン2以降の)JFMでの指定 \texttt{\{<stretch>,<shrink>\}} を
4929     \[
4930       (\text{<stretch>}+4)\cdot 8+\text{<shrink>}+4
4931     \]
4932     として0--63の整数にパックしたもの.
4933     \item[\texttt{ratio}, \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch}, \texttt{kanjiskip\_shrink}]
4934     JFM中の同名のフィールドの値がそのまま使われている.
4935   \end{description}
4936 \end{itemize}
4937 \item[ascent\textrm{, }descent]
4938 ……
4939 \item[chars\_cbcache]
4940 文字クラス決定の処理で.キャッシュとして使われる.
4941 \end{cslist}
4942 %</ja>
4943
4944 %<*en>
4945 The returned table \verb+new_jfont_info+ also should include these fields, but
4946 you are free to add more fields (to use them in the \texttt{luatexja.find\_char\_class} callback).
4947 The \verb+font_number+ is a font number.
4948 %</en>
4949 %<*ja>
4950 戻り値の \verb+new_jfont_info+ テーブルも上に述べたフィールドをそのまま含まなければならないが,
4951 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
4952 \verb+font_number+ はフォント番号である.
4953 %</ja>
4954
4955 %<*en>
4956 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
4957              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
4958              CID characters in a JFM. This callback doesn't replace any
4959              code of \LuaTeX-ja.
4960 %</en>
4961 %<*ja>
4962 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
4963 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
4964 用いられている.
4965 %</ja>
4966
4967 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
4968 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
4969 %<*en>
4970 This callback is called just when \LuaTeX-ja is trying to determine which
4971              character class a character \verb+chr_code+ belongs.
4972 A function used in this callback should be in the following form:
4973 %</en>
4974 %<*ja>
4975 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
4976 属するかを決定しようとする際に呼び出される.
4977 このコールバックで呼び出される関数は次の形をしていなければならない:
4978 %</ja>
4979 \begin{lstlisting}[numbers=left]
4980 function (<number> char_class, <table> jfont_info, <number> chr_code)
4981   if char_class~=0 then return char_class
4982   else
4983     ....
4984     return (<number> new_char_class or 0)
4985   end
4986 end
4987 \end{lstlisting}
4988
4989 %<*en>
4990 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
4991              routine or previous function calls in this callback, hence
4992              this argument may not be 0. Moreover, the returned
4993              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
4994              is not~0, otherwise you will overwrite the \LuaTeX-ja's
4995              default routine.
4996 %</en>
4997 %<*ja>
4998 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
4999 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
5000 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
5001 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
5002 デフォルトルーチンを書き換えることになる.
5003 %</ja>
5004
5005 %<en>\item[\texttt{luatexja.set\_width} callback]
5006 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
5007 %<*en>
5008 This callback is called when \LuaTeX-ja is trying to encapsule a
5009              \textbf{JAchar} \textit{glyph\_node}, to adjust its
5010              dimension and position.
5011 %</en>
5012 %<*ja>
5013 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
5014 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
5015 %</ja>
5016 \begin{lstlisting}[numbers=left]
5017 function (<table> shift_info, <table> jfont_info, <table> char_type)
5018   return <table> new_shift_info
5019 end
5020 \end{lstlisting}
5021
5022 %<*en>
5023 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
5024 \texttt{down} and \texttt{left} fields, which are the amount of shifting
5025              down/left the character in a scaled point.
5026 %</en>
5027 %<*ja>
5028 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
5029 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
5030 文字の下/左へのシフト量(sp単位)である.
5031 %</ja>
5032
5033 %<*en>
5034 A good example is \Pkg{test/valign.lua}.
5035 After loading this file, the vertical position of glyphs is automatically
5036 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
5037 to be that of letters in the character class~0. For example, suppose that
5038 \begin{itemize}
5039 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
5040   (the standard values of Japanese OpenType fonts);
5041 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
5042   (the standard values of Japanese TrueType fonts).
5043 \end{itemize}
5044 Then, the position of glyphs is shifted up by
5045 %</en>
5046 %<*ja>
5047 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
5048              JFM内で規定された文字クラス0の文字における$(\hbox{高
5049              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
5050              下位置が自動調整される.例えば,
5051 \begin{itemize}
5052 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
5053 (和文OpenTypeフォントの標準値)
5054 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
5055 \end{itemize}
5056 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にずらされることとなる:
5057 %</ja>
5058 \[
5059  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
5060 \]
5061 \end{description}
5062
5063
5064
5065 %<en>\section{Parameters}
5066 %<ja>\section{パラメータ}
5067 \subsection{\cs{ltjsetparameter}}
5068 \label{ssec:param}
5069
5070 %<*en>
5071 As described before, \cs{ltjsetparameter} and \cs{ltjgetparameter} are
5072 commands for accessing most parameters of \LuaTeX-ja. One of the main
5073 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
5074 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
5075 is the position of \verb+hpack_filter+ callback in the source
5076 of \LuaTeX, see Section~\ref{sec-para}.
5077 %</en>
5078 %<*ja>
5079 先に述べたように,\LuaTeX-jaの内部パラメータにアクセスするには
5080 \cs{ltjsetparameter}(または \cs{ltjglobalsetparameter})と \cs{ltjgetparameter} を用いる.
5081 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
5082 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
5083 コールバックの位置にある.\ref{sec-para}章を参照.
5084 %</ja>
5085
5086 %<*en>
5087 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} are commands
5088 for assigning parameters. These take one argument which is a
5089 \texttt{<key>=<value>} list.
5090 The difference between these two commands is the
5091 scope of assignment;
5092 \cs{ltjsetparameter} does a local assignment and
5093 \cs{ltjglobalsetparameter} does a global one.
5094 They also obey the value of \cs{globaldefs}, like other assignments.
5095 %</en>
5096 %<*ja>
5097 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} はパラメータを
5098 指定するための命令で,\texttt{<key>=<value>}のリストを
5099 引数としてとる.両者の違いはスコープであり,
5100 \cs{ltjsetparameter} はローカルな設定を行うのに対し,
5101 \cs{ltjglobalsetparameter} はグローバルな設定を行う.
5102 また,他のパラメータ指定と同様に \cs{globaldefs} の値にも従う.
5103 %</ja>
5104
5105 %<*en>
5106 The following is the list of parameters which can be specified by the
5107 \cs{ltjsetparameter} command. [\cs{cs}] indicates the counterpart
5108 in \pTeX, and symbols beside each parameter has the following meaning:
5109 %</en>
5110 %<*ja>
5111 以下は \cs{ltjsetparameter} に指定することができるパラメータの一覧である.
5112 [\cs{cs}]は\pTeX における対応物を示す.
5113 また,それぞれのパラメータの右上の記号には次の意味がある:
5114 %</ja>
5115 \begin{itemize}
5116 %<*en>
5117 \item ``$\ast$'' : values at the end of a paragraph or a hbox are
5118 adopted in the whole paragraph or the whole hbox.
5119 %</en>
5120 %<*ja>
5121 \item ``$\ast$'':段落やhboxの終端での値がその段落/hbox全体で用いられる.
5122 %</ja>
5123 %<*en>
5124 \item ``\dagger'': assignments are always global.
5125 %</en>
5126 %<*ja>
5127 \item ``\dagger'':指定は常にグローバルになる.
5128 %</ja>
5129 \end{itemize}
5130
5131 \begin{cslist}[style=standard]
5132 \item[\DParam{jcharwidowpenalty}\,=<penalty>$^\ast$] [\cs{jcharwidowpenalty}]\
5133
5134 %<*en>
5135 Penalty value for suppressing orphans. This penalty is inserted just
5136              after the last \textbf{JAchar} which is not regarded as a
5137              (Japanese) punctuation mark.
5138 %</en>
5139 %<*ja>
5140 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
5141 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
5142 挿入される.
5143 %</ja>
5144
5145 \item[\DParam{kcatcode}\,=\{<chr\_code>,<natural number>\}$^\ast$]\
5146
5147 %<*en>
5148 An additional attributes which each character whose character code is <chr\_code> has.
5149 At version~20120506.0 or later, the lowermost bit of <natural number> indicates
5150              whether the character is considered as a punctuation mark
5151              (see the description of \Param{jcharwidowpenalty} above).
5152 %</en>
5153 %<*ja>
5154 文字コードが<chr\_code>の文字が持つ付加的な属性値.
5155 バージョン20120506.0以降では,<natural number>の最下位ビットが,その文字が句読点と
5156 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
5157 %</ja>
5158
5159 \item[\DParam{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$] [\cs{prebreakpenalty}]\
5160
5161 %<*ja>
5162 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
5163              この文字の前に挿入/追加されるペナルティの量を指定する.
5164
5165 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
5166 \begin{lstlisting}
5167 \ltjsetparameter{prebreakpenalty={`〙,10000}}
5168 \end{lstlisting}
5169 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
5170              うわけではないができれば行頭にはきて欲しくない場合に,0と
5171              10000の間の値を指定するのも有用であろう.
5172
5173 \pTeX では,\cs{prebreakpenalty}, \cs{postbreakpenalty}において,
5174 \begin{itemize}
5175 \item 一つの文字に対して,pre, postどちらか一つしか指定することができない%
5176   \footnote{後から指定した方で上書きされる.}
5177 \item pre, post合わせて256文字分の情報を格納することしかできない
5178 \end{itemize}
5179 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
5180 %</ja>
5181 %<*en>
5182 Set a penalty which is inserted automatically before the character <chr\_code>,
5183 to prevent a line starts from this character. For example, a line cannot started
5184 with one of closing brackets ``〗'', so \LuaTeX-ja sets
5185 \begin{lstlisting}
5186 \ltjsetparameter{prebreakpenalty={`〙,10000}}
5187 \end{lstlisting}
5188 by default.
5189
5190 \pTeX\ has following restrictions on \cs{prebreakpenalty} and \cs{postbreakpenalty},
5191 but they don't exist in \LuaTeX-ja:
5192 \begin{itemize}
5193  \item Both \cs{prebreakpenalty} and \cs{postbreakpenalty} cannot be set
5194 for the same character.
5195  \item We can set \cs{prebreakpenalty} and \cs{postbreakpenalty} up to 256~characters.
5196 \end{itemize}
5197 %</en>
5198
5199 \item[\DParam{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$]
5200            [\cs{postbreakpenalty}]\
5201
5202 %<*ja>
5203 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
5204              この文字の後に挿入/追加されるペナルティの量を指定する.
5205 %</ja>
5206 %<*en>
5207 Set a penalty which is inserted automatically after the character <chr\_code>,
5208 to prevent a line ends with this character.
5209 %</en>
5210
5211 \item[\DParam{jatextfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5212 %<en>[\cs{textfont} in \TeX]
5213 %<ja>[\TeX の \cs{textfont}]
5214 \item[\DParam{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5215 %<en>[\cs{scriptfont} in \TeX]
5216 %<ja>[\TeX の \cs{scriptfont}]
5217 \item[\DParam{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5218 %<en>[\cs{scriptscriptfont} in \TeX]
5219 %<ja>[\TeX の \cs{scriptscriptfont}]
5220 \item[\DParam{yjabaselineshift}\,=<dimen>]\
5221 \item[\DParam{yalbaselineshift}\,=<dimen>] [\cs{ybaselineshift}]
5222 \item[\DParam{tjabaselineshift}\,=<dimen>]\
5223 \item[\DParam{talbaselineshift}\,=<dimen>] [\cs{tbaselineshift}]
5224
5225 \item[\DParam{jaxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$]\
5226
5227 %<*en>
5228 Set whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
5229 The followings are allowed for <mode>:
5230 %</en>
5231 %<*ja>
5232 文字コードが<chr\_code>の\textbf{JAchar}の前/後ろに\Param{xkanjiskip}の
5233 挿入を許すかどうかの設定.
5234 以下の<mode>が許される:
5235 %</ja>
5236 \begin{description}
5237 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5238 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5239 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5240 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5241 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5242 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5243 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
5244 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5245 \end{description}
5246 %<*en>
5247 This parameter is similar to the \cs{inhibitxspcode} primitive of \pTeX, but not compatible with \cs{inhibitxspcode}.
5248 %</en>
5249 %<*ja>
5250 このパラメータは\pTeX の \cs{inhibitxspcode} プリミティブと似ているが,
5251 互換性はない.
5252 %</ja>
5253 \item[\DParam{alxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$] [\cs{xspcode}]\
5254
5255 %<*en>
5256 Set whether inserting \Param{xkanjiskip} is allowed before/after a
5257              \textbf{ALchar} whose character code is <chr\_code>.
5258              The followings are allowed for <mode>:
5259 %</en>
5260 %<*ja>
5261 文字コードが<chr\_code>の\textbf{ALchar}の前/後ろに\Param{xkanjiskip}の
5262 挿入を許すかどうかの設定.
5263 以下の<mode>が許される:
5264 %</ja>
5265 \begin{description}
5266 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5267 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5268 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5269 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5270 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5271 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5272 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
5273 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5274 \end{description}
5275 %<*en>
5276 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
5277 %</en>
5278 %<*ja>
5279 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
5280 これら2つのパラメータは互いの別名となっていることに注意する.
5281 %</ja>
5282
5283 \item[\DParam{autospacing}\,=<bool>] [\cs{autospacing}]
5284 \item[\DParam{autoxspacing}\,=<bool>] [\cs{autoxspacing}]
5285 \item[\DParam{kanjiskip}\,=<skip>$^\ast$] [\cs{kanjiskip}]\
5286
5287 %<*ja>
5288 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
5289 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
5290 しかし,自然長が \cs{maxdimen} の場合は,例外的に和文フォントのJFM側で指定されている
5291 値を採用(こちらはフォントサイズに比例)することになっている.
5292 %</ja>
5293 %<*en>
5294 The default glue which inserted between two \textbf{JAchar}s.
5295 Changing current Japanese font does not alter this parameter, as \pTeX.
5296
5297 If the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5298 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec:jfm-str}).
5299 %</en>
5300
5301 \item[\DParam{xkanjiskip}\,=<skip>$^\ast$] [\cs{xkanjiskip}]\
5302
5303 %<*ja>
5304 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
5305 \Param{kanjiskip}と同じように,通常ではフォントサイズに比例して変わることはないが,
5306 自然長が \cs{maxdimen} の場合が例外である.
5307 %</ja>
5308 %<*en>
5309 The default glue which inserted between a \textbf{JAchar} and an
5310       \textbf{ALchar}.
5311 Changing current font does not alter this parameter, as \pTeX.
5312
5313 As \Param{kanjiskip}, if the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5314 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec:jfm-str}).
5315 %</en>
5316
5317
5318 \item[\DParam{differentjfm}\,=<mode>$^\dagger$]\
5319
5320 %<*en>
5321 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
5322 The allowed arguments are the followings:
5323 %</en>
5324 %<*ja>
5325 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
5326 入れるかを指定する.
5327 許される値は以下の通り:
5328 %</ja>
5329 \begin{quote}
5330 \texttt{average},
5331 \texttt{both},
5332 \texttt{large},
5333 \texttt{small},
5334 \texttt{pleft},
5335 \texttt{pright},
5336 \texttt{paverage}
5337 \end{quote}
5338 %<*en>
5339 The default value is \texttt{paverage}. \dots
5340 %</en>
5341 %<*ja>
5342 デフォルト値は \texttt{paverage} である.
5343 各々の値による差異の詳細は\ref{ssec:cluster-wa}節の「『右空白』の算出」を参照してほしい.
5344 %</ja>
5345
5346 \item[\DParam{jacharrange}\,=<ranges>]
5347 \item[\DParam{kansujichar}\,=\{<digit>, <chr\_code>\}$^\ast$] [\cs{kansujichar}]
5348
5349 \item[\DParam{direction}\,=<dir>\ \hbox{\rm (always local)}]\
5350
5351 %<*en>
5352 Assigning to this parameter has the same effect as
5353 \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5354 \cs{dtou}~(if $\hbox{<dir>}=1$) or \cs{utod}~(if $\hbox{<dir>}=11$).
5355 If the argument <dir> is not one of 4,~3, 1~nor~11,
5356 the behavior of this assignment is undefined.
5357 %</en>
5358 %<*ja>
5359 組方向を変更する \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5360 \cs{dtou}~(if $\hbox{<dir>}=1$), \cs{utod}~(if $\hbox{<dir>}=11$) と同じ役割を持つ.
5361 利用可能な状況もこれら4命令と同一である.引数<dir>が4,~3, 1,~11のいずれでも無いときの
5362 動作は未定義である.
5363 %</ja>
5364
5365 \end{cslist}
5366
5367
5368 \subsection{\cs{ltjgetparameter}}
5369 \label{ssec:getpar}
5370 %<*en>
5371 \cs{ltjgetparameter} is a control sequence for acquiring parameters. It
5372 always takes a parameter name as first argument.
5373 %</en>
5374 %<*ja>
5375 \cs{ltjgetparameter} はパラメータの値を取得するための命令であり,
5376 常にパラメータの名前を第一引数にとる.
5377 %</ja>
5378 \begin{LTXexample}
5379 \ltjgetparameter{differentjfm},
5380 \ltjgetparameter{autospacing},
5381 \ltjgetparameter{kanjiskip},
5382 \ltjgetparameter{prebreakpenalty}{`)}.
5383 \end{LTXexample}
5384
5385 %<*en>
5386 \emph{The return value of\/ \cs{ltjgetparameter} is
5387 always a string}, which is outputted by \texttt{tex.write()}.
5388 Hence any character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
5389 12~(other), while the space has 10~(space).
5390 %</en>
5391 %<*ja>
5392 \emph{\cs{ltjgetparameter} の戻り値は常に文字列である.}
5393 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
5394 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
5395 一方,空白のカテゴリーコードは10~(space)である.
5396 %</ja>
5397
5398 \begin{itemize}
5399 \item
5400 %<*en>
5401 If first argument is one of the
5402 following, no  additional argument is needed.
5403 %</en>
5404 %<*ja>
5405 第1引数が次のいずれかの場合には,追加の引数は必要ない.
5406 %</ja>
5407 \begin{quote}
5408 \sffamily
5409 jcharwidowpenalty, yjabaselineshift, yalbaselineshift, autospacing, autoxspacing,\\
5410 kanjiskip, xkanjiskip, differentjfm, direction
5411 \end{quote}
5412 %<*en>
5413 Note that \verb+\ltjgetparameter{autospacing}+~and~\verb+\ltjgetparameter{autoxspacing}+
5414 returns 1 or 0, not
5415 \texttt{true}~nor~\texttt{false}.
5416 %</en>
5417 %<*ja>
5418 \verb+\ltjgetparameter{autospacing}+ と \verb+\ltjgetparameter{autoxspacing}+ は,
5419 \texttt{true}や\texttt{false}を返すの\emph{ではなく},
5420 1か0のいずれかを返すことに注意,
5421 %</ja>
5422
5423 \item
5424 %<*en>
5425 If first argument is one of the
5426 following, an additional argument---a character code, for example---is needed.
5427 %</en>
5428 %<*ja>
5429 第1引数が次のいずれかの場合には,さらに文字コードを第2引数としてとる.
5430 %</ja>
5431 \begin{quote}
5432 \sffamily
5433 kcatcode, prebreakpenalty, postbreakpenalty, jaxspmode, alxspmode
5434 \end{quote}
5435 %<*en>
5436 \verb+\ltjgetparameter{jaxspmode}{...}+~and~\verb+\ltjgetparameter{alxspmode}{...}+
5437 returns 0,~1, 2,~or~3, instead of \texttt{preonly} etc.
5438 %</en>
5439 %<*ja>
5440 \verb+\ltjgetparameter{jaxspmode}{...}+ や \verb+\ltjgetparameter{alxspmode}{...}+\
5441 は,\texttt{preonly} などといった文字列ではなく,0から3までの値を返す.
5442 %</ja>
5443
5444 \item
5445 %<*en>
5446 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ returns \texttt{0}
5447 if ``characters which belong to the character range~<range> are \textbf{JAchar}'',
5448 \texttt{1} if ``\dots~are \textbf{ALchar}''.
5449 Although there is no character range~$-1$, specifying $-1$ to <range> does not cause an
5450       error (returns 1).
5451 %</en>
5452 %<*ja>
5453 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ は,<range>が\textbf{JAchar}達の
5454 範囲ならば0を,そうでなければ1を返す.「$-1$番の文字範囲」は存在しないが,<range>に$-1$を
5455 指定してもエラーは発生しない(1を返す).
5456 %</ja>
5457
5458 \item
5459 %<*en>
5460 For an integer~<digit> between 0~and~9,
5461      \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ returns the character code
5462 of the result of \cs{kansuji}<digit>.
5463 %</en>
5464 %<*ja>
5465 0--9の数<digit>に対して,
5466 \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ は,\cs{kansuji}<digit>で出力され
5467      る文字の文字コードを返す.
5468 %</ja>
5469
5470 \item
5471 %<*en>
5472 \verb+\ltjgetparameter{adjustdir}+ returns a integer which represents
5473 the direction of the surrounding vertical list.
5474 As \Param{direction}, the return value 1 means \emph{down-to-up} direction,
5475 3 means \emph{tate} direction (vertical typesetting),
5476 and 4 means \emph{yoko} direction (horizontal typesetting).
5477 %</en>
5478 %<*ja>
5479 \verb+\ltjgetparameter{adjustdir}+ は,周囲のvboxの組方向(言い換えれば,
5480 \cs{vadjust} で用いられる組方向)を表す数値を返す.
5481 \Param{direction}と同様に,1は \cs{dtou} 方向を,
5482 3は縦組みを,4は横組みを表す.
5483 %</ja>
5484
5485 \item
5486 %<*en>
5487 For an integer~<reg\_num> between 0~and~65535,
5488 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ returns the direction of
5489 \cs{box}<reg\_num>. If this box register is void, the returned value is zero.
5490 %</en>
5491 %<*ja>
5492 0--65535の数<reg\_num>に対して,
5493 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ は,\cs{box}<reg\_num>に
5494 格納されているボックスの組方向を表す.もしこのレジスタが空の場合は,0が返される.
5495 %</ja>
5496
5497 \item
5498 %<*en>
5499 The following parameter names \emph{cannot be specified} in \cs{ltjgetparameter}.
5500 %</en>
5501 %<*ja>
5502 次のパラメータ名を \cs{ltjgetparameter} に指定することはできない.
5503 %</ja>
5504 \begin{quote}
5505 \sffamily
5506 jatextfont, jascriptfont, jascriptscriptfont, jacharrange
5507 \end{quote}
5508
5509 \item
5510 %<*en>
5511 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ returns
5512 the range number which <chr\_code> belongs to
5513 (although there is no parameter named ``chartorange'').
5514
5515 If <chr\_code> is between 0 and 127, this <chr\_code> does not belong to
5516 any character range. In this case,
5517       \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+
5518 returns $-1$.
5519
5520 Hence, one can know whether <chr\_code> is \textbf{JAchar} or not
5521 by the following:
5522 %</en>
5523 %<*ja>
5524 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ によって
5525 <chr\_code>の属する文字範囲の番号を知ることができる.
5526
5527 <chr\_code>に0--127の値を指定した場合(このとき,<chr\_code>が属する
5528 文字範囲は存在しない)は$-1$が返る.
5529
5530 そのため,<chr\_code>が\textbf{JAchar}か\textbf{ALchar}かは
5531 次で知ることができる:
5532 %</ja>
5533 \begin{quote}
5534 \ttfamily \verb+\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{+%
5535   <chr\_code>\verb+}}+\\\null\hfill\verb+% 0 if JAchar, 1 if ALchar+
5536 \end{quote}
5537
5538 %<*en>
5539 \item Because the returned value is string, the following conditionals do not work
5540 if \Param{kanjiskip} (or~\Param{xkanjiskip}) has the stretch part or the shrink part.
5541 \begin{lstlisting}
5542 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5543 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5544 \end{lstlisting}
5545 The correct way is using a temporary register.
5546 \begin{lstlisting}
5547 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5548 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5549 \end{lstlisting}
5550 %</en>
5551 %<*ja>
5552 \item 返り値が文字列であることから,\Param{kanjiskip}や\Param{xkanjiskip}を直接
5553 \ \cs{ifdim} を使って比較することは望ましくない.伸び量や縮み量を持っている時には,
5554 次はエラーを発生させる:
5555 \begin{lstlisting}
5556 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5557 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5558 \end{lstlisting}
5559 レジスタに一旦代入するのが良い:
5560 \begin{lstlisting}
5561 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5562 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5563 \end{lstlisting}
5564 %</ja>
5565
5566 \end{itemize}
5567
5568
5569 %<*en>
5570 \subsection{Alternative Commands to \cs{ltjsetparameter}}
5571 The basic method to set parameters of \LuaTeX-ja is to use
5572 \cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}.
5573 However, these commands are slow, because they parse a key-value list,
5574 so several alternative commands are used in \LuaTeX-ja.
5575 \emph{This subsection is not for general \LuaTeX-ja users.}
5576
5577 \paragraph{Setting \Param{kanjiskip}~or~\Param{xkanjiskip}}
5578 In \Pkg{ltjsclasses}, every size-changing command such as \cs{Large}
5579 changes \cs{kanjiskip}~and~\cs{xkanjiskip}.
5580 But a simple implementation, as the code below, is slow since
5581 two key-value lists are parsed by \cs{ltjsetparameter}:
5582 \begin{lstlisting}
5583   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
5584   \@tempskipa=\ltjgetparameter{xkanjiskip}
5585   \ifdim\@tempskipa>\z@
5586     \if@slide
5587       \ltjsetparameter{xkanjiskip=0.1em}
5588     \else
5589       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
5590     \fi
5591   \fi
5592 \end{lstlisting}
5593
5594 Hence, \LuaTeX-ja defines more primitive commands, namely \cs{ltj@setpar@global},
5595 \cs{ltjsetkanjiskip}, and~\cs{ltjsetxkanjiskip}. Here
5596 \begin{quote}
5597   \lstinline+\ltj@setpar@global\ltjsetkanjiskip 10pt+
5598 \end{quote}
5599 and \lstinline+\ltjsetparameter{kanjiskip=10pt}+ has the same effect.
5600 The actual code of \Pkg{ltjsclasses} is shown below:
5601 \begin{lstlisting}
5602   \ltj@setpar@global
5603   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
5604   \@tempskipa=\ltjgetparameter{xkanjiskip}
5605   \ifdim\@tempskipa>\z@
5606     \if@slide
5607       \ltjsetxkanjiskip.1em
5608     \else
5609       \ltjsetxkanjiskip.25em plus .15em minus .06em
5610     \fi
5611   \fi
5612 \end{lstlisting}
5613
5614 Note that using \cs{ltjsetkanjiskip}~or~\cs{ltjsetxkanjiskip} alone,
5615 that is, without executing \cs{ltj@setpar@global} in advance, is \emph{not} supported.
5616 %</en>
5617
5618 %<*ja>
5619 \subsection{\cs{ltjsetparameter} の代替}
5620 原則として各種内部パラメータの設定には \cs{ltjsetparameter} もしくは
5621 \ \cs{ltjglobalsetparameter}\ を用いることになるが,
5622 \cs{ltjsetparameter} の実行には時間がかかるという難点があり,
5623 \LuaTeX-ja の内部ではより高速に実行できる別の形式を用いている.
5624 \emph{本節は一般利用者むけの内容ではない.}
5625
5626 \paragraph{\Param{kanjiskip}, \Param{xkanjiskip}の設定}
5627 \pLaTeXe 新ドキュメントクラスでは,
5628 \begin{lstlisting}
5629 \def\@setfontsize#1#2#3{%
5630   ...
5631   \kanjiskip=0zw plus .1zw minus .01zw
5632   \ifdim\xkanjiskip>\z@
5633     \if@slide \xkanjiskip=0.1em \else
5634       \xkanjiskip=0.25em plus 0.15em minus 0.06em
5635     \fi
5636   \fi}
5637 \end{lstlisting}
5638 と,フォントサイズを変更するごとに \cs{kanjiskip}, \cs{xkanjiskip} を変更している.
5639 この \cs{@setfontsize} は文書の中で多数回実行されるので.
5640 \LuaTeX-ja 用に素直に書き換えた
5641 \begin{lstlisting}
5642   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
5643   \@tempskipa=\ltjgetparameter{xkanjiskip}
5644   \ifdim\@tempskipa>\z@
5645     \if@slide
5646       \ltjsetparameter{xkanjiskip=0.1em}
5647     \else
5648       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
5649     \fi
5650   \fi
5651 \end{lstlisting}
5652 としたのではタイプセットが遅くなってしまう.
5653 そこで,\cs{ltjsetparameter} の中で
5654 \begin{itemize}
5655 \item \cs{globaldefs} の値を読み取る \cs{ltj@setpar@global}
5656 \item \Param{kanjiskip} の設定を行う \cs{ltjsetkanjiskip}
5657 \item \Param{xkanjiskip} の設定を行う \cs{ltjsetxkanjiskip}
5658 \end{itemize}
5659 を独立させ,\Pkg{ltjsclasses}では,
5660 \begin{lstlisting}
5661   \ltj@setpar@global
5662   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
5663   \@tempskipa=\ltjgetparameter{xkanjiskip}
5664   \ifdim\@tempskipa>\z@
5665     \if@slide
5666       \ltjsetxkanjiskip.1em
5667     \else
5668       \ltjsetxkanjiskip.25em plus .15em minus .06em
5669     \fi
5670   \fi
5671 \end{lstlisting}
5672 としている.
5673 \cs{ltj@setpar@global}を直前に実行せず,単独で
5674 \cs{ltjsetkanjiskip}, \cs{ltjsetxkanjiskip}を実行することは想定されていないので注意.
5675
5676
5677
5678 \paragraph{ベースライン補正量の設定}
5679 \pLaTeX の\Pkg{ascmac}パッケージでは,縦組の欧文ベースライン補正量の一時待避・復帰処理に
5680 \ \cs{@saveybaselineshift}\ という寸法レジスタを用い
5681 \begin{lstlisting}
5682 \@savetbaselineshift\tbaselineshift\tbaselineshift\z@
5683 ...
5684 \tbaselineshift\@savetbaselineshift
5685 \end{lstlisting}
5686 という処理を行っている.
5687
5688 これを\LuaTeX-ja 用に \cs{ltjsetparameter} を使って書き直すと,
5689 \begin{lstlisting}
5690 \@savetbaselineshift\ltjgetparameter{talbaselineshift}
5691 \ltjsetparameter{talbaselineshift=\z@}
5692 ...
5693 \ltjsetparameter{talbaselineshift=\@savetbaselineshift}
5694 \end{lstlisting}
5695 となる.
5696
5697 さて,縦組の欧文ベースライン補正量\Param{talbaselineshift}は,
5698 実際には \cs{ltj@tablshift} という属性レジスタに格納されている
5699 (\ref{sec-para}\nobreak 節参照).属性レジスタは長さではなく整数値を格納する\footnote{%
5700   従って,\texttt{\textbackslash @savetbaselineshift=\textbackslash ltj@tablshift}\
5701   のように記述することはできない.属性レジスタを \cs{tbaselineshift} という名称にしなかっ
5702   たのはそのためである.
5703 }ものであり,\cs{ltj@tablshift} は補正量を sp 単位で保持することから,
5704 上記のコードと同じ内容をより速い以下のコードで実現することができる.
5705 \begin{lstlisting}
5706 \@savetbaselineshift\ltj@tablshift sp%
5707 \ltj@tablshift\z@
5708 ...
5709 \ltj@tablshift\@savetbaselineshift
5710 \end{lstlisting}
5711 この手法は \Pkg{ascmac} パッケージの\LuaTeX-ja対応パッチ \Pkg{lltjp-tascmac.sty} で
5712 実際に用いられている.\Pkg{lltjp-tascmac.sty} は自動的に読み込まれるので,
5713 ユーザは何も気にせず普通に \Pkg{ascmac} パッケージを \cs{usepackage} で読みこめば良い.
5714 %</ja>
5715
5716
5717 %<en>\section{Other Commands for plain \TeX\ and \LaTeXe}
5718 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
5719 %<en>\subsection{Commands for compatibility with \pTeX}
5720 %<ja>\subsection{\pTeX 互換用命令}
5721
5722 %<*en>
5723 The following commands are implemented for compatibility with \pTeX.
5724 Note that the former five commands don't support JIS~X~0213, but only JIS~X~0208.
5725 The last \cs{kansuji} converts an integer into its Chinese numerals.
5726 %</en>
5727 %<*ja>
5728 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
5729 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
5730 %</ja>
5731 \begin{center}
5732 \cs{kuten}, \cs{jis}, \cs{euc}, \cs{sjis}, \cs{ucs}, \cs{kansuji}
5733 \end{center}
5734 %<*en>
5735 These six commands takes an internal integer, and returns a \emph{string}.
5736 %</en>
5737 %<*ja>
5738 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
5739 %</ja>
5740 \begin{LTXexample}
5741 \newcount\hoge
5742 \hoge="2423 %"
5743 \the\hoge, \kansuji\hoge\\
5744 \jis\hoge, \char\jis\hoge\\
5745 \kansuji1701
5746 \end{LTXexample}
5747
5748 %<*en>
5749 To change characters of Chinese numerals for each digit, set \Param{kansujichar} parameter:
5750 \begin{LTXexample}
5751 \ltjsetparameter{kansujichar={1,`壹}}
5752 \ltjsetparameter{kansujichar={7,`漆}}
5753 \ltjsetparameter{kansujichar={0,`零}}
5754 \kansuji1701
5755 \end{LTXexample}
5756 %</en>
5757
5758
5759 \subsection{\cs{inhibitglue}}
5760 %<*en>
5761 \cs{inhibitglue} suppresses the insertion of \textbf{JAglue}.
5762 The following is an example, using a special JFM that there will be a glue between
5763 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
5764 %</en>
5765 %<*ja>
5766 \cs{inhibitglue} は\textbf{JAglue}の挿入を抑制する.
5767 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
5768 ある.
5769 %</ja>
5770
5771 \begin{LTXexample}[width=0.4\textwidth]
5772 \jfont\g=file:KozMinPr6N-Regular.otf:jfm=test \g
5773 \fbox{\hbox{あウあ\inhibitglue ウ}}
5774 \inhibitglue\par\noindent あ1
5775 \par\inhibitglue\noindent あ2
5776 \par\noindent\inhibitglue あ3
5777 \par\hrule\noindent あoff\inhibitglue ice
5778 \end{LTXexample}
5779
5780 %<*en>
5781 With the help of this example, we remark the specification of \cs{inhibitglue}:
5782 %</en>
5783 %<*ja>
5784 この例を援用して,\cs{inhibitglue} の仕様について述べる.
5785 %</ja>
5786 \begin{itemize}
5787 %<*en>
5788 \item The call of \cs{inhibitglue} in the (internal) vertical mode is
5789       simply ignored.
5790 %</en>
5791 %<*ja>
5792 \item \emph{\cs{inhibitglue} の垂直モード中での呼び出しは意味を持たない}\footnote{%
5793   この点は\TeX~Live~2014での\pTeX における \cs{inhibitglue} の仕様変更と同じである.
5794 }.
5795 4行目の入力で有効にならないのは,\cs{inhibitglue} の時点では垂直モードであり,
5796 \cs{noindent} の時点で水平モードになるからである.
5797 %</ja>
5798
5799 %<*en>
5800 \item The call of \cs{inhibitglue} in the (restricted) horizontal
5801       mode is only effective on the spot; does not get over boundary of
5802       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
5803       kernings, as shown in the last line of above example.
5804 %</en>
5805 %<*ja>
5806 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
5807   有効であり,段落の境界を乗り越えない.
5808   さらに,\cs{inhibitglue} は上の例の最終行のように(欧文における)リガチャとカーニングを
5809   打ち消す.これは,\cs{inhibitglue} が内部的には「現在のリスト中にwhatsitノードを
5810   追加する」ことを行なっているからである.
5811 %</ja>
5812
5813 %<*en>
5814 \item The call of \cs{inhibitglue} in math mode is just ignored.
5815 %</en>
5816 %<*ja>
5817 \item \cs{inhibitglue} を数式モード中で呼び出した場合はただ無視される.
5818 %</ja>
5819
5820 %<*ja>
5821 \item \LaTeX で\LuaTeX-ja を使用する場合は,
5822 \cs{inhibitglue} の代わりとして \verb+\<+ を使うことができる.
5823 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
5824 注意すること.
5825 %</ja>
5826 \end{itemize}
5827
5828
5829 \subsection{\cs{ltjfakeboxbdd}, \cs{ltjfakeparbegin}}
5830 %<*en>
5831 Sometimes \texttt{'parbdd'}~and~\texttt{'boxbdd'} specifications~look like ``fail'',
5832 especially in paragraphs inside list environments.
5833 This is because \cs{everypar} inserts some nodes such as boxes and kerns, so
5834 the ``first letter'' in a paragraph is in fact not the first letter.
5835 %</en>
5836 %<*ja>
5837 リスト環境内での\cs{item}で始まる各項目などでは,
5838 「段落最初の鍵括弧が余計に半角字下げされる」など,
5839 JFMにある\texttt{'parbdd'}, \texttt{'boxbdd'}の指定が見かけ上破綻していることがある.
5840
5841 これは\TeX が\cs{everypar}を用いて段落開始時に記号類や空白などを挿入してしまっているため,
5842 段落最初の鍵括弧が実際には段落最初のノードではないことに起因する.以下に例を示した.
5843 %</ja>
5844 \begin{LTXexample}[width=0.3\textwidth]
5845 \parindent1\zw
5846 \noindent ああああああああ\par % for comparison
5847 「ああああああ \par            % normal paragraph
5848
5849 \everypar{\null}
5850 「ああああああ \par            % ???
5851 \end{LTXexample}
5852 %<*en>
5853 \cs{ltjfakeboxbdd}~and~\cs{ltjfakeparbegin} primitives resolve this situation.
5854 \begin{itemize}
5855   \item \cs{ltjfakeparbegin} creates a node which indicates
5856   ``beginning of an indented paragraph'' to the insertion process of \textbf{JAglue}.
5857  \item \cs{ltjfakeboxbdd} creates a node which indicates
5858   ``beginning/ending of a box'' to the insertion process of \textbf{JAglue}.
5859 \end{itemize}
5860 As an example, the example above can be improved as follows:
5861 %</en>
5862 %<*ja>
5863 \cs{ltjfakeboxbdd}, \cs{ltjfakeparbegin}はこの状況を改善する命令である.
5864 実際には\cs{everypar}の末尾にこれらを追加するという使い方がほとんどになるだろう.
5865 \begin{itemize}
5866   \item \cs{ltjfakeparbegin}は,実行された箇所が「インデントあり段落の開始」であると\LuaTeX-jaの
5867   和文処理グルー挿入処理に認識させる.この命令の直前に\textbf{JAchar}があった場合,
5868   この文字の後ろに入るグルー等の処理については未定義である
5869   \footnote{%
5870     この命令と同等の内容は,\cs{dirrctlua}の形で\Pkg{ltjsclasses}内で以前から使われていた.
5871     一般ユーザでも利用しやすくするため,バージョン20170505.0で新たに命令として定義した.
5872   }.
5873   \item \cs{ltjfakeboxbdd}は,実行された箇所が「ボックスの先頭と末尾」であると\LuaTeX-jaの
5874   和文処理グルー挿入処理に認識させる.
5875 \end{itemize}
5876 例えば,先ほどの例に対して適用すると,次のようになる.
5877 %</ja>
5878 \begin{LTXexample}[width=0.3\textwidth]
5879 \parindent1\zw
5880 \noindent ああああああああ\par % for comparison
5881 「ああああああ \par            % normal paragraph
5882
5883 \everypar{\null\ltjfakeparbegin}
5884 「ああああああ \par
5885 \end{LTXexample}
5886
5887
5888 \subsection{\cs{ltjdeclarealtfont}}
5889 \label{ssec:altfont}
5890 %<*en>
5891 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
5892 This \cs{ltjdeclarealtfont} uses in the following form:
5893 \begin{quote}
5894 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>\{<range>\}
5895 \end{quote}
5896 where  <base\_font\_cs>~and~<alt\_font\_cs> are defined by \cs{jfont}.
5897 Its meaning is
5898 \begin{quote}
5899 If the current Japanese font is <base\_font\_cs>, characters which belong to <range>
5900 is typeset by another Japanese font <alt\_font\_cs>, instead of <base\_font\_cs>.
5901 \end{quote}
5902 Here <range> is a comma-separated list of character codes, but also accepts negative integers:
5903 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
5904 by <base\_font\_cs>. Note that characters which do not exist in <alt\_font\_cs> are
5905 ignored.
5906
5907 For example, if \cs{hoge} uses \texttt{jfm-ujis.lua}, the standard JFM of \LuaTeX-ja,
5908 then
5909 \begin{lstlisting}
5910 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5911 \end{lstlisting}
5912 does
5913 \begin{quote}
5914 If the current Japanese font is \cs{hoge}, \texttt{U+3000}--\texttt{U+30FF}
5915 and characters in class~1 (ideographic opening brackets)
5916 are typeset by \cs{piyo}.
5917 \end{quote}
5918 %</en>
5919 %<*ja>
5920 \cs{jfont} の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
5921 使用出来る「実際のフォント」は1つである.
5922 しかし,\cs{ltjdeclarealtfont} を用いると,この原則から外れることができる.
5923
5924 \cs{ltjdeclarealtfont} は以下の書式で使用する:
5925 \begin{quote}
5926 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>\{<range>\}
5927 \end{quote}
5928 これは「現在の和文フォント」が<base\_font\_cs>であるとき,
5929 <range>に属する文字は<alt\_font\_cs>を用いて組版される,という意味である.
5930 \begin{itemize}
5931  \item <base\_font\_cs>, <alt\_font\_cs>は
5932 \cs{jfont} によって定義された和文フォントである.
5933  \item <range>は文字コードの範囲を表すコンマ区切りのリストであるが,
5934    例外として負数$-n$は「<base\_font\_cs>のJFMの文字クラス$n$に属する全ての文字」
5935    を意味する.
5936
5937 <range>中に<alt\_font\_cs>中に実際には存在しない文字が指定された場合は,
5938 その文字に対する設定は無視される.
5939 \end{itemize}
5940
5941 例えば,\cs{hoge} のJFMが\LuaTeX-ja標準の
5942 \ \texttt{jfm-ujis.lua} であった場合,
5943 \begin{lstlisting}
5944 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5945 \end{lstlisting}
5946 は「\cs{hoge} を利用しているとき,
5947 \texttt{U+3000}--\texttt{U+30FF}と
5948 文字クラス1(開き括弧類)中の文字だけは \cs{piyo} を用いる」
5949 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
5950 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
5951 マクロの都合による.
5952 %</ja>
5953
5954 %<*ja>
5955 \subsection{\cs{ltjalchar} と \cs{ltjjachar}}
5956 文字コードが$\text{<chr\_code>}~(\geq 128=\mathtt{0x80})$の文字を
5957 \ \cs{char} プリミティブを使い \cs{char}<chr\_code> として出力させると,
5958 その文字の属する文字範囲(\ref{ssec:setrange}節参照)によって
5959 \textbf{ALchar}か\textbf{JAchar}か,つまり欧文フォントで出力されるか和文フォントで出力され
5960 るかが決まる.
5961
5962 文字範囲の設定を無視し,文字コードが$\text{<chr\_code>}~(\geq 128=\mathtt{0x80})$の文字を強制的に
5963 \textbf{ALchar}, \textbf{JAchar}で出力する命令がそれぞれ
5964 \ \cs{ltjalchar},~\cs{ltjjachar} である.使用方法は \cs{char} と同じく
5965 \ \cs{ltjalchar}<chr\_code>, \cs{ltjjachar}<chr\_code>とすればよい.
5966 <chr\_code>が127以下の場合は,\cs{ltjjachar} であっても\textbf{ALchar}として出力されること
5967 に注意.
5968
5969 以下は\ref{ssec:setrange}節に載せた例に,\cs{char} の動作を追加したものである.
5970 \begin{LTXexample}[width=0.25\textwidth]
5971 \gtfamily\large % default, ALchar, JAchar
5972 ¶, \char`¶, \ltjalchar`¶, \ltjjachar`¶\\    % default: ALchar
5973 α, \char`α, \ltjalchar`α, \ltjjachar`α  % default: JAchar
5974 \end{LTXexample}
5975 %</ja>
5976
5977 %<en>\section{Commands for \LaTeXe}
5978 %<ja>\section{\LaTeXe 用の命令}
5979
5980 %<*ja>
5981 \subsection{\LaTeXe 下での和文フォントの読み込み}
5982 \label{ssec:ltx-jfm}
5983 バージョン20190107以降では,\LaTeXe の下で\LuaTeX-jaを使用した際に,
5984 \emph{横組用和文フォントと縦組み用和文フォントを両方一度に読み込み・選択せずに,
5985   実際にそれぞれを使う組方向になったときに行う}という方針にした.
5986 これは実際に読み込むフォント数を削減することで,
5987 タイプセットにかかる時間と(主にLuaの)メモリ消費を削減するためである(\cite{tc18ltja}).
5988
5989 \begin{itemize}
5990   \item \cs{selectfont}は横組用・縦組用和文フォントのうち,現在の組方向で使う方を
5991   実際に読み込み(・選択し),そうでない方は「フォントサイズとJFMのみ\LuaTeX-jaが把握している状態」
5992   (以下,\emph{JFM把握状態})とする.
5993
5994   \item 組方向変更命令\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod}には
5995   \begin{quote}
5996         新たな組方向での和文フォントが読み込まれていない(JFM把握状態)ならば,
5997         現在のエンコーディング・ファミリ・シリーズ・シェイプから改めて読み込む(または選択する)
5998   \end{quote}
5999   処理が付け加えられている.
6000   もとの「組方向を変更するだけ」の命令は\cs{ltj@@orig@yoko}のように\texttt{ltj@@orig@}が前についた
6001   命令に保存されている.
6002   
6003   \item \cs{jfont},~\cs{tfont},~\cs{DeclareFixedFont}で定義された和文フォントは
6004   その時点で実際にフォントが読み込まれる.すなわち,以下のコードにおいて,
6005   \cs{box0}中の\textbf{JAchar}は\cs{HOGE}でタイプセットされる.
6006 \begin{lstlisting}
6007   % in horizontal direction (\yoko)
6008   \DeclareFixedFont\HOGE{JT3}{gt}{m}{n}{12} % JT3: for vertical direction
6009   \HOGE
6010   \setbox0=\hbox{\tate あいう}
6011 \end{lstlisting}
6012   \end{itemize}
6013 %</ja>
6014
6015 %<en>\subsection{Patch for NFSS2}
6016 %<ja>\subsection{NFSS2へのパッチ}
6017 \label{ssec:nfsspat}
6018
6019 %<*en>
6020 Japanese patch for NFSS2 in \LuaTeX-ja
6021 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
6022 We will describe
6023 commands which are not described in Subsection~\ref{ssec:chgfnt}.
6024 %</en>
6025 %<*ja>
6026 \LuaTeX-jaのNFSS2への日本語パッチは
6027 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
6028 和文エンコーディングの管理等をLuaで書きなおしたものである.
6029 ここでは\ref{ssec:chgfnt}節で述べていなかった命令について
6030 記述しておく.
6031 %</ja>
6032
6033 \begin{cslist}%
6034 \item[\normalfont\bfseries %
6035 %<ja>追加の長さ変数達
6036 %<en>additonal dimensions
6037 ]
6038 %<*en>
6039 Like \pLaTeXe, \LuaTeX-ja defines the following dimensions
6040 for information of current Japanese font:
6041 %</en>
6042 %<*ja>
6043 \pLaTeXe と同様に,\LuaTeX-jaは「現在の和文フォントの情報」を格納する長さ変数
6044 %</ja>
6045 \begin{quote}
6046  \cs{cht}~(height), \cs{cdp}~(depth), \cs{cHT}~(sum of former two),\\
6047  \cs{cwd}~(width), \cs{cvs}~(lineskip), \cs{chs}~(equals to \cs{cwd})
6048 \end{quote}
6049 %<en>and its \cs{normalsize} version:
6050 %<ja>と,その \cs{normalsize} 版である
6051 \begin{quote}
6052  \cs{Cht}~(height), \cs{Cdp}~(depth),
6053  \cs{Cwd}~(width), \\\cs{Cvs}~(equals to \cs{baselineskip}),
6054  \cs{Chs}~(equals to \cs{cwd})%
6055 %<en>.
6056 \end{quote}
6057 %<*ja>
6058 を定義している.なお,\cs{cwd} と \cs{zw},また
6059 \cs{cHT} と \cs{zh} は一致しない可能性がある.なぜなら,
6060 \cs{cwd},~\cs{cHT} は「あ」の寸法から決定されるのに対し,
6061 \cs{zw} と \cs{zh} はJFMに指定された値に過ぎないからである.
6062 %</ja>
6063 %<*en>
6064 Note that \cs{cwd}~and~\cs{cHT} may  differ from \cs{zw}~and~\cs{zh}
6065 respectively.
6066 On the one hand the former dimensions are determined from the character ``あ'',
6067 but on the other hand \cs{zw}~and~\cs{zh} are specified by JFM.
6068 %</en>
6069
6070
6071 \item[\cs{DeclareYokoKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
6072 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6073 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6074 \item[\cs{DeclareTateKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
6075
6076 %<*en>
6077 In NFSS2 under \LuaTeX-ja, distinction between alphabetic fonts
6078              and Japanese fonts are only made by their
6079              encodings. For example, encodings OT1 and T1 are encodings for
6080              alphabetic fonts, and Japanese fonts cannot
6081              have these encodings. These command define a new encoding
6082              scheme for Japanese font families.
6083 %</en>
6084 %<*ja>
6085 \LuaTeX-jaのNFSS2においては,欧文フォントと和文フォントは
6086 そのエンコーディングによってのみ区別される.
6087 例えば,OT1とT1のエンコーディングは欧文フォントのエンコーディングであり,
6088 和文フォントはこれらのエンコーディングを持つことはできない.
6089 これらコマンドは横組用・縦組用和文フォントのための新しいエンコーディングを
6090 それぞれ定義する.
6091 %</ja>
6092
6093 \item[\cs{DeclareKanjiEncodingDefaults}\{<text-settings>\}\{<math-settings>\}]
6094 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6095 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6096 \item[\cs{DeclareKanjiSubstitution}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
6097 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6098 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6099 \item[\cs{DeclareErrorKanjiFont}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
6100
6101 %<*en>
6102 The above 3~commands are just the counterparts for \cs{DeclareFontEncodingDefaults} and~others.
6103 %</en>
6104 %<*ja>
6105 上記3つのコマンドはちょうどNFSS2 の \cs{DeclareFontEncodingDefaults} などに対応するものである.
6106 %</ja>
6107
6108 \item[\cs{reDeclareMathAlphabet}\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
6109
6110 % ToDo: en
6111 %<*ja>
6112 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
6113 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>(\cs{mathrm} 等)と,和文数式用フォ
6114              ントファミリ変更の命令<ja-cmd>(\cs{mathmc} 等)の2つを同時に行う命令として
6115              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
6116              <al-cmd>に同じものを指定する,すなわち,<al-cmd>で和文側も変
6117              更させるようにするのが一般的と思われる.
6118
6119 本命令は
6120 \begin{center}\tt
6121 <unified-cmd>\{<arg>\}\quad$\longrightarrow$\quad
6122 (<al-cmd>の1段展開結果)\{<ja-cmd>の1段展開結果)\{<arg>\}\}
6123 \end{center}
6124 と定義を行うので,使用には注意が必要である:
6125 %<en>\vspace{-\medskipamount}
6126 \begin{itemize}
6127 \item <al-cmd>,~<ja-cmd>は既に定義されていなければならない.
6128       \cs{reDeclareMathAlphabet}\\の後に
6129 両命令の内容を再定義しても,<unified-cmd>の内容にそれは反映されない.
6130 \item <al-cmd>,~<ja-cmd>に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
6131 \end{itemize}
6132 %</ja>
6133
6134 \item[\cs{DeclareRelationFont}\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\*
6135   \null\hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
6136 %<*en>
6137 This command sets the ``accompanied'' alphabetic font (given by the latter 4~arguments)
6138 with respect to a Japanese font given by the former 4~arguments.
6139 %</en>
6140 %<*ja>
6141 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントに対して,
6142 そのフォントに対応する「従属欧文」のフォントを後半の4引数により与える.
6143 %</ja>
6144 \item[\cs{SetRelationFont}]
6145 %<*en>
6146 This command is almost same as \cs{DeclareRelationFont}, except that this command does a local
6147 assignment, where \cs{DeclareRelationFont} does a global assignment.
6148 %</en>
6149 %<*ja>
6150 このコマンドは \cs{DeclareRelationFont} とローカルな指定であることを除いて
6151 ほとんど同じである(\cs{DeclareRelationFont} はグローバル).
6152 %</ja>
6153
6154 \item[\cs{userelfont}]
6155 %<*en>
6156 (Only)~at the next call of \cs{selectfont},
6157   change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
6158   font family with respect to current Japanese font family,
6159   which was set by
6160   \cs{DeclareRelationFont} or \cs{SetRelationFont}.
6161
6162   The following is an example of \cs{SetRelationFont} and \cs{userelfont}:
6163 %</en>
6164 %<*ja>
6165 次回(のみ)の\cs{selectfont}の実行時に,現在の欧文フォントのエンコーディング/ファミリ/…… を,
6166 \cs{DeclareRelationFont} か \cs{SetRelationFont} で指定された
6167 現在の和文フォントに対応する「従属欧文」フォントに変更する.
6168
6169   以下に \cs{SetRelationFont} と \cs{userelfont} の例を
6170 紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
6171 Latin Modern Sans Serif (TU/lmss/m/n) に変わっていることがわかる.
6172 %</ja>
6173 \begin{LTXexample}[width=0.3\textwidth]
6174 \makeatletter
6175 \SetRelationFont{JY3}{\k@family}{m}{n}{TU}{lmss}{m}{n}
6176   % \k@family: current Japanese font family
6177 \userelfont\selectfont あいうabc
6178 \end{LTXexample}
6179
6180 \item[\cs{adjustbaseline}]
6181 %<*en>
6182 In \pLaTeXe, \cs{adjustbaseline} sets \cs{tbaselineshift}
6183 to match the vertical center of ``M'' and that of ``あ''  in vertical typesetting:
6184 \[
6185 \text{\cs{tbaselineshift}} \leftarrow
6186 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
6187   + d_{\text{あ}} - d_{\text{M}},
6188 \]
6189 where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively.
6190 In \LuaTeX-ja, this \cs{adjustbaseline} does similar task, namely setting the
6191              \Param{talbaselineshift} parameter.
6192 If the \LaTeX\ is 2015/10/01 release or later, \LuaTeX-ja use a Japanese
6193 character whose character class is zero,  instead of `あ'.
6194 %</en>
6195 %<*ja>
6196 \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「あ」の中心線を一致させるために,
6197 \cs{tbaselineshift} を設定する役割を持っていた:
6198 \[
6199 \text{\cs{tbaselineshift}} \leftarrow
6200 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
6201   + d_{\text{あ}} - d_{\text{M}},
6202 \]
6203 ここで,$h_{a}$,~$d_{a}$はそれぞれ「$a$」の高さ・深さを表す.
6204 \LuaTeX-jaにおいても\cs{adjustbaseline} は同様に\Param{talbaselineshift}パラメータの調整処
6205              理を行っている.
6206
6207 同時に,これも\pLaTeXe の \cs{adjustbaseline} で同様の処理が行われていたが,
6208 「漢」の寸法を元に(本節の最初に述べた,小文字で始まる)\cs{cht}, \cs{cwd}
6209 といった長さ変数を設定する.
6210
6211 なお,\LaTeX が2015/10/01版以降の場合は,「あ」「漢」の代わりに
6212 「文字クラス0の和文文字」を用いる.
6213 %</ja>
6214
6215 \item[\cs{fontfamily}\{<family>\}]
6216 %<*en>
6217 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
6218 to <family>. See Subsection~\ref{ssec:fontfamilycmd} for detail.
6219 %</en>
6220 %<*ja>
6221 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
6222 和文,\emph{もしくは両方})を<family>に変更する.詳細は\ref{ssec:fontfamilycmd}節を参照すること.
6223 %</ja>
6224
6225
6226 \begin{figure}[!tb]
6227 \begin{LTXexample}[pos=b]
6228 \DeclareKanjiFamily{JY3}{edm}{}
6229 \DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
6230 \DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
6231 \DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
6232 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
6233 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
6234 {\kanjifamily{edm}\selectfont
6235 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
6236 \end{LTXexample}
6237 %<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
6238 %<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
6239 \label{fig:altkanji}
6240 \end{figure}
6241
6242 \item[\cs{DeclareAlternateKanjiFont}\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
6243   \null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
6244 %<*ja>
6245 \ref{ssec:altfont}節の\
6246 \cs{ltjdeclarealtfont} と同様に,前半の4引数の
6247 和文フォント(基底フォント)のうち<range>中の文字を
6248 第5から第8引数の和文フォントを使って組むように指示する.
6249 使用例を図\nobreak\ref{fig:altkanji}に載せた.
6250
6251 \begin{itemize}
6252  \item
6253 \cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
6254              ないといけない(その代わり即時発効)であったが,
6255 \cs{DeclareAlternateKanjiFont} の設定が
6256 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
6257 あるいは(これらを含むが)\cs{selectfont} が実行された時である.
6258  \item
6259 段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
6260 <range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
6261 と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
6262 \end{itemize}%
6263 %</ja>
6264 %<*en>
6265 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec:altfont}),
6266 characters in <range> of the Japanese font (we say the \emph{base font})
6267 which specified by first 4 arguments are typeset
6268 by the Japanese font which specified by fifth to eighth arguments
6269 (we say the \emph{alternate font}).
6270 An example is shown in \autoref{fig:altkanji}.
6271
6272 \begin{itemize}
6273  \item
6274 In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
6275 But this \cs{DeclareAlternateKanjiFont} is not so.
6276 In other words, \cs{DeclareAlternateKanjiFont} is effective only after
6277 current Japanese font is changed, or only after \cs{selectfont} is executed.
6278  \item \dots
6279 \end{itemize}%
6280 \vspace{-\medskipamount}
6281 %</en>
6282 \end{cslist}
6283
6284
6285 %<*en>
6286 Furthermore, \LuaTeX-ja applies patches which enables NFSS2 commands,
6287 such~as \cs{DeclareSymbolFont}~and~\cs{SetSymbolFont}, to specify
6288 Japanee fonts as math fonts.
6289
6290 Specifying \texttt{disablejfam} option in \cs{usepackage} prevents
6291 applying these patches.
6292 Hence one cannot write Japanese Characters in math mode directly
6293 if \texttt{disablejfam} option is specified.
6294 The code below does not work either:
6295 \begin{lstlisting}
6296 \DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
6297 \DeclareSymbolFontAlphabet{\mathmc}{mincho}
6298 \end{lstlisting}
6299 %</en>
6300 %<*ja>
6301 この他にも,標準では
6302 \cs{DeclareSymbolFont}, \cs{SetSymbolFont} などの命令で
6303 (NFSS2の枠組みで)数式フォントとして日本語フォントを使えるようにするためのパッチを当てている.
6304
6305 一方,\texttt{disablejfam}オプション指定時には,これらのパッチを当てないので
6306 \begin{lstlisting}
6307 \DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
6308 \DeclareSymbolFontAlphabet{\mathmc}{mincho}
6309 \end{lstlisting}
6310 のように設定しても,数式モード中に直に日本語を記述することはできない.
6311 \verb|$\mathmc{あ}$| のように \cs{mathmc} で囲んでもできない.
6312 %</ja>
6313
6314 %<en>\subsection{Detail of \cs{fontfamily} command}
6315 %<ja>\subsection{\cs{fontfamily}コマンドの詳細}
6316 \label{ssec:fontfamilycmd}
6317 %<*en>
6318 In this subsection, we describe when \cs{fontfamily}<family> changes current
6319 Japanese/alphabetic font family. Basically, current Japanese fotn family is changed to
6320 <family> if it is recognized as a Japanese font family, and similar with alphabetic font
6321 family. There is a case that current Japanese/alphabetic font family are both changed to
6322 <family>, and another case that <family> isn't recognized as a Japanese/alphabetic font
6323 family either.
6324
6325 \paragraph{Recognition as Japanese font family}
6326 First, Whether Japanese font family will be changed is determined in following order.
6327 This order is very similar to \cs{fontfamily} in \pLaTeXe, but we re-implemented in Lua.
6328 We use an auxiliary list~$N_{\mathrm{J}}$.
6329 %</en>
6330 %<*ja>
6331 本節では,\cs{fontfamily}<family> がいつ和文/欧文フォントファミリを変更するかについて解説
6332 する.基本的には,<family>が和文フォントファミリだと認識されれば和文側が,欧文フォントファ
6333 ミリだと認識されれば欧文側が変更される.どちらとも認識されれば和文・欧文の両方が変わるこ
6334 とになるし,当然どちらとも認識されないこともある.
6335
6336 \paragraph{和文フォントファミリとしての認識}
6337 まず,<family>が和文フォントファミリとして認識されるかは以下の順序で決定される.
6338 これは\pLaTeXe の \cs{fontfamily} にとても似ているが,ここではLuaによって実装している.
6339 補助的に「和文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{J}}$を用いる.
6340 %</ja>
6341 \begin{enumerate}
6342 %<*en>
6343 \item If the family~<family> has been defined already by \cs{DeclareKanjiFamily},
6344       <family> is recognized as a  Japanese font family.
6345       Note that <family> need not be defined under \emph{current} Japanese font encoding.
6346 %</en>
6347 %<*ja>
6348 \item ファミリ<family>が既に \cs{DeclareKanjiFamily} によって定義されている場合,
6349       <family>は和文フォントファミリであると認識される.
6350       ここで,<family>は現在の和文フォントエンコーディングで定義されていなくてもよい.
6351 %</ja>
6352 %<*en>
6353 \item If the family~<family> has been listed in a list~$N_{\mathrm{J}}$, this means
6354       that <family> is not a Japanese font family.
6355 %</en>
6356 %<*ja>
6357 \item ファミリ<family>がリスト$N_{\mathrm{J}}$に既に含まれていれば,それは
6358       <family>が和文フォントファミリではないことを意味する.
6359 %</ja>
6360 %<*en>
6361 \item If the \Pkg{luatexja-fontspec} package is loaded, we stop here, and <family> is not
6362       recognized as a Japanese font family.
6363
6364       If the \Pkg{luatexja-fontspec} package is \emph{not} loaded,
6365 now \LuaTeX-ja looks whether there exists a Japanese font encoding~<enc> such that
6366       a font definition named \texttt{<enc><family>.fd} (the file name is
6367       all lowercase) exists. If so, <family> is recognized as a  Japanese font family (the font definition file won't be loaded here).
6368       If not, <family> is not a Japanese font family, and
6369       <family> is appended to the list~$N_{\mathrm{J}}$.
6370 %</en>
6371 %<*ja>
6372 \item もし\Pkg{luatexja-fontspec}パッケージが読み込まれていれば,ここで終了であり,
6373 <family>は和文フォントファミリとして認識されないことになる.
6374
6375 もし\Pkg{luatexja-fontspec}パッケージが読み込まれていなければ,和文エンコーディング<enc>で
6376 フォント定義ファイル\texttt{<enc><family>.fd}(ファイル名は全て小文字)が存在するようなも
6377       のがあるかどうかを調べる.
6378 存在すれば,<family>は和文フォントファミリと認識される(フォント定義ファイルは読み込まれな
6379       い).
6380 存在しなければ,<family>は和文フォントファミリでないと認識され,リスト$N_{\mathrm{J}}$に<family>を追加することでそれを記憶する.
6381
6382 %</ja>
6383 \end{enumerate}
6384
6385 %<*en>
6386 \paragraph{Recognition as alphabetic font family}
6387 Next, whether alphabetic font family will be changed is determined in following order.
6388 We use auxiliary lists $F_{\mathrm{A}}$~and~$N_{\mathrm{A}}$,
6389 %</en>
6390 %<*ja>
6391 \paragraph{欧文フォントファミリとしての認識}
6392 同様に,<family>が和文フォントファミリとして認識されるかは以下の順序で決定される.
6393 補助的に「欧文フォントファミリと既に認識された」ファミリのリスト$F_{\textrm{A}}$と,
6394 「欧文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{A}}$を用いる.
6395 %</ja>
6396
6397 \begin{enumerate}
6398 %<*en>
6399 \item If the family~<family> has been listed in a list~$F_{\mathrm{A}}$,
6400       <family> is recognized as an alphabetic font family.
6401 %</en>
6402 %<*ja>
6403 \item ファミリ<family>がリスト$F_{\mathrm{A}}$に既に含まれていれば,
6404       <family>は欧文フォントファミリと認識される.
6405 %</ja>
6406 %<*en>
6407 \item If the family~<family> has been listed in a list~$N_{\mathrm{A}}$, this means
6408       that <family> is not  an alphabetic font family.
6409 %</en>
6410 %<*ja>
6411 \item ファミリ<family>がリスト$N_{\mathrm{A}}$に既に含まれていれば,それは
6412       <family>が欧文フォントファミリではないことを意味する.
6413 %</ja>
6414 %<*en>
6415 \item If there exists an alphabetic font encoding such that the family~<family> has been
6416       defined under it, <family> is recognized as an alphabetic font family, and
6417       to memorize this, <family> is appended to the list~$F_{\mathrm{A}}$.
6418 %</en>
6419 %<*ja>
6420 \item ある欧文フォントエンコーディング下でファミリ<family>が定義されていれば,
6421       <family>は欧文フォントファミリと認識され,リスト$F_{\mathrm{A}}$に<family>を追加することでこのことを記憶する.
6422 %</ja>
6423 %<*en>
6424 \item Now \LuaTeX-ja looks whether there exists an alphabetic font encoding~<enc> such that
6425       a font definition named \texttt{<enc><family>.fd} (the file name is
6426       all lowercase) exists. If so, current alphabetic font family will be changed to
6427       <family>~(the font definition file won't be loaded here).
6428       If not, current alphabetic font family won't be changed, and
6429       <family> is appended to the list~$N_{\mathrm{A}}$.
6430 %</en>
6431 %<*ja>
6432 \item 最終段階では,欧文エンコーディング<enc>で
6433 フォント定義ファイル\texttt{<enc><family>.fd}(ファイル名は全て小文字)が存在するようなも
6434       のがあるかどうかを調べる.
6435 存在すれば,<family>は欧文フォントファミリと認識される(フォント定義ファイルは読み込まれない).
6436 存在しなければ,<family>は欧文フォントファミリと認識されないので,リスト$N_{\mathrm{A}}$に
6437       <family>を追加してそのことを記憶する.
6438 %</ja>
6439 \end{enumerate}
6440
6441 %<*en>
6442 Also, each call of \cs{DeclareFontFamily} \emph{after} loading of \LuaTeX-ja makes
6443 the second argument (family) is appended to the list~$F_{\mathrm{A}}$.
6444 %</en>
6445 %<*ja>
6446 また,\cs{DeclareFontFamily}が\LuaTeX-jaの読み込み後に実行された場合は,
6447 第2引数(ファミリ名)が自動的に$F_{\mathrm{A}}$に追加される.
6448 %</ja>
6449
6450 %<*en>
6451 The above order is very similar to \cs{fontfamily} in \pLaTeXe, but more complicated (clause~3.).
6452 This is because  \pLaTeXe\ is a \emph{format} however \LuaTeX-ja is not,
6453 hence \LuaTeX-ja does not know calls of \cs{DeclareFontFamily} \emph{before} itself is
6454 loaded.
6455 %</en>
6456 %<*ja>
6457 以上の方針は\pLaTeXe における \cs{fontfamily} にやはり類似しているが,3.が加わり若干複雑になっている.
6458 それは\pLaTeXe がフォーマットであるのに対し\LuaTeX-jaはそうでないため,
6459 \LuaTeX-jaは自身が読み込まれる前にどういう\cs{DeclareFontFamily}の呼び出しがあったか
6460 把握できないからである.
6461 %</ja>
6462
6463 %<en>\paragraph{Remarks}
6464 %<ja>\paragraph{注意}
6465 %<*en>
6466 Of course, there is a case that <family> is not recognized as a Japanese font family,  nor
6467 an alphabetic font family.
6468 In this case, \LuaTeX-ja treats ``the argument <family> is wrong'', so
6469 set both current alphabetic and Japanese font family to <family>,
6470 to use the default family for font substitution.
6471 %</en>
6472 %<*ja>
6473 さて,引数によっては,「和文フォントファミリとも欧文フォントファミリも認識されなかった」
6474 という事態もあり得る.
6475   この場合,引数<family>は不正だった,ということになるので,
6476 和文・欧文の両方のフォントファミリを<family>に設定し,代用フォントが使われるに任せることにする.
6477 %</ja>
6478
6479 %<*en>
6480 \subsection{Notes on \cs{DeclareTextSymbol}}
6481 From \LaTeX~2017/01/01, the standard encoding of \LuaLaTeX\ is changed to the \texttt{TU}
6482 encoding. This menas that symbols defined by \texttt{T1}~and~\texttt{TS1} encodings can be used
6483 without loading any package. To produces these symbols in alphabetic fonts in \LuaTeX-ja,
6484 \LuaTeX-ja patches \cs{DeclareTextSymbol}, and reloads \texttt{tuenc.def}.
6485
6486 Under original definition of \cs{DeclareTextSymbol},
6487 internal commands which is defined by \cs{DeclareTextSymbol} (such as \cs{T1\cs{textquotedblleft}})
6488 are \textit{chardef} tokens. However, this no longer holds in \LuaTeX-ja;
6489 for example, the meaning of \cs{TU\cs{textquotedblleft}} is \cs{ltjalchar8220\ltjalchar"2423 }.
6490 %</en>
6491 %<*ja>
6492 \subsection{\cs{DeclareTextSymbol}使用時の注意}
6493 \LaTeX~(2017/01/01)以降では,\texttt{TU}エンコーディングが標準となり,特に何もしなくても
6494 \texttt{T1},~\texttt{TS1}エンコーディングで定義されていた記号類が
6495 使えるようになった.\LuaTeX-jaではこれらの命令によって記号が欧文フォントで出力されるようにするため,
6496 \cs{DeclareTextSymbol}命令を改変し,そして\texttt{TU}エンコーディングの定義である
6497 \texttt{tuenc.def}を再読込している.
6498
6499 従来は \cs{DeclareTextSymbol} で内部的に定義された\cs{T1\cs{textquotedblleft}}といった命令は
6500 \textit{chardef}トークンであった.しかし前段落で述べた改変によりもはやそうではなくなっており,例えば
6501 \cs{TU\cs{textquotedblleft}}は \cs{ltjalchar8220\ltjalchar"2423 } という定義になっている.%"
6502 %</ja>
6503
6504 \begin{table}[t]
6505   \centering\small
6506   \caption{strut}\label{tab:strutbox}\medskip
6507   \begin{tabular}{llcccl}
6508     \toprule
6509     \textbf{box}&\textbf{direction}&\textbf{width}&\textbf{height}&\textbf{depth}
6510     &\textbf{user command}\\
6511     \midrule
6512   \cs{ystrutbox}&yoko&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{ystrut}\\\midrule
6513   \cs{tstrutbox}&tate, utod&0&0.5\cs{baselineskip}&0.5\cs{baselineskip}&\cs{tstrut}\\\midrule
6514   \cs{dstrutbox}&dtou&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{dstrut}\\\midrule
6515   \cs{zstrutbox}&---&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{zstrut}\\\bottomrule
6516   \end{tabular}
6517 \end{table}
6518 %<*en>
6519 \subsection{\cs{strutbox}}
6520 As \pLaTeX~(2017/04/08 or later), \cs{strutbox} is \emph{a macro} which is expanded to one of
6521 \cs{ystrutbox},~\cs{tstrutbox},~and~\cs{dstrutbox}
6522 (all of them are shown in \autoref{tab:strutbox}), according to the current direction.
6523 Similarly, \cs{strut} now uses one of these boxes.
6524 %</en>
6525 %<*ja>
6526 \subsection{\cs{strutbox}}
6527 \pLaTeX~2017/04/08以降と同じように,
6528 \cs{strutbox}は現在の組方向によって\cs{ystrutbox}, \cs{tstrutbox}, \cs{dstrutbox}の
6529 いずれかに展開される\emph{マクロ}となっている(これらについては\autoref{tab:strutbox}参照).
6530 同様に\cs{strut}もこの3\nobreak ボックスのいずれかを組方向によって使い分けるようになっている.
6531
6532 \cs{zstrutbox}はutod方向(\pTeX でいう縦数式ディレクション)で使われる支柱ボックスであるが,
6533 実際に使われるのは\cs{zstrut}が明示的に発行された時,そして
6534 \Pkg{lltjext}パッケージで追加される組方向指定で \texttt{<u>} を指定した時,および
6535 周囲が縦組の状況で \texttt{<z>} を指定した時に限られている.
6536 %</ja>
6537
6538 %<*en>
6539 \section{Addon packages}
6540 \LuaTeX-ja has several addon packages.
6541 These addons are written as \LaTeX\ packages, but
6542 \Pkg{luatexja-otf} and~\Pkg{luatexja-adjust} can be loaded in plain \LuaTeX\
6543 by \cs{input}.
6544 %</en>
6545 %<*ja>
6546 \section{拡張パッケージ}
6547 \LuaTeX-jaには(動作には必須ではないが)自由に読み込める拡張が付属している.
6548 これらは\LaTeX のパッケージとして制作しているが,
6549 \Pkg{luatexja-otf}と\Pkg{luatexja-adjust}についてはplain \LuaTeX でも\
6550 \cs{input} で読み込み可能である.
6551 %</ja>
6552 \subsection{\Pkg{luatexja-fontspec}}
6553 \label{ssec:fontspec2}
6554 %<*en>
6555 As described in Subsection~\ref{ssec:fontspec}, this optional package
6556 provides the counterparts for several commands defined in the
6557 \Pkg{fontspec} package (requires \Pkg{fontspec}~v2.4).
6558 In addition to OpenType font features in the original \Pkg{fontspec},
6559 the following ``font features'' specifications are allowed for
6560 the commands of Japanese version:
6561 %</en>
6562 %<*ja>
6563 \ref{ssec:fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}%
6564 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
6565
6566 \Pkg{fontspec}パッケージで指定可能な各種OpenType機能に加えて,和文版のコマンドには
6567 以下の「フォント機能」を指定することができる:
6568 %</ja>
6569
6570
6571 \begin{cslist}
6572 \item[CID=<name>\textrm{, }JFM=<name>\textrm{, }JFM-var=<name>]
6573
6574 %<*en>
6575 These 3 keys correspond to \texttt{cid}, \texttt{jfm} and
6576 \texttt{jfmvar} keys for \cs{jfont}~and~\cs{tfont} respectively.
6577 See Subsections~\ref{ssec:jfont} and \ref{ssec:psft} for details
6578  of \texttt{cid}, \texttt{jfm} and
6579 \texttt{jfmvar} keys.
6580
6581 The \texttt{CID} key is effective only when with \texttt{NoEmbed}
6582 described below. The same JFM cannot be used in both horizontal Japanese fonts and
6583              vertical Japanese fonts, hence the \texttt{JFM} key
6584 will be actually used in \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
6585 %</en>
6586 %<*ja>
6587 これら3つのキーはそれぞれ \cs{jfont},~\cs{tfont}に対する
6588 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
6589 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec:jfont}節
6590              と\ref{ssec:psft}節を参照.
6591
6592 \texttt{CID} キーは下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
6593 また,横組用JFMと縦組用JFMは共用できないため,実際に \texttt{JFM} キーを用いる際は
6594 後に述べる\ \texttt{YokoFeatures} キーや \texttt{TateFeatures}\ の中で用いる
6595 ことになる.
6596 %</ja>
6597
6598 \item[NoEmbed]
6599 %<*en>
6600 By specifying this key, one can use ``name-only'' Japanese font which
6601 will not be embedded in the output PDF file. See Subsection~\ref{ssec:psft}.
6602 %</en>
6603 %<*ja>
6604 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
6605 できる.\ref{ssec:psft}節を参照.
6606 %</ja>
6607
6608 \begin{figure}[!tb]
6609 \begin{LTXexample}[width=0.25\textwidth]
6610 \jfontspec[
6611   YokoFeatures={Color=007F00}, TateFeatures={Color=00007F},
6612   TateFont=KozGoPr6N-Regular
6613 ]{KozMinPr6N-Regular}
6614 \hbox{\yoko 横組のテスト}\hbox{\tate 縦組のテスト}
6615 \addjfontfeatures{Color=FF0000}
6616 \hbox{\yoko 横組}\hbox{\tate 縦組}
6617 \end{LTXexample}
6618 %<ja>\caption{\texttt{TateFeatures} 等の使用例}
6619 %<en>\caption{An example of \texttt{TateFeatures} etc.}
6620 \label{fig:yokotate-fontspec}
6621 \end{figure}
6622
6623 \item[Kanjiskip=<bool>]
6624 %<*ja>
6625 \pageref{pg:ltjksp}ページで説明した \verb+\jfont+ 中での \texttt{ltjksp} 指定と
6626 同一の効力を持ち,
6627 JFM中における \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
6628 \texttt{kanjiskip\_shrink}キー(\pageref{pg:ksp_nat}ページ)の有効/無効を切り替える.
6629 標準値は \texttt{true} である.
6630 %</ja>
6631
6632 \item[TateFeatures=\{<features>\}\textrm{, }TateFont=<font>]
6633 %<*en>
6634 The \texttt{TateFeatures} key specifies font features which are only turned~on in
6635 vertical writing, such as \texttt{Style=VerticalKana}~(\texttt{vkna} feature).
6636 Similarly, the \texttt{TateFont} key specifies the Japanese font which will be used only
6637              in vertical writing.
6638 A demonstrarion is shown in \autoref{fig:yokotate-fontspec}.
6639 %</en>
6640 %<*ja>
6641 縦組において使用されるフォントや,縦組においてのみ適用されるフォント機能達を
6642 指定する.使用例は\autoref{fig:yokotate-fontspec}参照.
6643 %</ja>
6644
6645 \item[YokoFeatures=\{<features>\}]
6646 %<*en>
6647 The \texttt{YokoFeatures} key specifies font features which are only turned~on in
6648 horizontal writing,.
6649 A demonstrarion is shown in \autoref{fig:yokotate-fontspec}.
6650 %</en>
6651 %<*ja>
6652 同様に,横組においてのみ適用されるフォント機能達を
6653 指定する.使用例は\autoref{fig:yokotate-fontspec}参照.
6654 %</ja>
6655
6656
6657 \begin{figure}[!tb]
6658 \begin{LTXexample}[pos=b]
6659 \jfontspec[
6660   AltFont={
6661     {Range="4E00-"67FF, Color=007F00},
6662     {Range="6800-"9EFF, Color=0000FF},
6663     {Range="3040-"306F, Font=KozGoPr6N-Regular},
6664   }
6665 ]{KozMinPr6N-Regular}
6666 日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
6667 諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
6668 \end{LTXexample}
6669 %<ja>\caption{\texttt{AltFont} の使用例}
6670 %<en>\caption{An example of \texttt{AltFont}}
6671 \label{fig:altkanji-fontspec}
6672 \end{figure}
6673
6674 \item[AltFont]
6675
6676 %<*en>
6677 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec:altfont}) and
6678 \cs{DeclareAlternateKanjiFont}~(Subsection~\ref{ssec:nfsspat}),
6679 with this key, one can typeset some Japanese characters
6680 by a different font and/or using different features.
6681 The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
6682 as the following:
6683 %</en>
6684 %<*ja>
6685 \ref{ssec:altfont}節の \cs{ltjdeclarealtfont} や,
6686 \ref{ssec:nfsspat}節の \cs{DeclareAlternateKanjiFont} と同様に,
6687 このキーを用いると一部の文字を異なったフォントや機能たちを使って組むことができる.
6688 \texttt{AltFont} キーに指定する値は,次のように二重のコンマ区切りリストである:
6689 %</ja>
6690 \begin{lstlisting}[escapechar=\#]
6691 AltFont = {
6692   ...
6693   { Range=#\LARG range>#, #\LARG features>#},
6694   { Range=#\LARG range>#, Font=#\LARG font~name>#, #\LARG features># },
6695   { Range=#\LARG range>#, Font=#\LARG font~name># },
6696   ...
6697 }
6698 \end{lstlisting}
6699 %<*en>
6700 Each sublist should have the \texttt{Range} key
6701 (sublist which does not contain \texttt{Range} key is simply ignored).
6702 A demonstrarion is shown in \autoref{fig:altkanji-fontspec}.
6703 %</en>
6704 %<*ja>
6705 各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
6706 単純に無視される).指定例は\autoref{fig:altkanji-fontspec}に示した.
6707 %</ja>
6708 \end{cslist}
6709
6710 %<*ja>
6711 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
6712 \texttt{<ja-enc><family>.fd}は全く参照されなくなる.
6713 %</ja>
6714
6715
6716 %<*en>
6717 \paragraph{Remark on \texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} keys}
6718 \leavevmode\par
6719 In \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures} keys,
6720 one cannot specify per-shape settings such as \texttt{BoldFeatures}.
6721 For example,
6722 \begin{lstlisting}
6723 AltFont = {
6724   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6725     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6726 }
6727 \end{lstlisting}
6728 does \emph{not} work. Instead, one have to write
6729 \begin{lstlisting}
6730 UprightFeatures = {
6731   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6732 },
6733 BoldFeatures = {
6734   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6735 }
6736 \end{lstlisting}
6737
6738 On the other hand, \texttt{YokoFeatures}, \texttt{TateFeatures} and  \texttt{TateFont}
6739 keys can be specified in each list in the \texttt{AltFont} key. Also,
6740 one can specify \texttt{AltFont} inside \texttt{YokoFeatures},~\texttt{TateFeatures}.
6741
6742 Note that features which are specified in \texttt{YokoFeatures}~and~\texttt{TateFeatures}
6743 are always interpreted \emph{after} other ``direction-independent'' features.
6744 This explains why \cs{addjfontfeatures} at~line~6 in~\autoref{fig:yokotate-fontspec}
6745 has no effect, because a color specification is already done in
6746 \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
6747 %</en>
6748 %<*ja>
6749 \paragraph{\texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} 等の制限}
6750 \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures}の各キーは
6751 シェイプ別に指定されるべきものであり,
6752 内部では \texttt{BoldFeatures} などのシェイプ別の指定は行うことが出来ない.
6753 例えば.
6754 \begin{lstlisting}
6755 AltFont = {
6756   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6757     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6758 }
6759 \end{lstlisting}
6760 のように指定することは出来ず,
6761 \begin{lstlisting}
6762 UprightFeatures = {
6763   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6764 },
6765 BoldFeatures = {
6766   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6767 }
6768 \end{lstlisting}
6769 のように指定しなければならない.
6770
6771 一方,\texttt{AltFont} キー内の各リストでは
6772 \ \texttt{YokoFeatures},~\texttt{TateFeatures} 及び \texttt{TateFont} キーを
6773 指定することは可能であり.また\ \texttt{YokoFeatures},~\texttt{TateFeatures} キーの
6774 中身に \texttt{AltFont} を指定することができる.
6775
6776 また,\autoref{fig:yokotate-fontspec}後半部では6行目の色の指定が効かず,
6777 2行目で指定した\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による色の指定が有効になっ
6778 たままである.これは\emph{\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による
6779 OpenType機能指定は
6780 組方向に依存しないOpenType機能の指定より後に解釈される}からである.
6781
6782 %</ja>
6783
6784
6785 \subsection{\Pkg{luatexja-otf}}
6786 \label{ssec:ltjotf}
6787 %<*en>
6788 This optional package supports typesetting glyphs
6789 by specifying a CID number.
6790 The package \Pkg{luatexja-otf} offers the following 2~low-level
6791 commands:
6792 %</en>
6793 %<*ja>
6794 この追加パッケージはCID番号による文字の出力をサポートする.
6795 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
6796 %</ja>
6797 \begin{cslist}
6798 \item[\cs{CID}\{<number>\}]
6799 %<*en>
6800 Typeset a glyph whose CID number is <number>.
6801 If the Japanese font is neither Adobe-Japan1,~Adobe-GB1, Adobe-CNS1,~nor~Adobe-Korea1 CID-keyed font,
6802 \LuaTeX-ja treats that <number> is a CID number of Adobe-Japan1 character collection,
6803 and tries to typeset a ``most suitable glyph''.
6804 %</en>
6805 %<*ja>
6806 CID番号が<number>の文字を出力する.
6807 もし現在の和文フォントがAdobe-Japan1,~Adobe-GB1, Adobe-CNS1,~Adobe-Korea1の
6808   いずれのCID-keyed fontでもない場合,<number>はAdobe-Japan1のCID番号であると解釈し
6809   「適切なグリフ」\footnote{%
6810   例えばフォントにIVDコレクションAdobe-Japan1が含まれていれば,その情報を用いて
6811   グリフを選択する.
6812 }を出力する.
6813 %</ja>
6814
6815 \item[\cs{UTF}\{<hex\_number>\}]
6816 %<*en>
6817 Typeset a character whose character code is <hex\_number> (in hexadecimal).
6818 This command is similar to \verb+\char"+<hex\_number>,\ %"
6819 but please remind remarks below.
6820 %</en>
6821 %<*ja>
6822 文字コードが(16進で)<hex\_number>の文字を出力する.
6823 このコマンドは \verb+\char"+<hex\_number>と似ているが,下の注意を参照すること.%"
6824 %</ja>
6825 \end{cslist}
6826
6827 %<*ja>
6828 このパッケージは,マクロ集 \texttt{luatexja-ajmacros.sty}\footnote{\Pkg{otf}パッケージ付属の井上浩一氏によるマクロ集
6829 \texttt{ajmacros.sty} に対して
6830 漢字コードをUTF-8にしたり,plain \LuaTeX でも利用可能にするという
6831 修正を加えたものである.}\ も自動的に読み込む.
6832 \texttt{luatexja-ajmacros.sty} は,
6833 そのため,\Pkg{luatexja-otf} を読みこめば \texttt{ajmacros.sty} マクロ集にある \cs{aj半角} などのマクロもそのまま使うことができる.
6834 %</ja>
6835 %<*en>
6836 This package automatically loads \texttt{luatexja-ajmacros.sty}, which is slightly
6837 modified version of \texttt{ajmacros.sty}\footnote{Useful macros by iNOUE Koich!, for the
6838 \Pkg{japanese-otf} package.}.
6839 Hence one can use macros which sre defined in \texttt{ajmacros.sty}, such as~\cs{aj半角}.
6840 %</en>
6841
6842 %<en>\paragraph{Remarks}
6843 %<ja>\paragraph{注意}
6844 %<*en>
6845 Characters by \cs{CID} and \cs{UTF} commands are different from
6846 ordinary characters in the following points:
6847 %</en>
6848 %<*ja>
6849 \cs{CID} と \cs{UTF} コマンドによって出力される文字は
6850 以下の点で通常の文字と異なる:
6851 %</ja>
6852 \begin{itemize}
6853 %<*en>
6854 \item Always treated as \textbf{JAchar}s.
6855 %</en>
6856 %<*ja>
6857 \item 常に\textbf{JAchar}として扱われる.
6858 %</ja>
6859 %<*en>
6860 \item Processing codes for supporting OpenType features (\textit{e.g.},
6861       glyph replacement and kerning) by the \Pkg{luaotfload} package
6862       is not performed to these characters.
6863 %</en>
6864 %<*ja>
6865 \item OpenType機能(例えばグリフ置換やカーニング)をサポートするための
6866   \Pkg{luaotfload}パッケージのコードはこれらの文字には働かない.
6867 %</ja>
6868 \end{itemize}
6869
6870 %<en>\paragraph{Additional syntax of JFM}
6871 %<ja>\paragraph{JFMへの記法の追加}
6872
6873 %<*en>
6874 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
6875 chars} table in JFM now allows a string in the form
6876 \verb+'AJ1-xxx'+, which stands for the character
6877 whose CID number in Adobe-Japan1 is \verb+xxx+.
6878
6879 This extended notation is used in the standard JFM \texttt{jfm-ujis.lua}
6880 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
6881 %</en>
6882 %<*ja>
6883 \Pkg{luatexja-otf}パッケージを読み込むと,
6884 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
6885 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
6886
6887 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
6888 正しく半角幅で組むために利用されている.
6889 %</ja>
6890
6891 \subsection{\Pkg{luatexja-adjust}}
6892 \label{ssec:adj}
6893 \begin{figure}[t]
6894 \def\sq{%
6895   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6896    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6897   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6898 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6899   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6900   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6901 \newbox\gridbox
6902 \def\outbox#1{{\Large%
6903   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
6904   \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}%
6905   \hbox{\textcolor{cyan}{\copy\gridbox}\hskip-20\zw%
6906   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
6907 }}
6908
6909 {\centering
6910 \begin{tabular}{lc}
6911 \toprule
6912 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
6913 without priority&%
6914 \ltjdisableadjust
6915 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
6916 \ltjenableadjust\\
6917 with priority&%
6918 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
6919 %<en>\ltjdisableadjust
6920 \\
6921 \bottomrule
6922 \end{tabular}\par}
6923 \medskip
6924
6925 \fakefn{}{The value of
6926 \Param{kanjiskip} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
6927 for making the difference obvious.}
6928 %<ja>\caption{行長調整}\label{fig:adj}
6929 %<en>\caption{Line adjustment}\label{fig:adj}
6930 \end{figure}
6931
6932
6933 %<*en>
6934 (see Japanese version of this manual)
6935 %</en>
6936 %<*ja>
6937 この追加パッケージは以下の機能を提供する.詳細な仕様については\ref{sec-adjspec}章を参照してほしい.
6938 \begin{description}
6939  \item[行末文字の位置調整]
6940   \pTeX では,(是非はともかく)「行末の読点はぶら下げか二分取りか全角取りのいずれかに」のように
6941   行末文字と実際の行末の位置関係を2通り以上にすることは面倒であった.
6942   和文フォントメトリックだけでは「常に行末の読点はぶら下げ」といったことしかできず,
6943   前の文に書いたことを実現するには
6944   \begin{lstlisting}
6945 \def\。{%
6946   \penalty10000 % 禁則ペナルティ
6947   \hbox to0pt{。\hss}\penalty0 % ぶら下げの場合
6948   \kern.5\zw\penalty0 % 二分取りの場合
6949   \kern.5\zw\penalty0 % 全角取りの場合
6950 }
6951 \end{lstlisting}
6952   のような命令を定義し,文中の全ての句点を \lstinline+\。+ で書くことが必要だった.
6953
6954   \Pkg{luatexja-adjust}パッケージは,上で述べた行末文字と実際の行末との位置関係を
6955   2通り以上から自動的に選択する機能を提供する.
6956   \pdfTeX と同じように,「\TeX による行分割の後で行末文字の位置を補正する」方法と
6957   「行分割の過程で行末文字の位置を考慮に入れる」方法を選べるようにした
6958   (\Pkg{luatexja-adjust}パッケージの既定では前者).
6959   
6960  \item[優先順位付きの行長調整]
6961   \pTeX では,行長調整において優先度の概念が存在しなかったため,図
6962   \ref{fig:adj}上段における半角分の半端は,\autoref{fig:adj}中段のように,鍵
6963   括弧周辺の空白と和文間空白(\Param{kanjiskip})の両方によって負担される.し
6964   かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
6965   ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
6966   文字はベタ組で組まれる(\autoref{fig:adj}下段)ことになっている.
6967   \Pkg{luatexja-adjust}パッケージの提供する第2の機能は,
6968   \cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
6969   の行長調整である.
6970   \begin{itemize}
6971    \item 優先度付き行長調整は,段落を行分割した後に個々の行について行われるものである.
6972         そのため,行分割の位置は変化することはない.
6973         
6974         \verb+\hbox{...}+ といった「途中で改行できない水平ボックス」では(たとえ幅が指定されていても)無効である.
6975    \item 優先度付き行長調整を行うと,和文処理グルーの自然長は変化しないが,伸び量や縮み量は
6976         一般に変化する.そのため,既に組まれた段落を \cs{unhbox} などを利用して組み直す処理を
6977         行う場合には注意が必要である.
6978   \end{itemize}
6979   
6980  \item[「中身までみた」行送り計算]
6981   複数行に渡る文章を組版するときには行間に空きが入ることが普通である.
6982   \TeX では各行が一つずつの水平ボックスをなしていることを思い出すと,隣り合った
6983   2つの行(つまり水平ボックス)の間の空きは次のようにして決まるのだった:
6984   \begin{itemize}
6985    \item 「通常に組んだときの行間」$d$を,\cs{baselineskip}から
6986         「前の行」の深さと「次の行」の高さを加えたものを引いた値とする.
6987    \item $d\ge\cs{lineskiplimit}$の場合,
6988         標準の行送り\cs{baselineskip}で組んでも十分な間隔があると判断され,
6989         2行の間には長さ$d$の空白が挿入される.つまり行送りは\cs{baselineskip}.
6990    \item {\catcode`\<=12$d<\cs{lineskiplimit}$}の場合,
6991         2行の間には長さ\cs{lineskip}の空白が挿入される.
6992         そのため(設定値によるが,多くの場合)行送りは\cs{baselineskip}より広がる.
6993   \end{itemize}
6994
6995   \begin{figure}[t]
6996         \noindent\centering
6997         \begin{minipage}[b]{18\zw}
6998           \ltjenableadjust[profile=false, linestep=false]
6999           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7000           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7001           これを②式に代入すると……
7002           \par\vskip\abovecaptionskip
7003           \ltjenableadjust[profile=false, linestep=false]
7004           \par\centering\leavevmode{\small (a)}
7005         \end{minipage}%
7006         \kern2\zw
7007         \begin{minipage}[b]{18\zw}
7008           \ltjenableadjust[profile]
7009           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7010           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7011           これを②式に代入すると……
7012           \par\vskip\abovecaptionskip
7013           \ltjenableadjust[profile=false, linestep=false]
7014           \par\centering\leavevmode{\small (b)}
7015         \end{minipage}\par
7016           \caption{高い行が連続したときの状況}\label{fig:linegap1}
7017   \end{figure}
7018
7019   ここで,\TeX は行送りの決定で「高さ・深さを取っているものが
7020   行のどの水平位置にあるか」は一切考慮しないことに注意してほしい.そのため,
7021   \autoref{fig:linegap1}~(a)のように「必要以上に行間が空いて見える」状況が起こることがある.
7022
7023   \Pkg{luatexja-adjust}パッケージでは,「通常に組んだときの行間」$d$を
7024   各行の中身の文字・グルー・ボックスの寸法を勘案して計算するという方法を
7025   利用できるようにした.この機能を使うと,\autoref{fig:linegap1}~(b)のように
7026   行間の空きが必要以上に大きくなることを避けることができる.
7027   \begin{itemize}
7028         \item 段落中の隣り合った二行だけでなく,行間の空きは
7029         新たに水平ボックス$h$を(内部・外部問わず)垂直モードで追加した時にも自動で挿入される.
7030         その場合には,前段落で述べた「中身までみる」処理は
7031         \begin{itemize}
7032          \item 現在のリストにおける最後のノード
7033           \footnote{最後のノードが\cs{parskip}によるグルーであった場合のみ
7034                 さらに一つ前のノードを参照する}が水平ボックス$h'$であり,かつ
7035           \item \cs{prevdepth}の値とその$h'$の深さの値が一致している
7036         \end{itemize}
7037         場合にのみ発動するようにしている.
7038         \item 行の中身に水平ボックス$h''$が入ってくることもあるが,その場合は$h''$の中身までは参照しない.
7039         参照するようにしてしまうと,\cs{smash}など手動で行った高さ・深さ調整の意味がなくなってしまうからである.
7040   \end{itemize}
7041   
7042   \begin{figure}[t]
7043         \noindent\centering
7044         \begin{minipage}[b]{16\zw}
7045           \ltjenableadjust[profile]
7046           ……だから,①より$\dfrac{a^2}{b}= \dfrac{1+\sqrt{5}}2$.\\
7047           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7048           これを②式に代入すると……
7049           \par\vskip\abovecaptionskip
7050           \ltjenableadjust[profile=false, linestep=false]
7051           \par\centering\leavevmode{\small (a): 無効}
7052         \end{minipage}%
7053         \kern2\zw
7054         \begin{minipage}[b]{16\zw}
7055           \ltjsetparameter{linestep_factor=0.25}
7056           \ltjenableadjust[profile, linestep]
7057           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7058           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7059           これを②式に代入すると……
7060           \par\vskip\abovecaptionskip
7061           \ltjenableadjust[profile=false, linestep=false]
7062           \par\centering\leavevmode{\small (b): $0.25$\cs{baselineskip}刻み}
7063         \end{minipage}\par\medskip
7064         \begin{minipage}[b]{16\zw}
7065           \ltjsetparameter{linestep_factor=0.5}
7066           \ltjenableadjust[profile, linestep]
7067           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7068           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7069           これを②式に代入すると……
7070           \par\vskip\abovecaptionskip
7071           \ltjenableadjust[profile=false, linestep=false]
7072           \par\centering\leavevmode{\small (c): 0.5\cs{baselineskip}刻み}
7073         \end{minipage}%
7074         \kern2\zw
7075         \begin{minipage}[b]{16\zw}
7076           \ltjsetparameter{linestep_factor=1}
7077           \ltjenableadjust[profile, linestep]
7078           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7079           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7080           これを②式に代入すると……
7081           \par\vskip\abovecaptionskip
7082           \ltjenableadjust[profile=false, linestep=false]
7083           \par\centering\leavevmode{\small (d): \cs{baselineskip}刻み}
7084         \end{minipage}\par
7085           \caption{段階的な行送り増加}\label{fig:linegap2}
7086   \end{figure}
7087
7088  \item[段階的な行送り調整]
7089   既に述べたように,
7090   「通常に組んだときの行間」$d$が\cs{lineskiplimit}より小さい場合,\TeX 標準では
7091   行間は\cs{lineskip}となるのだった.
7092   このとき行送りは「前の行の深さ」,「次の行の高さ」,\cs{lineskip}の3つの和になるわけだが,
7093   場合によっては行送りを「\cs{baselineskip}の整数倍」などと切りのいい値に揃えたいという状況が
7094   考えられなくもない.
7095   
7096   \Pkg{luatexja-adjust}パッケージでは,{\catcode`\<=12$d<\cs{lineskiplimit}$}のときに
7097   行送りを\cs{baselineskip}の\Param{linestep\_factor}倍ずつ増減させて
7098   \begin{quote}
7099         行間が\cs{lineskip}以上となるような,
7100         最小の$(1+k\cdot \Param{linestep\_factor})\cs{baselineskip}$($k$は整数)の値
7101   \end{quote}
7102   とする機能を利用できるようにした.
7103   \autoref{fig:linegap2}の(a)がこの機能を無効にした状況で,(b),~(c),~(d)が
7104   それぞれ\Param{linestep\_factor}を0.25,~0.5,~1とした状況である.
7105
7106   なお,この機能は表組時(\cs{halign},~\cs{valign})には無効である.
7107   \LaTeX における表組環境(tabular, arrayなど)では,\cs{baselineskip},~\cs{lineskip}はどちらも0に設定されているので
7108   (代わりに各行に\cs{@arstrut}という支柱が入る)ために意味がないことと,
7109   数式を内部で表組を使って組むalign環境などではかえって行間が不揃いになってしまうからである.
7110 \end{description}
7111
7112 \Pkg{luatexja-adjust}パッケージは,上記で述べた4機能を有効化/無効化するための
7113 以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
7114
7115 \begin{cslist}
7116 \item[\cs{ltjenableadjust[...]}]
7117 \verb+...+ に指定したkey-valueリストに従い,「行末文字の位置調整」「優先順位付きの行長調整」
7118   「『中身までみた』行送り計算」「段階的な行送り調整」を有効化/無効化する.
7119 指定できるキーは以下の通り.
7120 \begin{description}
7121   \item[\texttt{lineend=[false,true,extended]}]
7122   行末文字の位置調整の機能を無効化(\texttt{false}),「行分割後に調整」の形で有効化(\texttt{true}),
7123   「行分割の仮定で考慮」の形で有効化(\texttt{extended})する.
7124   \item[\texttt{priority=[false,true]}]
7125   優先順位付きの行長調整を無効化(\texttt{false}),または有効化(\texttt{true}).
7126   \item[\texttt{profile=[false,true]}]
7127   「中身までみた」行送り計算を無効化(\texttt{false}),または有効化(\texttt{true}).
7128   \item[\texttt{linestep=[false,true]}]
7129   段階的な行送り調整を無効化(\texttt{false}),または有効化(\texttt{true}).
7130 \end{description}
7131 どのキーともキー名のみを指定した場合は値として\texttt{true}が指定されたものと扱われる.
7132
7133 互換性の為,オプション無しでただ\cs{ltjenableadjust}が呼び出された場合は,
7134 \begin{lstlisting}
7135 \ltjenableadjust[lineend=true,priority=true]
7136 \end{lstlisting}
7137 と扱われる.
7138   
7139 \item[\cs{ltjdisableadjust}]
7140 \Pkg{luatexja-adjust}パッケージの機能を無効化する.
7141 \begin{lstlisting}
7142 \ltjenableadjust[lineend=false,priority=false,profile=false,linestep=false]
7143 \end{lstlisting}
7144 と同義.
7145 \end{cslist}
7146
7147 また,次のパラメータが\cs{ltjsetparameter}内で
7148 追加される.いずれもグローバルに効力を発揮する.
7149 \begin{cslist}[style=standard]
7150 \item[\DParam{stretch\_priority}\,=\{<list>\}]
7151 \Param{kanjiskip}, \Param{xkanjiskip},および「\textbf{JAglue}以外のグルー」を,
7152 「行を自然長より伸ばす」場合の調整に用いる優先度を指定する.
7153
7154 指定方法は,<list>の中にkey-value listの形で
7155 \begin{lstlisting}
7156 stretch_priority={kanjiskip=-35,xkanjiskip=-25,others=50}
7157 \end{lstlisting}
7158 のようにして行う.キー名\texttt{kanjiskip},~\texttt{xkanjiskip}については
7159 そのままの意味であり,
7160 \texttt{others}キーが「\textbf{JAglue}以外のグルー」を表す.
7161 各キーの値は,JFMグルーにおける「優先度$i$」を$10i$に対応させた整数値であり,
7162   大きい方が先に伸ばされることを意味している.
7163   初期値は
7164 \begin{lstlisting}
7165 {kanjiskip=-35,xkanjiskip=-25,others=50}
7166 \end{lstlisting}
7167 であり,「優先度$-4$」と指定されているJFMグルーが最も伸びにくいようになっている.
7168
7169 \item[\DParam{shrink\_priority}\,=\{<list>\}]
7170 同様に,「行を自然長より縮める」場合の調整に用いる優先度を指定する.
7171 それ以外は\Param{stretch\_priority}と指定の形式は変わらない(初期値も変わらない).
7172
7173  \item[\DParam{linestep\_factor}\,=<float>]
7174   段階的な行送り調整の際,\cs{baselineskip}の自然長の何倍単位で行送りを変えるかを指定する.
7175   0を指定すると無効になるのと変わらない.また負数を指定すると,
7176   その絶対値が指定されたかのように扱われる.
7177   初期値は0.5(つまり半行単位)である.
7178
7179   \item[\DParam{profile\_hgap\_factor}\,=<float>]
7180   「中身まで見た」行送り計算の際,
7181   前の行にある深さが大きいものと次の行にある高さが大きいものが
7182   水平方向にどれだけ離れていないといけないかを
7183   「\cs{lineskip}の自然長の何倍か」で指定する.
7184   負数を指定すると,その絶対値が指定されたかのように扱われる.
7185   初期値は1(つまり\cs{lineskip}(の自然長))である.
7186 \end{cslist}
7187 %</ja>
7188
7189 \subsection{\Pkg{luatexja-ruby}}
7190 %<*en>
7191 This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
7192 using callbacks of \LuaTeX-ja.
7193 There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
7194 (Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
7195 %</en>
7196 %<*ja>
7197 この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
7198 前後の文字種に応じた前後への自動進入や,
7199 行頭形・行中形・行末形の自動的な使い分けが特徴である.
7200
7201 ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
7202 使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
7203 この節では簡単な使用方法のみ述べる.
7204 %</ja>
7205
7206 \begin{description}
7207 %<*en>
7208  \item[Group-ruby]
7209 By default, ruby characters (the second argument of \cs{ruby})
7210 are attached to base characters (the first argument), as one object.
7211 This type of ruby is called \emph{group-ruby}.
7212 %</en>
7213 %<*ja>
7214  \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
7215 第2引数にルビを記述する.
7216 %</ja>
7217 \begin{LTXexample}[width=0.3\textwidth]
7218 東西線\ruby{妙典}{みようでん}駅は……\\
7219 東西線の\ruby{妙典}{みようでん}駅は……\\
7220 東西線の\ruby{妙典}{みようでん}という駅……\\
7221 東西線\ruby{葛西}{かさい}駅は……
7222 \end{LTXexample}
7223 %<*en>
7224 As the above example, ruby hangover is allowed on the Hiragana before/after
7225 its base characters.
7226 %</en>
7227 %<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
7228
7229 %<*en>
7230 \item[Mono-ruby]
7231 To attach ruby characters to each base characters (\emph{mono-ruby}),
7232 one should use \cs{ruby} multiple times:
7233 %</en>
7234 %<*ja>
7235  \item[モノルビ] 親文字を1文字にするとモノルビとなる.
7236 2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
7237 その数だけ \cs{ruby} を書く必要がある.
7238 %</ja>
7239 \begin{LTXexample}[width=0.3\textwidth]
7240 東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
7241 \end{LTXexample}
7242
7243 %<*en>
7244  \item[Jukugo-ruby]
7245 Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
7246 %</en>
7247 %<*ja>
7248  \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
7249 複数グループのルビは熟語ルビとして組まれる.
7250 \cite{x4051}にあるように,
7251 どのグループでも「親文字」が対応するルビ以上の長さの場合は
7252 各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
7253 \cite{jlreq}で規定されている組み方とは異なるので注意.
7254 %</ja>
7255 \begin{LTXexample}
7256 \ruby{妙|典}{みよう|でん}\
7257 \ruby{葛|西}{か|さい}\
7258 \ruby{神楽|坂}{かぐら|ざか}
7259 \end{LTXexample}
7260 %<*en>
7261 If there are multiple groups in one \cs{ruby} call,
7262 A linebreak between two groups is allowed.
7263 %</en>
7264 %<ja> 複数ルビではグループとグループの間で改行が可能である.
7265 \begin{LTXexample}[width=0.3\textwidth]
7266 \vbox{\hsize=6\zw\noindent
7267   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7268   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7269   \hbox to   3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7270 }
7271 \end{LTXexample}
7272 \end{description}
7273
7274 %<*en>
7275 If the width of ruby characters are longer than that of base characters,
7276 \cs{ruby} automatically selects the appropriate form
7277 among the line-head form, the line-middle form, and the line-end form.
7278 %</en>
7279 %<*ja>
7280 また,ルビ文字のほうが親文字よりも長い場合は,自動的に
7281 行頭形・行中形・行末形のいずれか適切なものを選択する.
7282 %</ja>
7283 \begin{LTXexample}[width=0.3\textwidth]
7284 \vbox{\hsize=8\zw\noindent
7285 \null\kern3\zw ……を\ruby{承}{うけたまわ}る
7286      \kern1\zw ……を\ruby{承}{うけたまわ}る\\
7287 \null\kern5\zw ……を\ruby{承}{うけたまわ}る
7288 }
7289 \end{LTXexample}
7290
7291
7292 %<*ja>
7293 \subsection{\Pkg{lltjext}}
7294 \pLaTeX では縦組用の拡張として \Pkg{plext} パッケージが用意されていたが,
7295 それを\LuaTeX-ja用に書きなおしたものが本追加パッケージ \Pkg{lltjext} である.
7296
7297 従来の \Pkg{plext} パッケージとの違いは,
7298 {\catcode`\<=12
7299 \begin{itemize}
7300  \item 組方向オプション \texttt{<y>}(横組),\texttt{<t>}(縦組),
7301 \texttt{<z>}\ の他に\ \texttt{<d>}(dtou方向),\texttt{<u>}(utod方向)を追加した.
7302 \texttt{<z>} と \texttt{<u>} の違いは,\texttt{<z>} が(\Pkg{plext} パッケージと同様に)
7303 周囲の組方向が縦組のときにしか意味を持たない
7304   \footnote{%
7305     周囲の組方向が縦組以外のときは,\texttt{<z>} を指定しても中身の組方向は周囲の組方向と変わらない.
7306   }%
7307 のに対し,\texttt{<u>} にはそのような制限がないことである.
7308  \item 連数字用命令 \cs{rensuji} における位置合わせオプション \texttt{[l]}, \texttt{[c]},
7309        \texttt{[r]} の挙動を若干変更した.
7310 \end{itemize}
7311 }
7312
7313 %</ja>
7314 %<*en>
7315 \subsection{\texttt{lltjext.sty}}
7316 \pLaTeX\ supplies additional macros for vertical writing in the \Pkg{plext} package.
7317 The \Pkg{lltjext} package which we want to describe here is the \LuaTeX-ja
7318 counterpart of the \Pkg{plext} package.
7319 %</en>
7320
7321 %<*ja>
7322 念の為,本 \Pkg{lltjext} パッケージで追加・変更している命令の一覧を載せておく.
7323 \begin{cslist}
7324 \item[tabular\textrm{, }array\textrm{, }minipage環境]
7325 これらの環境は,
7326 \begin{lstlisting}
7327 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
7328 \begin{array}<dir>[pos]{table spec}   ... \end{array}
7329 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
7330 \end{lstlisting}
7331 のように,組方向オプション \texttt{\<dir\>} が拡張されている.
7332 既に述べたように,組方向オプションに指定できる値は以下の5つであり,
7333 それ以外を指定した時や無指定時は周囲の組方向と同じ組方向になる.
7334 \begin{description}
7335  \item[y] 横組(\cs{yoko})
7336  \item[t] 縦組(\cs{tate})
7337  \item[z] 周囲が縦組の時はutod方向,それ以外はそのまま
7338  \item[d] dtou方向
7339  \item[u] utod方向
7340 \end{description}
7341 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
7342 \cs{parbox} 命令も同様に,組方向の指定ができるように拡張されている.
7343
7344 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
7345 組方向<dir>で<contents>の中身をLRモードで組む命令である.
7346 <width>が正の値であるときは,ボックス全体の幅がその値となる.
7347 その際,中身は<pos>の値に従い,左寄せ(\texttt{l}),右揃え(\texttt{r}),
7348 中央揃え(それ以外)される.
7349 \item[picture環境]
7350 図表作成に用いる\texttt{picture}環境も,
7351 \begin{lstlisting}
7352 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
7353   ...
7354 \end{picture}
7355 \end{lstlisting}
7356 と組方向が指定できるように拡張されている.
7357 $x$成分の増加方向は字送り方向,$y$成分の増加方向は行送り方向の\emph{反対方向}となる.
7358 \Pkg{plext} パッケージと同様に
7359 内部ではベースライン補正(\Param{yalbaselineshift}パラメータなど)の影響を受けないように,
7360 \cs{put},~\cs{line}, \cs{vector}, \cs{dashbox}, \cs{oval},~\cs{circle}も
7361 ベースライン補正を受けないように再定義されている.
7362
7363 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
7364
7365 \item[\cs{Kanji}\{<counter\_name>\}]
7366
7367 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
7368                      }\cs{boutenchar}]
7369
7370 \item[参照番号]
7371 \end{cslist}
7372 %</ja>
7373 %<*en>
7374 \begin{cslist}
7375 \item[tabular\textrm{, }array\textrm{, }minipage\textrm{ environments}]
7376 These environments are extended by \texttt{\<dir\>}, which specifies the direction,
7377 as follows:
7378 \begin{lstlisting}
7379 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
7380 \begin{array}<dir>[pos]{table spec}   ... \end{array}
7381 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
7382 \end{lstlisting}
7383 This option permits one of the following five values. If none of them is specified,
7384 the direction inside the environment is same as that outside the enviromnent.
7385 \begin{description}
7386  \item[y] \emph{yoko} direction (horizontal writing)
7387  \item[t] \emph{tate} direction (vertical writing)
7388  \item[z] \emph{utod} direction if direction outside the env.\ is \emph{tate}.
7389  \item[d] \emph{dtou} direction
7390  \item[u] \emph{utod} direction
7391 \end{description}
7392 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
7393 \cs{parbox} command is also extended by \texttt{\<<dir>\>}.
7394
7395 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
7396 This commands typeset <contents> in LR-mode, in <dir> direction.
7397 If <width> is positive, the width of the box becomes this <width>.
7398 In this case, <contents> will be aligned to left (when <pos> is \texttt{l}),
7399 center (\texttt{c}), or~right (\texttt{r}).
7400   
7401 \item[picture\textrm{\ environment}]
7402 \texttt{picture} environment also extended by \texttt{\<<dir>\>}, as follows:
7403 \begin{lstlisting}
7404 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
7405   ...
7406 \end{picture}
7407 \end{lstlisting}
7408
7409 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
7410
7411 \item[\cs{Kanji}\{<counter\_name>\}]
7412
7413 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
7414                      }\cs{boutenchar}]
7415
7416 \item[参照番号]
7417 \end{cslist}
7418 %</en>
7419
7420 %<*ja>
7421 \paragraph{表組他の揃え位置}
7422 表組(\texttt{array}, \texttt{tabular}環境),\cs{parbox}命令,\cs{minipage}環境の
7423 揃え位置については\autoref{tab:lltjext_dir}を参照.\pLaTeX~2017-07-29と
7424 できるだけ同じ挙動になるようにしている.\autoref{tab:lltjext_dir}中のA--Dの意味は次の通り.
7425
7426 \begin{table}
7427   \caption{\Pkg{lltjext}パッケージにおける表組・\cs{parbox}命令他の揃え位置}
7428   \label{tab:lltjext_dir}
7429   {\centering
7430     \begin{tabular}{lcccc}
7431       \toprule
7432       ↓中身\周囲→&\cs{yoko}&\cs{tate}&\cs{utod}&\cs{dtou}\\
7433       \midrule
7434       \cs{yoko}&A&B&B&B\\
7435       \cs{tate}&B&A&D&C\\
7436       \cs{utod}&B&D&A&C\\
7437       \cs{dtou}&B&C&C&A\\
7438       \bottomrule
7439     \end{tabular}\par}
7440 \end{table}
7441
7442 \begin{description}
7443  \item[A] 周囲の組方向と中身の組方向が同じ場合.
7444   \begin{itemize}
7445    \item \texttt{[t]}指定のとき:
7446     中身の先頭行のベースラインが周囲のベースラインと一致する.
7447     表組で先頭行の上に罫線があった場合は,それがベースラインの位置
7448     \footnote{\LuaTeX-jaでは和文側のベースラインの位置も上下移動できることに注意.
7449       そのため「和文ベースライン」の位置に来るとは限らない.}となる.
7450    \item \texttt{[c]}指定のとき:
7451     中身の上下の中心が周囲の数式の軸を通る.
7452    \item \texttt{[b]}指定のとき:
7453     中身の最終行のベースラインが周囲のベースラインと一致する.
7454     表組で最終行の下に罫線があった場合は,それがベースラインの位置となる.
7455   \end{itemize}
7456  \item[B] 周囲の組方向と中身の組方向が90度ずれている場合.
7457   \begin{itemize}
7458    \item \texttt{[t]}指定のとき:
7459     表組においては,上端が周囲のベースラインと一致する.
7460     \cs{parbox}や\cs{minipage}環境においては,上端が周囲の和文文字の上端と一致する.
7461    \item \texttt{[c]}指定のとき:
7462     中身の上下の中心が周囲の数式の軸を通る.
7463    \item \texttt{[b]}指定のとき:
7464     表組においては,下端が周囲のベースラインと一致する.
7465     \cs{parbox}や\cs{minipage}環境においては,下端が周囲の和文文字の下端と一致する.
7466   \end{itemize}
7467  \item[C] 周囲の組方向と中身の組方向が180度ずれている場合.
7468   \cs{parbox}や\cs{minipage}環境においては,上のBの場合と同じ挙動である.表組においては,
7469   Aで\texttt{[t]}と\texttt{[b]}を入れ替えた
7470   \begin{itemize}
7471    \item \texttt{[t]}指定のとき:
7472     中身の最終行のベースラインが周囲のベースラインと一致する.
7473     最終行の下に罫線があった場合は,それがベースラインの位置となる.
7474    \item \texttt{[c]}指定のとき:
7475     中身の上下の中心が周囲の数式の軸を通る.
7476    \item \texttt{[b]}指定のとき:
7477     中身の先頭行のベースラインが周囲のベースラインと一致する.
7478     表組で先頭行の上に罫線があった場合は,それがベースラインの位置となる.
7479   \end{itemize}
7480  \item[D] 通常の縦組(\cs{tate})と「縦数式ディレクション」に相当する\cs{utod}方向が絡んだ場合.
7481   \cs{parbox}や\cs{minipage}環境においては,上のBの場合と同じ挙動である.表組においては,
7482   \begin{itemize}
7483    \item \texttt{[t]}指定のとき:
7484     中身の先頭行の欧文ベースラインが周囲の欧文ベースラインと一致する.
7485    \item \texttt{[c]}指定のとき:
7486     中身の上下の中心が周囲の数式の軸を通る.
7487    \item \texttt{[b]}指定のとき:
7488     中身の最終行の欧文ベースラインが周囲の欧文ベースラインと一致する.
7489   \end{itemize}
7490 \end{description}
7491 %</ja>
7492
7493 \subsection{\Pkg{luatexja-preset}}
7494 \label{ssec:preset}
7495
7496 %<*en>
7497 As described in Subsection~\ref{ssec:preset-abst},
7498 One can load the \Pkg{luatexja-preset}
7499 package to use several ``presets'' of Japanese fonts.
7500 This package provides functions in a part of \Pkg{japanese-otf} package (changing fonts)
7501 and a part of \Pkg{PXchfon} package (presets) by Takayuki Yato.
7502
7503 Options which are given in \cs{usepackage} but not described in this~subsection
7504 are simply passed to the \Pkg{luatexja-fontspec}\footnote{if \texttt{nfssonly} option is
7505 \emph{not} specified; in this case these options are simply ignored.}.
7506 For example, the line~5 in below example is equivalent to lines 1--3.
7507 %</en>
7508 %<*ja>
7509 \ref{ssec:preset-abst}節で述べたように,よく使われている和文フォント設定を一行で指定できるようにしたのが
7510 \Pkg{luatexja-preset}パッケージである.このパッケージは,
7511 \Pkg{otf}パッケージの一部(多書体化)と八登崇之氏による\Pkg{PXchfon}パッケージの一部(プリセット指定)
7512 とを合わせたような格好をしている.
7513
7514 パッケージ読み込み時に渡されたオプションのうち,
7515 本節にないものを指定した場合,それらはそのまま
7516 \Pkg{luatexja-fontspec}パッケージに渡される\footnote{\texttt{nfssonly} オプションが
7517 指定されていた場合は,\Pkg{luatexja-fontspec}パッケージは読み込まれないので単純に無視され
7518 る.}.例えば,下の1--3行目は5行目のように一行にまとめることができる.
7519 %</ja>
7520 \begin{lstlisting}
7521 \usepackage[no-math]{fontspec}
7522 \usepackage[match]{luatexja-fontspec}
7523 \usepackage[kozuka-pr6n]{luatexja-preset}
7524 %%--------
7525 \usepackage[no-math,match,kozuka-pr6n]{luatexja-preset}
7526 \end{lstlisting}
7527
7528 %<en>\subsubsection{General Options}
7529 %<ja>\subsubsection{一般的なオプション}
7530 \label{sssec:ltjpreset-general}
7531
7532 \begin{cslist}[before*=]
7533 \item[fontspec%
7534 %<en>\textrm{~(enabled by default)}
7535 %<ja>\emph{\gtfamily (既定)}
7536 ]
7537 %<*en>
7538 With this option, Japanese fonts are selected using functionality of
7539 the \Pkg{luatexja-fontspec} package. This means that the \Pkg{fontspec} package is
7540              automatically loaded by this package.
7541
7542 If you need to pass some options to \Pkg{fontspec}, you can load \Pkg{fontspec} manually
7543 before \Pkg{luatexja-preset}:
7544 %</en>
7545 %<*ja>
7546 \Pkg{luatexja-fontspec}パッケージの機能を用いて和文フォントを選択する.
7547 これは,\Pkg{fontspec}パッケージが自動で読み込まれることを意味する.
7548
7549 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
7550 \footnote{例えば,数式フォントまで置換されてしまい,\cs{mathit}によってギリシャ文字の
7551 斜体大文字が出なくなる,など.}場合は,
7552 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
7553 %</ja>
7554 \begin{lstlisting}
7555 \usepackage[no-math]{fontspec}
7556 \usepackage[...]{luatexja-preset}
7557 \end{lstlisting}
7558
7559 \item[nfssonly]
7560 %<*en>
7561 With this option, selecting Japanese fonts won't be performed using the functionality of
7562              the \Pkg{fontspec} package, but only standard NFSS2 (hence without
7563              \cs{addjfontfeatures} etc.).
7564 This option is ignored when \Pkg{luatexja-fontspec} package is loaded.
7565
7566 When this option is specified, \Pkg{fontspec}~and~\Pkg{luatexja-fontspec} are
7567 \emph{not} loaded by default. Nevertheless,
7568 the package\Pkg{fontspec} can coexist with the option, as the following:
7569 \begin{lstlisting}
7570 \usepackage{fontspec}
7571 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
7572 \end{lstlisting}
7573 In this case, one can use \cs{setmainfont} etc.\ to select \emph{alphabetic} fonts.
7574 %</en>
7575 %<*ja>
7576 \LaTeX 標準のフォント選択機構(NFSS2)を用いて
7577 \texttt{ltjpm}$n$(明朝),\texttt{ltjpg}$n$(ゴシック),
7578 それに後に述べる\texttt{deluxe}オプションが指定された場合には
7579 \texttt{ltjpmg}$n$(丸ゴシック)という
7580 和文フォントファミリを定義%
7581 \footnote{%
7582   $n$は自然数であり,\cs{ltjapplypreset}の実行(この命令は\Pkg{luatexja-preset}パッケージ
7583   読み込み時に自動的に実行される)ごとに増加していく.
7584 }し,これらを用いる.
7585
7586 本オプション指定時には\Pkg{fontspec}・\Pkg{luatexja-fontspec}パッケージは
7587 自動では読み込まれない,しかし,
7588 \begin{lstlisting}
7589 \usepackage{fontspec}
7590 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
7591 \end{lstlisting}
7592 のようにすれば,このオプションを指定すれば
7593 欧文フォントを\Pkg{fontspec}パッケージの機能を使って指定することができる.
7594
7595 一方,\Pkg{luatexja-preset}パッケージ読み込み時に
7596 既に\Pkg{luatexja-fontspec}パッケージが読み込まれている場合は
7597 \texttt{nfssonly}オプションは無視される.
7598 %</ja>
7599
7600 \item[match]
7601 %<*en>
7602 If this option is specified, usual family-changing commands such as
7603 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
7604 This option is passed to \Pkg{luatexja-fontspec}, if \texttt{fontspec}
7605 option is specifed.
7606 %</en>
7607
7608 %<*ja>
7609 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
7610 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
7611 欧文フォントだけでなく和文フォントも変更するようになる.
7612 \ \texttt{fontspec}\
7613 オプションが有効になっている場合は,このオプションは \Pkg{luatexja-fontspec} パッケージへと渡される.
7614 %</ja>
7615
7616
7617 \item[nodeluxe%
7618 %<en>\textrm{~(enabled by default)}
7619 %<ja>\emph{\gtfamily (既定)}
7620 ]
7621 %<*en>
7622 The nagation of \texttt{deluxe} option.
7623 Use one-weighted \textit{mincho} and \textit{gothic} font families.
7624 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and
7625 \verb+\gtfamily\mdseries+ use the same font.
7626 %</en>
7627 %<*ja>
7628 \texttt{deluxe}オプションの否定.
7629 \LaTeXe 環境下の標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
7630 より具体的に言うと,この設定の下では
7631 \ \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+,
7632 \verb+\gtfamily\mdseries+はみな同じフォントとなる.
7633 %</ja>
7634 \item[deluxe]
7635 %<*en>
7636 Use the mincho family with three weights (light, medium, and~bold),
7637 the gothic family with three weights (medium, bold, and extra~bold), and \textit{rounded gothic}%
7638 \footnote{Provided by \cs{mgfamily} and \cs{textmg},
7639 because ``rounded gothic'' is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
7640 Mincho light and gothic extra~bold can be by
7641 \cs{mcfamily}\cs{ltseries}~and~\cs{gtfamily}\cs{ebseries}, respectively.
7642
7643 \begin{itemize}
7644  \item Some presets do not have the light weight of mincho.
7645   In this case, we substitute the medium weight for the light weight.
7646  \item \Pkg{luatexja-preset} does not produce an error (only produces a warning), even if
7647   (one of) fonts for \cs{mcfamily}\cs{ltseries}, \cs{gtfamily}\cs{ebseries}, \cs{mgfamily}
7648   do not exist.
7649 \end{itemize}
7650 %</en>
7651 %<*ja>
7652 明朝体・ゴシック体各3ウェイトと,
7653 丸ゴシック体 (\cs{mgfamily}, \verb+\textmg{...}+) を利用可能にする.
7654 明朝体は細字・中字・太字の3ウェイトがあり,
7655 明朝体の細字は \cs{mcfamily}\cs{ltseries} で利用できる.
7656 また,ゴシック体は中字・太字・極太の3ウェイトがあり,
7657 ゴシック体の極太は \cs{gtfamily}\cs{ebseries} で利用できる%
7658 \footnote{過去との互換性のため,\cs{gtebfamily}, \cs{textgteb\{...\}} も
7659  依然として利用可能である.}.
7660
7661 \begin{itemize}
7662   \item プリセット設定によっては明朝体細字が用意されていないものもある.その場合は
7663   明朝体中字が代用される.
7664   \item 明朝体細字,ゴシック体極太,丸ゴシック体の3フォントについては
7665   実際にフォントをロードする前に存在するかチェックを行う.
7666   存在しなかったものについては警告を発し,
7667   それぞれ明朝体中字.ゴシック体太字,ゴシック体太字で代用する.
7668 \end{itemize}
7669 %</ja>
7670 \item[expert]
7671 %<*en>
7672 Use horizontal/vertical kana alternates, and define a command \cs{rubyfamily} to use kana
7673 characters designed for ruby.
7674 %</en>
7675 %<*ja>
7676 横組・縦組専用仮名を用いる.また,\cs{rubyfamily} でルビ用仮名が使用可能となる\footnote{%
7677   \cs{rubyfamily}とはいいつつ,実際にはフォントファミリを切り替えるのではない(通常では
7678   font featureの追加,\texttt{nfssonly} 指定時にはシェイプを \texttt{rb} に切り替え).
7679 }.
7680 %</ja>
7681 \item[bold]
7682 %<*en>
7683 Substitute bold series of gothic for  bold series of mincho.
7684 If \texttt{nodeluxe} option is enabled, medium series of gothic is also changed,
7685 since we use same font for both series of gothic.
7686 %</en>
7687 %<*ja>
7688 「明朝の太字」をゴシック体の太字によって代替する.
7689 もし\texttt{nodeluxe}オプションが指定されている場合は,ゴシック体は1ウェイトしか使用されな
7690            いため,
7691 「ゴシック体の中字」も同時に変更されることになる.
7692 %</ja>
7693 \item[jis90\textrm{,~}90jis]
7694 %<en>Use JIS~X~0208:1990 glyph variants if possible.
7695 %<ja>出来る限りJIS~X~0208:1990の字形を使う.
7696 \item[jis2004\textrm{,~}2004jis]
7697 %<en>Use JIS~X~0213:2004 glyph variants if possible.
7698 %<ja>出来る限りJIS~X~0213:2004の字形を使う.
7699 \item[jfm\_yoko=<jfm>]
7700 %<*en>
7701 Use the JFM \texttt{jfm-<jfm>.lua} for horizontal direction, instead of \texttt{jfm-ujis.lua}~(default JFM).
7702 %</en>
7703 %<*ja>
7704 横組用和文フォントで用いるJFMを\texttt{jfm-<jfm>.lua}にする.このオプションがない時は
7705 \LuaTeX\nobreakdash -ja標準の\texttt{jfm-ujis.lua}が用いられる.
7706 %</ja>
7707 \item[jfm\_tate=<jfm>]
7708 %<*en>
7709 Use the JFM \texttt{jfm-<jfm>.lua} for vertical direction, instead of \texttt{jfm-ujisv.lua}~(default JFM).
7710 %</en>
7711 %<*ja>
7712 縦用和文フォントで用いるJFMを\texttt{jfm-<jfm>.lua}にする.このオプションがない時は
7713 \LuaTeX-ja標準の\texttt{jfm-ujisv.lua}が用いられる.
7714 %</ja>
7715
7716 \item[jis]
7717 %<en>Same as \texttt{jfm\_yoko=jis}.
7718 %<ja>\texttt{jfm\_yoko=jis}と同じ.ここで用いるJFM\texttt{jfm-jis.lua}はJISフォントメトリックを元にしたものである.
7719
7720 \end{cslist}
7721 %<*en>
7722 Note that \texttt{jis90},~\texttt{90jis}, \texttt{jis2004}~and~\texttt{2004jis} only affect with mincho,
7723 gothic (and, possibly rounded gothic) families defined by this package.
7724 We didn't taken account of when more than one options among them are specified.
7725 %</en>
7726 %<*ja>
7727 \texttt{jis90},~\texttt{90jis}, \texttt{jis2004},~\texttt{2004jis}については本パッケージで定義された
7728 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.
7729 これら4オプションのうち複数が同時に指定された場合の動作については全く考慮していない.
7730 %</ja>
7731
7732 %<en>\subsubsection{Presets which support multi weights}
7733 %<ja>\subsubsection{多ウェイト用プリセットの一覧}
7734 \label{sssec:ltjpreset-multi}
7735
7736 %<*en>
7737 Besides \texttt{morisawa-pro}~and~\texttt{morisawa-pr6n} presets,
7738 fonts are specified by font name, not by file name.
7739 In following tables, starred fonts (e.g.~KozGo\dots-Regular) are used for medium series of \textit{gothic},
7740 \emph{if and only if \texttt{deluxe} option is specified}.
7741 %</en>
7742 %<*ja>
7743 \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
7744 (ファイル名でなく)フォント名で行われる.
7745 以下の表において,*\,つきのフォント(e.g.,~KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション指定時に}
7746 ゴシック体中字として用いられるものを示している.
7747 %</ja>
7748 \begin{cslist}[style=standard]
7749  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
7750 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7751  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
7752 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7753  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
7754
7755 %<*en>
7756 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
7757 There is not rounded gothic family in Kozuka fonts.
7758 %</en>
7759 %<*ja>
7760 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
7761 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
7762 %</ja>
7763 \begin{center}\small
7764 \begin{tabular}{lllll}
7765 \toprule
7766 \bfseries family&\bfseries series&\ttfamily kozuka-pro&\ttfamily kozuka-pr6&\ttfamily kozuka-pr6n\\
7767 \midrule
7768  &light&KozMinPro-Light&KozMinProVI-Light&KozMinPr6N-Light\\
7769 %<en>\textit{mincho}%
7770 %<ja>\textgt{明朝}%
7771  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
7772  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
7773 \midrule
7774  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
7775  &\smash{\raisebox{1.5ex}{medium}}
7776  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
7777 \cmidrule(l){2-5}
7778 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
7779 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
7780  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
7781  &extra bold&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
7782 \midrule
7783 %<en>\textit{rounded gothic}
7784 %<ja>\gt 丸ゴシック
7785 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
7786 \bottomrule
7787 \end{tabular}
7788 \end{center}
7789
7790 %<en>\newpage
7791  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
7792 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7793  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
7794
7795 %<*en>
7796 Hiragino fonts (except Hiragino~Mincho~W2) are bundled with Mac OS~X 10.5 or later.
7797 Some editions of a Japanese word-processor ``一太郎2012'' includes Hiragino ProN fonts.
7798 Note that fonts for gothic extra~bold (HiraKakuStd[N]-W8) only contains characters in
7799 Adobe-Japan1-3 character collection, while others contains those in
7800 Adobe-Japan1-5 character collection.
7801 %</en>
7802 %<*ja>
7803 ヒラギノフォントは,Mac OS~X以外にも,一太郎2012の上位エディションにもバンドルされている.
7804 極太ゴシック体として用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
7805 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
7806
7807 なお,明朝体細字として用いるヒラギノ明朝体W2はOS~Xや一太郎にはバンドルされておらず,
7808 別途購入する必要がある.
7809 %</ja>
7810 \begin{center}\small
7811 \begin{tabular}{llll}
7812 \toprule
7813 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
7814 \midrule
7815  &light&Hiragino~Mincho~Pro~W2&Hiragino~Mincho~ProN~W2\\
7816 %<en>\textit{mincho}%
7817 %<ja>\textgt{明朝}%
7818  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
7819  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
7820 \midrule
7821  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
7822  &\smash{\raisebox{1.5ex}{medium}}
7823  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
7824 \cmidrule(l){2-4}
7825 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
7826 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
7827  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
7828  &extra bold&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
7829 \midrule
7830 %<en>\textit{rounded gothic}
7831 %<ja>\gt 丸ゴシック
7832 &&Hiragino~Maru~Gothic~Pro~W4&Hiragino~Maru~Gothic~ProN~W4\\
7833 \bottomrule
7834 \end{tabular}
7835 \end{center}
7836
7837  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
7838 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7839  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
7840 \begin{center}\footnotesize
7841 \begin{tabular}{ll>{\tt}l>{\tt}l}
7842 \toprule
7843 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
7844 \midrule
7845  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
7846 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
7847 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
7848  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
7849 \midrule
7850  &medium
7851  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
7852 %<en>\textit{gothic}%
7853 %<ja>\gt ゴシック
7854  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
7855  &extra bold&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
7856 \midrule
7857 %<en>\textit{rounded gothic}
7858 %<ja>\gt 丸ゴシック
7859 &&A-OTF-Jun101Pro-Light.otf&A-OTF-ShinMGoPr6N-Light.otf\\
7860 \bottomrule
7861 \end{tabular}
7862 \end{center}
7863
7864
7865  \item[yu-win]  Yu fonts bundled with Windows~8.1.
7866 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7867  \item[yu-win10]  Yu fonts bundled with Windows~10.
7868 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7869  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks.
7870 \begin{center}\small
7871 \begin{tabular}{lllll}
7872 \toprule
7873 \bf family&\bf series&\texttt{yu-win}&\texttt{yu-win10}&\texttt{yu-osx}\\
7874 \midrule
7875  &light&YuMincho-Light&YuMincho-Light&(YuMincho~Medium)\\
7876 %<en>\textit{mincho}%
7877 %<ja>\textgt{明朝}%
7878  &medium&YuMincho-Regular&YuMincho-Regular&YuMincho~Medium\\
7879  &bold&YuMincho-Demibold&YuMincho-Demibold&YuMincho~Demibold\\
7880 \midrule
7881  &&YuGothic-Regular*&YuGothic-Regular*&YuGothic~Medium*\\
7882  &\smash{\raisebox{1.5ex}{medium}}%
7883         &YuGothic-Regular&YuGothic-Medium&YuGothic~Medium\\
7884 \cmidrule(l){2-5}
7885 %<en>\textit{gothic}%
7886 %<ja>\gt ゴシック
7887  &bold&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
7888  &extra bold&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
7889 \midrule
7890 %<en>\textit{rounded gothic}
7891 %<ja>\gt 丸ゴシック
7892 &&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
7893 \bottomrule
7894 \end{tabular}
7895 \end{center}
7896
7897 \item[moga-mobo]  MogaMincho, MogaGothic, and MoboGothic.
7898 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7899 \item[moga-mobo-ex]  MogaExMincho, MogaExGothic, and MoboExGothic.
7900 %<en>\par These fonts can be downloaded from \url{http://yozvox.web.fc2.com/}.
7901 %<ja>これらのフォントは \url{http://yozvox.web.fc2.com/} からダウンロードできる.
7902 \begin{center}\small
7903 \begin{tabular}{llll}
7904 \toprule
7905 \bf family&\bf series&\bf default, \texttt{90jis}~option&\bf \texttt{jis2004} option\\
7906 \midrule
7907  &medium&Moga90Mincho&MogaMincho\\
7908 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
7909 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
7910  &bold&Moga90Mincho Bold&MogaMincho Bold\\
7911 \midrule
7912  &medium&Moga90Gothic&MogaGothic\\
7913 %<en>\textit{gothic}%
7914 %<ja>\gt ゴシック
7915  &bold&Moga90Gothic Bold&MogaGothic Bold\\
7916  &extra bold&Moga90Gothic Bold&MogaGothic Bold\\
7917 \midrule
7918 %<en>\textit{rounded gothic}
7919 %<ja>\gt 丸ゴシック
7920 &&Mobo90Gothic&MoboGothic\\
7921 \bottomrule
7922 \end{tabular}
7923 \end{center}
7924 %<en>When \texttt{moga-mobo-ex} is specified, the font ``MogaEx90Mincho'' etc.\ are used.
7925 %<ja>\texttt{moga-mobo-ex}オプション指定時にはMogaEx90MinchoなどのExが名前についたフォントが使われる.
7926
7927 \item[ume]  Ume Mincho and Ume Gothic.
7928 %<en>\par These fonts can be downloaded from\\\hfill \url{https://ja.osdn.net/projects/ume-font/wiki/FrontPage}.
7929 %<ja>これらのフォントは \url{https://ja.osdn.net/projects/ume-font/wiki/FrontPage} からダウンロードできる.
7930 \begin{center}\small
7931 \begin{tabular}{lll}
7932 \toprule
7933 \bf family&\bf series&\bf default\\
7934 \midrule
7935  &medium&Ume Mincho\\
7936 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
7937 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
7938  &bold&Ume Mincho\\
7939 \midrule
7940  &&Ume Gothic*\\
7941  &\smash{\raisebox{1.5ex}{medium}}&Ume Gothic O5\\
7942 \cmidrule(l){2-3}
7943 %<en>\textit{gothic}%
7944 %<ja>\gt ゴシック
7945  &bold&Ume Gothic O5\\
7946  &extra bold&Ume Gothic O5\\
7947 \midrule
7948 %<en>\textit{rounded gothic}
7949 %<ja>\gt 丸ゴシック
7950 &&Ume Gothic O5\\
7951 \bottomrule
7952 \end{tabular}
7953 \end{center}
7954
7955  \item[sourcehan]  Source Han Serif and Source Han Sans fonts (Language-specific OTF \textit{or} OTC)
7956 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7957  \item[sourcehan-jp]  Source Han Serif JP and Source Han Sans JP fonts (Region-specific Subset OTF)
7958 \begin{center}\small
7959 \def\AD#1#2{Source Han #1 #2&Source Han #1 JP #2}%
7960 \begin{tabular}{lllll}
7961 \toprule
7962 \bf family&\bf series&\texttt{sourcehan}&\texttt{sourcehan-jp}\\
7963 \midrule
7964  &light&\AD{Serif}{Light}\\
7965 %<en>\textit{mincho}%
7966 %<ja>\textgt{明朝}%
7967  &medium&\AD{Serif}{Regular}\\
7968  &bold&\AD{Serif}{Bold}\\
7969 \midrule
7970  &&\AD{Sans}{Regular*}\\
7971  &\smash{\raisebox{1.5ex}{medium}}
7972  &\AD{Sans}{Medium}\\
7973 \cmidrule(l){2-4}
7974 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
7975 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
7976  &bold&\AD{Sans}{Bold}\\
7977  &extra bold&\AD{Sans}{Heavy}\\
7978 \midrule
7979 %<en>\textit{rounded gothic}
7980 %<ja>\gt 丸ゴシック
7981 &&\AD{Sans}{Heavy}\\
7982 \bottomrule
7983 \end{tabular}
7984 \end{center}
7985
7986
7987  \item[noto-otc]  Noto Serif CJK and Noto Sans CJK fonts (OTC)
7988 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
7989  \item[noto-otf]  Noto Serif CJK and Noto Sans CJK fonts (Language-specific OTF)
7990 \begin{center}\small
7991 \def\AD#1#2{Noto #1 CJK #2&Noto #1 CJK JP #2}%
7992 \begin{tabular}{lllll}
7993 \toprule
7994 \bf family&\bf series&\texttt{noto-otc}&\texttt{noto-otf}\\
7995 \midrule
7996  &light&\AD{Serif}{Light}\\
7997 %<en>\textit{mincho}%
7998 %<ja>\textgt{明朝}%
7999  &medium&\AD{Serif}{Regular}\\
8000  &bold&\AD{Serif}{Bold}\\
8001 \midrule
8002  &&\AD{Sans}{Regular*}\\
8003  &\smash{\raisebox{1.5ex}{medium}}
8004  &\AD{Sans}{Medium}\\
8005 \cmidrule(l){2-4}
8006 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8007 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
8008  &bold&\AD{Sans}{Bold}\\
8009  &extra bold&\AD{Sans}{Black}\\
8010 \midrule
8011 %<en>\textit{rounded gothic}
8012 %<ja>\gt 丸ゴシック
8013 &&\AD{Sans}{Black}\\
8014 \bottomrule
8015 \end{tabular}
8016 \end{center}
8017
8018 \end{cslist}
8019 %<en>\subsubsection{Presets which do not support multi weights}
8020 %<ja>\subsubsection{単ウェイト用プリセット一覧}
8021 \label{sssec:ltjpreset-single}
8022
8023 %<*en>
8024 Next, we describe settings for using only single weight.
8025 %</en>
8026 %<*ja>
8027 次に,単ウェイト用の設定を述べる.この4設定では
8028 明朝体太字・丸ゴシック体はゴシック体と同じフォントが用いられる.
8029 %</ja>
8030 \par\nobreak\medskip
8031 {\centering\small
8032 \begin{tabular}{lllll}
8033 \toprule
8034 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
8035 \midrule
8036 %<*en>
8037 \it mincho&Ryumin-Light (non-embedded)
8038 &IPA Mincho&IPAex Mincho&MS Mincho\\
8039 \it gothic&GothicBBB-Medium (non-embedded)
8040 &IPA Gothic&IPAex Gothic&MS Gothic\\
8041 %</en>
8042 %<*ja>
8043 \gtfamily 明朝&Ryumin-Light(非埋込)
8044 &IPA明朝&IPAex明朝&MS明朝\\
8045 \gtfamily ゴシック&GothicBBB-Medium(非埋込)
8046 &IPAゴシック&IPAexゴシック&MSゴシック\\
8047 %</ja>
8048 \bottomrule
8049 \end{tabular}\par\medskip}
8050
8051 %<en>\subsubsection{Presets which use HG fonts}
8052 %<ja>\subsubsection{HGフォントを使うプリセット}
8053 \label{sssec:ltjpreset-hg}
8054 %<*en>
8055 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
8056 In the table below, starred fonts (e.g., IPA~Gothic*) are used
8057 only if \texttt{jis2004} or \texttt{nodeluxe} option is spefified.
8058 %</en>
8059 %<*ja>
8060 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
8061 多ウェイト化した設定もある.以下の表では,*~付きのフォント(例:IPAゴシック*)は
8062 \texttt{jis2004}と\texttt{nodeluxe}のいずれかのオプションが有効になっているときに使われる.
8063 %</ja>
8064 \par\nobreak\medskip
8065 {\centering\small
8066 \begin{tabular}{lllll}
8067 \toprule
8068 \textbf{family}&\textbf{series}&\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
8069 \midrule
8070 %<*en>
8071 &medium&IPA Mincho&IPAex Mincho&MS Mincho\\
8072 \smash{\raisebox{1.5ex}{\textit{mincho}}}%
8073 &bold&HG Mincho E&HG Mincho E&HG Mincho E\\\midrule
8074 &&IPA Gothic*&IPAex Gothic*&MS Gothic*\\
8075 &\smash{\raisebox{1.5ex}{medium}}%
8076 &HG Gothic M&HG Gothic M&HG Gothic M\\\cmidrule{2-5}
8077 \textit{gothic}&bold&HG Gothic E&HG Gothic E&HG Gothic E\\\cmidrule{2-5}
8078 &extra bold&HG Soei Kaku Gothic UB&HG Soei Kaku Gothic UB&HG Soei Kaku Gothic UB\\\midrule
8079 \textit{rounded gothic}&&
8080 HG MaruGothic M PRO&HG MaruGothic M PRO&HG MaruGothic M PRO\\
8081 %</en>
8082 %<*ja>
8083 &medium&IPA明朝&IPAex明朝&MS明朝\\
8084 \smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8085 &bold&HG明朝E&HG明朝E&HG明朝E\\\midrule
8086 &&IPAゴシック*&IPAexゴシック*&MSゴシック*\\
8087 &\smash{\raisebox{1.5ex}{medium}}%
8088 &HGゴシックM&HGゴシックM&HGゴシックM\\\cmidrule{2-5}
8089 \textgt{ゴシック}&bold&HGゴシックE&HGゴシックE&HGゴシックE\\\cmidrule{2-5}
8090 &extra bold&HG創英角ゴシックUB&HG創英角ゴシックUB&HG創英角ゴシックUB\\\midrule
8091 \textgt{丸ゴシック}&&
8092 HG丸ゴシックM-PRO&HG丸ゴシックM-PRO&HG丸ゴシックM-PRO\\
8093 %</ja>
8094 \bottomrule
8095 \end{tabular}\par\medskip}
8096
8097 %<*en>
8098 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
8099 are internally specified by:
8100 \begin{description}
8101 \item[default] by font name (\texttt{HGMinchoE}, etc.).
8102 \item[\texttt{jis90}, \texttt{90jis}] by file name (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
8103 \item[\texttt{jis2004}, \texttt{2004jis}] by file name (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
8104 \end{description}
8105 %</en>
8106 %<*ja>
8107 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
8108 \begin{description}
8109 \item[標準] フォント名(\texttt{HGMinchoE} など)
8110 \item[\texttt{jis90}, \texttt{90jis}指定時] ファイル名 (%
8111 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
8112 \item[\texttt{jis2004}, \texttt{2004jis}指定時] ファイル名 (%
8113 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
8114 \end{description}
8115 として指定を行っているので注意すること.
8116 %</ja>
8117
8118 %<en>\subsubsection{Define/Use Custom Presets}
8119 %<ja>\subsubsection{新たなプリセットの定義}
8120
8121 %<*ja>
8122 バージョン20170904.0以降では,自分で新たなプリセットを定義することが出来るようになった.
8123 以下に説明する2命令はプリアンブルでしか実行できない.
8124 %</ja>
8125 %<*en>
8126 From version~20170904.0, one can define new presets using \cs{ltjnewpreset},
8127 and use them by \cs{ltjapplypreset}. These two commands can only be used in the preamble.
8128 %</en>
8129 \begin{cslist}
8130  \item[\cs{ltjnewpreset}\{<name>\}\{<specification>\}]
8131 %<*ja>
8132   新たに<name>という名称のプリセットを定義する.この名称は,
8133   すでに定義されているプリセット名や,
8134   \ref{sssec:ltjpreset-general}で定義されているオプション,さらに
8135   次の9つと重複してはならない.
8136   \begin{quote}
8137         \ttfamily
8138         mc mc-l mc-m mc-bx gt gt-m gt-bx gt-eb mg-m
8139   \end{quote}
8140
8141   <specification>は,プリセット名や以下のキー達のコンマ区切りリストを指定する:
8142   \begin{description}
8143    \item[\ttfamily mc-l=<font>] 明朝体細字(\cs{mcfamily}\cs{ltseries})
8144    \item[\ttfamily mc-m=<font>] 明朝体中字(\cs{mcfamily}\cs{mdseries})
8145    \item[\ttfamily mc-bx=<font>] 明朝体太字(\cs{mcfamily}\cs{bfseries})
8146    \item[\ttfamily gt-m=<font>] ゴシック体中字(\cs{gtfamily}\cs{mdseries})
8147    \item[\ttfamily gt-bx=<font>] ゴシック体太字(\cs{gtfamily}\cs{bfseries})
8148    \item[\ttfamily gt-eb=<font>] ゴシック体太字(\cs{gtfamily}\cs{ebseries})
8149    \item[\ttfamily mg-m=<font>] 丸ゴシック体(\cs{mgfamily})
8150    \item[\ttfamily mc=<font>] 明朝体の細字・中字・太字全部を設定.
8151         以下を指定したことと同じである:
8152         \begin{quote}
8153           \ttfamily mc-l=<font>, mc-m=<font>, mc-bx=<font>
8154         \end{quote}
8155    \item[\ttfamily gt=<font>] ゴシック体の中字・太字・極太全部を設定.
8156         以下を指定したことと同じである:
8157         \begin{quote}
8158           \ttfamily gt-m=<font>, gt-bx=<font>, gt-eb=<font>
8159         \end{quote}
8160   \end{description}
8161   なお,パッケージ読み込み時に \texttt{deluxe} が有効でない場合は,
8162   上記9キーのうち\texttt{mc}, \texttt{gt}しか実質的に意味を持たない.  
8163 %</ja>
8164 %<*en>
8165   Define new preset~<name>. This <name> cannot be same as other presets,
8166   options described in Subsubsection~\ref{sssec:ltjpreset-general}, nor
8167   following nine strings:
8168   \begin{quote}
8169         \ttfamily
8170         mc mc-l mc-m mc-bx gt gt-m gt-bx gt-eb mg-m
8171   \end{quote}
8172
8173   <specification> is a comma-separated list which consists of
8174   other presets and/or the following keys:
8175   \begin{description}
8176    \item[\ttfamily mc-l=<font>] mincho light
8177    \item[\ttfamily mc-m=<font>] mincho medium
8178    \item[\ttfamily mc-bx=<font>] mincho bold
8179    \item[\ttfamily gt-m=<font>] gothic medium
8180    \item[\ttfamily gt-bx=<font>] gothic bold
8181    \item[\ttfamily gt-eb=<font>] gothic extra~bold
8182    \item[\ttfamily mg-m=<font>] rounded gothic
8183    \item[\ttfamily mc=<font>] Same as
8184         \begin{quote}
8185           \ttfamily mc-l=<font>, mc-m=<font>, mc-bx=<font>
8186         \end{quote}
8187    \item[\ttfamily gt=<font>] Same as
8188         \begin{quote}
8189           \ttfamily gt-m=<font>, gt-bx=<font>, gt-eb=<font>
8190         \end{quote}
8191   \end{description}
8192   If \texttt{deluxe} is not specified at loading the package,
8193   only \texttt{mc}~and~\texttt{gt} keys (among above 9~keys) have a meaning.
8194 %</en>
8195  \item[\cs{ltjnewpreset}*\{<name>\}\{<specification>\}]
8196 %<*ja>
8197   \cs{ltjnewpreset}とほぼ同じであるが,こちらはすでに定義されているプリセット名
8198   を<name>に指定した場合にはエラーを出さずに定義を置き換える.
8199 %</ja>
8200 %<*en>
8201   Almost same as \cs{ltjnewpreset}. However, if <name> matches a preset which already defined,
8202   this command simply overwrite it.
8203 %</en>
8204  \item[\cs{ltjapplypreset}\{<name>\}]
8205 %<ja> <name>で指定されたプリセットを使って和文フォントを設定する.
8206 %<en> Set Japanese font families using preset~<name>.
8207 \end{cslist}
8208
8209 %<*ja>
8210 なお,\cs{ltjnewpreset}の第二引数<specification>に含まれる
8211 プリセット名は\cs{ltjnewpreset}の時点で定義されている必要はなく,
8212 \cs{ltjapplypreset}で実際に使うときに定義されていれば良い.
8213 そのため,次のような記述も可能である:
8214 \begin{lstlisting}
8215   \ltjnewpreset{hoge}{piyo,mc-bx=HiraMinProN-W6}
8216   \ltjnewpreset{piyo}{mg-m=HiraMaruProN-W4}
8217   \ltjapplypreset{hoge}
8218 \end{lstlisting}
8219
8220 \paragraph{注意}
8221 \cs{ltjnewpreset}で定義したプリセットには以下の制限がある.
8222 \begin{itemize}
8223   \item 非埋め込みのフォントを指定することはできない.
8224   \item \texttt{ipa-hg}などのいくつかのプリセットでは
8225   「\texttt{90jis}, \texttt{jis2004}が指定されているか否かでフォントの指定を変える」処理が
8226   行われていたが,\cs{ltjnewpreset}で定義したプリセットではこの処理は働かない.
8227   HGフォントやモガ明朝などを使うプリセットを定義する場合には注意すること.
8228 \end{itemize}
8229 %</ja>
8230 %<*en>
8231 Note that \cs{ltjnewpreset} does not ``expand'' the definition to define a preset.
8232 This means that one can write as the following:
8233 \begin{lstlisting}
8234   \ltjnewpreset{hoge}{piyo,mc-bx=HiraMinProN-W6}
8235   \ltjnewpreset{piyo}{mg-m=HiraMaruProN-W4}
8236   \ltjapplypreset{hoge}
8237 \end{lstlisting}
8238
8239 \paragraph{Restrictions}
8240 Presets which are defined by \cs{ltjnewpreset} have following restrictions:
8241 \begin{itemize}
8242   \item One cannot specify non-embedded fonts (such as Ryumin-Light).
8243   \item Some presets, such as \texttt{ipa-hg}, have a feature that
8244   fonts are changed according to whether \texttt{90jis}~or~\texttt{jis2004} is speified.
8245   This feature is not usable in presets which are defined by \cs{ltjnewpreset}.
8246 \end{itemize}
8247 %</en>
8248
8249
8250 \clearpage
8251 %<en>\part{Implementations}
8252 %<ja>\part{実装}
8253 \label{part-imp}
8254 %<en>\section{Storing Parameters}
8255 %<ja>\section{パラメータの保持}
8256 \label{sec-para}
8257 %<en>\subsection{Used dimensions, attributes and whatsit nodes}
8258 %<ja>\subsection{\LuaTeX-jaで用いられるレジスタとwhatsitノード}
8259
8260 %<*en>
8261 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
8262 %</en>
8263 %<*ja>
8264 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
8265 リストである.
8266 %</ja>
8267 \begin{list}{}{%
8268 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
8269 \def\dim#1{\item[\textbackslash #1\ \textrm{(dimension)}]}
8270 \def\cnt#1{\item[\textbackslash #1\ \textrm{(counter)}]}
8271 \def\attr#1{\item[\textbackslash #1\ \textrm{(attribute)}]}
8272 }
8273
8274 \dim{jQ}
8275 %<*en>
8276 \cs{jQ} is equal to
8277                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
8278                         a unit used in Japanese phototypesetting.
8279 So one should not change the value of this dimension.
8280 %</en>
8281 %<*ja>
8282 \cs{jQ} は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
8283 (「級」とも書かれる)に等しい.したがって,
8284 この寸法レジスタの値を変更してはならない.
8285 %</ja>
8286
8287 \dim{jH}
8288 %<*en>
8289 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
8290                          used in Japanese phototypesetting.
8291 This \cs{jH} is the same \cs{dimen} register as \cs{jQ}.
8292 %</en>
8293 %<*ja>
8294 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
8295 等しい.この \cs{jH} は \cs{jQ} と同じ寸法レジスタを指す.
8296 %</ja>
8297
8298 \dim{ltj@zw}
8299 %<*en>
8300 A temporal register for the ``full-width'' of current Japanese font.
8301 The command \cs{zw} sets this register to the correct value, and
8302 ``return'' this register itself.
8303 %</en>
8304 %<*ja>
8305 現在の和文フォントの「全角幅」を保持する一時レジスタ.
8306 \cs{zw} 命令は,このレジスタを適切な値に設定した後,
8307 「このレジスタ自体を返す」.
8308 %</ja>
8309
8310 \dim{ltj@zh}
8311 %<*en>
8312 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
8313 The command \cs{zh} sets this register to the correct value, and
8314 ``return'' this register itself.
8315 %</en>
8316 %<*ja>
8317 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
8318 \cs{zh} 命令は,このレジスタを適切な値に設定した後,
8319 「このレジスタ自体を返す」.
8320 %</ja>
8321
8322 \attr{jfam}
8323 %<*en>
8324 Current number of Japanese font family for math formulas.
8325 %</en>
8326 %<*ja>
8327 数式用の和文フォントファミリの現在の番号.
8328 %</ja>
8329
8330 \attr{ltj@curjfnt}
8331 %<*en>
8332 If this attribute is a positive number, it stores the font number of current Japanese font for horizontal direction.
8333 If this attribute is negative, it means that the Japanese font for horizontal direction is
8334 not loaded---\LuaTeX-ja only knows its size and JFM.
8335 %</en>
8336 %<*ja>
8337 基本的には現在の横組用和文フォントのフォント番号を格納しているが,
8338 \LaTeX 下で使用する場合は($-2$以下の)負数となることがある.
8339   負数の場合は「横組用和文フォントは実際には読み込まれておらず,そのフォントサイズとJFMだけが
8340   \LuaTeX-jaが把握している」状態を表す.
8341 %</ja>
8342
8343 \attr{ltj@curtfnt}
8344 %<*en>
8345 Similar to \cs{ltj@curjfnt}, but with current Japanese font for vertical direction.
8346 %</en>
8347 %<*ja>
8348 縦組用和文フォントに関する\cs{ltj@curjfnt}と同様の値.
8349 %</ja>
8350
8351 \attr{ltj@charclass}
8352 %<*en>
8353 The character class of a \textbf{JAchar}. This attribute is only set on a
8354                          \textit{glyph\_node} which contains a \textbf{JAchar}.
8355 %</en>
8356 %<*ja>
8357 \textbf{JAchar}の文字クラス.\textbf{JAchar}が格納された\textit{glyph\_node}でのみ使われる.
8358 %</ja>
8359
8360 \attr{ltj@yablshift}
8361 %<*en>
8362 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
8363 %</en>
8364 %<*ja>
8365 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
8366 %</ja>
8367
8368 \attr{ltj@ykblshift}
8369 %<*en>
8370 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
8371 %</en>
8372 %<*ja>
8373 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
8374 %</ja>
8375
8376 \attr{ltj@tablshift}
8377 \attr{ltj@tkblshift}
8378
8379 \attr{ltj@autospc}
8380 %<*en>
8381 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
8382 %</en>
8383 %<*ja>
8384 そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
8385 %</ja>
8386
8387 \attr{ltj@autoxspc}
8388 %<*en>
8389 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
8390 %</en>
8391 %<*ja>
8392 そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
8393 %</ja>
8394
8395 \attr{ltj@icflag}
8396 %<*en>
8397 An attribute for distinguishing ``kinds'' of a node. One of the following value is
8398 assigned to this attribute:
8399 %</en>
8400 %<*ja>
8401 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
8402 %</ja>
8403 \begin{description}
8404 \item[\textit{italic} (1)]
8405 %<*en>
8406 Kerns from italic correction (\verb+\/+), or from kerning information of a Japanese font.
8407 These kerns are ``ignored'' in the insertion process of \textbf{JAglue},
8408 unlike explicit \cs{kern}.
8409 %</en>
8410 %<*ja>
8411 イタリック補正(\verb+\/+)によるカーン,
8412 または \Pkg{luaotfload} によって挿入されたフォントのカーニング情報由来のカーン.
8413 これらのカーンは通常の \cs{kern} とは異なり,
8414 \textbf{JAglue}の挿入処理においては透過する.
8415 %</ja>
8416
8417 \item[\textit{packed} (2)]
8418
8419 \item[\textit{kinsoku} (3)]
8420 %<*en>
8421 Penalties inserted for the word-wrapping process (\emph{kinsoku shori}) of Japanese characters.
8422 %</en>
8423 %<ja>禁則処理のために挿入されたペナルティ.
8424 \item[\mathversion{bold}$(\textit{from\_jfm}-2)$--$(\textit{from\_jfm}+2)$~(4--8)]
8425 %<en>Glues/kerns from JFM.
8426 %<ja>JFM由来のグルー/カーン.
8427 \item[\textit{kanji\_skip}~(9), \textit{kanji\_skip\_jfm}~(10)]
8428 %<en>Glues from \Param{kanjiskip}.
8429 %<ja>和文間空白\Param{kanjiskip}を表すグルー.
8430 \item[\textit{xkanji\_skip}~(11), \textit{xkanji\_skip\_jfm}~(12)]
8431 %<en>Glues from \Param{xkanjiskip}.
8432 %<ja>和欧文間空白\Param{xkanjiskip}を表すグルー.
8433 \item[\textit{processed} (13)]
8434 %<en>Nodes which is already processed by \ldots.
8435 %<ja>\LuaTeX-ja の内部処理によって既に処理されたノード.
8436 \item[\textit{ic\_processed} (14)]
8437 %<*en>
8438 Glues from an italic correction, but already processed in the insertion process of \textbf{JAglue}s.
8439 %</en>
8440 %<ja>イタリック補正に由来するグルーであって,既に \textbf{JAglue} 挿入処理にかかったもの.
8441 \item[\textit{boxbdd} (15)]
8442 %<en>Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
8443 %<ja>hboxか段落の最初か最後に挿入されたグルー/カーン.
8444 \end{description}
8445
8446 %<*ja>
8447 また,挿入処理の結果であるリストの最初のノードでは,\verb+\ltj@icflag+ の値に
8448 \textit{processed\_begin\_flag}~(128)が追加される.これによって,\cs{unhbox} が
8449 連続した場合でも「ボックスの境界」が識別できるようになっている.
8450 %</ja>
8451
8452 \attr{ltj@kcat\,$i$}
8453 %<*en>
8454 Where $i$~is a natural number which is less than~7.
8455 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
8456 %</en>
8457 %<*ja>
8458 $i$は7より小さい自然数.
8459 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
8460 扱われるかを示すビットベクトルを格納する.
8461 %</ja>
8462
8463 \attr{ltj@dir}
8464 %<*ja>
8465 \textit{direction}~whatsit(後述)において組方向を示すために,あるいは\textit{dir\_box}の
8466                          組方向を用いる.\textit{direction}~whatsitにおいては値は
8467 \begin{quote}
8468  \textit{dir\_dtou} (1), \textit{dir\_tate} (3),
8469  \textit{dir\_yoko} (4), \textit{dir\_utod} (11)
8470 \end{quote}
8471 のいずれかであり,\textit{dir\_box}ではこれらに次を加えた値をとる(\ref{sec-dir-imp}章参照).
8472 %</ja>
8473 \begin{description}
8474 \item[\textit{dir\_node\_auto} (128)]
8475 %<ja> 異なる組方向に配置するために自動的に作られたボックス.
8476 \item[\textit{dir\_node\_manual} (256)]
8477 %<ja> \cs{ltjsetwd} によって「ボックスの本来の組方向とは異なる組方向での寸法」を
8478 %<ja> 設定したときに,それを記録するためのボックス.
8479 \end{description}
8480 %<ja> \TeX 側から見える値,つまり \verb+\the\ltj@dir+ の値は常に0である.
8481
8482 \cnt{ltjlineendcomment}
8483 %<*ja>
8484   \LuaTeX-jaは\textbf{JAchar}で入力行が終了した場合,その直後にコメント文字を
8485   おくことで余計な空白が挿入されることを防いでいる.
8486   \cs{ltjlineendcomment}はその際のコメント文字のUnicodeにおける符号位置を指定する
8487   (詳細は\ref{ssec:lineend}節を参照).
8488
8489   \LuaTeX-jaにおける既定値は$\texttt{"FFFFF}=1048575$であり,
8490   ユーザは内部動作を熟知していない限りこのカウンタの値を変更してはならない.
8491   \cs{ltjlineendcomment}の値がUnicodeの範囲外(負や,$\texttt{"10FFFF}=1114111$を超えた場合)
8492   にくることは想定されていない.
8493 %</ja>
8494 \end{list}
8495
8496 %<*en>
8497 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
8498 internal processing. All those nodes except \emph{direction} whatsits
8499 store a natural number (hence its \texttt{type} is 100).
8500 \emph{direction} whatsits store a node list, hence its \texttt{type} is 110.
8501 Their \texttt{user\_id} (used for distinguish user-defined whatsits)
8502 are allocated by \texttt{luatexbase.newuserwhatsitid}.
8503 %</en>
8504 %<*ja>
8505 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
8506 \textit{direction} whatsitはノードリストを格納するが,
8507 それ以外のwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
8508 user-defined whatsitを識別するための \texttt{user\_id} は\
8509 \texttt{luatexbase.newuserwhatsitid} により確保されており,
8510 下の見出しは単なる識別用でしかない.
8511 %</ja>
8512 \begin{description}
8513 \item[\textit{inhibitglue}]
8514 %<*en>
8515 Nodes for indicating that \cs{inhibitglue} is
8516            specified. The \texttt{value} field of these nodes doesn't matter.
8517 %</en>
8518 %<*ja>
8519 \cs{inhibitglue} が指定されたことを示すノード.これらのノードの\
8520 \texttt{value} フィールドは意味を持たない.
8521 %</ja>
8522
8523 \item[\textit{stack\_marker}]
8524 %<*en>
8525 Nodes for \LuaTeX-ja's stack system (see the next
8526            subsection). The \texttt{value} field of these nodes is
8527            current group level.
8528 %</en>
8529 %<*ja>
8530 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
8531 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
8532 %</ja>
8533
8534 \item[\textit{char\_by\_cid}]
8535 %<*en>
8536 Nodes for \textbf{JAchar} which the callback process of
8537            \Pkg{luaotfload} won't be applied, and the character code is
8538            stored in the \texttt{value} field. Each node of this type are
8539            converted to a \textit{glyph\_node} \emph{after}
8540            the callback process of luaotfload.
8541 Nodes of this type is used in \cs{CID}, \cs{UTF} and IVS support.
8542 %</en>
8543 %<*ja>
8544 \Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{JAchar}のためのノードで,
8545 \texttt{value} フィールドに文字コードが格納されている.
8546 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
8547 \emph{後で}\textit{glyph\_node}に変換される.
8548 \cs{CID}, \cs{UTF}やIVS対応処理でこの種類のノードが利用されている.
8549 %</ja>
8550
8551 \item[\textit{replace\_vs}]
8552 %<*en>
8553 Similar to \textit{char\_by\_cid} whatsits above.
8554 These nodes are for \textbf{ALchar} which the callback process of
8555            \Pkg{luaotfload} won't be applied.
8556 %</en>
8557 %<*ja>
8558 上の\textit{char\_by\_cid}と同様に,
8559 これらのノードは\Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{ALchar}のた
8560            めものである.
8561 %</ja>
8562
8563 \item[\textit{begin\_par}]
8564 %<*en>
8565 Nodes for indicating beginning of a paragraph.
8566 A paragraph which is started by \cs{item} in list-like environments has a horizontal box
8567 for its label before the actual contents. So \dots
8568 %</en>
8569 %<*ja>
8570 「段落の開始」を意味するノード.
8571 \texttt{list}環境,\texttt{itemize}環境などにおいて,\cs{item} で始まる各項目は……
8572 %</ja>
8573
8574 \item[\textit{direction}]
8575
8576 \end{description}
8577
8578 %<*en>
8579 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
8580 %</en>
8581 %<*ja>
8582 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
8583 %</ja>
8584
8585 %<en>\subsection{Stack system of \LuaTeX-ja}
8586 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
8587 \label{ssec:stack}
8588
8589 %<en>\paragraph{Background}
8590 %<ja>\paragraph{背景}
8591 %<*en>
8592 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
8593 are stored in it. To clarify the reason, imagine the parameter
8594 \Param{kanjiskip} is stored by a skip, and consider the following
8595 source:
8596 %</en>
8597 %<*ja>
8598 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
8599 これを用いて保持されている.その理由を明らかにするために,
8600 \Param{kanjiskip}パラメータがスキップレジスタで保持されているとし,
8601 以下のコードを考えてみよう:
8602 %</ja>
8603 \begin{LTXexample}
8604 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
8605 \setbox0=\hbox{%
8606   \ltjsetparameter{kanjiskip=5pt}ほげほげ}
8607 \box0.ぴよぴよ\par
8608 \end{LTXexample}
8609
8610 %<*en>
8611 As described in Subsection~\ref{ssec:param}, the only effective value of
8612 \Param{kanjiskip} in an hbox is the latest value, so the value of
8613 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
8614 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
8615 known from any callbacks.  In the \texttt{tex/packaging.w}, which is a
8616 file in the source of \LuaTeX, there are the following codes:
8617 %</en>
8618 %<*ja>
8619 \ref{ssec:param}節で述べたように,あるhboxの中で効力を持つ
8620 \Param{kanjiskip}の値は最後に現れた値のみであり,したがってボックス全体に適用される
8621 \Param{kanjiskip}は5\,ptであるべきである.しかし,\LuaTeX の実
8622 装を観察すると,この5\,ptという長さはどのコールバックからも知ることはできないことがわかる.
8623 \LuaTeX のソースファイルの1つ \texttt{tex/packaging.w} の中に,
8624 以下のコードがある:
8625 %</ja>
8626 \begin{lstlisting}[numbers=left,firstnumber=1226]
8627 void package(int c)
8628 {
8629     scaled h;                   /* height of box */
8630     halfword p;                 /* first node in a box */
8631     scaled d;                   /* max depth */
8632     int grp;
8633     grp = cur_group;
8634     d = box_max_depth;
8635     unsave();
8636     save_ptr -= 4;
8637     if (cur_list.mode_field == -hmode) {
8638         cur_box = filtered_hpack(cur_list.head_field,
8639                                  cur_list.tail_field, saved_value(1),
8640                                  saved_level(1), grp, saved_level(2));
8641         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
8642 \end{lstlisting}
8643 %<*en>
8644 Notice that \texttt{unsave()} is executed \emph{before}
8645 \texttt{filtered\_hpack()}, where \texttt{hpack\_filter} callback is
8646 executed) here. So ``5\,pt'' in the above source is orphaned at
8647 \texttt{unsave()}, and hence it can't be accessed from \texttt{hpack\_filter}
8648 callback.
8649 %</en>
8650 %<*ja>
8651 \texttt{unsave()} が \texttt{filtered\_hpack()}(これは \texttt{hpack\_filter} コールバックが
8652 実行されるところである)の\emph{前に}実行されていることに注意する.
8653 したがって,上記ソース中で5\,ptは \texttt{unsave()} のところで捨てられ,
8654 \texttt{hpack\_filter} コールバックからはアクセスすることができない.
8655 %</ja>
8656
8657 %<en>\paragraph{Implementation}
8658 %<ja>\paragraph{解決法}
8659
8660 %<*en>
8661 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
8662 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
8663 %</en>
8664 %<*ja>
8665 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{%
8666 \texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
8667 ベースにしている.
8668 %</ja>
8669
8670 %<*en>
8671 These are two \TeX\ count registers for maintaining information:
8672 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
8673 the \TeX's group level when the last assignment was done.  Parameters
8674 are stored in one big table named \texttt{charprop\_stack\_table}, where
8675 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
8676 a new stack level is created by \cs{ltjsetparameter}, all data of the
8677 previous level is copied.
8678 %</en>
8679 %<*ja>
8680 情報を保持するために,2つの\TeX の整数レジスタを用いている:
8681 \verb+\ltj@@stack+ にスタックレベル,\verb+\ltj@@group@level+ に最後の代入が
8682 なされた時点での\TeX のグループレベルを保持している.
8683 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
8684 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
8685 データを格納している.もし新しいスタックレベルが \cs{ltjsetparameter} によって
8686 生成されたら,前のレベルの全てのデータがコピーされる.
8687 %</ja>
8688
8689 %<*en>
8690 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
8691 another trick. When the stack level is about to be increased, a whatsit
8692 node whose type, subtype and value are 44~(\textit{user\_defined}),
8693 \textit{stack\_marker} and the current group level respectively is appended to the current
8694 list (we refer this node by \textit{stack\_flag}). This enables us to
8695 know whether assignment is done just inside a hbox. Suppose that the
8696 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
8697 group, then:
8698 %</en>
8699 %<*ja>
8700 上の「背景」で述べた問題を解決するために,\LuaTeX-jaでは次の手法を用いる:
8701 スタックレベルが増加するするとき,type, subtype, valueがそれぞれ
8702 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
8703 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
8704 これにより,あるhboxの中で代入がなされたかどうかを知ることが可能
8705 となる.スタックレベルを$s$,そのhbox groupの直後の\TeX のグループレベルを
8706 $t$とすると:
8707 %</ja>
8708 \begin{itemize}
8709 %<*en>
8710 \item If there is no \textit{stack\_flag} node in the list of the contents of the hbox, then
8711       no assignment was occurred inside the hbox. Hence values of
8712       parameters at the end of the hbox are stored in the stack
8713       level~$s$.
8714 %</en>
8715 %<*ja>
8716 \item もしそのhboxの中身を表すリストの中に\textit{stack\_flag}ノードがなければ,
8717   hboxの中では代入は起こらなかったということになる.
8718   したがって,そのhboxの終わりにおけるパラメータの値はスタックレベル$s$に
8719   格納されている.
8720 %</ja>
8721
8722 %<*en>
8723 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
8724       an assignment was occurred just inside the hbox group. Hence
8725       values of parameters at the end of the hbox are stored in the
8726       stack level~$s+1$.
8727 %</en>
8728 %<*ja>
8729 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
8730   hboxの中で代入が起こったことになる.
8731   したがって,hboxの終わりにおけるパラメータの値はスタックレベル$s+1$に
8732   格納されている.
8733 %</ja>
8734
8735 %<*en>
8736 \item If there are \textit{stack\_flag} nodes but all of their values
8737       are more than~$t+1$, then an assignment was occurred in the box,
8738       but it is done in more internal group. Hence values of
8739       parameters at the end of the hbox are stored in the stack
8740       level~$s$.
8741 %</en>
8742 %<*ja>
8743 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
8744   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
8745   起こったということになる.したがって,hboxの終わりでのパラメータの
8746   値はスタックレベル$s$に格納されている.
8747 %</ja>
8748 \end{itemize}
8749
8750 %<*en>
8751 Note that to work this trick correctly, assignments to
8752 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
8753 regardless the value of \cs{globaldefs}.
8754 To solve this problem, we use another trick: the assignment
8755 \hbox{\verb+\directlua{tex.globaldefs=0}+} is always local.
8756 %</en>
8757 %<*ja>
8758 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
8759 代入は \cs{globaldefs} の値によらず常にローカルでなければならないことに注意する.
8760 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
8761 用いることで解決している.
8762 %</ja>
8763
8764 %<*en>
8765 \subsection{Lua functions of the stack system}
8766 In this subsection, we will see how a user use \LuaTeX-ja's stack system to
8767 store some data which obeys the grouping of \TeX.
8768 %</en>
8769 %<*ja>
8770 \subsection{スタックシステムで使用される関数}
8771 本節では,ユーザが\LuaTeX-jaのスタックシステムを使用して,
8772 \TeX のグルーピングに従うような
8773 独自のデータを取り扱う方法を述べる.
8774 %</ja>
8775
8776 %<*en>
8777 The following function can be used to store data into a stack:
8778 \begin{lstlisting}
8779 luatexja.stack.set_stack_table(index, <any> data)
8780 \end{lstlisting}
8781 Any values which except \texttt{nil}~and~NaN are usable as \textit{index}.
8782 However, a user should use only negative integers or strings as \textit{index},
8783 since natural numbers are used by \LuaTeX-ja itself.
8784 Also, whether \textit{data} is stored locally or globally
8785 is determined by \texttt{luatexja.isglobal}
8786 (stored globally if and only if \texttt{luatexja.isglobal == 'global'}).
8787 %</en>
8788 %<*ja>
8789 スタックに値を設定するには,以下のLua関数を呼び出せば良い:
8790 \begin{lstlisting}
8791 luatexja.stack.set_stack_table(<any> index, <any> data)
8792 \end{lstlisting}
8793 直感的には,スタックテーブル中のインデックス\textit{index}の値を\textit{data}にする,という意味である.
8794 \textit{index}の値としては \texttt{nil} とNaN以外の任意の値を使えるが,
8795 自然数は\LuaTeX-jaが使用する(将来の拡張用も含む)ので,
8796 ユーザが使用する場合は負の整数値か文字列の値にすることが望ましい.
8797 また,ローカルに設定されるかグローバルに設定されるかは,\texttt{luatexja.isglobal} の値に依存する
8798 (グローバルに設定されるのは,\texttt{luatexja.isglobal == 'global'} であるちょうどその時).
8799 %</ja>
8800
8801 %<*en>
8802 Stored data can be obtained as the return value of
8803 \begin{lstlisting}
8804 luatexja.stack.get_stack_table(index, <any> default, <number> level)
8805 \end{lstlisting}
8806 where \textit{level} is the stack level, which is usually the value of \verb+\ltj@@stack+,
8807 and \textit{default} is the default value which will be returned if no values are stored
8808 in the stack table whose level is \textit{level}.
8809 %</en>
8810 %<*ja>
8811 スタックの値は,
8812 \begin{lstlisting}
8813 luatexja.stack.get_stack_table(<any> index, <any> default, <number> level)
8814 \end{lstlisting}
8815 の戻り値で取得できる.\textit{level}はスタックレベルであり,
8816 通常は \verb+\ltj@@stack+ の値を指定することになるだろう.
8817 \textit{default}はレベル\textit{level}のスタックに値が設定されていなかった場合に
8818 返すデフォルト値である.
8819 %</ja>
8820
8821 \begin{figure}[tb]
8822 \begin{lstlisting}[numbers=left, firstnumber=380]
8823 \protected\def\ltj@setpar@global{%
8824   \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
8825     \else\directlua{luatexja.isglobal=''}\fi
8826 }
8827 \protected\def\ltjsetparameter#1{%
8828   \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
8829 \protected\def\ltjglobalsetparameter#1{%
8830   \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
8831     \else\directlua{luatexja.isglobal='global'}\fi%
8832   \setkeys[ltj]{japaram}{#1}\ignorespaces}
8833 \end{lstlisting}
8834 %<ja>\caption{パラメータ設定命令の定義}
8835 %<en>\caption{Definiton of parameter setting commands}
8836 \label{fig:setpar-def}
8837 \end{figure}
8838
8839 %<*en>
8840 \subsection{Extending Parameters}
8841 Keys for \cs{ltjsetparameter}~and~\cs{ltjgetparameter} can be extended,
8842 as in \Pkg{luatexja-adjust}.
8843 %</en>
8844 %<*ja>
8845 \subsection{パラメータの拡張}
8846 ここでは,\Pkg{luatexja-adjust}で行なっているように,
8847 \cs{ltjsetparameter},~\cs{ltjgetparameter}に指定可能なキーを追加する方法
8848 を述べる.
8849 %</ja>
8850
8851 %<*en>
8852 \paragraph{Setting parameters}
8853 \autoref{fig:setpar-def} shows the \emph{most outer} definition of
8854 two commands,
8855 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter}.
8856 Most important part is the last \cs{setkeys},
8857 which is offered by the \Pkg{xkeyval} package.
8858
8859 Hence, to add a key in \cs{ltjsetparameter}, one only have to add a key
8860 whose prefix is \texttt{ltj} and whose family is \texttt{japaram}, as the following.
8861 \begin{lstlisting}
8862 \define@key[ltj]{japaram}{...}{...}
8863 \end{lstlisting}
8864
8865 \cs{ltjsetparameter}~and~\cs{ltjglobalsetparameter} automatically sets
8866 \texttt{luatexja.isglobal}. Its meaning is the following.
8867 \begin{align}
8868  \texttt{luatexja.isglobal} =
8869 \begin{cases}
8870  \texttt{'global'}&\text{global}\\
8871  \texttt{''}&\text{local}
8872 \end{cases}
8873 \end{align}
8874 This is determined not only by command name
8875 (\cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}),
8876 but also by the value of \cs{globaldefs}.
8877 %</en>
8878 %<*ja>
8879 \paragraph{パラメータの設定}
8880 \cs{ltjsetparameter} と,\cs{ltjglobalsetparameter} の定義は\autoref{fig:setpar-def}の
8881 のようになっている.
8882 本質的なのは最後の \cs{setkeys} で,これは\Pkg{xkeyval}パッケージの提供する命令である.
8883
8884 このため,\cs{ltjsetparameter} に指定可能なパラメータを追加するには,
8885 <prefix>を \texttt{ltj},<family>を \texttt{japaram} としたキーを
8886 \begin{lstlisting}
8887 \define@key[ltj]{japaram}{...}{...}
8888 \end{lstlisting}
8889 のように定義すれば良いだけである.
8890 なお,パラメータ指定がグローバルかローカルかどうかを示す \texttt{luatexja.isglobal} が,
8891 \begin{align}
8892  \texttt{luatexja.isglobal} =
8893 \begin{cases}
8894  \texttt{'global'}&\text{パラメータ設定はグローバル}\\
8895  \texttt{''}&\text{パラメータ設定はローカル}
8896 \end{cases}
8897 \end{align}
8898 として自動的にセットされる\footnote{命令が \cs{ltjglobalsetparameter} かどうかだけでは
8899 なく,実行時の \cs{globaldefs} の値にも依存して定まる.}.
8900 %</ja>
8901
8902 %<*en>
8903 \paragraph{Getting parameters}
8904 \cs{ltjgetparameter} is implemented by a Lua script.
8905
8906 For parameters that do not need additional arguments, one only have to
8907 define a function in the table \verb+luatexja.unary_pars+.
8908 For example, with the following function,
8909 \verb+\ltjgetparameter{hoge}+ returns a \emph{string} \texttt{42}.
8910 \begin{lstlisting}[numbers=left]
8911 function luatexja.unary_pars.hoge (t)
8912   return 42
8913 end
8914 \end{lstlisting}
8915 Here the argument of \verb+luatexja.unary_pars.hoge+ is
8916 the stack level of \LuaTeX-ja's stack system (see Subsection~\ref{ssec:stack}).
8917
8918 On the other hand, for parameters that need an additional argument
8919 (this must be an integer), one have to define a function in
8920 \verb+luatexja.binary_pars+ first. For example,
8921 \begin{lstlisting}[numbers=left]
8922 function luatexja.binary_pars.fuga (c, t)
8923   return tostring(c) .. ', ' .. tostring(42)
8924 end
8925 \end{lstlisting}
8926 Here the first argument $t$ is the stack level, as before.
8927 The second argument $c$ is just the second argument of \cs{ltjgetparameter}.
8928
8929 For parameters that need an additional argument, one also have to
8930 execute the \TeX\ code like
8931 \begin{lstlisting}
8932 \ltj@@decl@array@param{fuga}
8933 \end{lstlisting}
8934 to indicate that ``the parameter \texttt{fuga} needs an additional argument''.
8935 %</en>
8936 %<*ja>
8937 \paragraph{パラメータの取得}
8938 一方,\cs{ltjgetparameter} はLuaスクリプトによって実装されている.
8939 値を取得するのに追加引数の要らないパラメータについては,\verb+luatexja.unary_pars+\
8940 内に処理内容を記述した関数を定義すれば良い.例えば,Luaスクリプトで
8941 \begin{lstlisting}[numbers=left]
8942 function luatexja.unary_pars.hoge (t)
8943   return 42
8944 end
8945 \end{lstlisting}
8946 を実行すると,\verb+\ltjgetparameter{hoge}+ は \texttt{42} という\emph{文字列}を返す.
8947 関数 \verb+luatexja.unary_pars.hoge+ の引数$t$は,\ref{ssec:stack}節で述べた
8948 \LuaTeX-jaのスタックシステムにおけるスタックレベルである.
8949 戻り値はいかなる値であっても,最終的には文字列として出力されることに注意.
8950
8951 一方,追加引数(\emph{数値しか許容しない})が必要なパラメータについては,
8952 まずLuaスクリプトで処理内容の本体を記述しておく:
8953 \begin{lstlisting}[numbers=left]
8954 function luatexja.binary_pars.fuga (c, t)
8955   return tostring(c) .. ', ' .. tostring(42)
8956 end
8957 \end{lstlisting}
8958 引数$t$は,先に述べた通りのスタックレベルである.一方,引数$c$は\
8959 \cs{ltjgetparameter} の第2引数を表す数値である.
8960 しかしこれだけでは駄目で,
8961 \begin{lstlisting}
8962 \ltj@@decl@array@param{fuga}
8963 \end{lstlisting}
8964 を実行し,\TeX インターフェース側に
8965 「\verb+\ltjgetparameter{fuga}+ は追加引数が必要」ということを通知する必要がある.
8966 %</ja>
8967
8968 %<en>\section{Linebreak after a Japanese Character}
8969 %<ja>\section{和文文字直後の改行}
8970 \label{sec-lbreak}
8971 %<en>\subsection{Reference: behavior in \pTeX}
8972 %<ja>\subsection{参考:\pTeX の動作}
8973 %<*en>
8974 In~\pTeX, a line break after a Japanese character doesn't emit a space,
8975 since words are not separated by spaces in Japanese writings. However,
8976 this feature isn't fully implemented in \LuaTeX-ja due to the
8977 specification of callbacks in~\LuaTeX. To clarify the difference between
8978 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
8979 this subsection.
8980
8981 \pTeX's input processor can be described in terms of a finite state
8982 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
8983 internal states are as follows:
8984 \begin{itemize}
8985 \item State~$N$: new line
8986 \item State~$S$: skipping spaces
8987 \item State~$M$: middle of line
8988 \item State~$K$: after a Japanese character
8989 \end{itemize}
8990 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
8991 processor.  State~$K$ is similar to state~$M$, and is entered after
8992 Japanese characters.  The diagram of state transitions are indicated in
8993 \autoref{fig:ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
8994 after ``beginning/ending of a group'' characters.
8995 %</en>
8996
8997 %<*ja>
8998 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
8999 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
9000 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
9001
9002 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
9003 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
9004 以下に述べるような4状態を持っている.
9005
9006 \begin{itemize}
9007 \item State~$N$: 行の開始.
9008 \item State~$S$: 空白読み飛ばし.
9009 \item State~$M$: 行中.
9010 \item State~$K$: 行中(和文文字の後).
9011 \end{itemize}
9012 また,状態遷移は,\autoref{fig:ptexipro}のようになっており,図中の数字は
9013 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
9014 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
9015 じものになる.
9016
9017 この図から分かることは,
9018 \begin{quote}
9019 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
9020 \end{quote}
9021 ということである.
9022 %</ja>
9023
9024 \begin{figure}[!tb]
9025 \let\sp\textvisiblespace\small
9026 \begin{minipage}{.6\textwidth}%
9027 \begin{center}
9028 \unitlength=6.5mm\sf\mathversion{bold}
9029 \begin{tikzpicture}[
9030   ->, auto, shorten >=1pt
9031 ]
9032 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
9033 \node [shape=circle,draw, fill=b_cyan] (newline) at (4,7) {$N$};
9034 \node [shape=circle,draw, fill=b_cyan] (midline) at (4,4) {$M$};
9035 \node [shape=circle,draw, fill=b_cyan] (skipspc) at (8,7) {$S$};
9036 \node [shape=circle,draw, fill=b_pink]  (kanji) at (8,4) {$K$};
9037 \node [shape=rectangle,draw, fill=b_green] (scanacs) at (6,8) {scan a c.s.};
9038 \node (endk) at (8,2.5) {} ;
9039 \node (endm) at (4,2.5) {} ;
9040 \node (ends) at (8,8.5) {} ;
9041 \node (endn) at (4,8.5) {} ;
9042 \begin{scope}[font=\scriptsize]
9043 \path (newline) edge [bend right]    node [left]{G, O} (midline)
9044       (init)    edge                 node {} (newline)
9045       (midline) edge [bend right=10] node {10} (skipspc)
9046       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
9047       (skipspc) edge [loop right]    node {10} (skipspc)
9048       (newline) edge [loop right]    node {10} (newline)
9049       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
9050       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
9051       (midline) edge                 node {5\ [\sp]} (endm)
9052       (midline) edge [loop left]     node {G, O} (midline)
9053       (skipspc) edge                 node [right] {5} (ends)
9054       (newline) edge                 node {5 [\cs{par}]} (endn);
9055 \begin{scope}[red]
9056 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
9057       (midline) edge                 node [below]{J} (kanji)
9058       (kanji)   edge [bend left]     node {O} (midline)
9059       (kanji)   edge                 node {10} (skipspc)
9060       (kanji)   edge [loop right]    node {G, J} (kanji)
9061       (skipspc) edge [bend left]     node {J} (kanji)
9062       (kanji)   edge                 node {5} (endk)
9063 ;
9064 \end{scope}
9065 \end{scope}
9066 \end{tikzpicture}
9067 \end{center}
9068 \end{minipage}%
9069 \begin{minipage}{.4\textwidth}
9070 \begin{description}
9071 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
9072  and ending of group (usually \verb+}+).
9073 \item[\textsf{J}] Japanese characters.
9074 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
9075 \item[\textsf{10}] space (usually \sp).
9076 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
9077 \item[\textsf{[\sp]}, \textsf{[\cs{par}]}]
9078 emits a space, or~\cs{par}.
9079 \end{description}
9080 \end{minipage}
9081 \begin{itemize}
9082 \item We omitted about category codes
9083 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
9084 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
9085 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
9086 the input processor scans a control sequence (\textsf{scan a c.s.}).
9087 These paths are not shown in the above diagram.
9088
9089 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
9090 to State~$M$ (middle of line) sometimes.
9091 \end{itemize}
9092 %<en>\caption{State transitions of \pTeX's input processor}
9093 %<ja>\caption{\pTeX の入力処理部の状態遷移}
9094 \label{fig:ptexipro}
9095 \end{figure}
9096
9097
9098 %<en>\subsection{Behavior in \LuaTeX-ja}
9099 %<ja>\subsection{\LuaTeX-jaの動作}
9100   \label{ssec:lineend}
9101 %<*en>
9102 States in the input processor of \LuaTeX\ is the same as that of \TeX,
9103 and they can't be customized by any callbacks. Hence, we can only use
9104 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
9105 suppress a space by a line break which is after Japanese characters.
9106
9107 However, \verb+token_filter+ callback cannot be used either, since a
9108 character in category code 5~(\textit{end-of-line}) is converted into an space
9109 token \emph{in the input processor}.  So we can use only the
9110 \verb+process_input_buffer+ callback.  This means that suppressing a
9111 space must be done \emph{just before} an input line is read.
9112
9113 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
9114 \begin{quote}
9115 A character whose character code is \cs{ltjlineendcomment}%
9116 \footnote{Its default value is \texttt{"FFFFF}, so  \texttt{U+FFFFF} is used.
9117 The category code of \texttt{U+FFFFF} is set to 14~(\textit{comment}) by
9118 \LuaTeX-ja.} is appended to an input line, \emph{before \LuaTeX\ actually
9119 process it}, if and only if the following three conditions are satisfied:
9120 \begin{enumerate}
9121 \item The category code of \cs{endlinechar}%
9122 \footnote{Usually, it is $\langle$\textit{return}$\rangle$
9123       (whose character code is 13).} is 5~(\textit{end-of-line}).
9124 \item The category code of \cs{ltjlineendcomment} itself is 14~(\textit{comment}).
9125 \item The input line matches the following ``regular expression'':
9126 \[
9127   (\text{any char})^*(\textbf{JAchar})
9128   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
9129 \]
9130 \end{enumerate}
9131 \end{quote}
9132
9133 \paragraph{Remark}
9134 The following example shows the major difference from the behavior of \pTeX.
9135 \begin{LTXexample}
9136 \fontspec[Ligatures=TeX]{Linux Libertine O}
9137 \ltjsetparameter{autoxspacing=false}
9138 \ltjsetparameter{jacharrange={-6}}xあ
9139 y\ltjsetparameter{jacharrange={+6}}zい
9140 u
9141 \end{LTXexample}
9142 It is not strange that ``あ'' does not printed in the above output.
9143 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because
9144 ``あ'' in line~3 is considered as an \textbf{ALchar}.
9145
9146 Note that there is no space before ``y'' in the output, but
9147 there is a space before ``u''. This follows from following reasons:
9148 \begin{itemize}
9149 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
9150 ``あ'' is considered as an \textbf{JAchar}.
9151 Since  line~3 ends with an \textbf{JAchar},
9152 the comment character (whose character code is \cs{ltjlineendcomment}) is appended to this line,
9153 and hence the linebreak immediately after this line is ignored.
9154 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
9155 ``い'' is considered as an \textbf{ALchar}.
9156 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
9157 emits a space.
9158 \end{itemize}
9159 %</en>
9160
9161 %<*ja>
9162 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
9163 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
9164 きそうなコールバックとしては,\verb+process_input_buffer+や
9165 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
9166 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
9167 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
9168 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
9169 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
9170
9171 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
9172 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
9173 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
9174
9175 \begin{quote}
9176 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
9177 以下の3条件が満たされている場合,\LuaTeX-jaは\cs{ltjlineendcomment}番の文字
9178 \footnote{\cs{ltjlineendcomment}の既定値は\texttt{"FFFFF}であるので,
9179   既定では\texttt{U+FFFFF}が使われることになる.この文字はコメント文字として扱われるように
9180   \LuaTeX-ja内部で設定をしている.}%
9181 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
9182 \begin{enumerate}
9183 \item \cs{endlinechar}の文字\footnote{普通は,改行文字(文字コード13番)である.}
9184 のカテゴリーコードが5~(\textit{end-of-line})である.
9185 \item \cs{ltjlineendcomment}のカテゴリーコードが14~(\textit{comment})である.
9186 \item 入力行は次の「正規表現」にマッチしている:
9187 \[
9188   (\text{any char})^*(\textbf{JAchar})
9189   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
9190 \]
9191 \end{enumerate}
9192 \end{quote}
9193
9194 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
9195 \texttt{lstlisting}系環境などの日本語対応マクロを書かなくてすませるためのものである.
9196
9197 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
9198 次のように,\textbf{JAchar}の範囲を変更したちょうどその行においては挙動が異なる:
9199 \begin{LTXexample}
9200 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
9201 \ltjsetparameter{autoxspacing=false}
9202 \ltjsetparameter{jacharrange={-6}}xあ
9203 y\ltjsetparameter{jacharrange={+6}}zい
9204 u
9205 \end{LTXexample}
9206 上ソース中の「あ」は\textbf{ALchar}(欧文扱い)であり.
9207 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
9208 よって,出力に「あ」は現れないことは不思議ではない.
9209 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
9210 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
9211 上のように異なる挙動となっているが,それは以下の理由による:
9212 \begin{itemize}
9213 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
9214       「あ」は\textbf{JAchar}(和文扱い)である.よって3行目は\textbf{JAchar}で終わることになり,
9215       \cs{ltjlineendcomment}番のコメント文字が追加される.
9216       よって,直後の改行文字は無視されることになり,空白は入らない.
9217 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
9218       「い」は\textbf{ALchar}である.よって4行目は\textbf{ALchar}で終わることになり,
9219       直後の改行文字は空白に置き換わる.
9220 \end{itemize}
9221 このため,トラブルを避けるために,\textbf{JAchar}の範囲を\cs{ltjsetparameter}で編集した場合,
9222 その行はそこで改行するようにした方がいいだろう.
9223 %</ja>
9224
9225 %<*ja>
9226
9227 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
9228 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
9229 \label{sec-jfmglue}
9230 %<en>\subsection{Overview}
9231 %<ja>\subsection{概要}
9232
9233 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
9234 \pTeX では次のような仕様であった:
9235 \begin{itemize}
9236 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
9237 追加する過程で行われる.
9238 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
9239 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
9240 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
9241 \end{itemize}
9242 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
9243 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
9244 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
9245 カーニング処理がノードベースになったことに対応する変更である.
9246
9247 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
9248 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
9249 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
9250 であり,2つのクラスタの間には,ペナルティ,\cs{vadjust},whatsitなど,行組版
9251 には関係しないものがある.
9252
9253
9254 %<en>\subsection{Definition of a Cluster}
9255 %<ja>\subsection{「クラスタ」の定義}
9256
9257 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
9258 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
9259 \def\NA{$\text{\sf N}_{\text{\sf A}}$}
9260 \def\NB{$\text{\sf N}_{\text{\sf B}}$}
9261 \begin{defn}
9262 %<*en>
9263 A \emph{cluster} is consecutive nodes in one of the following forms,
9264 with the \textit{id} of it:
9265 %</en>
9266 %<*ja>
9267 \emph{クラスタ}は以下の形のうちのどれかひとつをとるノードのリストである:
9268 %</ja>
9269 \begin{enumerate}
9270 %<*en>
9271 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
9272       nodes come from a hbox which is already packaged, by unpackaging
9273       (\cs{unhbox}).
9274       The \textit{id} of the cluster is \textit{id\_pbox}.
9275 %</en>
9276 %<*ja>
9277 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
9278   これらのノードはある既にパッケージングされたhboxから \cs{unhbox} で
9279   アンパックされたものである.
9280   この場合,クラスタの\textit{id}は\textit{id\_pbox}である.
9281 %</ja>
9282
9283 %<*en>
9284 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
9285       The \textit{id} of the cluster is \textit{id\_math}.
9286 %</en>
9287 %<*ja>
9288 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
9289   この場合,クラスタの\textit{id}は\textit{id\_math}である.
9290 %</ja>
9291
9292 %<*en>
9293 \item A \textit{glyph\_node}~$p$, which represents a \textbf{JAchar}, with nodes which relate with it:
9294 %</en>
9295 %<*ja>
9296 \item \textbf{JAchar}を表す\textit{glyph\_node}~$p$とそれに関係するノード:
9297 %</ja>
9298 \begin{enumerate}
9299 %<*en>
9300 \item[(a)] A kern for the italic correction of~$p$.
9301 %</en>
9302 %<*ja>
9303 \item[(a)] $p$のイタリック補正のためのカーン.
9304 %</ja>
9305
9306 %<*en>
9307 \item[(b)] An accent attached to $p$ by \cs{accent}.
9308 %</en>
9309 %<*ja>
9310 \item[(b)] \cs{accent} による$p$に付随したアクセント.
9311 %</ja>
9312 \end{enumerate}
9313 \[
9314 \overbrace{%
9315  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
9316 \left\{\begin{array}{c}
9317 \Node{glyph}{accent}\\\noalign{\medskip}
9318 \Node{hbox}{accent (shifted vert.)}
9319 \end{array}\right\}\longrightarrow
9320 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(b)}}
9321 \longrightarrow
9322 \Node{glyph}{$p$}\longrightarrow
9323 \overbrace{%
9324 \Node{kern}{italic corr.}}^{\text{(a)}}
9325 \]
9326
9327 %<*en>
9328 In this case, the \textit{id} is \textit{id\_jglyph}.
9329 %</en>
9330 %<*ja>
9331 この場合の\textit{id}は\textit{id\_jglyph}である.
9332 %</ja>
9333
9334 %<*en>
9335 \item A list which begins from a \textit{glyph\_node} which represents a \textbf{ALchar},
9336       and consists of \textbf{ALchar} \textit{glyph\_node}s,
9337       kerns for adjusting accents~(its subtype is 2), kerns for italic corrections and
9338       kerns which are automatically inserted by \LuaTeX~or~luaotfload.
9339       In this case, the \textit{id} is \textit{id\_glyph}.
9340 %</en>
9341 %<*ja>
9342 \item \textbf{ALchar}を表す\textit{glyph\_node},\cs{accent} によるアクセント位置補正用の
9343       カーン(subtypeが2),そしてイタリック補正・カーニングによって挿入されたカーン達が連続
9344       したもの.この場合の\textit{id}は\textit{id\_glyph}である.
9345 %</ja>
9346
9347 %<*en>
9348 \item An box-like node, that is, an hbox, a vbox, a rule (\cs{vrule}) and an \textit{unset\_node}.
9349 The \textit{id} of the cluster is \textit{id\_hlist} if the node is an
9350       hbox which is not shifted vertically, or \textit{id\_box\_like}
9351       otherwise.
9352 %</en>
9353 %<*ja>
9354 \item 水平ボックス(hbox),垂直ボックス,罫線 (\cs{vrule}),
9355   そして\textit{unset\_node}.
9356   クラスタの\textit{id}は垂直に移動していないhboxならば\textit{id\_hlist},
9357   そうでなければ\textit{id\_box\_like}となる.
9358 %</ja>
9359
9360 %<*en>
9361 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
9362 The \textit{id} of the cluster is \textit{id\_glue}, \textit{id\_kern}
9363       and \textit{id\_disc}, respectively.
9364 %</en>
9365 %<*ja>
9366 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そしてdiscretionary break.
9367   その\textit{id} of the clusterはそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
9368   \textit{id\_disc}である.
9369 %</ja>
9370 \end{enumerate}
9371 %<*en>
9372 We use \textit{Np}, \textit{Nq} and \textit{Nr} to denote a cluster.
9373 %</en>
9374 %<*ja>
9375 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
9376 %</ja>
9377 \end{defn}
9378
9379 \paragraph{\textit{id}の意味}
9380 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
9381 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
9382 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
9383 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
9384 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
9385 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
9386
9387 \begin{description}
9388 \item[\textit{id\_jglyph}] \textbf{JAchar}(和文文字).\\
9389 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その\textbf{JAchar}を表している
9390 \textit{glyph\_node}そのものである.
9391 \item[\textit{id\_glyph}] \textbf{JAchar}(和文文字)以外のものを表す\textit{glyph\_node}~$p$.\\
9392 多くの場合,$p$は\textbf{ALchar}(欧文文字)を格納しているが,「ffi」などの合字によって作られた
9393 \textit{glyph\_node}である可能性もある.
9394 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
9395 一方,後者の場合,
9396 \begin{itemize}
9397 \item $\mathit{Np}.\mathit{head}$は,
9398 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
9399 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
9400 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
9401 \end{itemize}
9402 \item[\textit{id\_math}] インライン数式.\\
9403 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
9404 「文字コード$-1$の欧文文字」とおく.
9405 \item[\textit{id\_hlist}] 縦方向にシフトされていないhbox.\\
9406 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
9407 先頭・末尾のノードである.
9408 \medskip
9409 \begin{itemize}
9410 \item 状況によっては,\TeX ソースで言うと
9411 \begin{lstlisting}
9412 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
9413 \end{lstlisting}
9414 のように,$p$の内容が別のhboxで開始・終了している可能性も十分あり得る.そのような場合,
9415 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
9416 \emph{垂直方向にシフトされていない}hboxの
9417 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
9418 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされたhbox,
9419 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
9420 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
9421 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
9422 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
9423 と同様に再帰的に構成要素をたどっていく.
9424 \end{itemize}
9425 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
9426 まとめて1つのクラスタとして取り扱うだけである.
9427 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
9428 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
9429 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
9430 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
9431 全く考慮に入れない.
9432 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
9433 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
9434 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
9435 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
9436 \end{description}
9437
9438 \paragraph{クラスタの別の分類}
9439 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
9440 挿入処理では2つの隣り合ったクラスタの間に
9441 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
9442 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
9443 \begin{description}
9444 \item[和文A] リスト中に直接出現している\textbf{JAchar}.
9445 \textit{id}が\textit{id\_jglyph}であるか,\\
9446 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
9447
9448 \item[和文B] リスト中のhboxの中身の先頭として出現した\textbf{JAchar}.和文Aとの違いは,これの前に
9449 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
9450 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
9451
9452 \item[欧文] リスト中に直接/hboxの中身として出現している「\textbf{JAchar}以外の文字」.次の3つの場合が該当:
9453 \begin{itemize}
9454 \item \textit{id}が\textit{id\_glyph}である.
9455 \item \textit{id}が\textit{id\_math}である(つまりこのクラスタは1つの文中数式をなす).
9456 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
9457 \end{itemize}
9458 \item[箱] box,またはそれに類似するもの.次の2つが該当:
9459 \begin{itemize}
9460 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
9461 \item \textit{id}が\textit{id\_box\_like}である.
9462 \end{itemize}
9463
9464 \end{description}
9465
9466 \subsection{段落/hboxの先頭や末尾}
9467 \paragraph{先頭部の処理}
9468 まず,段落/hboxの一番最初にあるクラスタ\textit{Np}を探索する.
9469 hboxの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
9470 \begin{itemize}
9471 \item \cs{parindent} 由来のhbox($\mathit{subtype}=3$)
9472 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
9473 \end{itemize}
9474 これは,\cs{parindent}由来のhboxがクラスタを構成しないようにするためである.
9475
9476 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
9477 \begin{enumerate}
9478 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
9479 \item 問題のリストが字下げありの段落(\cs{parindent} 由来のhboxあり)の場合は,
9480 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
9481 \item そうでないとき(\verb+noindent+ で開始された段落やhbox)は,
9482 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
9483 \end{enumerate}
9484 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
9485 そこで,以下の場合には,$g$の直前に \cs{penalty10000} を挿入する:
9486 \begin{itemize}
9487 \item 問題にしているリストが段落であり,かつ
9488 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
9489 \end{itemize}
9490
9491 \paragraph{末尾の処理}
9492 末尾の処理は,問題のリストが段落のものかhboxのものかによって異なる.
9493 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\
9494 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
9495 \textit{Nq}の直後に挿入するのみである.
9496
9497 一方.前者(段落)の場合は,リストの末尾は常に \cs{penalty10000} と,
9498 \cs{parfillskip} 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
9499 %この \cs{parfillskip} 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
9500 段落の最後の「通常の\textbf{JAchar}${}+{}$句点」が独立した行となるのを防ぐために,
9501 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
9502
9503 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
9504 かつその文字の\Param{kcatcode}が偶数であるような
9505 最後のクラスタの直前にあるものたちである%
9506 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
9507 を約物として考えていることになる.
9508 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
9509
9510 \subsection{概観と典型例:2つの「和文A」の場合}
9511 \label{ssec:cluster-wa}
9512 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
9513 ペナルティ,\cs{vadjust},whatsitなど,行組版には関係しないものがある.模式的に表すと,
9514 \[
9515  \Node{cluster}{\textit{Nq}}\longrightarrow
9516 \overbrace{
9517 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
9518 \longrightarrow \Node{cluster}{\textit{Np}}
9519 \]
9520 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
9521 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
9522 \[
9523  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
9524 \overbrace{
9525 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow
9526 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow
9527 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
9528 \Node{cluster}{\textit{Np}}
9529 \]
9530
9531 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
9532 この場合が全ての場合の基本となる.
9533
9534 \paragraph{「右空白」の算出}
9535 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの\textbf{JAchar}間に入る空白量となる.
9536 \begin{description}
9537 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
9538       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
9539 \begin{enumerate}
9540 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
9541       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
9542 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
9543       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
9544 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
9545 この場合,まず
9546 \[
9547 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
9548 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
9549 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
9550 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
9551 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
9552 }}
9553 \]
9554 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
9555
9556 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する<ratio>の値を$d_b$,~$d_a$とする.
9557 \begin{itemize}
9558 \item
9559 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
9560 \Param{kanjiskip}を採用することとなる.
9561 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,<ratio>の値は0であるかのように扱われる.
9562 \item
9563 \Param{diffrentjfm}の値が \texttt{pleft}, \texttt{pright},
9564       \texttt{paverage} のとき,
9565 <ratio>の指定に従って比例配分を行う.
9566 JFM由来のグルー/カーンは以下の値となる:
9567 \[
9568  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
9569 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
9570 \]
9571 ここで.$f(x,y)$は
9572 \[
9573  f(x,y)=\begin{cases}
9574 x&\text{if\ }\Param{diffrentjfm}=\texttt{pleft};\\
9575 y&\text{if\ }\Param{diffrentjfm}=\texttt{pright};\\
9576 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{paverage};
9577 \end{cases}.
9578 \]
9579 \item
9580 \Param{differentjfm}がそれ以外の値の時は,<ratio>の値は無視され,JFM由来のグルー/カーンは以下の値となる:
9581 \[
9582  f(\textit{gb},\textit{ga})
9583 \]
9584 ここで.$f(x,y)$は
9585 \[
9586  f(x,y)=\begin{cases}
9587 \min(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{small};\\
9588 \max(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{large};\\
9589 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{average};\\
9590 x+y&\text{if\ }\Param{diffrentjfm}=\texttt{both};
9591 \end{cases}.
9592 \]
9593 \end{itemize}
9594 \end{enumerate}
9595
9596 例えば,
9597 \begin{lstlisting}
9598 \jfont\foo=psft:Ryumin-Light:jfm=ujis;-kern
9599 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis;-kern
9600 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo;-kern
9601 \end{lstlisting}
9602 という3フォントを考え,
9603 \[
9604  \overbrace{\Node{glyph}{\cs{ foo}, `あ'}}^{p}
9605 \longrightarrow \overbrace{\Node{glyph}{\cs{bar}, `い'}}^{q}
9606 \longrightarrow \overbrace{\Node{glyph}{\cs{baz}, `う'}}^{r}
9607 \]
9608 という3ノードを考える(それぞれ単独でクラスタをなす).
9609 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
9610 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
9611 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
9612 以下で定めた量「右空白」として採用する.
9613 この段階においては,\cs{inhibitglue} は効力を持たないため,
9614 結果として,2つの\textbf{JAchar}間には常に何らかのグルー/カーンが挿入されることとなる.
9615 \begin{enumerate}
9616 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
9617 \Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
9618 \item ユーザ側から見た\Param{kanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
9619 なければ,\Param{kanjiskip}パラメタの値を持つglueを採用する.
9620 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
9621 どちらか片方のクラスタだけが\textbf{JAchar}(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
9622 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
9623 \end{enumerate}
9624 \end{description}
9625 %\paragraph{「左空白」の算出とそれに伴う補正}
9626 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
9627 %挿入は一切行われない(機能自体削除している).
9628 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
9629 \paragraph{禁則用ペナルティの挿入}
9630 まず,
9631 \[
9632  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
9633 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
9634 \]
9635 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
9636 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
9637 算出では単純な整数の加減算を行う.
9638
9639 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
9640 \begin{description}
9641 \item[P-normal~{[PN]}]
9642 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
9643 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
9644 また,$10000 + (-10000) = 0$としている.
9645
9646 少々困るのは,(a)部分にペナルティが存在していない場合である.
9647 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
9648 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
9649 ということになるが,実際には僅かにこれより複雑である.
9650 \begin{itemize}
9651 \item 「右空白」がカーンであるとき,
9652 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
9653 この場合は$a\neq 0$であってもペナルティの挿入はしない.
9654 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
9655 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
9656 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
9657 %\textit{penalty\_node}を作って挿入する.
9658 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
9659 \end{itemize}
9660 \end{description}
9661
9662 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
9663   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
9664 \begin{table}[t]
9665 %<en>\caption{Summary of JFM glues}
9666 %<ja>\caption{JFM グルーの概要}
9667 \label{tab-jfmglue}
9668 %<en>\medskip
9669 \begin{center}
9670 \small
9671 \begin{tabular}{c|cccccc}
9672 \toprule
9673 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
9674 \sf 和文A&
9675 \gkf{E}{M→K}{PN}&
9676 \gkf{---}{\OA →K}{PN}&
9677 \gkf{---}{\NA →X}{PN}&
9678 \gkf{---}{\OA}{PA}&
9679 \gkf{---}{\OA}{PN}&
9680 \gkf{---}{\OA}{PS}\\
9681 \sf 和文B&
9682 \gkf{E}{\OB→K}{PA}&
9683 \gkf{---}{K}{PS}&
9684 \gkf{---}{X}{PS}\\
9685 \sf 欧文&
9686 \gkf{E}{\NB →X}{PA}&
9687 \gkf{---}{X}{PS}\cr
9688 \sf 箱&\gkf{E}{\OB}{PA}\\
9689 \sf glue&\gkf{E}{\OB}{PN}\\
9690 \sf kern&\gkf{E}{\OB}{PS}\\
9691 \bottomrule
9692 \end{tabular}
9693 \end{center}
9694 \begin{quote}
9695 %<*en>
9696 In the table above, {\small\gkf{E}{M→K}{PN}} means that
9697 %</en>
9698 %<*ja>
9699 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
9700 %</ja>
9701 \begin{enumerate}
9702 %<*en>
9703 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
9704 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
9705 %</en>
9706 %<*ja>
9707 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
9708   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
9709 %</ja>
9710
9711 % %<*en>
9712 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is
9713 %   determined by the method ``\textsf{line-end~[E]}''.
9714 % %</en>
9715 % %<*ja>
9716 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
9717 %   方法で決定される.
9718 % %</ja>
9719
9720 %<*en>
9721 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty
9722   between two clusters for \emph{kinsoku shori}.
9723 %</en>
9724 %<*ja>
9725 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを設定するために「\textsf{P-normal~[PN]}」の方法を採用する.
9726 %</ja>
9727 \end{enumerate}
9728 \end{quote}
9729 \end{table}
9730
9731 \subsection{その他の場合}
9732 本節の内容は\autoref{tab-jfmglue}にまとめてある.
9733
9734 \paragraph{和文Aと欧文の間}
9735 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
9736 \begin{itemize}
9737 \item 「右空白」については,まず以下に述べる\textsf{欧文境界B~[\NB]}により空白を決定しようと試みる.
9738 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
9739 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
9740 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
9741 \end{itemize}
9742 \begin{description}
9743 \item[欧文境界B~{[\NB]}] 以下で求めた量を「右空白」として採用する.
9744 この処理は\textsf{JFM-origin~[M]}の変種と考えて良く,
9745 典型例は「和文の閉じ括弧と欧文文字の間に入る半角アキ」である.
9746 \begin{enumerate}
9747 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合%
9748 (証としてwhatsitノードが自動挿入される),未定義.
9749 \item そうでなければ,
9750 \textit{Nq}と「文字コードが$x$の文字」との間に入るグルー/カーンとする.
9751 この$x$は次の場合分けによる:
9752   \begin{itemize}
9753     \item $\mathit{Np}.\mathit{id}$が\textit{id\_math}のとき(つまりクラスタ\textit{Np}が文中数式を表す)
9754     ときは,$x=-1$.
9755     \item \textit{Np}の中身の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
9756 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数)ときは,
9757     $x=\text{\texttt{'nox\_alchar'}}$.
9758     \item 以上のいずれでもないときは,$x=\text{\texttt{'alchar'}}$.
9759   \end{itemize}
9760 \end{enumerate}
9761 \item[\Param{xkanjiskip}~{[X]}]
9762 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
9763 以下で定めた量を「右空白」として採用する.
9764 \cs{inhibitglue} は効力を持たない.
9765 \begin{enumerate}
9766 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
9767 \begin{itemize}
9768 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
9769 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
9770 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
9771 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
9772 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
9773 \end{itemize}
9774 \item ユーザ側から見た\Param{xkanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
9775 なければ,\Param{xkanjiskip}パラメタの値を持つglueを採用する.
9776 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
9777 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
9778 \end{enumerate}
9779 \end{description}
9780
9781 \paragraph{欧文と和文Aの間}
9782 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
9783 \textsf{和文A}のクラスタが逆になるので,\textsf{欧文境界B~[\NB]}の部分が変わるだけである.
9784 \begin{itemize}
9785 \item 「右空白」については,まず以下に述べる\textsf{欧文境界A~[\OA]}により空白を決定しようと試みる.
9786 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
9787 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
9788 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
9789 \end{itemize}
9790 \begin{description}
9791 \item[欧文境界A~{[\NA]}] これは\textsf{欧文境界B~[\NB]}で\textit{Np}と\textit{Nq}の役割が
9792   交換されたものと思えば良い.
9793   この処理で定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
9794 \begin{enumerate}
9795 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
9796   未定義.
9797 \item そうでなければ,
9798 「文字コードが$x$の文字」と\textit{Np}との間に入るグルー/カーンと定める.
9799 $x$は\textit{Nq}から\textsf{欧文境界B~[\NB]}におけるそれと同じ方法で定めるが,
9800 \texttt{'nox\_alchar'}か\texttt{'alchar'}は
9801 \begin{quote}
9802   \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
9803 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
9804 \end{quote}
9805   か否かで判断する.
9806 \end{enumerate}
9807 \end{description}
9808
9809 \paragraph{和文Aと箱・グルー・カーンの間}
9810 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
9811 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
9812 ペナルティの挿入処理は若干異なったものとなっている.
9813 \begin{itemize}
9814 \item 「右空白」については,以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
9815 それが失敗した場合は,「右空白」は挿入されない.
9816 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
9817 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
9818 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
9819 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
9820 \[
9821  a:=(\text{\textit{Nq}の文字に対する\Param{postbreakpenalty}の値}).
9822 \]
9823 \begin{description}
9824 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
9825 (明示的に両クラスタの間に \cs{penalty10000} があった場合を除き)いつも許容される.そのため,
9826 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
9827 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
9828 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
9829 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
9830 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
9831 \end{description}
9832 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
9833 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
9834 \end{itemize}
9835
9836 \begin{description}
9837 \item[Boundary-B~{[\OB]}] この処理は\textsf{欧文境界B~[\NB]}と同様であり,
9838   $x$が次によって決まることのみが異なる:
9839   \begin{itemize}
9840     \item \textit{Np}がグルーやカーンのときは,$x=\text{\texttt{'glue'}}$.
9841     \item そうでない(\textit{Np}が\textsf{箱})ときは,$x=\text{\texttt{'jcharbdd'}}$.
9842   \end{itemize}
9843 \item[P-allow~{[PA]}]
9844 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
9845 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
9846
9847 (a)部分にペナルティが存在していない場合,
9848 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
9849 そのために,以下のいずれかの場合に$a$をもつ\textit{penalty\_node}を作って
9850 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
9851 \begin{itemize}
9852 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
9853 \item $a\neq 0$のときは,「右空白」がグルーであっても\textit{penalty\_node}を作る.
9854 \end{itemize}
9855
9856 \item[P-suppress~{[PS]}]
9857 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
9858 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
9859
9860 (a)部分にペナルティが存在していない場合,
9861 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
9862 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
9863 そのため,「右空白」がglueであれば,その直前に \cs{penalty10000} を挿入する.
9864 \end{description}
9865
9866 \paragraph{箱・グルー・カーンと和文Aの間}
9867 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
9868 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
9869 %が,「左空白」がなくなることにのみ注意.
9870 \begin{itemize}
9871 \item 「右空白」については,以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
9872 それが失敗した場合は,「右空白」は挿入されない.
9873 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
9874 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
9875 $\mathit{Nq}.\mathit{tail}$は無意味なので,
9876 \[
9877  a:=(\text{\textit{Np}の文字に対する\Param{prebreakpenalty}の値}).
9878 \]
9879 \begin{description}
9880 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
9881 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
9882 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
9883 \end{description}
9884 \end{itemize}
9885
9886 \begin{description}
9887 \item[Boundary-A~{[\OA]}] この処理は\textsf{欧文境界A~[\NA]}と同様であり,
9888   $x$が次によって決まることのみが異なる:
9889   \begin{itemize}
9890     \item \textit{Nq}がグルーやカーンのときは,$x=\text{\texttt{'glue'}}$.
9891     \item そうでない(\textit{Nq}が\textsf{箱})ときは,$x=\text{\texttt{'jcharbdd'}}$.
9892   \end{itemize}
9893 \end{description}
9894
9895 \paragraph{和文Aと和文Bの違い}
9896 先に述べたように,\textsf{和文B}はhboxの中身の先頭(or 末尾)として出現している
9897 \textbf{JAchar}である.リスト内に直接ノードとして現れている\textbf{JAchar}(\textsf{和文A})との違いは,
9898 \begin{itemize}
9899 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
9900 (\textsf{JFM由来[M]},\textsf{Boundary-A~[\OA]}など)の挿入は行われない.
9901 %「左空白」の算出も行われない.
9902 例えば,
9903 \begin{itemize}
9904 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
9905 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
9906 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
9907 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
9908 \end{itemize}
9909 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
9910 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
9911 \textsf{P-suppress~[PS]}が用いられる.
9912 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
9913 \end{itemize}
9914
9915
9916 次が具体例である:
9917 \begin{LTXexample}
9918 あ.\inhibitglue A\\
9919 \hbox{あ.}A\\
9920 あ.A
9921 \end{LTXexample}
9922 \begin{itemize}
9923 \item 1行目の\cs{inhibitglue}は\textsf{欧文境界B~[\NB]}の処理のみを抑止するので,ピリオドと「A」の間には
9924 \Param{xkanjiskip}(四分アキ)が入ることに注意.
9925 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(hboxの中身の末尾として登場しているから)ので,
9926 そもそも\textsf{欧文境界B~[\NB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
9927 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
9928 ピリオドと「A」の間には\textsf{欧文境界B~[\NB]}由来の半角アキが入ることになる.
9929 \end{itemize}
9930 %</ja>
9931
9932 %<*ja>
9933 \section{ベースライン補正の方法}
9934 \subsection{\texttt{yoffset} フィールド}
9935 \Param{yalbaselineshift}等のベースライン補正は,基本的には対象となっている
9936 \textit{glyph\_node}の \texttt{yoffset} フィールドの値を増減することによって
9937 実装されている.なお,\texttt{yoffset} の値は上方向への移動量であるのに対し,
9938 \Param{yalbaselineshift}などは下方向への移動量である.
9939
9940 さて,\texttt{yoffset} の増減によって見かけのグリフ位置は上下に移動するが,
9941 仮想ボディの高さ$h$,深さ$d$については
9942 \begin{description}
9943 \catcode`\<=12\catcode`\>=12
9944  \item[$\texttt{yoffset}\geq 0$のとき]
9945 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$,
9946 $d = \max(\texttt{depth} - \texttt{yoffset}, 0)$,
9947  \item[$\texttt{yoffset}<0$のとき]
9948 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, $d=\texttt{depth}$.
9949 \end{description}
9950 という仕様になっている.つまり,\texttt{yoffset} が負(グリフを下ける)の場合に深さは増加しな
9951 い(\autoref{tab:yoffset_and_im}参照).
9952
9953 \begin{table}[t]
9954 \caption{\texttt{yoffset} and imaginary body}
9955 \label{tab:yoffset_and_im}
9956 \centering\small
9957 \fboxsep0pt
9958 \def\T#1#2{\fcolorbox{blue}{white}{%
9959   \setbox0=\hbox{\LARGE #1%
9960     \directlua{
9961       local p = tex.nest[tex.nest.ptr].tail
9962       p.yoffset = #2 * 65536
9963     }%
9964   }%
9965   \copy0\kern-\wd0\smash{\color{red}\vrule width \wd0 height 0.2pt depth 0.2pt}%
9966 }}
9967 \begin{tabular}{>{\bfseries}lccccc}
9968 \toprule
9969 \texttt{yoffset}&10\,pt&5\,pt&0&$-5$\,pt&$-10$\,pt\\
9970 \midrule
9971 仮想ボディ&\T{y}{10}, \T{H}{10}&\T{y}{5}, \T{H}{5}&\T{y}{0}, \T{H}{0}%
9972 &\T{y}{-5}, \T{H}{-5}&\T{y}{-10}, \T{H}{-10}\\[10pt]
9973 \bottomrule
9974 \end{tabular}
9975 \end{table}
9976
9977 \subsection{\textbf{ALchar}の補正}
9978 上記の問題について,\textbf{ALchar}のベースライン補正では
9979 「正しい深さ」を持った罫線(rule)を補うという対応策をとった.
9980 この罫線による補正は,\textit{id}が\textit{id\_glyph}であるクラスタ単位,
9981 大雑把に言えば音節単位で行われる.
9982 文字列``Typeset''を
9983 \begin{itemize}
9984  \item フォントはLatin Modern Roman (\texttt{lmroman10-regular.otf}) 10\,pt
9985  \item \Param{yalbaselineshift}は5\,pt
9986 \end{itemize}
9987 という状況で組んだ場合を例にとって説明しよう.
9988
9989 \LuaTeX・\Pkg{luaotfload}によるカーニング・ハイフネーションが終わった段階では,……
9990
9991
9992
9993 %</ja>
9994
9995 %<en>\section{Patch for the \Pkg{listings} Package}
9996 %<ja>\section{\Pkg{listings} パッケージへの対応}
9997
9998 %<*en>
9999 It is well-known that the \Pkg{listings} package outputs weird results
10000 for Japanese input.
10001 The \Pkg{listings} package makes most of letters active and assigns
10002 output command for each letter~(\cite{listings}).
10003 But Japanese characters are not included in these activated letters.
10004 For \pTeX{} series, there is no method to make Japanese characters active;
10005 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
10006 %</en>
10007 %<*ja>
10008 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
10009 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
10010 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
10011 力命令を割り当てている(\cite{listings}).
10012 しかし,そこでアクティブにする文字の中に,和文文
10013 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
10014 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
10015 %</ja>
10016
10017 %<*en>
10018 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
10019 The callback function inserts the output command (active character \cs{ltjlineendcomment})
10020 before each letter above \texttt{U+0080}.
10021 This method can omits the process to make all Japanese characters active
10022 (most of the activated characters are not used in many cases).
10023 %</en>
10024 %<*ja>
10025 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
10026 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
10027 という方法をとっている.出力命令としては,アクティブ文字化した\cs{ltjlineendcomment}を用いている.
10028 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
10029 見通しが良い実装になっている.
10030 %</ja>
10031
10032
10033 %<*en>
10034 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
10035 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
10036 %</en>
10037 %<*ja>
10038 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
10039 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
10040 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
10041 意識する必要はない.
10042 %</ja>
10043
10044 %<en>\subsection{Notes and additional keys}
10045 %<ja>\subsection{注意}
10046 % %<*en>
10047 % \paragraph{Escaping to \LaTeX}
10048 % We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
10049 % But it has a drawback; any commands whose name contains a \textbf{JAchar}
10050 % cannot be used in any ``escape to \LaTeX''.
10051
10052 % Consider the following input:
10053 % %</en>
10054 % %<*ja>
10055 % \paragraph{\LaTeX へのエスケープ}
10056 % 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
10057 % \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
10058 % \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
10059 % 例えば次のような入力を考えよう:
10060 % %</ja>
10061 % \begin{verbatim*}
10062 % \begin{lstlisting}[escapechar=\#]
10063 % #\ほげ xぴよ#
10064 % \end{lstlisting}
10065 % \end{verbatim*}
10066 % %<en>The line~2 is transformed by the callback to
10067 % %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
10068 % \begin{lstlisting}[showspaces, escapechar=\!]
10069 % #\!\IVSA FFFFF!ほ!\IVSA FFFFF!げ x!\IVSA FFFFF!ぴ!\IVSA FFFFF!よ#
10070 % \end{lstlisting}
10071 % %<*en>
10072 % before the line is actually processed.
10073 % In the escape (between the character ``\verb+#+''),
10074 % the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
10075 % Hence the control symbol ``\cs{}\IVSA FFFFF'' will be executed,
10076 % instead of ``\verb+\ほげ+''.
10077 % %</en>
10078 % %<*ja>
10079 % と変換されてから,実際の処理に回される.
10080 % 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
10081 % \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
10082 % 結局「\verb+\ほげ+」の代わりに
10083 % 「\cs{}\IVSA FFFFF」というcontrol symbolが実行されることになる.
10084 % %</ja>
10085
10086 %<*en>
10087 \paragraph{Variation selectors}
10088 \Pkg{lltjp-listings} add two keys, namely \texttt{vsraw}~and~\texttt{vscmd},
10089 which specify how variation selectors are treated in
10090 \texttt{lstlisting} or other enviroments.
10091 Note that these additional keys are not usable in the preamble,
10092 since \Pkg{lltjp-listings} is loaded at \verb+\begin{document}+.
10093
10094 \texttt{vsraw} is a key which takes a boolean value, and its default value is
10095 false.
10096 \begin{itemize}
10097  \item If the \texttt{vsraw} key is true, then
10098 variation selectors are ``combined'' with the previous character.
10099 %</en>
10100 %<*ja>
10101 \paragraph{異体字セレクタの扱い}
10102 \texttt{lstlisting} 環境などの内部にある異体字セレクタを扱うため,
10103 \Pkg{lltjp-listings} では \texttt{vsraw} と \texttt{vscmd} という2つのキーを追加した.
10104 しかし,\Pkg{lltjp-listings} が実際に読み込まれるのは \verb+\begin{document}+\
10105 のところであるので,プリアンブル内ではこれらの追加キーは使用できない.
10106
10107 \texttt{vsraw}は,ブール値の値をとるキーであり,標準ではfalseである.
10108 \begin{itemize}
10109  \item trueの場合は,異体字セレクタは「直前の文字に続けて」出力される.
10110 もしもIVSサポート(\ref{ssec:ltjotf}節)が有効になっていた場合は,
10111 以下の例(左側は入力,右側はその出力)のようになる.
10112 %</ja>
10113 \begin{LTXexample}
10114 \begin{lstlisting}[vsraw=true]
10115 葛󠄀城市,葛󠄁飾区,葛西
10116 \end{lstlisting}
10117 \end{LTXexample}
10118 %<*en>
10119 \item If the \texttt{vsraw} key is false, then
10120 variation selectors are typeset by an appropriate command, which is specified by
10121       the \texttt{vscmd} key.
10122 The default setting of the \texttt{vscmd} key produces the following.
10123 %</en>
10124 %<*ja>
10125 \item falseの場合は,異体字セレクタは適当な命令によって「見える形で」出力される.
10126 どのような形で出力されるかを規定するのが \texttt{vscmd} キーであり,
10127 \Pkg{lltjp-listings} の標準設定では以下の例の右側のように出力される.
10128 %</ja>
10129 \begin{LTXexample}
10130 \begin{lstlisting}[vsraw=false,
10131    vscmd=\ltjlistingsvsstdcmd]
10132 葛󠄀城市,葛󠄁飾区,葛西
10133 \end{lstlisting}
10134 \end{LTXexample}
10135 %<ja> ちなみに,本ドキュメントでは次のようにしている:
10136 %<en> For example, the following code is the setting of the \texttt{vscmd} key in this document.
10137 \begin{lstlisting}[numbers=left]
10138 \def\IVSA#1#2#3#4#5{%
10139   \textcolor{blue}{\raisebox{3.5pt}{\tt%
10140     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
10141 }
10142 {\catcode`\%=11
10143   \gdef\IVSB#1{\expandafter\IVSA\directlua{
10144     local cat_str = luatexbase.catcodetables['string']
10145     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
10146 }}}
10147 \lstset{vscmd=\IVSB}
10148 \end{lstlisting}
10149 \end{itemize}
10150 %<*en>
10151 The default output command of variation selectors is stored in \verb+\ltjlistingsvsstdcmd+.
10152 %</en>
10153 %<*ja>
10154 既定の出力命令を復活させたい場合は\ \verb+vscmd=\ltjlistingsvsstdcmd+\
10155 とすれば良い.
10156 %</ja>
10157
10158 %<*en>
10159 \paragraph{The \texttt{doubleletterspace} key}
10160 Even the column format is \texttt{[c]fixed}, sometimes characters are not vertically aligned.
10161 The following example  is typeset with \texttt{basewidth=2em}, and
10162 you'll see the leftmost ``\texttt{H}'' are not vertically aligned.
10163 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
10164 :H:
10165 :HHHH:
10166 \end{lstlisting}
10167
10168 \Pkg{lltjp-listing} adds the \texttt{doubleletterspace} key (not activated by default, for
10169 compatibility) to
10170 improve the situation, namely doubles inter-character space in each output unit.
10171 With this key, the above input now produces better output.
10172 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
10173 :H:
10174 :HHHH:
10175 \end{lstlisting}
10176 %</en>
10177 %<*ja>
10178 \paragraph{\texttt{doubleletterspace}キー}
10179 \Pkg{listings}パッケージで列揃えが \texttt{[c]fixed} となっている場合でも,
10180 場合によっては文字が縦に揃わない場合もある.
10181 例を以下に示そう.これは強調するために \texttt{basewidth=2em} を設定している.
10182 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
10183 :H:
10184 :HHHH:
10185 \end{lstlisting}
10186 1行目と2行目の「\texttt{H}」の位置が揃っていないが,
10187 これは出力単位ごとに,先頭・末尾・各文字間に同じ量の空白を挿入することによる.
10188
10189 \Pkg{lltjp-listing}では,このような症状を改善させるために \texttt{doubleletterspace} キー
10190 を追加した(標準では互換性のために無効になっている).このキーを有効にすると,
10191 出力単位中の各文字間の空白を2倍にすることで文字を揃いやすくしている.
10192 上と同じものを \texttt{doubleletterspace} キーを有効にして組んだものが以下であり,
10193 きちんと「\texttt{H}」の位置が揃っていることが分かる.
10194 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
10195 :H:
10196 :HHHH:
10197 \end{lstlisting}
10198 %</ja>
10199
10200 %<en>\subsection{Class of characters}
10201 %<ja>\subsection{文字種}
10202
10203 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
10204 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
10205 \begin{enumerate}
10206 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
10207 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
10208 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
10209 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
10210 %<en>\item Collects \textit{others}.
10211 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
10212 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
10213 %<ja>\item letterが出現したら集めた文字列を出力する.
10214 %<en>\item Turns back to 1.
10215 %<ja>\item 1.に戻る.
10216 \end{enumerate}
10217 %<*en>
10218 By the above process, line breaks inside of an identifier are blocked.
10219 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
10220 for the name of identifiers or not.
10221 %</en>
10222 %<*ja>
10223 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
10224 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
10225 %</ja>
10226
10227 %<*en>
10228 For Japanese characters, line breaks are permitted on both sides
10229 except for brackets, dashes, etc.
10230 Hence the patch \Pkg{lltjp-listings} introduces
10231 a new flag \verb+\lst@ifkanji+, which indicates
10232 whether the previous character is a Japanese character or not.
10233 For illustration, we introduce following classes of characters:
10234 %</en>
10235 %<*ja>
10236 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
10237 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
10238 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
10239 以降,説明のために以下のように文字を分類する:
10240 %</ja>
10241 \begin{center}
10242 \small
10243 \begin{tabular}{lccccc}
10244 \toprule
10245 &Letter&Other&Kanji&Open&Close\\\midrule
10246 \verb+\lst@ifletter+&T&F&T&F&T\\
10247 \verb+\lst@ifkanji+&F&F&T&T&F\\
10248 %<en>Meaning&char in an identifier&other alphabet&%
10249 %<en>most of Japanese char&opening brackets&closing brackets\\
10250 %<ja>意図&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
10251 \bottomrule
10252 \end{tabular}
10253 \end{center}
10254 %<*en>
10255 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
10256 Other according to circumstances.
10257 %</en>
10258 %<*ja>
10259 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
10260 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
10261 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
10262 これは間違いではない.
10263 %</ja>
10264
10265 %<*en>
10266 For example, let us consider the case an Open comes after a Letter.
10267 Since an Open represents Japanese open brackets,
10268 it is preferred to be permitted to insert line break after the Letter.
10269 Therefore, the collected character string is output in this case.
10270 %</en>
10271 %<*ja>
10272 例えば,Letterの直後にOpenが来た場合を考える.
10273 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
10274 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
10275 %</ja>
10276
10277 %<*en>
10278 The following table summarizes $5\times 5=25$ cases:
10279 %</en>
10280 %<*ja>
10281 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
10282 %</ja>
10283 \begin{center}
10284 \small
10285 \begin{tabular}{llccccc}
10286 \toprule
10287 %<*en>
10288 &&\multicolumn{4}{c}{Next}\\\cmidrule(lr){3-7}
10289 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
10290 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
10291 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
10292 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
10293 Prev&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
10294 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
10295 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
10296 %</en>
10297 %<*ja>
10298 &&\multicolumn{4}{c}{後ろ側の文字}\\\cmidrule(lr){3-7}
10299 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
10300 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
10301 直&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
10302 前&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
10303 文&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
10304 字&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
10305 種&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
10306 %</ja>
10307 \bottomrule
10308 \end{tabular}
10309 \end{center}
10310 %<en>In the above table,
10311 %<ja>上の表において,
10312 \begin{itemize}
10313 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
10314 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
10315
10316 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
10317 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
10318 \end{itemize}
10319
10320 %<*en>
10321 Characters above or equal to~\texttt{U+0080} \emph{except Variation Selectors}
10322 are classified into above 5~classes by the following rules:
10323 %</en>
10324 %<*ja>
10325 \texttt{U+0080}以降の\emph{異体字セレクタ以外の}各文字が
10326 Letter, Other, Kanji, Open, Closeのどれに属するかは次によって決まる:
10327 %</ja>
10328 \begin{itemize}
10329 %<en>\item \textbf{ALchar}s above or equal to~\texttt{U+0080} are classified as Letter.
10330 %<ja>\item \<(\texttt{U+0080}以降の)\textbf{ALchar}は,すべてLetter扱いである.
10331
10332 %<en>\item \textbf{JAchar}s are classified in the order as follows:
10333 %<ja>\item \textbf{JAchar}については,以下の順序に従って文字種を決める:
10334 \begin{enumerate}
10335 %<en>\item Characters whose \Param{prebreakpenalty} is greater than or equal to 0 are classified as Open.
10336 %<ja>\item \Param{prebreakpenalty}が0以上の文字はOpen扱いである.
10337
10338 %<en>\item Characters whose \Param{postbreakpenalty} is greater than or equal to 0 are classified as Close.
10339 %<ja>\item \Param{postbreakpenalty}が0以上の文字はClose扱いである.
10340
10341 %<en>\item Characters that don't satisfy the above two conditions are classified as Kanji.
10342 %<ja>\item 上の3条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
10343 \end{enumerate}
10344 \end{itemize}
10345
10346 %<*en>
10347 The width of halfwidth kana (\texttt{U+FF61}--\texttt{U+FF9F})
10348 is same as the width of \textbf{ALchar};
10349 the width of the other \textbf{JAchar}s is double the width of \textbf{ALchar}.
10350 %</en>
10351 %<*ja>
10352 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
10353 半角カナは欧文文字1文字分の幅となる.
10354 %</ja>
10355
10356 %<*en>
10357 This classification process is executed every time a character appears in
10358 the \texttt{lstlisting} environment or other environments/commands.
10359 %</en>
10360 %<*ja>
10361 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
10362 %</ja>
10363
10364 %<*ja>
10365 \section{和文の行長補正方法}
10366 \label{sec-adjspec}
10367 \Pkg{luatexja-adjust}で提供される優先順位付きの行長調整の詳細を大まかに述べると,次のようになる.
10368 \begin{itemize}
10369 \item (\texttt{lineend=extended}の場合)\textbf{JAglue}の挿入処理のところで,
10370   ……
10371 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
10372       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{xkanjiskip},
10373       \Param{kanjiskip},JFMグルー)と
10374       それ以外のグルーの全てで(優先順位なく)負担される.
10375 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
10376       落中の各行ごとに},行末文字の位置を調整(\texttt{lineend=true}の場合)したり,優先度付きの行長調整
10377       を実現するためにグルーの伸縮度を調整する.
10378       その処理においては,グルーの自然長と\textbf{JAglue}以外の
10379       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
10380       変更する設計とした.
10381 \end{itemize}
10382 この章の残りでは各処理について解説する.
10383
10384 \paragraph{準備:合計伸縮量の計算}
10385 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
10386 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
10387 いう4つの無限大レベル(後ろの方ほど大きい)がある.行の調整に
10388 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている行では,
10389 「行末文字の位置調整」のみ行い,「グルーの調整」は行わない.}
10390
10391 まず,段落中の行中のグルーを
10392 \begin{itemize}
10393 \item \textbf{JAglue}ではないグルー
10394 \item JFMグルー(優先度\footnote{%
10395   \ref{ssec:jfm-str}節にあるように,
10396   各JFMグルーには$-4$から3までの優先度がついている.場合によっては
10397   伸びと縮みで異なる優先度が付いているかもしれない.}%
10398 別にまとめられる)
10399 \item 和欧文間空白(\Param{xkanjiskip})
10400 \item 和文間空白(\Param{kanjiskip})
10401 \end{itemize}
10402 の$1+1+8+1=10$つに類別する.
10403 そして許容されている伸び量(\texttt{stretch}の値)の合計を
10404 無限のレベルごとに
10405 \begin{align*}
10406  T^{+}_{l}&:= \sum_{\text{$\texttt{stretch\_order}(p) = l$}} \texttt{stretch}(p),&
10407  l\in \{\text{(finite)}, \texttt{fi}, \texttt{fil}, \texttt{fill}, \texttt{filll}\}
10408 \end{align*}
10409 と計算する.さらに,
10410 \begin{align*}
10411 T^{+}&:=T^{+}_{L^+},&L^{+} = \max \{l\in
10412  \{\text{(finite)}, \texttt{fi}, \texttt{fil}, \texttt{fill}, \texttt{filll}\}:
10413  T^{+}_l\neq 0\}
10414 \end{align*}
10415 とおく.有限の伸び量については,上記の8種類の類別ごとにも合計を計算する.
10416 さらに縮み量(\texttt{shrink}の値)についても同様の処理を行い,$T^{-}$を計算する.
10417
10418 また,行長から自然長を引いた値を\textit{total}とおく.
10419
10420 \subsection{行末文字の位置調整(行分割後の場合)}
10421 行末が\textbf{JAchar}であり,この文字の属する文字クラスでは
10422 \begin{quote}
10423   \texttt{end\_adjust = \{$a_{1}$, $a_{2}$, ..., $a_{n}$\}}
10424 \end{quote}
10425 であったとする.
10426 このとき,以下の条件を満たした場合,
10427 この文字クラスに対する\texttt{end\_adjust}の値のいずれかだけこの文字の位置を移動させる.
10428 \begin{description}
10429   \item[最終行以外] 行長調整に無限大の伸縮度が用いられていない.
10430   すなわち,$\textit{total}>0$ならば$L^{+}=(\text{finite})$であり,
10431   $\textit{total}>0$ならば$L^{-}=(\text{finite})$である.
10432   \item[最終行] 行長調整に無限大に伸び縮みするグルーが用いられたなら,それは\cs{parfillskip}のみであり,
10433     かつ,次の不等式が成立する:
10434   \[
10435    \min\{0,a_{1}\}\text{\cs{zw}}\leq (\text{\cs{parfillskip}の実際の長さ}) \leq \max\{0,a_{n}\}\text{\cs{zw}}
10436   \]
10437 \end{description}
10438
10439 各$1\leq i\leq n$に対して,
10440 「行末に$a_{i}$全角だけのカーンを追加した時の,\textit{glue\_set}の値」を
10441 $b_{i}$とおく.式で書くと,
10442 \[
10443 \catcode`\<=12
10444 b_{i} = \begin{cases}
10445   |\textit{total}-a_{i}\text{\cs{zw}}|/T^{+}
10446           &(\textit{total}-a_{i}\text{\cs{zw}}\geq 0)\\
10447   |\textit{total}-a_{i}\text{\cs{zw}}|/T^{-}
10448           &(\textit{total}-a_{i}\text{\cs{zw}}<0)
10449 \end{cases}.
10450 \]
10451 $b_{i}$達の最小値を与えるような$i$を$j$としたとき\footnote{%
10452   そのような$i$が2つ以上あるときは,$|\textit{total}-a_{i}\cdot \text{\cs{zw}}|$,
10453   $|a_{i}|$, $a_i$の順で比較して一番小さくなるものが選ばれる.
10454 },
10455 行末に大きさ$a_{j}$のカーンを追加する.
10456 \textit{total}から$a_{j}$全角の大きさだけ引いておく.
10457
10458 \subsection{行末文字の位置調整(行分割での考慮)}
10459 \texttt{lineend=extended}が指定されている場合,\TeX による行分割が行われる前に
10460 各\textbf{JAchar}の直後に,その文字が行末に来たときの位置補正用のノードを挿入していく.
10461
10462 \ref{sec-jfmglue}章の用語を使って述べる.
10463 前側のクラスタ\textit{Nq}が「和文A」「和文B」であり,
10464 JFMによって\texttt{end\_adjust}の値が
10465 \begin{quote}
10466   \texttt{end\_adjust = \{$a_{1}$, $a_{2}$, ..., $a_{n}$\}}
10467 \end{quote}
10468 であったとする.このとき,次のクラスタ\textit{Np}の直前に以下のノード列を挿入する.
10469 \textbf{JAglue}の挿入過程で禁則処理のために「\textit{Nq}と\textit{Np}の間のペナルティ値を増やす」ことが
10470 行われることがあるが,以下で述べられている$(n+1)$個のペナルティはみなその処理対象になっている.
10471 \begin{align*}
10472   \Node{kern}{$a_{1}\text{\cs{zw}}$}
10473   &\longrightarrow \Node{penalty}{$0$} \longrightarrow\Node{kern}{$(a_{2}-a_{1})\text{\cs{zw}}$}
10474   \longrightarrow \Node{penalty}{$0$} \longrightarrow\Node{kern}{$(a_{3}-a_{2})\text{\cs{zw}}$}\\
10475   &\longrightarrow
10476   \cdots \longrightarrow\Node{penalty}{$0$} \longrightarrow
10477   \Node{kern}{$(a_{n}-a_{n-1})\text{\cs{zw}}$}
10478   \longrightarrow \Node{penalty}{$0$} \longrightarrow
10479   \Node{kern}{$-a_{n}\text{\cs{zw}}$} \longrightarrow \Node{penalty}{$10000$}
10480 \end{align*}
10481 $n$個あるペナルティの箇所が改行可能箇所である.いずれかで改行された場合は,
10482 その前にあるカーン($n$箇所のうちどこで改行しても,合計の長さは$a_{i}$の形)は行末に残るが,
10483 後ろのペナルティ・カーンは除去される.なお,$a_1=0$のときは最初の幅が$a_{1}\text{\cs{zw}}$のカーンは不要なので挿入されず,
10484 さらにかつ$n=1$であった場合は後ろのペナルティも挿入されない.
10485
10486 なお,段落の末尾には\cs{penalty10000}と\cs{parfillskip}由来のグルーが自動的に入るが,
10487 これらとの兼ね合いのため\emph{最後のクラスタについては上記のノード挿入処理は行われない}.
10488 段落最終行の行末文字の位置調整は,すでに述べた「行分割後の場合」における最終行の処理をそのまま用いている.
10489
10490 \subsection{グルーの調整}
10491 $|\textit{total}|$の分だけが,行中のグルーの伸び量,あるいは縮み量に応じて負担されることになる.
10492 以下,$\textit{total}\geq 0$であると仮定して話を進めるが,負のときも同様である.
10493 \Pkg{luatexja-adjust}の初期値では以下の順に伸び量を負担するようになっており,
10494 (優先度$-4$のJFMグルーは例外として)できるだけ\Param{kanjiskip}を自然長のままにすることを
10495 試みている.この順番は\Param{stretch\_priority}(縮み量については\Param{shrink\_priority})
10496 パラメータで変更可能である.
10497 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
10498  \item \textbf{JAglue}以外のグルー
10499  \item 優先度3のJFMグルー
10500  \item 優先度2のJFMグルー
10501  \item 優先度1のJFMグルー
10502  \item 優先度0のJFMグルー
10503  \item 優先度$-1$のJFMグルー
10504  \item 優先度$-2$のJFMグルー
10505  \item \Param{xkanjiskip}
10506  \item 優先度$-3$のJFMグルー
10507  \item \Param{kanjiskip}
10508  \item 優先度$-4$のJFMグルー
10509 \end{enumerate}
10510 \begin{enumerate}
10511  \item 行末の\textbf{JAchar}を移動したことで$\textit{total}=0$となれば,
10512 調整の必要はなく,行が格納されているhboxの
10513 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
10514 以降,$\textit{total}\neq 0$と仮定する.
10515  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
10516        合計,と称す)よりも小さければ,
10517 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
10518 よって,以下の処理を行う:
10519 \begin{enumerate}
10520 \item 各\textbf{JAglue}の伸び量を0とする.
10521 \item 行が格納されているhboxの
10522 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
10523 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
10524 \end{enumerate}
10525 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(K)のどこまで負担すれば
10526 \textit{total}以上になるかを計算する.
10527 例えば,
10528 \[\catcode`\<=12
10529  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
10530  \qquad 0\le p<1
10531 \]
10532 であった場合,各グルーは次のように組まれる:
10533 \begin{itemize}
10534  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
10535  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
10536  \item (D)--(K)に属するグルーは自然長のまま.
10537 \end{itemize}
10538 実際には,前に述べた「設計」に従い,次のように処理している:
10539 \begin{enumerate}
10540 \item (C)に属するグルーの伸び量を$p$倍する.
10541 \item (D)--(K)に属するグルーの伸び量を0とする.
10542 \item 行が格納されているhboxの
10543 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
10544 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
10545 \end{enumerate}
10546 \item \textit{total}が(A)--(K)の伸び量の合計よりも大きい場合,どうしようもないので
10547       \verb+^^;+何もしない.
10548 \end{enumerate}
10549
10550 %</ja>
10551
10552 %<*ja>
10553 \section{IVS対応}
10554 \verb+luatexja.otf.enable_ivs()+ を実行し,IVS対応を有効にした状態では,
10555 \verb+pre_linebreak_filter+ や \verb+hpack_filter+ コールバックには
10556 次の4つが順に実行される状態となっている:
10557 \begin{description}
10558 \item[\tt ltj.do\_ivs] \textit{glyph\_node}~$p$の直後に,異体字セレクタ(を表す\textit{glyph\_node})
10559 が連続した場合に,$p$のフォントに対応したが持つ「異体字情報」に従って出力するグリフを変える.
10560
10561 しかし,単に$p.\textit{char}$を変更するだけでは,後から
10562 OpenType機能の適用(すぐ下)により置換される可能性がある.そのため,
10563 \cs{CID} や \cs{UTF} と同じように,\textit{glyph\_node}~$p$の代わりに
10564 \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを用いている.
10565 \item[(\Pkg{luaotfload} によるfont featureの適用)]
10566 \item[\tt ltj.otf] \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを
10567 きちんと\textit{glyph\_node}に変換する.この処理は,\cs{CID}, \cs{UTF}やIVSによる置換が,
10568 OpenType機能の適用で上書きされてしまうのを防止するためである.
10569 \item[\tt ltj.main\_process] \textbf{JAglue}の挿入処理(\ref{sec-jfmglue}章)と,
10570 JFMの指定に従って各\textbf{JAchar}の「寸法を補正」することを行う.
10571 \end{description}
10572
10573 問題は各フォントの持っているIVS情報をどのように取得するか,である.
10574 \Pkg{luaotfload} はフォント番号<font\_number>の情報を\
10575 \texttt{fonts.hashes.identifiers[<font\_number>]} 以下に格納している.
10576 しかし,OpenTypeフォントのIVS情報は格納されていないようである%
10577 \footnote{TrueTypeフォントに関しては,
10578 \begin{center}
10579 \texttt{fonts.hashes.idenfiers[<font\_number>]%
10580   .resources.variants[<selector>][<base\_char>]}
10581 \end{center}
10582 に,<base\_char>番の文字の後に異体字セレクタ<selector>が続いた場合に
10583 出力すべきグリフが書かれてある.}.
10584 %例えば,小塚明朝Pr6N~Rでは,
10585
10586 一方,\LuaTeX 内部の \texttt{fontloader} の返すテーブルには
10587 OpenTypeフォントでもTrueTypeフォントでもIVS情報が格納されている.
10588 具体的には……
10589
10590 そのため,\LuaTeX-jaのIVS対応においては,\LuaTeX 内部の\
10591 \texttt{fontloader} を直接用いることで,フォントのIVS情報を取得している.
10592 20140114.0以降でキャッシュを用いるようにした要因はここにあり,
10593 \texttt{fontloader} の呼び出しでかなり時間を消費することから,
10594 %%% to_table を使わなくしたことで,メモリ使用量は減った
10595 IVS情報をキャッシュに保存することで2回目以降の実行時間を節約している.
10596 %</ja>
10597
10598
10599 %<*ja>
10600 \section{複数フォントの「合成」(未完)}
10601 \section{\LuaTeX-jaにおけるキャッシュ}
10602 \Pkg{luaotfload}パッケージが,各TrueType・OpenTypeフォントの情報を
10603 キャッシュとして保存しているのと同様の方法で,
10604 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
10605 \begin{itemize}
10606  \item 通常,キャッシュは\texttt{\$TEXMFVAR/luatexja/}以下に保存され,
10607 そこから読み込みが行われる.
10608  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua})以外にも,
10609 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
10610 \begin{itemize}
10611  \item \LuaTeX とLuaJIT\TeX ではバイトコードの形式が異なるため,バイナリ形式の
10612 キャッシュは共有できない.\LuaTeX 用のバイナリキャッシュは \texttt{.luc},
10613 LuaJIT\TeX 用のは \texttt{.lub} と拡張子を変えることで対応している.
10614  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
10615 テキスト形式のものよりそちらを優先して読み込む.
10616  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
10617 同時に更新される.
10618 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
10619 \LuaTeX-jaはバイナリキャッシュを作成する.
10620 \end{itemize}
10621 \end{itemize}
10622 %</ja>
10623 %<*en>
10624 \section{Cache Management of \LuaTeX-ja}
10625 \LuaTeX-ja creates some cache files to reduce the loading time.
10626 in a similar way to the \Pkg{luaotfload} package:
10627 \begin{itemize}
10628  \item Cache files are usually stored in (and loaded from)
10629 \texttt{\$TEXMFVAR/luatexja/}.
10630  \item In addition to caches of the text form (the extension is ``\texttt{.lua}''),
10631 caches of the \emph{binary}, precompiled form are supported.
10632 \begin{itemize}
10633  \item We cannot share same binary cache for \LuaTeX\ and LuaJIT\TeX.
10634 Hence we distinguish them by their extension, ``\texttt{.luc}'' for \LuaTeX\
10635 and ``\texttt{.lub}'' for LuaJIT\TeX.
10636  \item In loading a cache, the binary cache precedes
10637 the text form.
10638  \item When \LuaTeX-ja updates a cache \texttt{hoge.lua},
10639 its binary version is also updated.
10640 \end{itemize}
10641 \end{itemize}
10642 %</en>
10643
10644 %<*ja>
10645 \subsection{キャッシュの使用箇所}
10646
10647 \LuaTeX-ja では以下の3種類のキャッシュを使用している:
10648 \begin{cslist}
10649 \item[ltj-cid-auto-adobe-japan1.lua]
10650 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
10651 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
10652 生成には\texttt{UniJIS2004-UTF32-\{H, V\}}, \texttt{Adobe-Japan1-UCS2}という3つの
10653 CMapが必要である.
10654
10655 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
10656 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
10657 キャッシュの名称,必要となるCMapについては\autoref{tab:cid-cache}を参照して欲しい.
10658
10659 \item[extra\_***.lua]
10660 フォント``\texttt{***}''における異体字セレクタの情報,縦組用字形への変換テーブル,そして
10661 縦組時における幅を格納している.構造は以下の通り:
10662 %</ja>
10663 %<*en>
10664 \subsection{Use of cache}
10665
10666 \LuaTeX-ja uses the following cache:
10667 \begin{cslist}
10668 \item[ltj-cid-auto-adobe-japan1.lua]
10669 The font table of a CID-keyed non-embedded Japanese font.
10670 This is loaded in every run.
10671 It is created from three CMaps, \texttt{UniJIS2004-UTF32-\{H,V\}} and
10672              \texttt{Adobe-Japan1-UCS2},
10673 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
10674
10675 Similar caches are created as \autoref{tab:cid-cache},
10676 if you specified \texttt{cid} key in \cs{jfont}
10677 to use other CID-keyed non-embedded fonts for Chinese or Korean,
10678 as in Page~\pageref{para-cid}.
10679
10680 \item[extra\_***.lua]
10681 This file stores the table which stores the following.
10682 \begin{itemize}
10683  \item unicode variants in a font ``\texttt{***}''
10684  \item vertical width of glyphs, if it is not equal to the sum of
10685 the height of ascender and the depth of descender
10686  \item vertical variants
10687 \end{itemize}
10688 The following is the structure of the that table.
10689 %</en>
10690
10691 \begin{table}[!tb]
10692  \centering\small
10693 \caption{\texttt{cid} key and corresponding files}
10694 \label{tab:cid-cache}
10695 \vspace*{\medskipamount}
10696 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
10697 \toprule
10698 \bf \texttt{cid} key&\bf name of the cache &
10699 \multicolumn{2}{c}{\bf used CMaps}\\
10700 \midrule
10701 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.lua&UniJIS2004-UTF32-*&Adobe-Japan1-UCS2\\
10702 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.lua&UniKS-UTF32-*&Adobe-Korea1-UCS2\\
10703 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.lua&UniGB-UTF32-*&Adobe-GB1-UCS2\\
10704 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.lua&UniCNS-UTF32-*&Adobe-CNS1-UCS2\\
10705 \bottomrule
10706 \end{tabular}
10707 \end{table}
10708
10709 \begin{lstlisting}
10710 return {
10711  {
10712   [10955]={    -- U+2ACB "Subset Of Above Not Equal To"
10713    [65024]=983879, -- <2ACB FE00>
10714    ["vwidth"]=0.98, -- vertical width
10715   },
10716   [37001]={    -- U+9089 "邉"
10717    [0]=37001,  --   <9089 E0100>
10718    991049,     --   <9089 E0101>
10719    ...
10720    ["vform"]=995025, -- vertical variant
10721   },
10722   ...
10723   ["unicodes"]={
10724     ["aj102.pe.vert"]=984163, -- glyph name to unicode
10725     ...
10726   }
10727  },
10728  ["chksum"]="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", -- checksum of the fontfile
10729  ["version"]=11, -- version of the cache
10730 }
10731 \end{lstlisting}
10732 %<*ja>
10733 \item[ltj-jisx0208.\{luc|lub\}]
10734 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイナリ化したものである.
10735 これはJIS~X~0208とUnicodeとの変換テーブルであり,
10736 \pTeX との互換目的の文字コード変換命令で用いられる.
10737 %</ja>
10738 %<*en>
10739 \item[ltj-jisx0208.\{luc|lub\}]
10740 The binary version of \texttt{ltj-jisx0208.lua}.
10741 This is the conversion table between JIS~X~0208 and Unicode
10742 which is used in Kanji-code conversion commands for compatibility with \pTeX.
10743 %</en>
10744 \end{cslist}
10745
10746 %<*en>
10747 \subsection{Internal}
10748 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
10749 (\texttt{ltj-base.lua}).
10750 There are three public functions for cache management in \texttt{luatexja.base},
10751 where <filename> stands for the file name \emph{without suffix}:
10752 \begin{cslist}
10753 \item[save\_cache(<filename>, <data>)]
10754 Save a non-nil table <data> into a cache <filename>.
10755 Both the text form <filename>\texttt{.lua} and its binary version
10756 are created or updated.
10757
10758 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
10759
10760 Same as \texttt{save\_cache}, except that only the binary cache is updated.
10761 The third argument <serialized\_data> is not usually given.
10762 But if this is given, it is treated as a string representation of <data>.
10763
10764 \item[load\_cache(<filename>, <outdate>)]
10765 Load the cache <filename>.
10766 <outdate> is a function which takes one argument (the contents of the cache),
10767 and its return value is whether the cache is outdated.
10768
10769 \texttt{load\_cache} first tries to
10770 read the binary cache <filename>\texttt{.\{luc|lub\}}.
10771 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
10772 If the binary cache is not found or
10773 its contents is outdated, \texttt{load\_cache} tries to
10774 read the text form <filename>\texttt{.lua}.
10775 Hence, the return value of \texttt{load\_cache} is non-nil,
10776 if and only if the updated cache is found.
10777 \end{cslist}
10778 %</en>
10779 %<*ja>
10780 \subsection{内部命令}
10781 \LuaTeX-jaにおけるキャッシュ管理は,\texttt{luatexja.base}~(\texttt{ltj-base.lua})に
10782 実装しており,以下の3関数が公開されている.
10783 ここで,<filename>は保存するキャッシュのファイル名を\emph{拡張子なしで}指定する.
10784 \begin{cslist}
10785 \item[save\_cache(<filename>, <data>)]
10786 nilでない<data>をキャッシュ<filename>に保存する.
10787 テキスト形式の<filename>\texttt{.lua}のみならず,
10788 そのバイナリ版も作成/更新される.
10789
10790 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
10791
10792 \texttt{save\_cache}と同様だが,バイナリキャッシュのみが更新される.
10793 第3引数<serialized\_data>が与えられた場合,それを
10794 <data>の文字列化表現として使用する.
10795 そのため,<serialized\_data>は普通は指定しないことになるだろう.
10796
10797 \item[load\_cache(<filename>, <outdate>)]
10798 キャッシュ<filename>を読み込む.
10799 <outdate>は1引数(キャッシュの中身)をとる関数であり,
10800 その戻り値は「キャッシュの更新が必要」かどうかを示すブール値でないといけない.
10801
10802 \texttt{load\_cache}は,まずバイナリキャッシュ<filename>\texttt{.\{luc|lub\}}を
10803 読みこむ.もしその内容が「新しい」,つまり<outdate>の評価結果が \texttt{false} なら
10804 \texttt{load\_cache}はこのバイナリキャッシュの中身を返す.
10805 もしバイナリキャッシュが見つからなかったか,「古すぎる」ならばテキスト版
10806              <filename>\texttt{.lua}を読み込み,その値を返す.
10807
10808 以上より,\texttt{load\_cache}自体がnilでない値を返すのは,ちょうど「新しい」キャッシュが
10809 見つかった場合である.
10810 \end{cslist}
10811 %</ja>
10812
10813
10814 %<*ja>
10815 \section{縦組の実装}
10816 \label{sec-dir-imp}
10817 \ref{sec-direction}章の最初でも述べたように,
10818 \LuaTeX-jaは横組(\texttt{TLT})で組んだボックスを回転させる方式で
10819 縦組を実装している.
10820
10821 \LuaTeX-jaにおける縦組の実装は
10822 \pTeX における実装(\cite{ptexdoc,ptextug})をベースにしている.
10823
10824 \subsection{direction~whatsit}
10825 \textit{direction}~whatsitとは,\textit{direction}という特定の \verb+user_id+ を持つ
10826 whatsitのことであり,以下のタイミングで作られる.
10827 \begin{itemize}
10828  \item 組方向を \cs{tate} 等で変更したとき.
10829  \item \cs{hbox}, \cs{vbox}, \cs{vtop} による明示的なボックスの開始時.\\
10830 \verb+\hbox{}+, \verb+\vbox{}+ といった,
10831 \begin{itemize}
10832  \item \cs{tate} 等によりボックス内部の組方向を変更していない
10833  \item ボックスの中身のリストが空である
10834 \end{itemize}
10835 場合は,\LuaTeX の \verb+hpack_filter+, \verb+vpack_filter+ といった
10836 callbackに処理が回らない.そこで,\LuaTeX-ja では,\cs{everyhbox}, \cs{everyvbox} を利用す
10837        ることで各ボックスの先頭に確実に追加するようにしている\footnote{%
10838   問題は \cs{hbox to 25pt\{\}} という状況である.実際のこのボックスの中身は空でない(少な
10839        くともdirection whatsitがある)ため,何も対策をしなければhpack時にUnderfill警告が発
10840        生してしまうことになる.\LuaTeX-jaではそうならないように「\cs{hbadness},
10841        \cs{vbadness} を一時的に10000に変更し,hpack, vpack後に元の値に戻す」処理を行ってい
10842        る.
10843 }.
10844  \item \cs{vsplit}によってvboxを分割した時の「残り」の先頭.
10845  \item \LuaTeX-ja読み込み前に作成したボックスの寸法を \cs{ltjsetwd} 等によって変更した時.
10846  \item \cs{insert} によるinsertionでは,中身の先頭に\textit{direction}~whatsitは作られず,
10847 その代わりに中身の各ボックス・罫線の直前に作られる\footnote{%
10848  これは,ページ分割の過程でinsertionが分割される時,「現在のページで出力される部分」が空と
10849        なることがあることによる.先頭にwhatsitを置くと,最悪でも「現在のページにwhatsitが
10850        残る」ことになってしまう.}.
10851 \end{itemize}
10852 なお,\verb+\vtop{...}+ の場合は,先頭にdirection whatsitを置くと
10853 ボックスの高さが常に0\,ptになるという問題が発生する.そのため,この場合に限っては
10854 vpack時にdirection whatsitをリストの2番目に移動させている.
10855
10856 direction whatsitはあくまでも組方向処理のための補助的なノードであるので,
10857 \cs{unhbox}, \cs{unhcopy} によってボックスの中身が展開される時には展開直前に削除される.
10858 これは
10859 \begin{lstlisting}
10860  % yoko direction
10861 \setbox0=\hbox{\tate B}
10862 \noindent % 水平モードに入る.この時点でのリストの中身は空
10863 \unhbox0 A
10864 \end{lstlisting}
10865 といった場合に,段落が縦組で組まれたり,あるいは
10866 \begin{lstlisting}
10867 \setbox0=\hbox{}
10868 \leavevmode \hbox{A}\unhbox0
10869 \setbox1=\lastbox % \box1 はどうなる?
10870 \end{lstlisting}
10871 で \cs{box1} が \cs{hbox\{A\}} でなく空になってしまうことを防ぐためである.
10872
10873
10874 \subsection{\textit{dir\_box}}
10875 縦中横など異方向のボックスを配置する場合に,周囲の組方向と大きさを整合させるため,
10876 \LuaTeX-jaでは \verb+\ltj@dir+ が128以降の\textit{hlist\_node}, \textit{vlist\_node}を
10877 用いる.これらは\pTeX における\textit{dir\_node}の役割と同じ果たしており,
10878 この文章中では\textit{dir\_box}と呼称する.
10879
10880 \subsubsection{異方向のボックスの整合}
10881 \textit{dir\_box}の第一の使用目的は,異方向のボックスの大きさを整合させることである.
10882 例えば,
10883 \begin{lstlisting}
10884  % yoko direction
10885 平成\hbox{\tate 26}年
10886 \end{lstlisting}
10887 は段落中で
10888 \[
10889  \xymatrix{
10890    {}\Node{glyph}{`平'}\ar[r]&{}\Node{glyph}{`成'}\ar[r]&
10891    {}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[r]\ar[d]^{\text{中身}}&{}\Node{glyph}{`年'}\\
10892    &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
10893  }
10894 \]
10895 というリストを作る.その後,この段落が終了したときに,
10896 \LuaTeX-jaの\textbf{JAglue}挿入処理が行われ
10897 \[
10898  \xymatrix{
10899    {}\Node{glyph}{`平'}\ar[r]
10900   &{}\textcolor{blue}{\Node{glue}{\Param{xkanjiskip}}}\ar[r]
10901   &{}\Node{glyph}{`成'}\ar[r]
10902   &{}\textcolor{blue}{\Node{penalty}{0}}
10903     \ar`r[d] `[l] `[ddll] `[dl] [dl]
10904   \\
10905   &&{}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{yoko})}{3.02779}{10.00003}{0.0}}\ar[r]\ar[d]^{\text{中身}}
10906   &{}\textcolor{blue}{\Node{penalty}{0}}\ar[r]
10907   &{}\Node{glyph}{`年'}\\
10908   &&{}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[d]^{\text{中身}}\\
10909   &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
10910  }
10911 \]
10912 のようになる(青字は\textbf{JAglue},赤字が整合処理のための\textit{dir\_box}である).
10913 \TeX の \cs{showbox} 形式で書けば
10914
10915 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
10916 \catcode`\@=0 @catcode`@\=12
10917 .\tenmin 平
10918 @textcolor{blue}{.\glue 0.0 plus 0.4 minus 0.4}
10919 .\tenmin 成
10920 @textcolor{blue}{.\penalty 0}
10921 @textcolor{red}{.\hbox(10.00003+0.0)x3.02779, direction TLT}
10922 ..\hbox(3.02779+0.0)x10.00003, direction TLT
10923 ...\whatsit4=[]
10924 ...\tenrm 2
10925 ...\tenrm 6
10926 @textcolor{blue}{.\penalty 0}
10927 .\tenmin 年
10928 }\medskip
10929
10930 \noindent である.
10931
10932 なお,\cs{raise},~\cs{lower}, \cs{moveleft},~\cs{moveright} といったボックス移動命令では.
10933 移動を正しく表現するために段落やボックスの途中でも異方向のボックスは\textit{dir\_box}にカ
10934 プセル化している.
10935 例えば
10936 \begin{lstlisting}
10937  % yoko direction
10938 平成\raise1pt\hbox{\tate 26}年\showlists
10939 \end{lstlisting}
10940 は以下のような結果を得る.
10941
10942 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
10943 \catcode`\@=0 @catcode`@\=12
10944 (前略)
10945 \tenrm 平
10946 \tenrm 成
10947 @textcolor{red}{\hbox(10.00003+0.0)x3.02779, shifted -1.0, direction TLT}
10948 .\hbox(3.02779+0.0)x10.00003, direction TLT
10949 ..\whatsit4=[]
10950 ..\tenrm 2
10951 ..\tenrm 6
10952 \tenrm 年
10953 }\medskip
10954
10955 また,メインの垂直リストに異方向のボックスが追加される場合にも同様に即座に
10956 \textit{dir\_box}にカプセル化している.ページ分割のタイミングを正
10957 しく\TeX が判断するためである.
10958 \cs{lastbox} によるボックスの取得では,\textit{dir\_box}は削除される.
10959
10960 \subsubsection{異方向のボックス寸法の格納}
10961 第二の使用目的は,現在の組方向がボックス本来の組方向とは異なる状況で,
10962 \cs{ltjsetwd} によってボックス寸法を設定されたことを記録することである.
10963
10964 例えば
10965 \begin{lstlisting}[numbers=left]
10966 \setbox0=\hbox{\vrule width 10pt height 5pt depth 2pt}
10967 \setbox1=\hbox{\tate\ltjsetwd0=20pt}
10968 \wd0=9pt
10969 \setbox1=\hbox{\dtou\ltjsetwd0=20pt}
10970 \setbox0=\hbox{\dtou a\box0}
10971 \end{lstlisting}
10972 というコードを考える.1行目で \cs{box0} には横組の
10973 幅10\,pt,高さ5\,pt,深さ2\,ptのボックスが代入される.
10974 よって,
10975 \begin{itemize}
10976  \item 縦組下では \cs{box0} は幅7\,pt,高さ・深さ5\,ptのボックスとして扱われる.
10977  \item \cs{dtou} 下では \cs{box0} は幅7\,pt,高さ10\,pt,深さ0\,ptのボックスとして扱われる.
10978 \end{itemize}
10979 このとき,\cs{box0} の\emph{中身}は
10980 \[
10981  \xymatrix{
10982    {}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
10983  }
10984 \]
10985 である.
10986
10987 さて,2行目で縦組時の \cs{box0} の幅が20\,ptに設定される.この情報が
10988 direction~whatsit内部のノードリストに,\textit{dir\_box}として格納される:
10989 \[
10990  \xymatrix{
10991    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
10992    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}}
10993  }
10994 \]
10995
10996 次に,3行目では横組時の,つまり \cs{box0} 本来の組方向での深さが9\,ptに変更される.
10997 このとき,\cs{box0} は
10998 \begin{itemize}
10999  \item 縦組下では寸法代入が既に行われているので,2行目で作成された\textit{dir\_box}の通り
11000        に幅20\,pt,高さ・深さ5\,ptのボックスとして扱われる.
11001  \item \cs{dtou} 下ではまだ寸法代入が行われていないので,
11002 \cs{box0} の寸法変更に追従し,幅7\,pt,高さ9\,pt,深さ0\,ptのボックスとして扱われる.
11003 \end{itemize}
11004
11005 4行目では \cs{dtou} 下での\cs{box0} の幅が20\,ptに設定されるので,2行目と同じように
11006 \[
11007  \xymatrix{
11008    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
11009    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[r]&
11010    {}\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}
11011  }
11012 \]
11013 と\textit{dir\_box}が作成される.
11014
11015 このように寸法代入によってつくられた\textit{dir\_box}は,前節の整合過程のときに再利用され
11016 る.上記の例でいえば,5行目を実行した後の \cs{box0} の内容は
11017 \[
11018  \xymatrix{
11019    {}\Node{whatsit}{\cs{dtou}}\ar[r]&
11020    {}\Node{glyph}{`a'}\ar[r]&
11021    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[d]_{\text{中身}}\\
11022    &&{}\HNode{hbox}{9.0}{5.0}{2.0}\ar[d]_{\text{中身}}\\
11023    &&{}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
11024  }
11025 \]
11026 のようになる.
11027 %</ja>
11028
11029 \newpage
11030 \begin{thebibliography}{99}
11031   \addcontentsline{toc}{section}{\refname}
11032 \bibitem{texbytopic}
11033 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
11034 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
11035 \bibitem{uptex} Takuji Tanaka. \newblock
11036 upTeX---Unicode version of pTeX with CJK extensions,
11037 TUG 2013, October 2013.
11038 %<ja>\newblock
11039 %<en>\\\null\hfill
11040 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
11041 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert.
11042 %<en>\newblock
11043 %<ja>\\\null\hfill
11044 \url{http://mytexpert.osdn.jp/index.php?Listings}
11045 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
11046 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
11047 \url{http://www.w3.org/TR/jlreq/}%
11048 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
11049 \bibitem{min10} 乙部厳己.「min10フォントについて」\\\null\hfill
11050 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
11051 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard). 「JIS~X~4051,
11052 日本語文書の組版方法(Formatting rules for Japanese documents)」, 1993, 1995, 2004.
11053 \bibitem{ptexdoc} 濱野尚人,田村明史,倉沢良一.「\TeX の出版への応用—縦組み機能の組み込み—」.
11054 \\\null\hfill\texttt{.../texmf-dist/doc/ptex/base/ptexdoc.pdf}
11055 \bibitem{ptextug} Hisato Hamano. \newblock
11056 \textit{Vertical Typesetting with \TeX}, TUGBoat~\textbf{11}(3), 346--352, 1990.
11057 \bibitem{pdfstd} International Organization for Standardization. \newblock
11058 ISO 32000-1:2008, \textit{Document management -- Portable document format -- Part 1: PDF
11059       1.7}, 2008. \newblock
11060 \\\null\hfill
11061 \url{http://www.iso.org/iso/iso\_catalogue/catalogue_tc/catalogue\_detail.htm?csnumber=51502}
11062 \bibitem{tc18ltja} 北川弘典.「\LuaTeX-jaの近況」,\TeX Conf~2018.\\
11063   \url{https://osdn.net/projects/luatex-ja/wiki/Documentation/attach/tc18ltja.pdf}
11064 \end{thebibliography}
11065
11066 \end{document}
11067 %</!showexpl>
11068 %<*showexpl>
11069 %%
11070 %% config file for showexpl.sty
11071 %%
11072 %% Copyright The LuaTeX-ja project team, 2012
11073 %%
11074 \ProvidesFile{showexpl.cfg}
11075   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
11076 \lstset{}
11077 \def\SX@Info{}
11078 \endinput
11079 %</*showexpl>