OSDN Git Service

Releases 20240514.0
[luatex-ja/luatexja.git] / doc / luatexja.dtx
1 %<*!showexpl>
2 %#! lualatex -shell-escape
3 %% KozMinPr6N-Regular.otf is needed to typeset this document.
4
5 %%%%% section ==> 章
6 %%%%% subsection => 節
7 \IfFileExists{luatex85.sty}{\RequirePackage{luatex85}}{}
8
9 %<en>\documentclass[a4paper,titlepage]{article}
10 %<ja>\documentclass[a4paper,10ptj,titlepage]{ltjsarticle}
11
12 %%%%%%%%
13 \makeatletter
14 %%%%%%%%
15 \def\pgfsysdriver{pgfsys-pdftex.def}
16 \usepackage{metalogo,amsmath,array,tikz,pict2e,multienum,float,mathtools}
17 \usepackage{booktabs,multicol,luatexja-ruby}
18 \usepackage[all]{xy}
19 \usepackage{lltjext,alltt,comment}
20
21 %%%%%%%% fonts
22 \usepackage{luatexja-otf}
23 \usepackage[no-math]{fontspec}
24 \setmainfont[Ligatures=TeX,RawFeature=-notdef]{Linux Libertine O}
25 \setmonofont[RawFeature=-notdef, Ligatures=CommonOff, %CharacterVariant={31,45,61,36},
26 %<en>  Scale=0.8132073118633364, FakeStretch=1.183236,
27 %<ja>  Scale=MatchLowercase, FakeStretch=1.137121,
28   Contextuals=AlternateOff, Kerning=Off,
29   Ligatures={CommonOff,RequiredOff,ContextualOff,RareOff,HistoricOff,TeXOff},
30   ItalicFont=Iosevka Slab Oblique,
31   BoldFont=Iosevka Slab Bold, BoldItalicFont=Iosevka Slab Bold Oblique,
32 ]{Iosevka Slab}
33 \setsansfont[Scale=MatchLowercase,Ligatures=TeX,RawFeature=-notdef]{Linux Biolinum O}
34 \usepackage[match]{luatexja-fontspec}
35 \usepackage[haranoaji]{luatexja-preset}
36 \usepackage{unicode-math}
37 \setmonojfont{HaranoAjiGothic-Regular.otf}
38 \setmathfont[Scale=MatchLowercase]{XITSMath}
39 \newjfontface\KOZM{KozMinPr6N-Regular.otf}
40
41 \setLaTeXa{\scshape a}
42 %<*ja>
43 \def\emph#1{\textbf{\textgt{#1}}}
44 \def\headfont{\normalfont\bfseries\gtfamily}\normalsize
45 %</ja>
46 %<*en>
47 \frenchspacing\sloppy
48 \usepackage[margin=25mm,lmargin=30mm,rmargin=30mm,footskip=6mm]{geometry}
49 \usepackage{luatexja-adjust}\ltjdisableadjust
50 \parskip=\smallskipamount
51 \makeatletter
52 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
53     {3.25ex \@plus1ex \@minus.2ex}%
54     {-1em}%
55     {\normalfont\normalsize\bfseries\raisebox{.2ex}{$\mdlgblksquare\mkern1mu$}}}
56 %</en>
57 %<*ja>
58 \usepackage[textwidth=44\zw, lines=41, footskip=6mm]{geometry}
59 \usepackage{luatexja-adjust}%\ltjdisableadjust
60 \advance\leftmargini-1\zw
61 %</ja>
62 %<en>\long\def\fakefn#1#2{\par\noindent{\footnotesize\hbox to1.8em{\hss#1}#2\par}}
63 %<*ja>
64 \long\def\fakefn#1#2{%
65   \par{\footnotesize\advance\leftskip 3\zw\parindent1\zw\noindent
66   \llap{#1\hskip.3\zw}#2\par}}
67 %</ja>
68 %%%%%%%% listings
69
70 %%%%%%%% IVS
71
72 \def\IVS#1{\char\numexpr "E0100+#1\relax}%"
73 \def\IVSA#1#2#3#4#5{%
74   \hbox to1em{\hss\textcolor{blue}{\raisebox{3.5pt}{\normalfont\ttfamily%
75     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{0#1#2\crcr#3#4#5\crcr}\hss}}}}\hss}%
76 }
77 {\catcode`\%=11
78   \gdef\IVSB#1{\expandafter\IVSA\directlua{
79     local cat_str = luatexbase.catcodetables['string']
80     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
81 }}}
82 \def\UCSA#1#2#3#4{%
83   \hbox to1em{\hss\textcolor{blue}{\raisebox{3.5pt}{\normalfont\ttfamily%
84     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{#1#2\crcr#3#4\crcr}\hss}}}}\hss}%
85 }
86 \def\UCSB#1#2{%
87   \hbox to1em{\hss\textcolor{red}{\raisebox{3.5pt}{\normalfont\ttfamily%
88     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{\hss#1\hss\crcr\hss#2\hss\crcr}\hss}}}}\hss}%
89 }
90
91 \usepackage{listings,showexpl,enumitem}
92 \lstset{
93   basicstyle=\ttfamily\small, pos=r, breaklines=true,
94   numbers=none, rframe={}, basewidth=0.5em, numberstyle=\tiny, numbersep=0.5em,
95   explpreset={numberstyle=\tiny, numbers=left, numbersep=1em, columns=fixed},
96   morecomment=[l]{\%}, commentstyle=\color{green}
97 }
98 % Suppress output from showexpl to stdout.
99 \makeatletter
100 \let\SX@Info\relax
101
102 %%%%%%%% colors
103 %% modified from http://jfly.iam.u-tokyo.ac.jp/colorset/
104 \usepackage{transparent}
105 \definecolor{red}{rgb}{1, 0.16, 0}
106 \definecolor{blue}{rgb}{0, 0.25, 1}
107 \definecolor{gray}{rgb}{.50, .53, .56}
108 \definecolor{green}{rgb}{.21, .63, .42}
109 \definecolor{cyan}{rgb}{0.40, .80, 1}
110 \definecolor{b_gray}{rgb}{0.78, 0.78, 0.80}
111 \definecolor{b_pink}{rgb}{1, 0.82, 0.82}
112 \definecolor{b_green}{rgb}{.53, .91, .69}
113 \definecolor{b_cyan}{rgb}{0.70, .92, 98}
114
115 %%%%%%%% hyperref
116 \usepackage{hyperref,bookmark}
117 %<*en>
118 \title{The \LuaTeX-ja package}
119 \author{The \LuaTeX-ja project team}
120 \date{\LuaTeXjaversion~(\today)}
121 %</en>
122 %<*ja>
123 \title{\LuaTeX-jaパッケージ}
124 \author{\LuaTeX-jaプロジェクトチーム}
125 \date{\LuaTeXjaversion(\today)}
126 %</ja>
127 \hypersetup{%
128         unicode,
129         colorlinks,
130         allbordercolors=1 1 1,
131         allcolors=blue,
132 %<*en>
133         pdfauthor={The LuaTeX-ja project team},
134         pdftitle={The LuaTeX-ja package}
135 %</en>
136 %<*ja>
137         pdfauthor={LuaTeX-jaプロジェクトチーム},
138         pdftitle={LuaTeX-jaパッケージ}
139 %</ja>
140 }
141 \usepackage{bxghost}
142 %<*ja>
143 \def\HyRef@autoref#1#2{%
144   \begingroup
145     \Hy@safe@activestrue
146     \expandafter\HyRef@autosetref\csname r@#2\endcsname{#2}{#1}%
147   \endgroup\eghostguarded{}%" 欧文ゴースト
148 }
149 \def\figureautorefname{図}
150 \def\tableautorefname{表}
151 %</ja>
152
153 %%%%%%%% definition env.
154 \usepackage{amsthm}
155 \theoremstyle{definition}
156 %<en>\newtheorem{defn}{Definition}
157 %<ja>\newtheorem{defn}{定義}
158 \DeclareMathOperator\nint{nint}
159
160 %%%%%%%% logo
161 \usepackage{metalogo}
162 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
163 \DeclareRobustCommand\LuaTeX{Lua\TeX}
164 \DeclareRobustCommand\pdfTeX{pdf\TeX}
165 \DeclareRobustCommand\pTeX{p\kern-.15em\TeX}
166 \DeclareRobustCommand\upTeX{up\kern-.15em\TeX}
167 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
168 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
169 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\pTeX}
170
171 %%%%%%%% other macros
172 \newlist{cslist}{description}{2}
173 \setlist[cslist]{%
174     style=nextline,font=\mdseries\ttfamily,
175     before*=\def\<{\char`\<}\def\>{\char`\>}\def\{{\char`\{}\def\}{\char`\}},
176     topsep=\medskipamount,
177 %<ja> leftmargin=2\zw,
178 %<en> leftmargin=2em,
179 }
180
181 \def\labelenumii{(\arabic{enumii})}
182 \long\def\@makecaption#1#2{%
183   \vskip\abovecaptionskip
184   \sbox\@tempboxa{{\small #1. #2}}%
185   \ifdim \wd\@tempboxa >\hsize
186     {\small #1. #2}\par
187   \else
188     \global \@minipagefalse
189     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
190   \fi
191   \vskip\belowcaptionskip}
192
193 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
194 \def\cs#1{\texttt{\upshape
195   \texorpdfstring{\hbox{\ltjsetparameter{autoxspacing=false}\textbackslash#1}}{\textbackslash#1}}}
196 \ltjsetparameter{alxspmode={`\\,allow}}
197 \def\text@#1{%
198   \ifnum\mathstyle<\scriptstyle
199         \mbox{#1}
200   \else\ifnum\mathstyle<\scriptscriptstyle
201         \mbox{\let\f@size\sf@size\selectfont#1}
202   \else
203         \mbox{\let\f@size\ssf@size\selectfont#1}
204   \fi\fi
205 }
206 %%%%%%%%
207 \makeatother
208 %%%%%%%%
209
210 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
211   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}\strut#2\cr}}}}}\,}
212 \def\HNode#1#2#3#4{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
213   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}%
214   width:\hfill\ #2\cr height:\hfill\ #3\cr depth:\hfill\ #4\cr
215   }}}}}\,}
216 \protected\def\+{\insertxkanjiskip late}
217 \makeatletter
218 \def\Param#1{\texorpdfstring{\@Param{#1}}{#1}} % parameter name
219 \protected\def\@Param#1{\eghostguarded{\hyperlink{fld:#1}{\underline{\smash{\textsf{#1}}}}}}
220 \protected\def\DParam#1{\eghostguarded{\hypertarget{fld:#1}{\underline{\smash{\textsf{#1}}}}}} % parameter name (definition)
221 \def\Pkg#1{\texorpdfstring{\textsf{#1}}{#1}} % packages/classes
222
223 \begin{document}
224 \lstset{
225   vscmd=\IVSB
226 }
227
228 \def\meta#1{{\normalfont\rmfamily\itshape$\langle$#1\/$\rangle$}}
229 \maketitle
230
231 \tableofcontents
232 \bigskip
233
234 %<*en>
235 \textbf{This documentation is far from complete. It may have many
236 grammatical (and contextual) errors.} Also, several parts
237 are written in Japanese only.
238 %</en>
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{lstlisting}
351 \kanjiskip=10pt  \dimen0=kanjiskip
352 \tbaselineshift=0.1zw
353 \dimen0=\tbaselineshift
354 \prebreakpenalty`ぁ=100
355 \ifydir ... \fi
356 \end{lstlisting}
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{lstlisting}
361 \ltjsetparameter{kanjiskip=10pt}  \dimen0=\ltjgetparameter{kanjiskip}
362 \ltjsetparameter{talbaselineshift=0.1\zw}
363 \dimen0=\ltjgetparameter{talbaselineshift}
364 \ltjsetparameter{prebreakpenalty={`ぁ,100}}
365 \ifnum\ltjgetparameter{direction}=4 ... \fi
366 \end{lstlisting}
367 %<*en>
368 Note that \pTeX\ adds new two useful units, namely \texttt{zw}~and~\texttt{zh}.
369 As shown above, \emph{they are changed to \cs{zw}~and~\cs{zh} respectively} in \LuaTeX-ja.%
370 \footnote{\LuaTeX-ja 20200127.0 introduces \cs{ltj@zw}~and~\cs{ltj@zh}, which are copy of
371   \cs{zw}~and~\cs{zh}.}
372 %</en>
373 %<*ja>
374 特に注意してほしいのは,\pTeX で追加された\texttt{zw}と\texttt{zh}という単位は
375 \LuaTeX-ja では使用できず,\emph{\cs{zw}, \cs{zh} と制御綴の形にしないといけない}という点である
376 \footnote{%
377   別のパッケージやユーザが\cs{zw},~\cs{zh}を書き換えてしまうことに対応するため,
378   \LuaTeX-ja 20200127.0以降では,\cs{ltj@zw},~\cs{ltj@zh}がそれぞれ\cs{zw},~\cs{zh}の
379   コピーとして定義されている.
380 }.
381 %</ja>
382
383 %<*en>
384 \paragraph{Linebreak after a Japanese character}
385 In \pTeX, a line break after Japanese character is ignored (and
386       doesn't yield a space), since line breaks (in source files) are
387       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
388       doesn't have this feature completely, because of a specification
389       of \LuaTeX. For the detail, see Section~\ref{sec-lbreak}.
390 %</en>
391 %<*ja>
392 \paragraph{和文文字直後の改行}
393 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
394       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
395       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
396       詳しくは\ref{sec-lbreak}章を参照.
397 %</ja>
398
399 %<*en>
400 \paragraph{Spaces related to Japanese characters}
401 The insertion process of glues/kerns between two Japanese
402       characters and between a Japanese character and other characters
403       (we refer glues/kerns of both kinds as \textbf{JAglue}) is rewritten from
404       scratch.
405 %</en>
406 %<*ja>
407 \paragraph{和文関連の空白}
408 2つの和文文字の間や,和文文字と欧文文字の間に入るグルー/カーン
409       (両者をあわせて\textbf{JAglue}と呼ぶ)の挿入処理が0から書き直されている.
410 %</ja>
411
412 \begin{itemize}
413 %<*en>
414 \item As \LuaTeX's internal ligature handling is \emph{node-based}
415       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
416       insertion process of \textbf{JAglue} is now \emph{node-based}.
417 %</en>
418 %<*ja>
419 \item \LuaTeX の内部での合字の扱いは「ノード」を単位として行われるようになっている(例えば,
420       \verb+of{}fice+ で合字は抑制されない).それに合わせ,\textbf{JAglue}の挿入処理も
421       ノード単位で実行される.
422 %</ja>
423
424 %<*en>
425 \item Furthermore, nodes between two characters which have no effects in
426       line break (\textit{e.g.}, \cs{special} node) and kerns from
427       italic correction are ignored in the insertion process.
428 %</en>
429 %<*ja>
430 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \cs{special} ノード)や,
431   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
432 %</ja>
433
434 %<*en>
435 \item \emph{Caution: due to above two points, many methods which did for the
436       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
437       effective anymore.} In concrete terms, the following two methods are not effective anymore:
438 %</en>
439 %<*ja>
440 \item \emph{注意:上の2つの変更により,従来\textbf{JAglue}の挿入処理を分断するのに
441       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
442 %</ja>
443 \begin{lstlisting}
444 ちょ{}っと    ちょ\/っと
445 \end{lstlisting}
446 %<*en>
447       If you want to do so, please put an empty horizontal box (hbox) between it instead:
448 %</en>
449 %<*ja>
450       もし同じことをやりたければ,空の水平ボックス(hbox)を間に挟めばよい:
451 %</ja>
452 \begin{lstlisting}
453 ちょ\hbox{}っと
454 \end{lstlisting}
455
456 %<*en>
457 \item In the process, two Japanese fonts which only differ in their ``real''
458       fonts are identified.
459 %</en>
460 %<*ja>
461 \item 処理中では,2つの和文フォントは,実フォントが異なるだけの場合には同一視
462       される.
463 %</ja>
464 \end{itemize}
465
466 %<*en>
467 \paragraph{Directions}
468 From version~20150420.0, \LuaTeX-ja supports vertical writing.
469 We implement this feature by using callbacks of \LuaTeX; so it must \emph{not} be confused
470 with $\Omega$-style direction support of \LuaTeX\ itself.
471 Due to implementation, the dimension returned by \cs{wd},~\cs{ht}, or~\cs{dp} depends
472 on the content of the register \emph{only}. This is major difference with \pTeX.
473 %</en>
474 %<*ja>
475 \paragraph{組方向}
476 バージョン20150420.0からは,不安定ながらも\LuaTeX-ja における縦組みをサポートしている.
477 なお,\LuaTeX 本体も$\Omega$流の組方向をサポートしているが,それとは全くの別物であること
478 に注意してほしい.
479 特に,異なった組方向のボックスを扱う場合には
480 \cs{wd}, \cs{ht}, \cs{dp}等の仕様が\pTeX と異なるので注意.詳細は第\ref{sec-direction}章を参照.
481 %</ja>
482
483 %<*en>
484 \paragraph{\cs{discretionary}}
485 Japanese characters in discretionary break (\cs{discretionary}) is not supported.
486 %</en>
487 %<*ja>
488 \paragraph{\cs{discretionary}}
489  \cs{discretionary} 内に直接和文文字を記述することは,\pTeX においても想定されていなかった
490  感があるが.\LuaTeX-jaにおいても想定していない.和文文字をどう
491       しても使いたい場合は \cs{hbox} で括ること.
492 %</ja>
493
494 %<*en>
495 \paragraph{Greek and Cyrillic letters, and ISO~8859-1 symbols}
496 By default, \LuaTeX-ja uses Japanese fonts to typeset Greek and Cyrillic letters,
497       To change this behavior,
498       put \verb!\ltjsetparameter{jacharrange={-2,-3}}! in the preamble.
499       For the detailed description, see Subsection~\ref{ssec:setrange}.
500
501 From version~20150906.0, characters which belongs both ISO~8859-1 and JIS~X~0208,
502 such as \P~and~\S, are now typeset in alphabetic fonts.
503 %</en>
504 %<*ja>
505 \paragraph{ギリシャ文字・キリル文字とISO~8859-1の記号}
506 標準では,\LuaTeX-jaはギリシャ文字やキリル文字を和文フォントを使っ
507       て組む.ギリシャ語などを本格的に組むなどこの状況が望ましくない場合,
508       プリアンブルに
509 \begin{lstlisting}
510  \ltjsetparameter{jacharrange={-2,-3}}
511 \end{lstlisting}
512       を入れると
513       上記種類の文字は欧文フォントを用いて組まれるようになる.
514       詳しい説明は\ref{ssec:setrange}節を参照してほしい.
515
516 また,\P,~\S といったISO~8859-1の上位領域とJIS~X~0208の共通部分の文字は
517       バージョン20150906.0から標準で欧文扱いとなった.\LaTeXe\ 2017/01/01以降では
518 標準でTUエンコーディングのLatin Modernフォントが使われるので,
519 特に何もせずソース中にそのまま記述してもこれらの文字が出力される.
520 和文扱いで出力するには \verb+\ltjjachar`§+ のように \cs{ltjjachar} 命令
521 を使えばよい.
522 %</ja>
523
524 %<en>\subsection{Notations}
525 %<ja>\subsection{用語と記法}
526
527 %<*en>
528 In this document, the following terms and notations are used:
529 %</en>
530 %<*ja>
531 本ドキュメントでは,以下の用語と記法を用いる:
532 %</ja>
533 \begin{itemize}
534 %<*en>
535 \item Characters are classified into following two types.
536       Note that the classification can be customized by a user
537       (see Subsection~\ref{ssec:setrange}).
538 %</en>
539 %<*ja>
540 \item 文字は次の2種類に分けられる.この類別は固定されているものではなく,ユーザが後から変更可能である
541       (\ref{ssec:setrange}節を参照).
542 %</ja>
543 \begin{itemize}
544 %<*en>
545 \item \textbf{JAchar}: standing for characters which is used in Japanese typesetting,
546       such as Hiragana,~Katakana, Kanji, and~other Japanese punctuation marks.
547 %</en>
548 %<*ja>
549 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった
550       日本語組版に使われる文字のことを指す.
551 %</ja>
552
553 %<en>\item \textbf{ALchar}: standing for all other characters like latin alphabets.
554 %<ja>\item \textbf{ALchar}: ラテンアルファベットを始めとする,その他全ての文字を指す.
555 \end{itemize}
556
557 %<*en>
558 We say \emph{alphabetic fonts} for fonts used in \textbf{ALchar},
559 and \emph{Japanese fonts} for fonts used in \textbf{JAchar}.
560 %</en>
561 %<*ja>
562 そして,\textbf{ALchar}の出力に用いられるフォントを\emph{欧文フォント}と呼び,
563 \textbf{JAchar}の出力に用いられるフォントを\emph{和文フォント}と呼ぶ.
564 %</ja>
565 %<*en>
566 \item A word in a sans-serif font with underline (like \Param{prebreakpenalty})
567       means an internal parameter for Japanese typesetting, and it
568       is used as a key in \cs{ltjsetparameter} command.
569 %</en>
570 %<*ja>
571 \item 下線つきローマン体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
572       パラメータを表し,これらは \cs{ltjsetparameter} 命令のキーとして
573       用いられる.
574 %</ja>
575 %<*en>
576 \item A word in a sens-serif font without underline (like \Pkg{fontspec})
577       means a package or a class of \LaTeX.
578 %</en>
579 %<*ja>
580 \item 下線なしサンセリフ体の語(例:\Pkg{fontspec})は\LaTeX の
581       パッケージやクラスを表す.
582 %</ja>
583 %<*en>
584 \item In this document, natural numbers start from~zero.
585   $\omega$ denotes the set of all natural numbers which can be used in \TeX.
586 %</en>
587 %<*ja>
588 \item 本ドキュメントでは,自然数は0から始まる.(\TeX で扱える)自然数全体の集合は$\omega$と表記する.
589 %</ja>
590 \end{itemize}
591
592 %<en>\subsection{About the project}
593 %<ja>\subsection{プロジェクトについて}
594
595 %<en>\paragraph{Project Wiki} Project Wiki is under construction.
596 %<ja>\paragraph{プロジェクトWiki} プロジェクトWikiは構築中である.
597 %<*en>
598 \begin{itemize}
599 \item \url{https://github.com/luatexja/luatexja/wiki/Home(en)} (English)
600 \item \url{https://github.com/luatexja/luatexja/wiki} (Japanese)
601 \item \url{https://github.com/luatexja/luatexja/wiki/Home(zh)} (Chinese)
602 \end{itemize}
603 %</en>
604 %<*ja>
605 \begin{itemize}
606 \item \url{https://github.com/luatexja/luatexja/wiki}(日本語)
607 \item \url{https://github.com/luatexja/luatexja/wiki/Home(en)}(英語)
608 \item \url{https://github.com/luatexja/luatexja/wiki/Home(zh)}(中国語)
609 \end{itemize}
610 %</ja>
611
612 %<en>This project is hosted by GitHub.
613 %<ja>本プロジェクトはGitHubのサービスを用いて運営されている.
614
615 %<en>\paragraph{Members}\
616 %<ja>\clearpage\paragraph{開発メンバー}\
617
618 %<*en>
619 \begin{multienumerate}
620 \def\labelenumi{$\bullet$}
621 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
622 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
623 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
624 \end{multienumerate}
625 %</en>
626 %<*ja>
627 \begin{multienumerate}
628 \def\labelenumi{$\bullet$}
629 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
630 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
631 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
632 \end{multienumerate}
633 %</ja>
634
635 % \paragraph{Acknowledgments} -- 挿入するならここ
636
637 %<en>\clearpage
638 %<en>\section{Getting Started}
639 %<ja>\section{使い方}
640 %<en>\subsection{Installation}
641 %<ja>\subsection{インストール}
642 \label{ssec:install}
643 %<en>The following packages are needed for the \LuaTeX-ja\ package.
644 %<ja>\LuaTeX-jaパッケージの動作には次のパッケージ類が必要である.
645 \begin{itemize}
646 \item \href{http://www.luatex.org/}{\LuaTeX}\ 1.10.0 (or later)
647 %<en>  (DVI output (\cs{outputmode=0} is not supported.)
648 %<ja>  (DVI出力(\cs{outputmode=0})は対応していない.)
649 \item recent \href{https://github.com/latex3/luaotfload}{\Pkg{luaotfload}} (v3.1 or later recommended)
650 \item \Pkg{adobemapping} (Adobe cmap and pdfmapping files)
651 \item \href{https://github.com/josephwright/etoolbox/}{\Pkg{etoolbox}}
652 %<en>  (if you want to use \LuaTeX-ja with \LaTeXe)
653 %<ja>  (\LaTeXe 下で\LuaTeX-jaを使う場合)
654 \item \Pkg{ltxcmds}, \Pkg{pdftexcmds}
655 \item \href{https://github.com/wspr/fontspec/}{\Pkg{fontspec}} v2.7c (or later)
656 %<*en>
657 \item \emph{Harano Aji fonts} (\url{https://github.com/trueroad/HaranoAjiFonts})\\
658   More specifically, HaranoAjiMincho-Regular~and~HaranoAjiGothic-Medium.
659 %</en>
660 %<*ja>
661 \item \emph{原ノ味フォント(\url{https://github.com/trueroad/HaranoAjiFonts})}\\
662 \LuaTeX-jaの最低限の動作には原ノ味明朝Regular~(HaranoAjiMincho-Regular)と
663 原ノ味角ゴシックMedium~(HaranoAjiGothic-Medium)があれば十分である.
664 %</ja>
665 \end{itemize}
666
667 %<*en>
668 Now \LuaTeX-ja is available from
669 CTAN (in the \texttt{macros/luatex/generic/luatexja} directory), and
670 the following distributions:
671   \begin{itemize}
672   \item \href{https://www.tug.org/texlive/}{\TeX~Live} (in \texttt{texmf-dist/tex/luatex/luatexja})
673   \item MiK\TeX\ (in \texttt{luatexja.tar.xz})
674   \end{itemize}
675 Harano Aji fonts are also available in these distributions
676 (\texttt{haranoaji} in \TeX~Live and MiK\TeX).
677 %</en>
678 %<*ja>
679 現在,\LuaTeX-jaはCTAN (\texttt{macros/luatex/generic/luatexja})に収録されている他,
680 以下のディストリビューションにも収録されている:
681   \begin{itemize}
682   \item MiK\TeX\ (\texttt{luatexja.tar.lzma})
683   \item \TeX~Live (\texttt{texmf-dist/tex/luatex/luatexja})
684   \end{itemize}
685 これらのディストリビューションは原ノ味フォントも収録している
686 (\TeX~Live, MiK\TeX では\texttt{haranoaji}).
687 %</ja>
688
689 %<*en>
690 \paragraph{HarfBuzz~and~\LuaTeX-ja}
691 Using \LuaTeX-ja with LuaHB\TeX (\LuaTeX\ integrated with
692 \href{https://github.com/harfbuzz/harfbuzz}{HarfBuzz}) is not well tested.
693 Maybe documents can typeset without an error,
694 but with unwanted results (especially, vertical typesetting and \cs{CID}).
695
696 Especially,
697 \emph{We don't recommend defining a Japanese font with HarfBuzz},
698 by specifying \texttt{Renderer=Harfbuzz}~etc.\ (\Pkg{fontspec}) or~{mode=harf} (otherwise).
699 %</en>
700 %<*ja>
701 \paragraph{HarfBuzzと\LuaTeX-ja}
702 現時点では,HarfBuzzの機能を用いたときの\LuaTeX-jaの使用は十分にテストされていない.
703 エラーが発生せずにタイプセットできるかもしれないが,特に縦組時や
704 \cs{CID}などで意図しない結果となりうる可能性が大きい.
705 特に,\emph{\texttt{Renderer=Harfbuzz}等(\Pkg{fontspec})や\texttt{mode=harf}指定(それ以外)を通じて
706   和文フォントに対してHarfBuzzを用いることは推奨しない}.
707 %</ja>
708
709 %<en>\paragraph{Manual installation}
710 %<ja>\paragraph{手動インストール方法}
711
712 \begin{enumerate}
713 %<*en>
714 \item Download the source, by one of the following method.
715       At the present, \LuaTeX-ja has no \emph{stable} release.
716
717 \begin{itemize}
718 \item Clone the Git repository by
719 \begin{lstlisting}
720 $ git clone https://github.com/luatexja/luatexja.git
721 \end{lstlisting}
722 \item Download the \texttt{zip} archive of HEAD in the \texttt{master} branch from
723 \begin{flushleft}
724 \url{https://github.com/luatexja/luatexja/archive/refs/heads/master.zip}.
725 \end{flushleft}
726 \end{itemize}
727
728 Note that the \texttt{master} branch, and hence the archive in CTAN, are not updated frequently;
729 the forefront of development is not the \texttt{master} branch.
730 %</en>
731 %<*ja>
732 \item ソースを以下のいずれかの方法で取得する.現在公開されているのはあくまでも
733       開発版であって,安定版でないことに注意.
734
735 \begin{itemize}
736 \item Gitリポジトリを次のコマンドでクローンする:
737 \begin{lstlisting}
738 $ git clone https://github.com/luatexja/luatexja.git
739 \end{lstlisting}
740 \item \texttt{master} ブランチのスナップショット(\texttt{zip} 形式)をダウンロードする:
741 \begin{flushleft}
742 \url{https://github.com/luatexja/luatexja/archive/refs/heads/master.zip}.
743 \end{flushleft}
744 \end{itemize}
745 \texttt{master} ブランチ(従って,CTAN内のアーカイブも)はたまにしか更新されないことに注意.
746 主な開発は\texttt{master}の外で行われ,比較的まとまってきたらそれを \texttt{master} に
747 反映させることにしている.
748 %</ja>
749
750 %<*en>
751 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
752 But only the contents in \texttt{src/} are needed to work \LuaTeX-ja.
753 %</en>
754 %<*ja>
755 \item 「Gitリポジトリをクローン」以外の方法でアーカイブを取得したならば,それを展開する.
756       \texttt{src/} をはじめとしたいくつかのディレクトリができるが,
757       動作には \texttt{src/} 以下の内容だけで十分.
758 %</ja>
759
760 %<*en>
761 \item If you downloaded this package from CTAN, you have to run following commands
762     to generate classes:
763 %</en>
764 %<*ja>
765 \item もしCTANから本パッケージを取得したのであれば,日本語用クラスファイルを生成するために,
766 以下を実行する必要がある:
767 %</ja>
768 \begin{lstlisting}
769 $ cd src
770 $ lualatex ltjclasses.ins
771 $ lualatex ltjsclasses.ins
772 $ lualatex ltjltxdoc.ins
773 \end{lstlisting}
774
775 %<*en>
776 \item Copy all the contents of \texttt{src/} into one of your \texttt{TEXMF} tree.
777       \texttt{TEXMF/tex/luatex/luatexja/} is an example location.
778       If you cloned entire Git repository, making a symbolic link of \texttt{src/}
779       instead copying is also good.
780 %</en>
781 %<*ja>
782 \item \texttt{src} の中身を自分の \texttt{TEXMF} ツリーにコピーする.
783       場所の例としては,例えば
784 \begin{quote}
785  \texttt{TEXMF/tex/luatex/luatexja/}
786 \end{quote}
787       がある.
788       シンボリックリンクが利用できる環境で,かつリポジトリを直接取得したのであれば,
789       (更新を容易にするために)コピーではなくリンクを貼ることを勧める.
790 %</ja>
791 %<*en>
792 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
793 %</en>
794 %<*ja>
795 \item 必要があれば,\texttt{mktexlsr} を実行する.
796 %</ja>
797 \end{enumerate}
798
799 %<*en>
800 \subsection{Cautions}
801 For changes from \pTeX, see Subsection~\ref{ssec:chgptex}.
802 %</en>
803 %<*ja>
804 \subsection{注意点}
805 \pTeX からの変更点として,\ref{ssec:chgptex}節も熟読するのが望ましい.
806 ここでは一般的な注意点を述べる.
807 %</ja>
808 \begin{itemize}
809 %<*en>
810 \item The encoding of your source file must be UTF-8. Other
811       encodings, such as EUC-JP or Shift-JIS, are not supported.
812 %</en>
813 %<*ja>
814 \item 原稿のソースファイルの文字コードはUTF-8固定である.
815       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
816 %</ja>
817 %<*en>
818 \item \LuaTeX-ja is very slower than \pTeX, and uses a lot of memory.
819 %</en>
820 %<*ja>
821 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
822   コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
823   また,和文フォントを読み込むために多量のメモリを消費することにも注意が必要である.
824 %</ja>
825
826 \item
827 %<*en>
828 Note that when \LuaTeX-ja is loaded in plain \LuaTeX,
829 we cannot use color specification on font loading, such as
830 \begin{lstlisting}
831   \font\hoge=lmroman10-regular.otf:color=FF0000 % \font primitive
832 \end{lstlisting}
833 This is because codes for shifting baseline in math mode (\LuaTeX-ja) collide with and prevents loading
834 codes for font color (\Pkg{luaotfload}) in these environments.
835 \emph{We recommend to use \LaTeX\ 2020-02-02 (or later)}, since we can avoid this collision in there.
836 %</en>
837 %<*ja>
838 なお,\LuaTeX-jaをplain~\LuaTeX で用いる場合,
839 以下のような\emph{フォント読み込み時の色指定}(\cs{textcolor}命令ではなく!)\emph{は利用できない}.
840 \begin{lstlisting}
841   \font\hoge=lmroman10-regular.otf:color=FF0000 % \font primitive
842 \end{lstlisting}
843 これは,\LuaTeX-jaによる数式内のベースライン補正(\ref{ssec:baseline}節)のコードが
844 \Pkg{luaotfload}パッケージのフォント色処理のコードと衝突するためである.
845 \LaTeX\ 2020-02-02以降では衝突回避のための仕組みが備わっているので.\emph{\LaTeX\ 2020-02-02以降での使用を勧める}.
846 %</ja>
847 \end{itemize}
848
849 %<en>\subsection{Using in plain \TeX}
850 %<ja>\subsection{plain \TeX で使う}
851 \label{ssec:plain}
852
853 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
854 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
855 \begin{lstlisting}
856 \input luatexja.sty
857 \end{lstlisting}
858 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
859 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
860
861 \begin{itemize}
862 %<*en>
863 \item The following 12~Japanese fonts are preloaded:
864 \begin{center}\small
865 \begin{tabular}{llllll}
866 \toprule
867 \textbf{direction}&
868 \textbf{classification}&\textbf{font name}&\bfseries ``10\,pt''&\bfseries ``7\,pt''&\bfseries ``5\,pt''\\\midrule
869 \smash{\raisebox{-1ex}{\emph{yoko} (horizontal)}}&
870 \emph{mincho}&HaranoAjiMincho-Regular&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
871 &\emph{gothic}&HaranoAjiGothic-Medium&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
872 \midrule
873 \smash{\raisebox{-1ex}{\emph{tate} (vertical)}}&
874 \emph{mincho}&HaranoAjiMincho-Regular&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
875 &\emph{gothic}&HaranoAjiGothic-Medium&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
876 \bottomrule
877 \end{tabular}
878 \end{center}
879 %</en>
880 %<*ja>
881 \item 以下の12個の和文フォントが定義される:
882 \begin{center}\small
883 \begin{tabular}{llllll}
884 \toprule
885 \emph{組方向}&\emph{字体}&\emph{フォント名}&\bfseries``10\,pt''&\bfseries``7\,pt''&\bfseries``5\,pt''\\\midrule
886 \smash{\raisebox{-0.7\zh}{横組}}&
887 明朝体&原ノ味明朝Regular&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
888 &\textgt{ゴシック体}&原ノ味角ゴシックMedium&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
889 \midrule
890 \smash{\raisebox{-0.7\zh}{縦組}}&
891 明朝体&原ノ味明朝Regular&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
892 &\textgt{ゴシック体}&原ノ味角ゴシックMedium&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
893 \bottomrule
894 \end{tabular}
895 \end{center}
896 %</ja>
897 \begin{itemize}
898 %<*en>
899 \item The ``default'' Japanese fonts (and~JFMs for them) can be 
900   modified by defining \cs{ltj@stdmcfont} etc.\ \emph{before}
901   one inputs \texttt{luatexja.sty} (Subsection~\ref{ssec:cfg}).
902 %</en>
903 %<*ja>
904 \item 標準和文フォントやJFMを原ノ味フォントから別のものに置き換えるには,
905   \cs{ltj@stdmcfont}等を\texttt{luatexja.sty}読み込み\emph{前}に定義すればよい.
906   \ref{ssec:cfg}節を参照.
907 %</ja>
908
909 %<*en>
910 \item A character in an alphabetic font is generally smaller than a
911       Japanese font in the same size. So actual size specification of
912       these Japanese fonts is in fact smaller than that of alphabetic
913       fonts, namely scaled by 0.962216.
914 %</en>
915 %<*ja>
916 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
917       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
918       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
919       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
920 %</ja>
921 \end{itemize}
922
923 %<*en>
924 \item The amount of glue that are inserted between a \textbf{JAchar} and
925       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
926 %</en>
927 %<*ja>
928 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{xkanjiskip})の
929       量は次のように設定されている:
930 %</ja>
931 \[
932  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
933  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
934 \]
935 \end{itemize}
936
937 %<en>\subsection{Using in \LaTeX}
938 %<ja>\subsection{\LaTeX で使う}
939 \label{ssec:ltx}
940
941 %<*en>
942 Using in \LaTeXe\ is basically same. To set up the minimal environment
943 for Japanese, you only have to load \texttt{luatexja.sty}:
944 %</en>
945 %<*ja>
946 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
947 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
948 %</ja>
949 \begin{lstlisting}
950 \usepackage{luatexja}
951 \end{lstlisting}
952 %<*en>
953 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
954 plfonts.dtx} and \texttt{pldefs.ltx}).
955 %</en>
956 %<*ja>
957 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
958 なされる.
959 %</ja>
960
961 \begin{itemize}
962 %<*en>
963 \item Font encodings for Japanese fonts are \texttt{JY3}~(for horizontal direction) and
964 \texttt{JT3}~(for vertical direction).
965 %</en>
966 %<*ja>
967 \item 和文フォントのエンコーディングとしては,横組用には \texttt{JY3},縦組用には\
968 \texttt{JT3}が用いられる.
969 %</ja>
970
971 %<*en>
972 \item Traditionally, Japanese documents use only two families: \emph{mincho}~(明朝体) and
973  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
974       is used in the headings or for emphasis.
975 \begin{center}\small
976 \begin{tabular}{lllc}
977 \toprule
978 \textbf{classification}&\textbf{commands}&&\textbf{family}\\\midrule
979 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
980 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
981 (Japanese counterpart for typewriter font)&---&---&\cs{jttdefault}\\
982 \bottomrule
983 \end{tabular}
984 \end{center}
985   Here \cs{jttdefault} specifies the Japanese font family in \cs{verb}~or~\texttt{verbatim}
986   environment, and its default value is \cs{mcdefault} (mincho family).%
987   \footnote{%
988         When \Pkg{ltjsclasses} classes are used, or
989         \Pkg{luatexja-fontspec} (or \Pkg{luatexja-preset}) is loaded with \texttt{match} option,
990         \cs{ttfamily} changes the current Japanese font amily to \cs{jttdefault}.
991         These classes and packages also redefine \cs{jttdefault} to
992         \cs{gtdefault} (\emph{gothic}~family).
993   } \LuaTeX-ja does not define commands to only switch current Japanese font family to
994   \cs{jttdefault}.
995
996 \item
997 By default, the following fonts are used for these two families.
998 \begin{center}\small
999 \begin{tabular}{lllll}
1000 \toprule
1001 \textbf{classification}&\textbf{family}&\textbf{\cs{mdseries}}&\textbf{\cs{bfseries}}&\textbf{scale}\\\midrule
1002 \emph{mincho} (明朝体)&\texttt{mc}&HaranoAjiMincho-Regular&HaranoAjiGothic-Medium&0.962216\\
1003 \emph{gothic} (\textgt{ゴシック体})&\texttt{gt}&HaranoAjiGothic-Medium&HaranoAjiGothic-Medium&0.962216\\
1004 \bottomrule
1005 \end{tabular}
1006 \end{center}
1007 \item Note that the bold series (series \texttt{bx}~or~\texttt{b}) in both family
1008      are same as the medium series of gothic family.
1009      There is no italic nor slanted shape for these \texttt{mc}~and~\texttt{gt}.
1010 %</en>
1011 %<*ja>
1012 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる.
1013 \begin{center}\small
1014 \begin{tabular}{llll}
1015 \toprule
1016 \emph{字体}&\emph{命令}&&\emph{ファミリ名}\\\midrule
1017 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
1018 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
1019 (タイプライタ体と合わせる和文)&---&&\cs{jttdefault}\\
1020 \bottomrule
1021 \end{tabular}
1022 \end{center}
1023   \cs{jttdefault}は\cs{verb}や\texttt{verbatim}環境中の和文文字に使われる和文フォントファミリであり,
1024   標準値は\cs{mcdefault},つまり明朝体である
1025   \footnote{%
1026         \Pkg{ltjsclasses}を使用したり,また\Pkg{luatexja-fontspec}や\Pkg{luatexja-preset}パッケージを
1027         \texttt{match}オプションを指定して読み込んだときは,単なる\cs{ttfamily}によっても和文フォントが
1028         \cs{jttdefault}に変更される.また,これらのクラスファイルやパッケージは
1029         \cs{jttdefault}を \cs{gtdefault}(ゴシック体)に再定義する.
1030   }.和文フォントファミリ(のみ)を\cs{jttdefault}に切り替える命令は準備していない.
1031
1032 \item 標準では,次のフォントが用いられる:
1033 \begin{center}\small
1034 \begin{tabular}{lllll}
1035 \toprule
1036 \emph{字体}&\emph{ファミリ}&\textbf{\cs{mdseries}}&\textbf{\cs{bfseries}}&\emph{スケール}\\\midrule
1037 明朝体&\texttt{mc}&原ノ味明朝Regular&原ノ味角ゴシックMedium&0.962216\\
1038 \textgt{ゴシック体}&\texttt{gt}&原ノ味角ゴシックMedium&原ノ味角ゴシックMedium&0.962216\\
1039 \bottomrule
1040 \end{tabular}
1041 \end{center}
1042
1043 明朝・ゴシックどちらのファミリにおいても,太字(\cs{bfseries})のフォントは
1044 ゴシック体中字(\cs{gtfamily}\cs{mdseries})で使われるフォントと同じであることに注意.
1045 また,どちらのファミリでもイタリック体・スラント体は定義されない.
1046
1047  \item 和文の太字を表すシリーズ名は,(元々のComputer Modernが
1048   太字に\texttt{bx}を用いていたことから)伝統的に\texttt{bx}~(Bold Extended)が使われてきた.
1049   しかし,太字にシリーズ\texttt{b}を使うフォントも増えてきたため,
1050   バージョン20180616.0以降では和文の太字として\texttt{bx},~\texttt{b}の両方を扱えるようにした.
1051 %</ja>
1052
1053 %<*en>
1054  \item From version~20181102.0, one can specifies \texttt{disablejfam} option at
1055   loading \LuaTeX-ja. This option prevents loading a patch for \LaTeX, which are
1056   needed to support Japanese characters in math mode.
1057
1058   Without \texttt{disablejfam} option, one can typeset Japanese characters in
1059   math mode as~\verb+$あ$+ (see Page~\pageref{para:jachar_in_math}) as before.
1060   Japanese characters in math mode are typeset by the font family \texttt{mc}.
1061 %</en>
1062 %<*ja>
1063  \item バージョン20181102.0以降では,\texttt{disablejfam}オプションを\LuaTeX-ja読み込み時に
1064   指定できるようになった.このオプションは,数式モード中に直に和文文字を書けるようにするための
1065   \LaTeX へのパッチを読み込まない.
1066
1067   \texttt{disablejfam}のない状況では,以前と同様に和文文字を数式モード中に
1068   直に書くことができる(但し\pageref{para:jachar_in_math}ページの記述も参照).
1069   その際には明朝体(\texttt{mc})で出力される.
1070 %</ja>
1071
1072 %<*en>
1073 \item If you use the \Pkg{beamer} class with the default font theme (which uses sans serif
1074       fonts) and with \LuaTeX-ja, you might want to change default Japanese fonts to
1075       the gothic family. The following line  changes  the default Japanese font family
1076       to it:
1077 %</en>
1078 %<*ja>
1079 \item \Pkg{beamer}クラスを既定のフォント設定で使う場合,既定欧文フォントがサンセリフなの
1080       で,既定和文フォントもゴシック体にしたいと思うかもしれない.その場合はプリアンブルに
1081 次を書けばよい:
1082 %</ja>
1083 \begin{lstlisting}
1084  \renewcommand{\kanjifamilydefault}{\gtdefault}
1085 \end{lstlisting}
1086
1087 %<*ja>
1088 \item \pLaTeX と同様に,\texttt{mc},~\texttt{gt}両ファミリには「従属欧文」書体が定義されている.
1089   これらは\cs{userelfont}を\cs{selectfont}(や,その他の「実際に」
1090   フォントを変更する命令)の前で実行することにより使うことができる.
1091
1092   \pLaTeX では標準の欧文フォントはOT1エンコーディングのComputer Modern Roman (\texttt{cmr})%
1093   であったが,2017年以降の\LuaLaTeX ではTUエンコーディングのLatin Modern Roman (\texttt{lmr})%
1094   に変更されている.そのため,前段落で述べた「従属欧文」も,Latin Modern Romanに設定している.
1095 %</ja>
1096
1097 \end{itemize}
1098
1099 %<*en>
1100 However, above settings are not sufficient for Japanese-based
1101 documents. To typeset Japanese-based documents, you are better to use
1102 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
1103 the present, \LuaTeX-ja has the counterparts of \Pkg{jclasses} (standard
1104 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
1105 Okumura), namely, \Pkg{ltjclasses}\footnote{%
1106   \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls},
1107   \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls}.
1108   The latter \texttt{ltjt*.cls} are for vertically written Japanese documents.
1109 } and \Pkg{ltjsclasses}\footnote{%
1110   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls}, \texttt{ltjsreport.cls},~\texttt{ltjskiyou.cls}.}.
1111
1112 Original \Pkg{jsclasses} use \cs{mag}~primitive to set the main document font size.
1113 However, \LuaTeX\ does not support \cs{mag} in PDF~output,
1114 so \Pkg{ltjsclasses} uses the \texttt{nomag*} option\footnote{Same effect as 
1115   the \Pkg{BXjscls} classes (by Takayuki Yato) and \Pkg{jsclasses}.
1116   However, these classes uses only \TeX\ code, but \Pkg{ltjsclasses} uses Lua code.}
1117  by default to set the main font size. If this causes some unexpected behavior, specify
1118 \texttt{nomag} option in \cs{documentclass}.
1119 %</en>
1120 %<*ja>
1121 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
1122 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
1123 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
1124 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}%
1125 (奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,
1126 \Pkg{ltjclasses}\footnote{%
1127   横組用は \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls} であり,
1128   縦組用は \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls} である.
1129 },
1130 \Pkg{ltjsclasses}\footnote{%
1131   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls}, \texttt{ltjsreport.cls},~\texttt{ltjskiyou.cls}.}%
1132 がそれぞれ\LuaTeX-ja標準で用意されている.
1133
1134 元々の\Pkg{jsclasses}では本文のフォントサイズを設定するのに\cs{mag}プリミティブが使われていたが,
1135 \LuaTeX ではPDF出力時の\cs{mag}のサポートが廃止された.
1136 そのため,\Pkg{ltjsclasses}では\texttt{nomag*}オプション
1137 \footnote{\Pkg{jsclasses}や,八登崇之氏による\Pkg{BXjscls}クラスにおける同名のオプションと
1138   同じ.上記クラスは\TeX コードのみで実装しているが,\Pkg{ltjsclasses}ではLuaコードも用いている.}が標準で
1139 有効になっており,これを使って本文フォントサイズの設定を行っている.
1140 しかし,この\texttt{nomag*}オプションでは(バージョン20180121.0より前で\Pkg{unicode-math}パッケージ使用時に起きたように)予想外の意図しない現象に遭遇する危険がある.そのような場合は
1141 \cs{documentclass}において\texttt{nomag}オプションを指定してほしい.
1142 %</ja>
1143
1144 %<*ja>
1145 \paragraph{脚注とボトムフロートの出力順序}
1146 オリジナルの\LaTeX では脚注はボトムフロートの上に出力され,また\cs{raggedbottom}命令でページの高さが不揃いであることを許した場合には
1147 脚注の下端の垂直位置もページに応じて変わるようになっている.
1148 一方,日本語の組版では脚注はボトムフロートの下に来るのが一般的であるので,
1149 \pLaTeX ではそのように変更されており,
1150 さらに\cs{raggedbottom}命令を実行した後でも脚注は常にページの下端に固定されるようになっている.
1151
1152 \LuaTeX-jaでは「欧文クラスの中にちょっとだけ日本語を入れる」という利用も考慮し,
1153 脚注とボトムフロートの順序,及び\cs{raggedbottom}時の脚注の垂直位置は\LaTeX 通りとした.
1154 これらを制御するには以下の手段がある:
1155 \begin{itemize}
1156  \item \pLaTeX のように,脚注をボトムフロートの下に組む場合には
1157   \Pkg{stfloats}パッケージを利用して
1158   \begin{lstlisting}
1159     \usepackage{stfloats}\fnbelowfloat
1160   \end{lstlisting}
1161   とする.この状況から「脚注をボトムフロートの上に組む」という\LaTeX の標準の挙動に戻したければ,
1162   \Pkg{stfloats}パッケージの\cs{fnunderfloat}命令を使用する.
1163   \item \cs{raggedbottom}時の脚注の垂直位置は,\cs{iffnfixbottom}という真偽値で制御する.
1164   \begin{description}
1165     \item[偽(\cs{fnfixbottomfalse})の場合] \LaTeX 標準と同じく,本文と脚注の間の空白は\cs{skip}\cs{footins}のみ.
1166     従って脚注の垂直位置はページにより変動する.
1167     \item[真(\cs{fnfixbottomtrue})の場合] \pLaTeX や\Pkg{footmisc}パッケージを\texttt{bottom}オプションで
1168     読み込んだ場合のように,脚注は常にページの下端に固定される.
1169   \end{description}
1170 \item ただし,\LuaTeX-jaが提供する「互換クラス」(\Pkg{ltjclasses}, \Pkg{ltjsclasses})では,
1171   \pLaTeX と合わせるために以下のようにしている:
1172   \begin{itemize}
1173     \item \cs{fnfixbottomtrue}が自動的に実行される
1174     \item \Pkg{stfloats}パッケージが\LuaTeX から参照できる場所にあった場合は
1175     自動的に読み込み,\cs{fnbelowfloat}を実行する.
1176   \end{itemize}
1177 \end{itemize}
1178 なお,\Pkg{stfloats}パッケージを使う代わりに,
1179 \Pkg{footmisc}パッケージを \texttt{bottom}オプションを指定して読み込む
1180 という「解決法」もある.
1181 %</ja>
1182 %%% ↑は英訳しない
1183
1184 %<*en>
1185 \paragraph{\Pkg{geometry} package and classes for vertical writing}
1186 It is well-known that the \Pkg{geometry} package produces the following error, when classes for
1187 vertical writing is used:
1188 %</en>
1189 %<*ja>
1190 \paragraph{縦組での\Pkg{geometry}パッケージ}
1191 \pLaTeX の縦組用標準クラスファイルでは\Pkg{geometry}パッケージを利用することは出来ず,
1192 %</ja>
1193 \begin{lstlisting}
1194 ! Incompatible direction list can't be unboxed.
1195 \@begindvi ->\unvbox \@begindvibox
1196                                    \global \let \@begindvi \@empty
1197 \end{lstlisting}
1198 %<*en>
1199 Now, \LuaTeX-ja automatically applies the patch \Pkg{lltjp-geometry} to the
1200 \Pkg{geometry} package, when the direction of the document is \emph{tate} (vertical
1201 writing).
1202 This patch \Pkg{lltjp-geometry} also can be used in \pLaTeX; for the detail, please refer
1203 \url{lltjp-geometry.pdf}~(Japanese).
1204 %</en>
1205 %<*ja>
1206 というようなエラーが発生することが知られている.
1207 \LuaTeX-jaでは, \texttt{ltjtarticle.cls} といった縦組クラスの下でも
1208 \Pkg{geometry}パッケージが利用できるようにパッチ\Pkg{lltjp-geometry}パッケージを自動的に当てている.
1209
1210 なお,\Pkg{lltjp-geometry}パッケージは\pTeX 系列でも明示的に読み込むことによって
1211 使用可能である.詳細や注意事項は \url{lltjp-geometry.pdf} を参照のこと.
1212 %</ja>
1213
1214
1215 %<en>\section{Changing Fonts}
1216 %<ja>\section{フォントの変更}
1217
1218 \subsection{plain \TeX~and~\LaTeXe}
1219 \label{ssec:chgfnt}
1220
1221 \paragraph{plain \TeX}
1222 %<*en>
1223 To change Japanese fonts in plain \TeX, you must use the command
1224 \cs{jfont}~and~\cs{tfont}. So please see Subsection~\ref{ssec:jfont}.
1225 %</en>
1226 %<*ja>
1227 plain \TeX で和文フォントを変更するためには,
1228 \pTeX のように \cs{jfont} 命令や \cs{tfont} 命令を直接用いる.
1229 \ref{ssec:jfont}節を参照.
1230 %</ja>
1231
1232 \paragraph{\LaTeXe\ (NFSS2)}
1233 %<*en>
1234 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
1235 %</en>
1236 %<*ja>
1237 \LaTeX で用いる際には,\pLaTeXe\ (\texttt{plfonts.dtx})用のフォント選択機構の大部分を流用している.
1238 %</ja>
1239
1240 %<*en>
1241 \begin{center}\small
1242 \begin{tabular}{>{\bfseries}llllll}
1243 \toprule
1244 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
1245 Alphabetic fonts
1246 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1247 &\cs{useroman}\\
1248 Japanese fonts
1249 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1250 &\cs{usekanji}\\
1251 both&---&--&\cs{fontseries}&\cs{fontshape}$^*$&---\\
1252 auto select&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1253 \bottomrule
1254 \end{tabular}
1255 \end{center}
1256 %</en>
1257 %<*ja>
1258 \begin{center}\small
1259 \begin{tabular}{llllll}
1260 \toprule
1261 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェイプ}&\emph{選択}\\\midrule
1262 \emph{欧文}
1263 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1264 &\cs{useroman}\\
1265 \emph{和文}
1266 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1267 &\cs{usekanji}\\
1268 \emph{両方}&---&--&\cs{fontseries}&\cs{fontshape}$^*$&---\\
1269 \emph{自動選択}&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1270 \bottomrule
1271 \end{tabular}
1272 \end{center}
1273 %</ja>
1274
1275 \begin{itemize}
1276 %<*en>
1277 \item \cs{fontfamily}, \cs{fontseries}, and~\cs{fontshape} try to change
1278       attributes of Japanese fonts, as well as those of alphabetic fonts.
1279       Of course, \cs{selectfont} is needed to select current text fonts.
1280
1281       Note that \cs{fontshape} always changes current alphabetic font shape,
1282       but it does \emph{not} change current Japanese font shape if
1283       the target shape is unavailable for current Japanese encoding/family/series.
1284       For the detail, see Subsection~\ref{ssec:nfsspat}.
1285 %</en>
1286 %<*ja>
1287 \item \cs{fontfamily}, \cs{fontseries}, \cs{fontshape} は欧文・和文フォント両方の属性を変更しようとする.
1288       もちろん,それらを実際に反映させるには手動で \cs{selectfont} を実行する必要がある.
1289
1290       なお,\cs{fontshape\{\meta{shape}\}}は常に欧文フォントのシェイプを設定するが,
1291       もしも現在の和文フォントファミリ・シリーズで要求されたシェイプが利用不能だった場合には,和文フォントのシェイプは変更しない.
1292       詳細は\ref{ssec:nfsspat}節を参照すること.
1293 %</ja>
1294
1295 %<*en>
1296 \item \verb+\fontencoding{+\meta{encoding}\verb+}+ changes the encoding of alphabetic fonts
1297       or Japanese fonts depending on the argument. For example,
1298       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
1299       \texttt{JY3}, and \verb+\fontencoding{T1}+ changes the encoding of
1300       alphabetic fonts to \texttt{T1}.
1301       \cs{fontfamily} also changes the current Japanese font family,
1302       the current alphabetic font family, \emph{or both}.
1303       For the detail, see Subsection~\ref{ssec:nfsspat}.
1304 %</en>
1305 %<*ja>
1306 \item  ここで,\cs{fontencoding\{\meta{encoding}\}}は,引数により和文側か欧文
1307       側かのどちらかのエンコーディングを変更する.例えば,
1308       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1309       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1310       \texttt{T1}へと変更する.\cs{fontfamily} も引数により和文側,欧文
1311       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1312       \ref{ssec:nfsspat}節を参照すること.
1313 %</ja>
1314
1315 %<*en>
1316 \item For defining a Japanese font family, use
1317       \cs{DeclareKanjiFamily} instead of
1318       \cs{DeclareFontFamily}. (In previous version of \LuaTeX-ja,
1319       using \cs{DeclareFontFamily} didn't cause any problem. But this no longer applies
1320       the current version.)
1321 \item Defining a Japanese font shape can be done by usual \cs{DeclareFontShape}:
1322 %</en>
1323 %<*ja>
1324 \item 和文フォントファミリの定義には \cs{DeclareFontFamily} の
1325       代わりに \cs{DeclareKanjiFamily} を用いる.以前の
1326       実装では \cs{DeclareFontFamily} を用いても問題は生じなかったが,現在の実装では
1327       そうはいかない.
1328 \item 和文フォントのシェイプを定義するには,通常の \cs{DeclareFontShape} を使えば良い:
1329 %</ja>
1330 \begin{lstlisting}
1331 \DeclareFontShape{JY3}{mc}{b}{n}{<-> s*HaranoAjiMincho--Bold:jfm=ujis;-kern}{}
1332     % Harano Aji Mincho Bold
1333 \end{lstlisting}
1334 %<*ja>
1335 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1336 \ref{ssec:altfont}節の \cs{ltjdeclarealtfont} と,その\LaTeX 版の\
1337 \cs{DeclareAlternateKanjiFont}(\ref{ssec:nfsspat}節)を参照せよ.
1338 %</ja>
1339
1340 \end{itemize}
1341
1342 %<*en>
1343 \paragraph{Japanese characters in math mode}
1344 \label{para:jachar_in_math}
1345
1346 Since \pTeX\ supports Japanese characters in math mode, there are
1347 sources like the following:
1348 %</en>
1349 %<*ja>
1350 \paragraph{数式モード中の和文文字}
1351 \label{para:jachar_in_math}
1352   
1353 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1354 以下のようなソースが見られた:
1355 %</ja>
1356
1357 \begin{LTXexample}
1358 $f_{高温}$~($f_{\text{high temperature}}$).
1359 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1360 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1361 \end{LTXexample}
1362 %<*en>
1363 We (the project members of \LuaTeX-ja) think that using
1364 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1365 In this point of view,
1366 %</en>
1367 %<*ja>
1368 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1369 ときのみ許されると考えている.
1370 この観点から,
1371 %</ja>
1372
1373 \begin{itemize}
1374 %<*en>
1375 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1376 ``よって'' is used as a conjunction.
1377 %</en>
1378 %<*ja>
1379 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1380       して,「よって」が接続詞として用いられているからである.
1381 %</ja>
1382 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1383 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1384 \end{itemize}
1385 %<en>Hence, in our opinion, the above input should be corrected as:
1386 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1387 \begin{LTXexample}
1388 $f_{\text{高温}}$~%
1389 ($f_{\text{high temperature}}$).
1390 \[ y=(x-1)^2+2\quad
1391   \mathrel{\mbox{よって}}\quad y>0 \]
1392 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1393 \end{LTXexample}
1394
1395 %<*en>
1396 We also believe that using Japanese characters as identifiers is rare,
1397 hence we don't describe how to change Japanese fonts in math mode in
1398 this chapter. For the method, please see Subsection~\ref{ssec:math}.
1399
1400 {\emshape When \LuaTeX-ja is loaded with \texttt{disablejfam}~option,
1401   one cannot write Japanese characters in math mode as~\verb+$素$+.
1402   At that case, one have to use \cs{mbox} (or~\cs{text} in the \Pkg{amsmath} package).
1403 }
1404 %</en>
1405 %<*ja>
1406 なお\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1407 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1408 記述しない.この方法については\ref{ssec:math}節を参照のこと.
1409
1410 {\gtfamily\bfseries
1411   既に記述した通り,\texttt{disablejfam}オプションを指定して\LuaTeX-jaを読み込んだ場合は,
1412   \verb+$素$+ のように直接和文文字を数式モード中に記述することはできなくなる.
1413   \cs{mbox},あるいは\Pkg{amsmath}パッケージの提供する\cs{text}命令などを使うことになる.
1414 }
1415 %</ja>
1416
1417
1418
1419 %<en>\subsection{\Pkg{luatexja-fontspec} package}
1420 %<ja>\subsection{\Pkg{luatexja-fontspec}パッケージ}
1421 \label{ssec:fontspec}
1422 %<*en>
1423 To use the functionality of the \Pkg{fontspec} package to Japanese fonts,
1424 it is needed to load the \Pkg{luatexja-fontspec} package in the preamble, as follows:
1425 \begin{quote}
1426 \ttfamily \textbackslash usepackage[\meta{options}]\{luatexja-fontspec\}
1427 \end{quote}
1428 This \Pkg{luatexja-fontspec} package
1429 automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1430 packages, if needed.
1431 %</en>
1432 %<*ja>
1433 \Pkg{fontspec}パッケージは,\LuaTeX・\XeTeX において
1434 TrueType・OpenTypeフォントを容易に扱うためのパッケージであり,このパッケージを読み込んでお
1435 けばUnicodeによる各種記号の直接入力もできるようになる.
1436 \LuaTeX-jaでは和文と欧文を区別しているため,\Pkg{fontspec}パッケージの機能は欧文フォントに
1437 対してのみ有効なものとなっている.
1438
1439 \LuaTeX-ja上において,\Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場
1440 合は\Pkg{luatexja-fontspec}パッケージを読み込む:
1441 \begin{quote}
1442 \ttfamily \textbackslash usepackage[\meta{options}]\{luatexja-fontspec\}
1443 \end{quote}
1444 このパッケージは自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1445 %</ja>
1446
1447 %<*en>
1448 In the \Pkg{luatexja-fontspec} package, several commands are defined as
1449 counterparts of original commands in the \Pkg{fontspec} package
1450 (see \autoref{tab:ltj_fntspc}):
1451 %</en>
1452 %<*ja>
1453 \Pkg{luatexja-fontspec}パッケージでは,\autoref{tab:ltj_fntspc}の
1454 「和文」行に示した命令を\Pkg{fontspec}パッケージの元のコマンド(「欧文」行)
1455 に対応するものとして定義している:
1456 %</ja>
1457 %<*en>
1458 \begin{table}
1459 \caption{Commands of \Pkg{luatexja-fontspec}}\label{tab:ltj_fntspc}
1460 \medskip
1461 {\centering\small
1462 \begin{tabular}{>{\bfseries}lllll}
1463 \toprule
1464 Japanese fonts
1465 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}\\
1466 Alphabetic fonts
1467 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1468 \midrule
1469 Japanese fonts
1470 &\cs{newjfontfamily}&\cs{renewjfontfamily}&\cs{setjfontfamily}\\
1471 Alphabetic fonts
1472 &\cs{newfontfamily}&\cs{renewfontfamily}&\cs{setfontfamily}\\
1473 \midrule
1474 Japanese fonts
1475 &\cs{newjfontface}&\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1476 Alphabetic fonts
1477 &\cs{newfontface}&\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1478 \bottomrule
1479 \end{tabular}\par}
1480 \end{table}
1481 %</en>
1482 %<*ja>
1483 \begin{table}
1484 \caption{\Pkg{luatexja-fontspec}で定義される命令}\label{tab:ltj_fntspc}
1485 \medskip
1486 {\centering\small
1487 \begin{tabular}{lllll}
1488 \toprule
1489 \emph{和文}
1490 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}\\
1491 \emph{欧文}
1492 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1493 \midrule
1494 \emph{和文}
1495 &\cs{newjfontfamily}&\cs{renewjfontfamily}&\cs{setjfontfamily}\\
1496 \emph{欧文}
1497 &\cs{newfontfamily}&\cs{renewfontfamily}&\cs{setfontfamily}\\
1498 \midrule
1499 \emph{和文}
1500 &\cs{newjfontface}&\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1501 \emph{欧文}
1502 &\cs{newfontface}&\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1503 \bottomrule
1504 \end{tabular}\par}
1505 \end{table}
1506 %</ja>
1507
1508 %<en> The package option of \Pkg{luatexja-fontspec} are the followings:
1509 %<ja> \Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである:
1510 \begin{cslist}
1511  \item[match]
1512 %<*en>
1513 If this option is specified, usual family-changing commands such as
1514 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
1515 %</en>
1516
1517 %<*ja>
1518 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
1519 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
1520 欧文フォントだけでなく和文フォントも変更するようになる.
1521 %</ja>
1522
1523  \item[pass=\meta{options}]
1524 %<en> \emph{(Obsoleted)}\ Specify options \meta{options} which will be passed to the \Pkg{fontspec} package.
1525 %<ja> \Pkg{fontspec} パッケージに渡すオプション \meta{options} を指定する.本オプションは時代遅れである.
1526
1527 \item[scale=\meta{float}]
1528 %<*en>
1529 Override the ratio of the font size of Japanese fonts to that of alphabetic fonts.
1530 The default value is determined as follows:
1531   \begin{itemize}
1532     \item The value of \cs{Cjascale} is used, if this control sequence is already defined.
1533     \item It is calculated automatically from the current Japanese font at the loading of the
1534     package, if \cs{Cjascale} is not defined.
1535   \end{itemize}
1536 \cs{Cjascale} is defined in \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
1537 %</en>
1538 %<*ja>
1539 欧文に対する和文の比率を手動で上書きするときに使用する.
1540 標準では
1541 \begin{itemize}
1542   \item \cs{Cjascale}が定義されている場合
1543   \footnote{\LuaTeX-ja が用意しているクラスファイル(\Pkg{ltjclasses},~\Pkg{ltjsclasses})を
1544   使う場合はこちらに当てはまる.}は,それを用いる.
1545   \item \cs{Cjascale}が未定義の場合は,\Pkg{luatexja-fontspec}読み込み時の和文フォントから自動計算される.
1546 \end{itemize}
1547 %</ja>
1548 \end{cslist}
1549
1550 %<*en>
1551 All other options listed above are simply passed to the \Pkg{fontspec} package.
1552 This means that two lines below are equivalent, for example.
1553 %</en>
1554 %<*ja>
1555 上記にないオプションは全て \Pkg{fontspec} パッケージに渡される.
1556 例えば,下の2行は同じ意味になる:
1557 %</ja>
1558 \begin{lstlisting}
1559 \usepackage[no-math]{fontspec}\usepackage{luatexja-fontspec}
1560 \usepackage[no-math]{luatexja-fontspec}
1561 \end{lstlisting}
1562 %<*en>
1563 Note that kerning information in a font is not used
1564 (that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands.
1565 This is because of the compatibility with previous versions of \LuaTeX-ja
1566 (see \ref{para-kern}).
1567
1568 Below is an example of \cs{jfontspec}.
1569 %</en>
1570 %<*ja>
1571 これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
1572 言い換えれば \texttt{kern} featureは標準では無効化となっている.
1573 これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
1574
1575 以下に\cs{jfontspec}の使用例を示す.
1576 %</ja>
1577
1578 \begin{LTXexample}[width=0.4\textwidth]
1579 \jfontspec[CJKShape=NLC]{HaranoAjiMincho-Regular}
1580 JIS~X~0213:2004→辻鯵\par
1581 \jfontspec[CJKShape=JIS1990]{HaranoAjiMincho-Regular}
1582 JIS~X~0208-1990→辻鯵\par
1583 \jfontspec[CJKShape=JIS1978]{HaranoAjiMincho-Regular}
1584 JIS~C~6226-1978→辻鯵
1585 \end{LTXexample}
1586
1587 %<en>\subsection{Presets of Japanese fonts}
1588 %<ja>\subsection{和文フォントのプリセット設定}
1589 \label{ssec:preset-abst}
1590
1591 %<*en>
1592 With \Pkg{luatexja-preset} package, 
1593 one use one of ``preset'' to simplify Japanese font setting.
1594 For details of package options, and those of each presets, please see Subsecion~\ref{ssec:preset}.
1595 The following presets are defined:
1596 %</en>
1597 %<*ja>
1598 よく使われている和文フォント設定を一行で指定できるようにしたのが
1599 \Pkg{luatexja-preset}パッケージである.オプションや各プリセットの詳細については
1600 \ref{ssec:preset}節を参照して欲しい.
1601 現時点では以下のプリセットが定義されている:
1602 %</ja>
1603 \begin{quote}
1604   \ttfamily
1605   \hyphenchar\font=-1 \exhyphenchar=-1
1606   haranoaji, hiragino-pro, hiragino-pron, ipa, ipa-hg, ipaex, ipaex-hg,
1607   kozuka-pr6, kozuka-pr6n, kozuka-pro, moga-mobo, moga-mobo-ex,
1608   bizud, morisawa-pr6n, morisawa-pro, ms, ms-hg, noembed, noto-otc, noto-otf, noto, noto-jp, 
1609   sourcehan, sourcehan-jp, ume, yu-osx, yu-win, yu-win10
1610 \end{quote}
1611
1612 %<ja> 例えば,本ドキュメントでは\Pkg{luatexja-preset}パッケージを
1613 %<en> For example, this document loads \Pkg{luatexja-preset} package by
1614 \begin{lstlisting}
1615 \usepackage[haranoaji]{luatexja-preset}
1616 \end{lstlisting}
1617 %<ja>として読み込み,原ノ味フォントを使うことを指定している.
1618 %<en> which means that Harano Aji fonts will be used in this document.
1619
1620
1621 %<*en>
1622 \subsection{\cs{CID}, \cs{UTF}, and macros in \Pkg{japanese-otf} package}
1623 Under \pLaTeX, \Pkg{japanese-otf} package (developed by Shuzaburo Saito) is
1624 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1625 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1626 supports some of functions in the \Pkg{japanese-otf} package,
1627 as an external package \Pkg{luatexja-otf}.
1628 %</en>
1629 %<*ja>
1630 \subsection{\cs{CID}, \cs{UTF}と\Pkg{otf}パッケージのマクロ}
1631 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1632 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1633 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1634 一部を(\Pkg{luatexja-otf}という別のパッケージとして)実装した.
1635 %</ja>
1636
1637 \begin{LTXexample}[width=0.4\textwidth]
1638 森\UTF{9DD7}外と\CID{13966}田百\UTF{9592}とが
1639 \UTF{9AD9}島屋に\\
1640 \CID{7652}飾区の\CID{13706}野家,
1641 \CID{1481}城市,葛西駅,\\
1642 高崎と\CID{8705}\UTF{FA11},濱と\ajMayuHama\\
1643 \aj半角{カタカナ}\ajKakko3\ajMaruYobi{2}%
1644 \ajLig{令和}\ajLig{○問}\ajJIS
1645 \end{LTXexample}
1646
1647 %<*ja>
1648 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1649 \begin{cslist}
1650 \item[deluxe] 明朝体・ゴシック体各3ウェイトと,丸ゴシック体を扱えるようになる.
1651 \item[expert] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も
1652 \ \cs{rubyfamily}\ によって扱えるようになる.
1653 \item[bold] ゴシック体を標準で太いウェイトのものに設定する.
1654 \end{cslist}
1655 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1656 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1657 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1658
1659 これら3オプションについては,
1660 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1661 あるいは対応する内容を\ref{ssec:chgfnt}節,\ref{ssec:nfsspat}節 (NFSS2) や
1662 \ref{ssec:fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1663 %</ja>
1664
1665 %<en>\section{Changing Internal Parameters}
1666 %<ja>\section{パラメータの変更}
1667
1668 %<*en>
1669 There are many internal parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1670 most of them are not stored as internal register of \TeX, but as an
1671 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1672 parameters, you have to use commands \cs{ltjsetparameter} and
1673 \cs{ltjgetparameter}.
1674 %</en>
1675 %<*ja>
1676 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1677 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1678 これらのパラメータを設定・取得するためには \cs{ltjsetparameter} と \cs{ltjgetparameter} を
1679 用いる.
1680 %</ja>
1681
1682 %<en>\subsection{Range of \textbf{JAchar}s}
1683 %<ja>\subsection{\textbf{JAchar}の範囲}
1684 \label{ssec:setrange}
1685
1686 %<*en>
1687 \LuaTeX-ja divides the Unicode codespace \texttt{U+0080}--\texttt{U+10FFFF}
1688 into \emph{character ranges},
1689 numbered 1 to 217. The grouping can be (globally) customized by \cs{ltjdefcharrange}.
1690 The next line adds whole characters in Supplementary Ideographic Plane
1691 and the character ``漢'' to the character range~100.
1692 %</en>
1693 %<*ja>
1694 \LuaTeX-jaは,Unicodeの \texttt{U+0080}--\texttt{U+10FFFF} の空間を
1695 1番から217番までの\emph{文字範囲}に分割している.
1696 区分けは \cs{ltjdefcharrange} を用いることで(グローバルに)変更することができ,
1697 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1698 %</ja>
1699 \begin{lstlisting}
1700 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1701 \end{lstlisting}
1702
1703 %<*en>
1704 A character can belong to only one character range.
1705 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
1706 and if one executes the above line, then SIP will belong to the range~100 and be
1707 removed from the range~4.
1708 %</en>
1709 %<*ja>
1710 各文字はただ一つの文字範囲に所属することができる.
1711 例えば,SIP内の文字は全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1712 属しているが,上記の指定を行えばSIP内の文字は100番に属すようになり,4番からは除かれる.
1713 %</ja>
1714
1715 %<*en>
1716 The distinction between \textbf{ALchar} and \textbf{JAchar} is performed by character ranges.
1717 This can be edited by setting the \textsf{jacharrange} parameter.
1718 For example, the code below is just the default setting of \LuaTeX-ja, and
1719 it sets
1720 \begin{itemize}
1721  \item a character which belongs character ranges 1,~4, 5, and~8 is \textbf{ALchar},
1722  \item a character which belongs character ranges 2,~3, 6, 7,~and~9 is \textbf{JAchar}.
1723 \end{itemize}
1724 %</en>
1725 %<*ja>
1726 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1727 これは\textsf{jacharrange}パラメータによって編集できる.
1728 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1729 \begin{itemize}
1730  \item 1番,4番,5番,8番の文字範囲に属する文字は\textbf{ALchar}.
1731  \item 2番,3番,6番,7番,9番の文字範囲に属する文字は\textbf{JAchar}.
1732 \end{itemize}
1733 %</ja>
1734 \begin{lstlisting}
1735 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, -8, +9}}
1736 \end{lstlisting}
1737 %<*en>
1738 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
1739 Negative integer $-n$ in the list means that ``each character in the range~$n$ is an
1740 \textbf{ALchar}'',
1741 and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
1742 %</en>
1743 %<*ja>
1744 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
1745 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
1746 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
1747 %</ja>
1748
1749 %<*en>
1750 Note that characters \texttt{U+0000}--\texttt{U+007F} are always treated as an
1751 \textbf{ALchar} (this cannot be customized).
1752 %</en>
1753 %<*ja>
1754 なお,\texttt{U+0000}--\texttt{U+007F} は常に\textbf{ALchar}として扱われる(利用者が変更す
1755 ることは出来ない).
1756 %</ja>
1757
1758 %<*en>
1759 \paragraph{Default character ranges}
1760 \LuaTeX-ja predefines nine character ranges for convenience. They are
1761 determined from the following data:
1762 %</en>
1763 %<*ja>
1764 \paragraph{文字範囲の初期値}
1765 \LuaTeX-jaでは9つの文字範囲を予め定義しており,
1766 これらは以下のデータに基づいて決定している.
1767 %</ja>
1768 \begin{itemize}
1769 %<en>\item Blocks in Unicode~12.0.0.
1770 %<ja>\item Unicode~12.0のブロック.
1771 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1- and Unicode.
1772 %<ja>\item Adobe-Japan1-7のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
1773 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
1774 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
1775 \end{itemize}
1776
1777 %<*en>
1778 Now we describe these nine ranges. The superscript ``J'' or ``A'' after the
1779 number shows whether each character in the range is treated as
1780 \textbf{JAchar}s or not by default. These settings are similar to the
1781 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
1782 Any characters equal to or above \texttt{U+0080} which does not belong to
1783 these eight ranges belongs to the character range~217.
1784 %</en>
1785 %<*ja>
1786 以下ではこれら9つの文字範囲について記述する.添字のアルファベット「J」「A」
1787 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの初期設定は
1788 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものであるが,
1789 8ビットフォント使用時のトラブルを防ぐために \texttt{U+0080}--\texttt{U+00FF} の文字は全部
1790 \textbf{ALchar}としている.
1791 なお,\texttt{U+0080} 以降でこれら9つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
1792 %</ja>
1793 \begin{description}
1794 %<*en>
1795 \item[Range~8${}^{\text{A}}$] The intersection of the upper half of ISO~8859-1
1796          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese).
1797   The character list is indicated in \autoref{tab:rng8}.
1798 %</en>
1799 %<*ja>
1800 \item[範囲8${}^{\text{A}}$] ISO~8859-1の上位領域(ラテン1補助)と
1801   JIS~X~0208の共通部分.文字のリストは\autoref{tab:rng8}を参照.
1802 %</ja>
1803 \begin{table}[!tb]
1804 %<en>\caption{Characters in predefined character range~8.}\medskip
1805 %<ja>\caption{文字範囲8に指定されている文字.}
1806 \label{tab:rng8}
1807 \centering\footnotesize
1808 \def\ch#1{\char"#1~(\texttt{U+00#1})}%"
1809 \begin{tabular}{llll}
1810 \ch{A7}&{Section Sign}&
1811 \ch{A8}&{Diaeresis}\\
1812 \ch{B0}&{Degree sign}&
1813 \ch{B1}&{Plus-minus sign}\\
1814 \ch{B4}&{Spacing acute}&
1815 \ch{B6}&{Paragraph sign}\\
1816 \ch{D7}&{Multiplication sign}&
1817 \ch{F7}&{Division Sign}
1818 \end{tabular}
1819 \end{table}
1820
1821 %<*en>
1822 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-7.
1823   This range consists of the Unicode ranges indicated in \autoref{tab:rng1},
1824   \emph{except characters in the range~8 above}.
1825 %</en>
1826 %<*ja>
1827 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-7との共通部分があるもの.
1828                              この範囲は\autoref{tab:rng1}で示したUnicodeのブロックのうち
1829                              \emph{範囲8を除いた}部分で構成されている.
1830 %</ja>
1831 \begin{table}[!tb]
1832 %<en>\caption{Unicode blocks in predefined character range~1.}\medskip
1833 %<ja>\caption{文字範囲1に指定されているUnicodeブロック.}
1834 \label{tab:rng1}
1835 \centering\footnotesize
1836 \begin{tabular}{llll}
1837  \texttt{U+0080}--\texttt{U+00FF}&Latin-1 Supplement&
1838  \texttt{U+0100}--\texttt{U+017F}&Latin Extended-A\\
1839  \texttt{U+0180}--\texttt{U+024F}& Latin Extended-B&
1840  \texttt{U+0250}--\texttt{U+02AF}& IPA Extensions\\
1841  \texttt{U+02B0}--\texttt{U+02FF}& Spacing Modifier Letters&
1842  \texttt{U+0300}--\texttt{U+036F}& Combining Diacritical Marks\\
1843  \texttt{U+1E00}--\texttt{U+1EFF}&Latin Extended Additional
1844 \end{tabular}
1845 \end{table}
1846 %<*en>
1847 \item[Range~2${}^{\text{\kern.1emJ}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1848            fonts) has some of these characters.
1849 %</en>
1850 %<*ja>
1851 \item[範囲2${}^{\text{\kern.1emJ}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
1852                              和文フォント)には,これらの文字の一部が含まれている.
1853 %</ja>
1854 \begin{multicols}{2}
1855 \begin{itemize}
1856 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
1857 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
1858 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
1859 \\\
1860 \end{itemize}
1861 \end{multicols}
1862 %<*en>
1863 \item[Range~3${}^{\text{\kern.1emJ}}$] Miscellaneous symbols. The block list is
1864            indicated in \autoref{tab:rng3}.
1865 %</en>
1866 %<*ja>
1867 \item[範囲3${}^{\text{\kern.1emJ}}$] 記号類.ブロックのリストは\autoref{tab:rng3}%
1868                              に示してある.
1869 %</ja>
1870 \begin{table}[!tb]
1871 %<en>\caption{Unicode blocks in predefined character range~3.}\medskip
1872 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
1873 \label{tab:rng3}
1874 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1875 \centering\footnotesize
1876 \begin{tabular}{llll}
1877 "2070--"209F&Superscripts and Subscripts\\
1878 "20A0--"20CF&Currency Symbols&
1879 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1880 "2100--"214F&Letterlike Symbols&
1881 "2150--"218F&Number Forms\\
1882 "2190--"21FF&Arrows&
1883 "2200--"22FF&Mathematical Operators\\
1884 "2300--"23FF&Miscellaneous Technical&
1885 "2400--"243F&Control Pictures\\
1886 "2500--"257F&Box Drawing&
1887 "2580--"259F&Block Elements\\
1888 "25A0--"25FF&Geometric Shapes&
1889 "2600--"26FF&Miscellaneous Symbols\\
1890 "2700--"27BF&Dingbats&
1891 "2900--"297F&Supplemental Arrows-B\\
1892 "2980--"29FF&Misc.\ Math Symbols-B&
1893 "2B00--"2BFF&Misc.\ Symbols and Arrows
1894 \end{tabular}
1895 \end{table}
1896 %<*en>
1897 \item[Range~9${}^{\text{J}}$] The intersection of the ``General Punctuation'' block
1898   (\texttt{U+2000}--\texttt{U+206F})
1899   and Adobe-Japan1-7 character collection.
1900   This character range characters in \autoref{tab:rng9}.
1901 %</en>
1902 %<*ja>
1903 \item[範囲9${}^{\text{J}}$] Unicodeの「一般句読点」ブロック(\texttt{U+2000}--\texttt{U+206F})と
1904   Adobe-Japan1-7の共通部分.
1905   この文字範囲は\autoref{tab:rng9}に示した文字で構成される.
1906 %</ja>
1907 \begin{table}[!tb]
1908 %<en>\caption{Characters in predefined character range~9.}\medskip
1909 %<ja>\caption{文字範囲9に指定されている文字.}
1910 \label{tab:rng9}
1911 \centering\footnotesize
1912 \def\ch#1{%
1913   {\fboxsep0pt\fcolorbox{cyan}{white}%
1914   {\normalsize\KOZM\UTF{20#1}}}\ (\texttt{U+20#1})} %"
1915 % 13: JIS X0213, AJ, Adobe-Japan-1 only
1916 \begin{tabular}{ll>{\color{white}}lll>{\color{white}}l}
1917   \ch{02}&{En space}&AJ&
1918   \ch{10}&{Hyphen}&\\
1919   \ch{11}&{Non-breaking hyphen}&AJ&
1920   \ch{13}&{En dash}&13\\
1921   \ch{14}&{Em dash}&&
1922   \ch{15}&{Horizontal bar}&\\
1923   \ch{16}&{Double vertical line}&&
1924   \ch{18}&{Left single quotation mark}&\\
1925   \ch{19}&{Right single quotation mark}&&
1926   \ch{1A}&{Single low-9 quotation mark}&AJ\\
1927   \ch{1C}&{Left double quotation mark}&&
1928   \ch{1D}&{Right double quotation mark}&\\
1929   \ch{1E}&{Double low-9 quotation mark}&AJ&
1930   \ch{20}&{Dagger}&\\
1931   \ch{21}&{Double dagger}&&
1932   \ch{22}&{Bullet}&13\\
1933   \ch{25}&{Two dot leader}&&
1934   \ch{26}&{Horizontal ellipsis}&\\
1935   \ch{30}&{Per mille sign}&&
1936   \ch{32}&{Prime}&\\
1937   \ch{33}&{Double prime}&&
1938   \ch{39}&{Single left-pointing angle quot.}&AJ\\
1939   \ch{3A}&{Single right-pointing angle quot.}&AJ&
1940   \ch{3B}&{Reference mark}&\\
1941   \ch{3C}&{Double exclamation mark}&13&
1942   \ch{3E}&{Overline}&\\
1943   \ch{3F}&{Undertie}&13&
1944   \ch{42}&{Asterism}&13\\
1945   \ch{44}&{Fraction slash}&AJ&
1946   \ch{47}&{Double question mark}&13\\
1947   \ch{48}&{Question exclamation mark}&13&
1948   \ch{49}&{Exclamation question mark}&13\\
1949   \ch{51}&{Two asterisks aligned vertically}&13
1950 \end{tabular}
1951 \end{table}
1952 %<*en>
1953 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1954            of almost all Unicode blocks which are not in other
1955            predefined ranges. Hence, instead of showing the block list,
1956            we put the definition of this range itself.
1957 %</en>
1958 %<*ja>
1959 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
1960                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
1961                              で構成されている.したがって,ブロックのリストを示す
1962                              代わりに,範囲の定義そのものを示す.
1963 %</ja>
1964 \begin{lstlisting}[escapechar=\!]
1965 \ltjdefcharrange{4}{%
1966    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
1967   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A95F, "A980-"ABFF, "E000-"F8FF,
1968   "FB00-"FE0F, "FE20-"FE2F, "FE70-"FEFF, "10000-"1AFFF, "1B170-"1F0FF,
1969   "1F300-"1FFFF, ... !\rmfamily (and characters in \texttt{U+2000}--\texttt{U+206F} which are not in range 9)!
1970 } % non-Japanese
1971 \end{lstlisting}
1972 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
1973 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
1974 %<en>\item[Range~6${}^{\text{\kern.1emJ}}$] Characters used in Japanese. The block list is indicated in \autoref{tab:rng6}.
1975 %<ja>\item[範囲6${}^{\text{\kern.1emJ}}$] 日本語で用いられる文字.ブロックのリストは\autoref{tab:rng6}に示す.
1976 \begin{table}[!tb]
1977 %<en>\caption{Unicode blocks in predefined character range~6.}\medskip
1978 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
1979 \label{tab:rng6}
1980 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1981 \centering\footnotesize
1982 \begin{tabular}{llll}
1983 "2460--"24FF&Enclosed Alphanumerics&
1984 "2E80--"2EFF&CJK Radicals Supplement\\
1985 "3000--"303F&CJK Symbols and Punctuation&
1986 "3040--"309F&Hiragana\\
1987 "30A0--"30FF&Katakana&
1988 "3190--"319F&Kanbun\\
1989 "31F0--"31FF&Katakana Phonetic Extensions&
1990 "3200--"32FF&Enclosed CJK Letters and Months\\
1991 "3300--"33FF&CJK Compatibility&
1992 "3400--"4DBF&CJK Unified Ideographs Ext-A\\
1993 "4E00--"9FFF&CJK Unified Ideographs&
1994 "F900--"FAFF&CJK Compatibility Ideographs\\
1995 "FE10--"FE1F&Vertical Forms&
1996 "FE30--"FE4F&CJK Compatibility Forms\\
1997 "FE50--"FE6F&Small Form Variants&
1998 "FF00--"FFEF&Halfwidth and Fullwidth Forms\\
1999 "{1B}000--"{1B}0FF&Kana Supplement&
2000 "{1B}100--"{1B}12F&Kana Extended-A\\
2001 %"{1B}130--"{1B}16F&Small Kana Extension
2002 "{1F}100--"{1F}1FF&Enclosed Alphanumeric Supp.&
2003 "{1F}200--"{1F}2FF&Enclosed Ideographic Supp.\\
2004 "{20}000--"{2F}FFF&(Supp. Ideographic Plane)&
2005 "{30}000--"{3F}FFF&(Tert. Ideographic Plane)\\
2006 "{E0}100--"{E0}1EF&Variation Selectors Supp.
2007 \end{tabular}
2008 \end{table}
2009 %<*en>
2010 \item[Range~7${}^{\text{\kern.1emJ}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-7.
2011 The block list is indicated in \autoref{tab:rng7}.
2012 %</en>
2013 %<*ja>
2014 \item[範囲7${}^{\text{\kern.1emJ}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-7に
2015                             含まれていないもの.
2016                             ブロックのリストは\autoref{tab:rng7}に示す.
2017 %</ja>
2018 \begin{table}[!tb]
2019 %<en>\caption{Unicode blocks in predefined character range~7.}\medskip
2020 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
2021 \label{tab:rng7}
2022 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2023 \centering\small
2024 \begin{tabular}{llll}
2025 "1100--"11FF&Hangul Jamo&
2026 "2F00--"2FDF&Kangxi Radicals\\
2027 "2FF0--"2FFF&Ideographic Description Characters&
2028 "3100--"312F&Bopomofo\\
2029 "3130--"318F&Hangul Compatibility Jamo&
2030 "31A0--"31BF&Bopomofo Extended\\
2031 "31C0--"31EF&CJK Strokes&
2032 "A000--"A48F&Yi Syllables\\
2033 "A490--"A4CF&Yi Radicals&
2034 "A960--"A97F&Hangul Jamo Extended-A\\
2035 "AC00--"D7AF&Hangul Syllables&
2036 "D7B0--"D7FF&Hangul Jamo Extended-B
2037 \end{tabular}
2038 \end{table}
2039 \end{description}
2040
2041 %<*en>
2042 \paragraph{Notes on \texttt{U+0080}--\texttt{U+00FF}}
2043 You should treat characters in \\texttt{U+0080}--\texttt{U+00FF} as \textbf{ALchar},
2044 when you use traditional 8-bit fonts, such as the \Pkg{marvosym} package.
2045
2046 For example, \cs{Frowny} which is provided by the \Pkg{marvosym} package has
2047 the same codepoint as \S\ (\text{U+00A7}).
2048 Hence, as previous versions of \LuaTeX-ja, if these characters are treated as
2049 \text{JAchar}s, then \cs{Frowny} produces ``\ltjjachar`§'' (in a Japanese font).
2050
2051 To avoid such situations, the default setting of \LuaTeX-ja is changed in version~20150906.0
2052 so that all characters \texttt{U+0080}--\texttt{U+00FF} are treated as \textbf{ALchar}.
2053
2054 If you want to output a character as \textbf{ALchar} and \textbf{JAchar} regardless the range
2055 setting, you can use \cs{ltjalchar} and \cs{ltjjachar} respectively, as the following example.
2056 \begin{LTXexample}[width=0.3\textwidth]
2057 \gtfamily\large % default, ALchar, JAchar
2058 ¶, \ltjalchar`¶, \ltjjachar`¶\\   % default: ALchar
2059 α, \ltjalchar`α, \ltjjachar`α  % default: JAchar
2060 \end{LTXexample}
2061 %</en>
2062 %<*ja>
2063 \paragraph{\texttt{U+0080}--\texttt{U+00FF}についての注意}
2064 \LuaTeX-jaで,\Pkg{marvosym}パッケージ等,Unicodeフォントでなく
2065 伝統的な8ビットフォントを用いる場合には注意が必要である.
2066
2067 例えば,\Pkg{marvosym}パッケージの提供する \cs{Frowny} も,符号位置は167,つまりUnicodeにおける
2068 \S\ (\text{U+00A7}) と同じ符号位置にある.
2069 即ち,以前のバージョンのように,「前節の文字範囲8内の文字は\textbf{JAchar}」という設定で
2070 あったとすると,上記の \cs{Frowny} は和文フォントで「\ltjjachar`§」を出力することになる.
2071
2072 このような事態を避けるために,バージョン20150906.0からは \texttt{U+0080}--\texttt{U+00FF} の範囲の
2073 文字は全て\textbf{ALchar}となるように初期設定を変更している.
2074
2075 なお,文字範囲の設定に関わらず1つの文字を\textbf{ALchar}, \textbf{JAchar}で出力したい場合には,
2076 以下の例のようにそれぞれ \cs{ltjalchar},~\cs{ltjjachar} に該当文字の文字コードを渡せばよい.
2077 \begin{LTXexample}[width=0.3\textwidth]
2078 \gtfamily\large % default, ALchar, JAchar
2079 ¶, \ltjalchar`¶, \ltjjachar`¶\\   % default: ALchar
2080 α, \ltjalchar`α, \ltjjachar`α  % default: JAchar
2081 \end{LTXexample}
2082 %</ja>
2083
2084 %<*ja>
2085 \paragraph{絵文字など,複数コードポイントの列で表現される字形をを利用する場合の注意}
2086 (\Pkg{luaotfload}による)OpenType機能や合字等の処理は,\LuaTeX-jaが
2087 段落・水平ボックスの中身全体に対して「この文字は\textbf{JAchar}だから和文フォントで組む」と
2088 フォントを置き換えた後に適用される.
2089 そのため,異体字セレクタや絵文字といった複数のコードポイントの列で表現される文字を
2090 組む場合には,列全体で\textbf{JAchar}の範囲か\textbf{ALchar}の範囲かが
2091 統一されていないといけない.
2092
2093 例えば,CJK統合漢字(とその拡張達)と
2094 IVS用の異体字セレクタ(\texttt{U+E0100}--\texttt{U+E01EF})は標準では
2095 どちらも同じ文字範囲6であるため,(フォントがサポートしていれば)IVSは正しく機能する.
2096 しかし,下の例のように異体字セレクタを\textbf{ALchar}の文字範囲(4)に移動させると,
2097 IVSは機能しなくなる:
2098 \ltjdefcharrange{4}{"E0100-"E01EF}
2099 \begin{LTXexample}
2100 \ltjdefcharrange{4}{"E0100-"E01EF}
2101 葛󠄀城市,葛󠄁飾区,葛西
2102 \end{LTXexample}
2103 \ltjdefcharrange{6}{"E0100-"E01EF}
2104
2105 また,標準では絵文字として使われる可能性が大きい一部の文字が\textbf{JAchar}となっている
2106 \footnote{同じUnicodeブロック内にAdobe-Japan1-6の文字があったため.}.
2107 絵文字を用いる場合にはこの点に留意する必要がある.
2108
2109 \begin{center}
2110   \begin{minipage}{.5\textwidth}\small\ttfamily
2111 \verb!\ltjsetparameter{jacharrange={+3}}!\\
2112 \verb!\font\nce=NotoColorEmoji.ttf:mode=harf\nce!\\
2113 \IVSA 1F469\UCSB{ZW}{J}\UCSA 2764\UCSB{VS}{16}\UCSB{ZW}J\IVSA 1F48B\UCSB{ZW}J\IVSA 1F468\ 
2114   \textcolor{green}{\% U+2764: JAchar}\\
2115 \verb!\ltjsetparameter{jacharrange={-3}}!\\
2116 \IVSA 1F469\UCSB{ZW}{J}\UCSA 2764\UCSB{VS}{16}\UCSB{ZW}J\IVSA 1F48B\UCSB{ZW}J\IVSA 1F468\ 
2117   \textcolor{green}{\% U+2764: ALchar}
2118   \end{minipage}%
2119   \begin{minipage}{.5\textwidth}
2120 \ltjsetparameter{jacharrange={+3}}
2121 \font\nce=NotoColorEmoji.ttf:mode=harf\nce
2122 👩‍❤️‍💋‍👨
2123 \ltjsetparameter{jacharrange={-3}}
2124 👩‍❤️‍💋‍👨
2125   \end{minipage}
2126 \end{center}
2127 \ltjsetparameter{jacharrange={+3}}
2128 %</ja>
2129
2130
2131 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
2132 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
2133 \label{subs-kskip}
2134
2135 %<en>\textbf{JAglue} is divided into the following three categories:
2136 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
2137 \begin{itemize}
2138 %<*en>
2139 \item Glues/kerns specified in JFM. If \cs{inhibitglue} is issued
2140       around a \textbf{JAchar}, this glue will not be inserted at the
2141       place.
2142 %</en>
2143 %<*ja>
2144 \item JFMで指定されたグルー/カーン.もし \cs{inhibitglue} が\textbf{JAchar}の周りで
2145       発行されていれば,このグルーは挿入されない.
2146 %</ja>
2147 %<*en>
2148 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
2149       kanjiskip}).
2150 %</en>
2151 %<*ja>
2152 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{kanjiskip}).
2153 %</ja>
2154 %<*en>
2155 \item The default glue which inserted between a \textbf{JAchar} and an
2156       \textbf{ALchar} (\Param{xkanjiskip}).
2157 %</en>
2158 %<*ja>
2159 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{xkanjiskip}).
2160 %</ja>
2161 \end{itemize}
2162 %<*en>
2163 The value (a skip) of \Param{kanjiskip} or
2164 \Param{xkanjiskip} can be changed as the following.
2165 Note that only their values \emph{at the end of a paragraph or a hbox are
2166 adopted in the whole paragraph or the whole hbox.
2167 }
2168 %</en>
2169 %<*ja>
2170 \Param{kanjiskip}や\Param{xkanjiskip}の値
2171 は以下のようにして変更可能である.
2172 %</ja>
2173 \begin{lstlisting}
2174 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
2175                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
2176 \end{lstlisting}
2177 %<*en>
2178 Here \cs{zw} is a internal dimension
2179 which stores fullwidth of the current Japanese font.
2180 This \cs{zw} can be used as the unit \texttt{zw} in \pTeX.
2181
2182 The value of these parameter can be get by \cs{ltjgetparameter}.
2183 Note that the result by \cs{ltjgetparameter} is \emph{not} the internal quantities,
2184 but \emph{a string} (hence \cs{the} cannot be prefixed).
2185 %</en>
2186 %<*ja>
2187 ここで,\cs{zw} は現在の和文フォントの全角幅を表す長さであり,
2188 \pTeX における長さ単位 \texttt{zw} と同じように使用できる.
2189
2190 これらのパラメータの値は以下のように取得できる.
2191 戻り値は内部値ではなく\emph{文字列}である(\cs{the} は前置できない)ことに注意してほしい:
2192 %</ja>
2193 \begin{LTXexample}
2194 kanjiskip: \ltjgetparameter{kanjiskip},\\
2195 xkanjiskip: \ltjgetparameter{xkanjiskip}
2196 \end{LTXexample}
2197
2198 %<*en>
2199 It may occur that JFM contains the data of ``ideal width of
2200 \Param{kanjiskip}''
2201 and/or ``ideal width of \Param{xkanjiskip}''.
2202 To use these data from JFM, set the value of \Param{kanjiskip} or
2203 \Param{xkanjiskip} to \cs{maxdimen}
2204 (these ``ideal width'' cannot be retrived by \cs{ltjgetparameter}).
2205 %</en>
2206 %<*ja>
2207 JFMは「望ましい\Param{kanjiskip}の値」や
2208 「望ましい\Param{xkanjiskip}の値」を持っていることがある.
2209 これらのデータを使うためには,\Param{kanjiskip}や%
2210 \Param{xkanjiskip}の値を \cs{maxdimen} の値に設定すればよいが,
2211 \cs{ltjgetparameter} によって取得することはできないので注意が必要である.
2212 %</ja>
2213
2214 %<en>\subsection{Insertion setting of \Param{xkanjiskip}}
2215 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
2216
2217 %<*en>
2218 It is not desirable that \Param{xkanjiskip} is inserted into every
2219 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
2220 \Param{xkanjiskip} should not be inserted after opening parenthesis
2221 (\textit{e.g.}, compare ``(あ'' and ``(\+あ'').
2222 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
2223 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
2224 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
2225 %</en>
2226 %<*ja>
2227 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
2228 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
2229 後には挿入されるべきではない(「(あ」と「(\+あ」を
2230 比べてみよ).
2231 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
2232 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
2233 \Param{alxspmode}をそれぞれ変えることで制御することができる.
2234 %</ja>
2235 \begin{LTXexample}
2236 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
2237 pあq い!う
2238 \end{LTXexample}
2239
2240 %<*en>
2241 The second argument \texttt{preonly} means that the insertion of
2242 \Param{xkanjiskip} is allowed before this character, but not after.
2243 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{inhibit}.
2244 %</en>
2245 %<*ja>
2246 2つ目の引数の \texttt{preonly}は「\Param{xkanjiskip}の挿入はこの文字の
2247 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
2248 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
2249 %</ja>
2250
2251 %<*en>
2252 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
2253 on the current version. Therefore, line~1 in the code above can be rewritten
2254 as follows:
2255 %</en>
2256 %<*ja>
2257 なお,現行の
2258 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
2259 上のコードの1行目を次のように変えても同じことになる:
2260 %</ja>
2261 \begin{lstlisting}
2262 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
2263 \end{lstlisting}
2264 %<*en>
2265 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec:param}).
2266 %</en>
2267 %<*ja>
2268 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec:param}節を参照).
2269 %</ja>
2270
2271 %<*en>
2272 If you want to enable/disable all insertions of \Param{kanjiskip} and
2273 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
2274 parameters to \texttt{true}/\texttt{false}, respectively.
2275 %</en>
2276 %<*ja>
2277 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
2278 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2279 \texttt{true}/\texttt{false}に設定すればよい.
2280 %</ja>
2281
2282 %<en>\subsection{Shifting the baseline}
2283 %<ja>\subsection{ベースラインの移動}
2284 \label{ssec:baseline}
2285 %<*en>
2286 To make a match between a Japanese font and an alphabetic font, sometimes
2287 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2288 by setting \cs{ybaselineshift} (or \cs{tbaselineshift}) to a non-zero length (the
2289 baseline of \textbf{ALchar} is shifted below). However, for documents
2290 whose main language is not Japanese, it is good to shift the baseline of
2291 Japanese fonts, but not that of alphabetic fonts.
2292 Because of this, \LuaTeX-ja can independently set the shifting amount
2293 of the baseline of alphabetic fonts and that of Japanese fonts.
2294 \begin{center}
2295  \small
2296 \begin{tabular}{>{\bfseries}lcc}
2297 \toprule
2298 &\bfseries Horizontal writing (\emph{yoko} direction) etc.
2299 &\bfseries Vertical writing(\emph{tate} direction)\\
2300 \midrule
2301 Alphabetic fonts&\Param{yalbaselineshift}
2302      parameter&\Param{talbaselineshift} parameter\\
2303 Japanese fonts&\Param{yjabaselineshift}
2304      parameter&\Param{tjabaselineshift} parameter\\
2305 \bottomrule
2306 \end{tabular}
2307 \end{center}
2308 %</en>
2309 %<*ja>
2310 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2311 必要になる.\pTeX ではこれは \cs{ybaselineshift}(または\cs{tbaselineshift})を設定することで
2312 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2313 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2314 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2315 と和文フォントのベースラインのシフト量を独立に設定できるようになっている.
2316 \begin{center}
2317  \small
2318 \begin{tabular}{>{\bfseries}lcc}
2319 \toprule
2320 &\bfseries 横組など&\bfseries 縦組\\
2321 \midrule
2322 欧文フォントのシフト量&\Param{yalbaselineshift}
2323      parameter&\Param{talbaselineshift} parameter\\
2324 和文フォントのシフト量&\Param{yjabaselineshift}
2325      parameter&\Param{tjabaselineshift} parameter\\
2326 \bottomrule
2327 \end{tabular}
2328 \end{center}
2329 %</ja>
2330
2331 %<*en>
2332 Here the horizontal line in the below example is the baseline of a line.
2333 %</en>
2334 %<*ja>
2335 下の例において引かれている水平線がベースラインである.
2336 %</ja>
2337 \begin{LTXexample}
2338 \vrule width 150pt height 0.2pt depth 0.2pt \hskip-120pt
2339 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2340 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2341 \end{LTXexample}
2342
2343 %<*en>
2344 There is an interesting side-effect: characters in different size can be
2345 vertically aligned center in a line, by setting two parameters appropriately.
2346 The following is an example (beware the value is not well tuned):
2347 %</en>
2348 %<*ja>
2349 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2350 異なる文字を中心線に揃えることができる.
2351 以下は一つの例である(値はあまり調整されていないことに注意):
2352 %</ja>
2353 \begin{LTXexample}[width=0.4\textwidth]
2354 \vrule width 150pt height4.417pt depth-4.217pt%
2355 \kern-150pt
2356 \large xyz漢字
2357 {\scriptsize
2358   \ltjsetparameter{yjabaselineshift=-1.757pt,
2359     yalbaselineshift=-1.757pt}
2360   漢字xyzあいう
2361 }あいうabc
2362 \end{LTXexample}
2363
2364 %<*en>
2365 Note that setting positive \Param{yalbaselineshift}~or~\Param{talbaselineshift}
2366 parameters does not increase the depth of one-letter \emph{syllable} $p$ of \textbf{Alchar}, if
2367 its left-protrusion~(\cs{lpcode}) and right-protrusion~(\cs{rpcode}) are both non-zero.
2368 This is because
2369 \begin{itemize}
2370 \item These two parameters are implemented by setting \texttt{yoffset} field of a
2371 glyph node, and this does not increase the depth of the glyph.
2372 \item To cope with the above situation, \LuaTeX-ja automatically supplies
2373 a rule in every syllable.
2374 \item However, we cannot use this ``supplying a rule'' method if a syllable comprises just
2375       one letter whose \cs{lpcode}~and~\cs{rpcode} are both non-zero.
2376 \end{itemize}
2377
2378 This problem does not apply for \Param{yjabaselineshift}~nor~\Param{tjabaselineshift},
2379 becuse a \emph{JAchar} is encapsulated by a horizontal box if needed.
2380 %</en>
2381 %<*ja>
2382 なお,以下の場合には1文字の\textbf{ALchar}からなる「音節」の深さは増加しないことに注意.
2383 \begin{itemize}
2384  \item \Param{yalbaselineshift},~\Param{talbaselineshift}パラメータが正になっている.
2385  \item 「音節」を構成する唯一の文字$p$の
2386 左余白への突出量(\cs{lpcode}),右余白への突出量(\cs{rpcode})がどちらも非零である.
2387 \end{itemize}
2388 \emph{JAchar}は必要に応じて1文字ずつボックスにカプセル化されるため,
2389 \Param{yjabaselineshift},~\Param{tjabaselineshift}パラメータについてはこのような問題は起こらない.
2390 %</ja>
2391
2392 %<*ja>
2393 \paragraph{数式における挙動:\pTeX との違い}
2394 \textbf{ALchar}のベースラインを補正する\Param{yalbaselineshift}, \Param{talbaselineshift}パラメータは
2395 ほぼ\pTeX における \cs{ybaselineshift}, \cs{tbaselineshift} に対応しているものであるが,
2396 数式中の挙動は異なっているので注意が必要である(\autoref{tab:math_bsa}参照).
2397 \begin{itemize}
2398  \item バージョン20221002.0以降では,
2399   \pTeX~4.0.0と同様に数式が\Param{yalbaselineshift}だけシフトされる.
2400
2401   しかしそれでは数式中に直に書かれた\cs{hbox},~\cs{vbox}中の欧文には
2402   \Param{yalbaselineshift}が二重に適用されることになるので,
2403   数式中に直に書かれた\cs{hbox},~\cs{vbox}には
2404   \Param{yalbaselineshift}を打ち消す補正をしている.
2405
2406   なお,\cs{vcenter}によるボックスにはこの「打ち消す補正」は行われないので注意.
2407 \item \pTeX では数式のスタイルごとに「打ち消す補正」の割合を\cs{textbaselineshiftfactor},
2408   \cs{scriptbaselineshiftfactor}, \cs{scriptscriptbaselineshiftfactor}で
2409   指定できるようにしたが,\LuaTeX-jaでは2番の数式ファミリ(\cs{fam2})に使われているフォントの
2410   大きさから自動で計算する.
2411
2412 \item 数式中に直に書かれた和文文字(\autoref{tab:math_bsa}中の``あ'')については
2413   \pTeX と\LuaTeX-jaで違いが見られる.
2414   \pTeX では,欧文文字と変わらず欧文ベースライン補正(\cs{ybaselineshift})がかかり,
2415   また周囲に和欧文間空白(\cs{xkanjiskip})が入りうる.
2416   その一方,\LuaTeX-jaでは「和文ベースライン補正(\Param{yjabaselineshift})がかかる」見た目に
2417   なり,また周囲に和欧文間空白は入らない.
2418 \end{itemize}
2419 \begin{table}
2420 \small\centering
2421 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2422 \label{tab:math_bsa}
2423 \newdimen\origbaselineskip
2424 \origbaselineskip=\baselineskip
2425 \begin{tabular}{lp{35\zw}}
2426 \toprule
2427 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2428 \begin{lstlisting}
2429 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2430 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$,
2431 $\sqrt{A}-\underline{X}+\frac{あ3}{2あ}-\vcenter{\hbox{aお}}$
2432 \end{lstlisting}\\
2433 \noalign{\vskip-\origbaselineskip}
2434 \midrule
2435 \emph{\pTeX~(p4.0.0)}&
2436 {\ltjsetparameter{yalbaselineshift=10pt}%
2437 \protected\def\>{\hskip\ltjgetparameter{xkanjiskip}}
2438 数式abc: $\lower10pt\hbox{あ}\>a\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2439 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2440 $\sqrt{A}-\underline{X}
2441   +\frac{\lower10pt\hbox{\scalebox{0.7}{あ}}\>3}{2\>\lower10pt\hbox{\scalebox{0.7}{あ}}}-\vcenter{\hbox{aお}}$
2442 \par}\\\noalign{\vskip-\origbaselineskip}\midrule
2443 \emph{\LuaTeX-ja}&
2444 {\ltjsetparameter{yalbaselineshift=10pt}%
2445 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2446 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$,
2447 $\sqrt{A}-\underline{X}+\frac{あ\>3}{2あ}-\vcenter{\hbox{aお}}$
2448 \par}\\
2449 \noalign{\vskip-\origbaselineskip}
2450 \bottomrule
2451 \end{tabular}
2452 \end{table}
2453 %</ja>
2454
2455 %<*en>
2456 \subsection{\emph{kinsoku} parameters and OpenType features}
2457 Among parameters which related to Japanese word-wrapping process (\emph{kinsoku shori}),
2458 \begin{quote}
2459  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2460  \Param{postbreakpenalty}~and~\Param{kcatcode}
2461 \end{quote}
2462 are stored by each character codes.
2463
2464 OpenType font features are ignored in these parameters.
2465 For example, a fullwidth katakana ``ア'' on line~10 in the below input is replaced to
2466 its halfwidth variant ``ア'', by \verb+hwid+ feature.
2467 However, the penalty inserted after it is 10 which is the \Param{postbreakpenalty} of
2468 ``ア'', not 20.
2469 %</en>
2470 %<*ja>
2471 \subsection{禁則処理関連パラメータとOpenType機能}
2472 禁則処理や \Param{kanjiskip}, \Param{xkanjiskip} の挿入に関連したパラメータのうち
2473 \begin{quote}
2474  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2475  \Param{postbreakpenalty}, \Param{kcatcode}
2476 \end{quote}
2477 は,文字コードごとに設定する量である.
2478
2479 \Pkg{fontspec}パッケージを使う(\ref{ssec:fontspec}節)場合など,
2480 各種のOpenType機能を適用することもあると思うが,前段落に述べたパラメータ類は,
2481 \emph{OpenType機能の適用前の文字コードによって適用される.}
2482 例えば,以下の例において10行目の「ア」は,\verb+hwid+ featureの適用により半角カタカナの「ア」
2483 に置き換わる.しかし,その直後に挿入される \Param{postbreakpenalty}は,置換前の「ア」に対する値10である.
2484 %</ja>
2485
2486 \begin{LTXexample}[width=0.2\textwidth]
2487 \ltjsetparameter{postbreakpenalty={`ア, 10}}
2488 \ltjsetparameter{postbreakpenalty={`ア, 20}}
2489
2490 \newcommand\showpostpena[1]{%
2491   \leavevmode\setbox0=\hbox{#1\hbox{}}%
2492   \unhbox0\setbox0=\lastbox\the\lastpenalty}
2493
2494 \showpostpena{ア},
2495 \showpostpena{ア},
2496 {\addjfontfeatures{CharacterWidth=Half}\showpostpena{ア}}
2497 \end{LTXexample}
2498
2499 \clearpage
2500 %<en>\part{Reference}
2501 %<ja>\part{リファレンス}
2502 \label{part-ref}
2503 \suppressfloats[t]
2504 %<*ja>
2505 \section{\LuaTeX-jaにおける \cs{catcode}}
2506 \label{sec-catcode}
2507 \subsection{予備知識:\pTeX と\upTeX における \cs{kcatcode}}
2508 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2509 は \cs{kcatcode} の値によって決定されるのであった.
2510 詳細は\autoref{tab:kcat}を参照されたい.
2511 %</ja>
2512 %<*en>
2513 \section{\cs{catcode} in \LuaTeX-ja}
2514 \label{sec-catcode}
2515 \subsection{Preliminaries: \cs{kcatcode} in \pTeX\ and \upTeX}
2516 In \pTeX~and~\upTeX, the value of \cs{kcatcode} determines
2517 whether a Japanese character can be used in a control word.
2518 For the detail, see \autoref{tab:kcat}.
2519 %</en>
2520
2521 \begin{table}[t]
2522 \small
2523 \caption{\cs{kcatcode} in \upTeX}
2524 \label{tab:kcat}
2525 %<en>\medskip
2526
2527 \noindent\hfill
2528 \begin{tabular}{llccc}
2529 \toprule
2530 \bfseries \cs{kcatcode}&
2531 %<*en>
2532 \bfseries meaning&
2533 \bfseries control word&
2534 \bfseries widow penalty&
2535 \bfseries linebreak\\
2536 %</en>
2537 %<*ja>
2538 \bfseries 意図&
2539 \bfseries 制御綴中に使用&
2540 \bfseries 文字ウィドウ処理&
2541 \bfseries 直後での改行\\
2542 %</ja>
2543 \midrule
2544 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2545 16&kanji&Y&Y&ignored\\
2546 17&kana&Y&Y&ignored\\
2547 18&other&N&N&ignored\\
2548 19&hangul&Y&Y&space\\
2549 \bottomrule
2550 \end{tabular}\hfill\null
2551
2552 \medskip
2553
2554 %<*ja>
2555 文字ウィドウ処理:「漢字が一文字だけ次の行に行くのを防ぐ」
2556 \cs{jcharwidowpenalty} が,
2557 その文字の直前に挿入されうるか否か,を示す.
2558 %</ja>
2559 \end{table}
2560
2561 %<*en>
2562 \cs{kcatcode} can be set by a row of JIS~X~0208 in \pTeX,
2563 and generally by a Unicode block\footnote{%
2564   \upTeX\ divides \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)
2565   into three subblocks, and \cs{kcatcode} can be set by a subblock.
2566 }
2567 in \upTeX. So characters which can be used in a control word
2568 slightly differ between \pTeX~and~\upTeX.
2569 %</en>
2570 %<*ja>
2571 \pTeX では \cs{kcatcode} はJIS~X~0208の区単位,
2572 \upTeX では概ねUnicodeブロック単位\footnote{%
2573   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2574   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2575   それぞれ別々に \cs{kcatcode} が指定できるようになっている.
2576 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2577 制御綴内で使用可能な文字が微妙に異なっている.
2578 %</ja>
2579
2580 %<*en>
2581 \subsection{Case of \LuaTeX-ja}
2582 The role of \cs{kcatcode} in \pTeX~and~\upTeX\ can be
2583 divided into the following four kinds,
2584 and \LuaTeX-ja can control these four kinds separately:
2585 \begin{itemize}
2586  \item
2587 \emph{Distinction between \textbf{JAchar} or \textbf{ALchar}}
2588 is controlled by the character range, see Subsection~\ref{ssec:setrange}.
2589  \item
2590 \emph{Whether the character can be used in a control word}
2591 is controlled by setting \cs{catcode} to 11~(enabled) or 12~(disabled), as usual.
2592  \item
2593 \emph{Whether \Param{jcharwidowpenalty} can be inserted before the character}
2594 is controlled by the lowermost bit of the \Param{kcatcode} parameter.
2595  \item
2596 \emph{Linebreak after a \textbf{JAchar}} does not produce a space.
2597 \end{itemize}
2598 %</en>
2599 %<*ja>
2600 \subsection{\LuaTeX-jaの場合}
2601 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \cs{kcatcode} の役割を
2602 分割している:
2603 \begin{description}
2604  \item[欧文/和文の区別 (\upTeX)]
2605 \cs{ltjdefcharrange} と\textsf{jacharrange}パラメータ(\ref{ssec:setrange}節)
2606  \item[制御綴中に使用可か]
2607 \LuaTeX 自身の \cs{catcode} でよい
2608  \item[\Param{jcharwidowpenalty}が挿入可か]
2609 \Param{kcatcode}パラメータの最下位ビット
2610  \item[直後の改行]
2611 日本語しか想定していないので,\textbf{JAchar}直後の改行で半角スペースが挿入されることはない.
2612 \end{description}
2613 %</ja>
2614
2615 %<*en>
2616 Default setting of \cs{catcode} of Unicode characters with \LuaTeX\ is slightly inconvenient
2617 for \pTeX~users to shifting to \LuaTeX-ja,
2618 because several fullwidth characters which can be used in a control word with \pTeX,
2619 such as ``\texttt{1}''~(FULLWIDTH DIGIT ONE), cannnot be used in a control word with \LuaTeX.
2620 Hence, \LuaTeX-ja changes the \cs{catcode} of some characters%
2621 ---whose line breaking class is ``ID''~(Ideographic) in UAX~\#14---,
2622 to allow these characters in the control word.
2623 %</en>
2624 %<*ja>
2625 最近の(2015-10-01以降の)\LuaLaTeX では漢字や仮名を制御綴内に
2626 使用することが可能であるが,全角英数字は使用できない.
2627 これでは\pTeX で使用できた\cs{1年目西暦}\footnote{科研費\LaTeX で使用されているそうです.}などが使えないため,
2628 \LuaTeX-jaへの移行で手間が生じることになる.
2629
2630 そのため,\LuaTeX-jaでは全角英数字など一部の文字
2631 \footnote{正確には,Unicodeの行分割アルゴリズム(UAX~\#14)で``ID''~(Ideographic)と指定されている文字.}の
2632 \cs{catcode}を11に変更し,これらの文字を制御綴中で使用可能にしている.
2633 %</ja>
2634
2635 \begin{table}
2636  \centering\small
2637 %<en>\caption{Difference of the set of non-kanji JIS~X~0208 characters which can be used in a control word}
2638 %<ja>\caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2639 %<en>\medskip
2640 \label{tab:kcat-diff}
2641 \def\D#1#2#3#4{%
2642   {\fboxsep0pt\fcolorbox{cyan}{white}%
2643   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2644 \leavevmode\hbox to 0pt{\hss\begin{tabular}[t]{cccccc}
2645 \toprule
2646 %<en>&\textbf{row}&\textbf{col.}&\textbf{\pTeX}&\textbf{\upTeX}&\textbf{\LuaTeX-ja}\\
2647 %<ja>&\emph{区}&\emph{点}&\emph{\pTeX}&\emph{\upTeX}&\emph{\LuaTeX-ja}\\
2648 \midrule
2649 %\D 3000&1&1&N&N&Y\\
2650 \D 30FB&1&6&N&Y&N\\
2651 \D 309B&1&11&N&Y&N\\
2652 \D 309C&1&12&N&Y&N\\
2653 \D FF40&1&14&N&N&Y\\
2654 \D FF3E&1&16&N&N&Y\\
2655 \D FFE3&1&17&N&N&Y\\
2656 \D FF3F&1&18&N&N&Y\\
2657 \D 30FD&1&19&N&Y&Y\\
2658 \D 30FE&1&20&N&Y&Y\\
2659 \D 309D&1&21&N&Y&Y\\
2660 \D 309E&1&22&N&Y&Y\\
2661 \D 3003&1&23&N&N&Y\\
2662 \D 4EDD&1&24&N&Y&Y\\
2663 \D 3005&1&25&N&N&Y\\
2664 \D 3006&1&26&N&N&Y\\
2665 \D 3007&1&27&N&N&Y\\
2666 \D 30FC&1&28&N&Y&Y\\
2667 \bottomrule
2668 \end{tabular}\qquad
2669 \begin{tabular}[t]{cccccc}
2670 \toprule
2671 %<en>&\textbf{row}&\textbf{col.}&\textbf{\pTeX}&\textbf{\upTeX}&\textbf{\LuaTeX-ja}\\
2672 %<ja>&\emph{区}&\emph{点}&\emph{\pTeX}&\emph{\upTeX}&\emph{\LuaTeX-ja}\\
2673 \midrule
2674 \D FF0F&1&31&N&N&Y\\
2675 \D FF3C&1&32&N&N&Y\\
2676 \D FF5E&1&33&N&N&Y\\
2677 \D FF5C&1&35&N&N&Y\\
2678 \D FF0B&1&60&N&N&Y\\
2679 \D FF1D&1&65&N&N&Y\\
2680 \D FF1C&1&67&N&N&Y\\
2681 \D FF1E&1&68&N&N&Y\\
2682 \D FF03&1&84&N&N&Y\\
2683 \D FF06&1&85&N&N&Y\\
2684 \D FF0A&1&86&N&N&Y\\
2685 \D FF20&1&87&N&N&Y\\
2686 \D 3012&2&9&N&N&Y\\
2687 \D 3013&2&14&N&N&Y\\
2688 \D FFE2&2&44&N&N&Y\\
2689 \D 212B&2&82&N&N&Y\\
2690 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Greek letters (row 6)}&Y&N&Y\\
2691 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Cyrillic letters (row 7)}&N&N&Y\\
2692 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&Y&N&Y\\
2693 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&N&N&Y\\
2694 \bottomrule
2695 \end{tabular}\hss}\par
2696 \end{table}
2697
2698 %<*en>
2699 \subsection{Non-kanji characters in a control word}
2700 {\def\D#1{%
2701   {\fboxsep0pt\fcolorbox{cyan}{white}{#1}}}%
2702 Because the engine differ, so non-kanji JIS~X~0208 characters
2703 which can be used in a control word differ in \pTeX, in \upTeX,~and~in \LuaTeX-ja.
2704 \autoref{tab:kcat-diff} shows the difference.
2705 Except for three characters \D{・},~\D{゛},~and~`\D{゜},
2706 \LuaTeX-ja admits more characters in a control word than \upTeX.}
2707
2708 Difference becomes larger, if we consider
2709 non-kanji JIS~X~0213 characters.
2710 For the detail, see \url{https://github.com/h-kitagawa/kct}.
2711 %</en>
2712 %<*ja>
2713 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2714
2715 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2716 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2717 異なっているところだけを載せると,\autoref{tab:kcat-diff}のようになる.
2718 「・」「゛」「゜」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2719 制御綴に使用可能になっている.
2720
2721 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2722 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\
2723 \texttt{kct-out.pdf} などを参照すること.
2724 %</ja>
2725
2726
2727 %<*en>
2728 \section{Directions}
2729 \LuaTeX\ supports four $\Omega$-style directions: \texttt{TLT},~\texttt{TRT}, \texttt{RTT}
2730 and \texttt{LTL}.
2731 However, neither directions are not well-suited for typesetting Japanese vertically, hence we
2732 implemented vertical writing by rotating \texttt{TLT}-box by 90~degrees.
2733 %</en>
2734 %<*ja>
2735 \section{縦組}
2736 \label{sec-direction}
2737 \LuaTeX 本体でも,$\Omega$・$\aleph$由来の機能として,複数の組方向をサポートしている.
2738 しかし,\LuaTeX がサポートするのは \texttt{TLT},~\texttt{TRT}, \texttt{RTT},~\texttt{LTL}\
2739 のみであり,日本語の縦組に使うのは望ましくない\footnote{%
2740 和文文字だけならば \texttt{RTT} を使えばなんとかなると思うが,
2741 欧文文字が入ってきた場合はうまくいかず,\texttt{RTR} という組方向が必要になる.
2742 }.そのため,\LuaTeX-jaでは横組(\texttt{TLT})で組んだボックスを回転させる方式で
2743 縦組を実装した.
2744 %</ja>
2745
2746 %<ja>\subsection{サポートする組方向}
2747 \begin{table}[t]
2748 %<ja>\caption{\LuaTeX-ja のサポートする組方向}
2749 %<en>\caption{Directions supported by \LuaTeX-ja}
2750 %<en>\medskip
2751 \label{tab-dir}
2752 \centering\small
2753 \def\obox#1{%
2754   \setbox0=\hbox{\yoko\hbox{#1%
2755   \large\ltjsetparameter{talbaselineshift=0pt}%
2756   \vrule height 25pt width 0.4pt depth 15pt\kern-.2pt%
2757   \raise25pt\hbox to 0pt{\hss\composite{*r^@{>>}}\hss}%
2758   \raise-15pt\hbox to 0pt{\hss\composite{*l^@{>|}}\hss}\kern.2pt%
2759   \vrule height.2pt depth.2pt width 60pt\hbox to 0pt{\hss\composite{*d^@{>}}\hss}\kern-60pt
2760   \hbox to 60pt{\,銀は、Ag\hss}}}%
2761   \raise\dimexpr 0.5\ltjgetdp0-0.5\ltjgetht0\box0%
2762 }
2763 %<*ja>
2764 \begin{tabular}{>{\bfseries}lcccc}
2765 \toprule
2766 &横組&縦組 &「dtou方向」&「utod方向」\\
2767 \midrule
2768 命令&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2769 字送り方向&水平右向き(→)&垂直下向き(↓)&垂直上向き(↑)&垂直下向き(↓)\\
2770 行送り方向&垂直下向き(↓)&水平左向き(←)&水平右向き(→)&水平左向き(←)\\
2771 使用する和文フォント&横組用(\cs{jfont})&縦組用(\cs{tfont})&
2772 \multicolumn{2}{c}{%
2773   横組用(\cs{jfont})の$90^\circ$回転}\\[\smallskipamount]
2774 組版例\null $^*$ &\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2775 \noalign{\medskip}
2776 \bottomrule
2777 \end{tabular}
2778
2779 \medskip\raggedright
2780 \def\R#1{%
2781   \raise0.38\zw\hbox{%
2782     \vrule height.2pt  depth.2pt width2\zw%
2783     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2784   }%
2785 }
2786 $^*$\ 幅(width),高さ(height),深さ(depth)の増加方向を,
2787 それぞれ「\R{>}」,「\R{>>}」,「\R{>|}」で表している.
2788 \raggedright
2789 %</ja>
2790
2791 %<*en>
2792 \begin{tabular}{>{\bfseries}lcccc}
2793 \toprule
2794 &horizontal (\emph{yoko}~direction)&vertical (\emph{tate}~direction)&%
2795   \emph{dtou} direction&\emph{utod} direction\\
2796 \midrule
2797 Commands&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2798 Beginning of the page&Top&Right&Left&Right\\
2799 Beginning of the line&Left&Top&Bottom&Top\\
2800 Used Japanese font&horizontal (\cs{jfont})&vertical (\cs{tfont})&
2801 \multicolumn{2}{c}{%
2802   horizontal ($90^\circ$ rotated)}\\[\smallskipamount]
2803 Example&\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2804 \noalign{\medskip}
2805 (Notation used in $\Omega$)&TLT&RTR, RTT&LBL&RTR\\
2806 \bottomrule
2807 \end{tabular}
2808
2809 \medskip\raggedright
2810 \def\R#1{%
2811   \raise0.38\zw\hbox{%
2812     \vrule height.2pt  depth.2pt width2\zw%
2813     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2814   }%
2815 }
2816 \raggedright
2817 %</en>
2818 \end{table}
2819
2820 %<*en>
2821 \LuaTeX-ja supports four directions, as shown in \autoref{tab-dir}.
2822 The second column (\emph{yoko} direction) is just horizontal writing,
2823 and the third column (\emph{tate} direction) is vertical writing.
2824 The fourth column (\emph{dtou} direction) is actually a hidden feature of \pTeX.
2825 We implemented this for debugging purpose.
2826 The fifth column (\emph{utod} direction) corresponds the ``\texttt{tate (math) direction}'' of \pTeX.
2827
2828 Directions can be changed by \cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod},
2829 only when the current list is null.
2830 These commands cannot be executed in unrestricted horizontal modes, nor math modes.
2831 The direction of a math formula is changed to
2832 \emph{utod}, when the direction outside the math formula is \emph{tate} (vertical writing).
2833 %</en>
2834
2835 %<*ja>
2836 \LuaTeX-jaがサポートする組方向は\autoref{tab-dir}に示す4つである.
2837 4列目の \cs{dtou} は聞き慣れない命令だと思うが,
2838 実は\pTeX に同名の命令が(ドキュメントには書かれていないが)存在する.
2839 Down-TO-Upの意味なのだろう.\cs{dtou} を使用する機会はないだろうが,
2840 \LuaTeX-jaではデバッグ用に実装している.
2841 5列目の \cs{utod} は,\pTeX で言う「縦数式ディレクション」に相当するものである.
2842
2843 組方向は,\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod} をそれぞれ使用することで,
2844 現在作成中のリストやボックスが空の時にのみ変更可能である.
2845 ただし,現在のモードが非制限水平モードや(文中,別行立て問わず)数式モードであるときには
2846 組方向を変更することは出来ない.
2847 また,縦組中の数式内のボックスは\pTeX と同じように組方向が \cs{utod} となる.
2848
2849 なお,\LaTeX の下で\LuaTeX-jaを使用する場合,組方向変更命令には
2850 「新たな組方向下での和文フォントを必要なら読み込み(・選択する)」という
2851 処理が付け加えられている(\ref{ssec:ltx-jfm}節参照).
2852 %</ja>
2853
2854 %<*en>
2855 \subsection{Boxes in different direction}
2856
2857 As in \pTeX, one can use boxes of different direction in one document.
2858 The below is an example.
2859 \begin{LTXexample}
2860 ここは横組%     yoko
2861 \hbox{\tate %   tate
2862   \hbox{縦組}%  tate
2863   の中に
2864   \hbox{\yoko 横組の内容}% yoko
2865   を挿入する
2866 }
2867 また横組に戻る% yoko
2868 \end{LTXexample}
2869
2870 \autoref{tab-diffdir} shows how a box is arranged when
2871 the direction  inside the box and that outside the box differ.
2872 %</en>
2873 %<*ja>
2874 \subsection{異方向のボックス}
2875
2876 縦組の中に「42」などの2桁以上の算用数字を横組で組むなど,
2877 異なる組方向を混在させることがしばしば行われる.
2878 組方向の混在も\pTeX と同じようにできる:
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 異なる組方向のボックスを配置した場合にどう組まれるかの仕様も,\pTeX を
2891 踏襲している.\autoref{tab-diffdir}に示す.
2892 %</ja>
2893
2894 \begin{table}[t]
2895 %<ja>\caption{異方向のボックスの配置}
2896 %<en>\caption{Boxes in different direction}
2897 %<en>\medskip
2898 \label{tab-diffdir}
2899  \centering\small\unitlength3mm
2900  \def\TATEeg{%
2901    \hbox{\smash{\begin{picture}(0,0)(-2,0)
2902      \thicklines
2903      \polyline(-2,0)(-2,-7)(5,-7)(5,0)
2904      \put(0,0){\circle*{0.3}}
2905      \put(2.5,-4){\makebox(0,0){\hbox{\tate\bfseries \emph{tate}/\emph{utod}}}}
2906      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
2907      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
2908      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
2909    \end{picture}}}%
2910  }
2911  \def\DTOUeg{%
2912    \hbox{\smash{\begin{picture}(0,0)(-5,0)
2913      \thicklines
2914      \polyline(-5,0)(-5,7)(2,7)(2,0)
2915      \put(0,0){\circle*{0.3}}
2916      \put(-2.5,4){\makebox(0,0){\hbox{\dtou\bfseries \emph{dtou}}}}
2917      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
2918      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
2919      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
2920    \end{picture}}}%
2921  }
2922  \def\YOKOeg{%
2923    \hbox{\smash{\begin{picture}(0,0)
2924      \thicklines
2925      \polyline(0,5)(7,5)(7,-2)(0,-2)
2926      \put(4,2.5){\makebox(0,0){\hbox{\yoko\bfseries \emph{yoko}}}}
2927      \put(0,0){\circle*{0.3}}
2928      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
2929      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
2930      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
2931    \end{picture}}}%
2932  }
2933 \begin{tabular}{ccc}
2934 \toprule
2935 %<ja>\emph{横組中に配置}&\emph{縦組中に配置}&%
2936 %<ja>\emph{組方向 \cs{dtou} 中に配置}\\
2937 %<en>\textbf{typeset in \emph{yoko} direction}
2938 %<en>&\textbf{typeset in \emph{tate} or \emph{utod} direction}
2939 %<en>&\textbf{typeset in \emph{dtou} direction}\\
2940 \midrule
2941  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2942    \put(0,0){\line(1,0){3.8}}
2943    \put(4,7){\TATEeg}
2944    \put(11.2,0){\line(1,0){3.8}}
2945 %
2946    \put(2,7){\line(1,0){1.8}}
2947    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
2948    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
2949    \put(3,-2){\vector(0,1){2}}
2950    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
2951 %
2952    \put(4,7.2){\line(0,1){1.8}}
2953    \put(11,7.2){\line(0,1){1.8}}
2954    \put(6,8){\vector(-1,0){2}}
2955    \put(9,8){\vector(1,0){2}}
2956    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
2957 %
2958  \end{picture}\vspace{-\baselineskip}
2959    \begin{align*}
2960    W_{\mathrm{Y}} &= h_{\mathrm{T}}+d_{\mathrm{T}},\\
2961    H_{\mathrm{Y}} &= w_{\mathrm{T}},\\
2962    D_{\mathrm{Y}} &=0\,\mathrm{pt}
2963    \end{align*}%
2964  }&
2965  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2966    \put(7.5,-0.2){\line(0,-1){2.8}}
2967    \put(4,2){\YOKOeg}
2968    \put(7.5, 7.2){\line(0,1){3.8}}
2969 %
2970    \put(2,7){\line(1,0){1.8}}
2971    \put(2,0){\line(1,0){1.8}}
2972    \put(3,5){\vector(0,1){2}}
2973    \put(3,2){\vector(0,-1){2}}
2974    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
2975 %
2976    \put(4,7.2){\line(0,1){1.8}}
2977    \put(11,7.2){\line(0,1){1.8}}
2978    \put(8,8){\vector(-1,0){0.5}}\put(8,8){\vector(1,0){3}}
2979    \put(7,8){\vector(-1,0){3}}\put(7,8){\vector(1,0){0.5}}
2980    \put(9.25,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
2981    \put(5.75,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
2982 %
2983  \end{picture}\vspace{-\baselineskip}
2984    \begin{align*}
2985    W_{\mathrm{T}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
2986    H_{\mathrm{T}} &= w_{\mathrm{Y}}/2,\\
2987    D_{\mathrm{T}} &= w_{\mathrm{Y}}/2
2988    \end{align*}%
2989  }&
2990  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2991    \put(11,-0.2){\line(0,-1){2.8}}
2992    \put(4,2){\YOKOeg}
2993    \put(11, 7.2){\line(0,1){3.8}}
2994 %
2995    \put(2,7){\line(1,0){1.8}}
2996    \put(2,0){\line(1,0){1.8}}
2997    \put(3,5){\vector(0,1){2}}
2998    \put(3,2){\vector(0,-1){2}}
2999    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3000 %
3001    \put(4,7.2){\line(0,1){1.8}}
3002    \put(11,7.2){\line(0,1){1.8}}
3003    \put(7.5,8){\vector(-1,0){3.5}}\put(7.5,8){\vector(1,0){3.5}}
3004    \put(13,8){\vector(-1,0){2}}
3005    \put(7.5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3006    \put(12,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3007 %
3008  \end{picture}\vspace{-\baselineskip}
3009    \begin{align*}
3010    W_{\mathrm{D}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3011    H_{\mathrm{D}} &= w_{\mathrm{Y}},\\
3012    D_{\mathrm{D}} &= 0\,\mathrm{pt}
3013    \end{align*}%
3014  }%
3015 \\\midrule
3016  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3017    \put(0,0){\line(1,0){3.8}}
3018    \put(4,0){\DTOUeg}
3019    \put(11.2,0){\line(1,0){3.8}}
3020 %
3021    \put(2,7){\line(1,0){1.8}}
3022    \put(3,3.5){\vector(0,1){3.5}}\put(3,3.5){\vector(0,-1){3.5}}
3023    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
3024    \put(3,-2){\vector(0,1){2}}
3025    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
3026 %
3027    \put(4,7.2){\line(0,1){1.8}}
3028    \put(11,7.2){\line(0,1){1.8}}
3029    \put(6,8){\vector(-1,0){2}}
3030    \put(9,8){\vector(1,0){2}}
3031    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3032 %
3033  \end{picture}\vspace{-\baselineskip}
3034    \begin{align*}
3035    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3036    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
3037    D_{\mathrm{Y}} &= 0\,\mathrm{pt}
3038    \end{align*}%
3039  }&
3040  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3041    \put(9,-0.2){\line(0,-1){2.8}}
3042    \put(4,0){\DTOUeg}
3043    \put(9, 7.2){\line(0,1){3.8}}
3044 %
3045    \put(2,7){\line(1,0){1.8}}
3046    \put(2,0){\line(1,0){1.8}}
3047    \put(3,5){\vector(0,1){2}}
3048    \put(3,2){\vector(0,-1){2}}
3049    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3050 %
3051    \put(4,7.2){\line(0,1){1.8}}
3052    \put(11,7.2){\line(0,1){1.8}}
3053    \put(6.5,8){\vector(-1,0){2.5}}\put(6.5,8){\vector(1,0){2.5}}
3054    \put(10,8){\vector(-1,0){1}}\put(10,8){\vector(1,0){1}}
3055    \put(10,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3056    \put(6.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3057 %
3058  \end{picture}\vspace{-\baselineskip}
3059    \begin{align*}
3060    W_{\mathrm{T}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3061    H_{\mathrm{T}} &= d_{\mathrm{D}},\\
3062    D_{\mathrm{T}} &= h_{\mathrm{D}}
3063    \end{align*}%
3064  }&
3065  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3066    \put(6,-0.2){\line(0,-1){2.8}}
3067    \put(4,7){\TATEeg}
3068    \put(6, 7.2){\line(0,1){3.8}}
3069 %
3070    \put(2,7){\line(1,0){1.8}}
3071    \put(2,0){\line(1,0){1.8}}
3072    \put(3,5){\vector(0,1){2}}
3073    \put(3,2){\vector(0,-1){2}}
3074    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3075 %
3076    \put(4,7.2){\line(0,1){1.8}}
3077    \put(11,7.2){\line(0,1){1.8}}
3078    \put(5,8){\vector(-1,0){1}}\put(5,8){\vector(1,0){1}}
3079    \put(8.5,8){\vector(-1,0){2.5}}\put(8.5,8){\vector(1,0){2.5}}
3080    \put(5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3081    \put(8.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3082 %
3083  \end{picture}\vspace{-\baselineskip}
3084    \begin{align*}
3085    W_{\mathrm{D}} &= w_{\mathrm{T}},\\
3086    H_{\mathrm{D}} &= d_{\mathrm{T}},\\
3087    D_{\mathrm{D}} &= h_{\mathrm{T}}
3088    \end{align*}%
3089  }\\
3090 \bottomrule
3091 \end{tabular}
3092 \end{table}
3093
3094
3095
3096 %<*en>
3097 \paragraph{\cs{wd} and direction}
3098 In \pTeX, \cs{wd},~\cs{ht},~\cs{dp} means the dimensions of a box register
3099 \emph{with respact to the current direction}.
3100 This means that the value of \cs{wd0} etc.\ might differ when the current direction is
3101 different, even if \cs{box0} stores the same box.
3102 However, this no longer applies in \LuaTeX-ja.
3103
3104 \begin{LTXexample}
3105 % yoko direction
3106 \setbox0=\hbox to 20pt{foo}
3107 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3108 \wd0=100pt
3109 \the\wd0,~\hbox{\tate \the\wd0}
3110 \end{LTXexample}
3111
3112 To access box dimensions \emph{with respect to current direction},
3113 one have to use the following commands instead of \cs{wd} wtc.
3114 \begin{cslist}
3115
3116  \item[\cs{ltjgetwd}\meta{num}\textrm{, }\cs{ltjgetht}\meta{num}\textrm{, }%
3117   \cs{ltjgetdp}\meta{num}]
3118 These commands return \emph{an internal dimension} of \cs{box\meta{num}} with respect to
3119 the current direction. One can use these in \cs{dimexpr} primitive, as the followings.
3120 \begin{lstlisting}
3121 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3122 \end{lstlisting}
3123 The following is an example.
3124 \begin{LTXexample}[width=0.3\textwidth]
3125 \parindent0pt
3126 \setbox32767=\hbox{\yoko よこぐみ}
3127 \fboxsep=0mm\fbox{\copy32767}
3128 \vbox{\hsize=20mm
3129 \yoko YOKO \the\ltjgetwd32767, \\
3130   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3131 \vbox{\hsize=20mm\raggedleft
3132 \tate TATE \the\ltjgetwd32767, \\
3133   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3134 \vbox{\hsize=20mm\raggedleft
3135 \dtou DTOU \the\ltjgetwd32767, \\
3136   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3137 \end{LTXexample}
3138
3139  \item[\cs{ltjsetwd}\meta{num}=\meta{dimen}\textrm{, }\cs{ltjsetht}\meta{num}=\meta{dimen}\textrm{, }%
3140   \cs{ltjsetdp}\meta{num}=\meta{dimen}]
3141 These commands set the dimension of \cs{box\meta{num}}. One does not need
3142         to group the argument \meta{num}; four calls of \cs{ltjsetwd} below have the same meaning.
3143 \begin{lstlisting}
3144 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3145 \end{lstlisting}
3146
3147 \end{cslist}
3148 %</en>
3149 %<*ja>
3150 \paragraph{\cs{wd} 達と組方向}
3151 ボックスレジスタ \cs{box}\meta{num} にセットされているボックスの幅・高さ・深さの取得や
3152 変更にはそれぞれ \cs{wd},~\cs{ht},~\cs{dp} プリミティブを用いるのであった.
3153 \pTeX ではこれらのプリミティブは,「現在の組方向におけるボックスの寸法」を指すもので,
3154 同じボックスに対しても現在の組方向によって返る値は異なるものであった.
3155
3156 \LuaTeX-jaにおいては状況が異なり,\cs{wd},~\cs{ht},~\cs{dp} が返す値は
3157 現在の組方向には依存しない.下の例のように,横組のボックスが格納されていれば
3158 \cs{wd}等は常に「横組におけるボックスの寸法」を意味する.
3159
3160 \begin{LTXexample}
3161 % yoko direction
3162 \setbox0=\hbox to 20pt{foo}
3163 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3164 \wd0=100pt
3165 \the\wd0,~\hbox{\tate \the\wd0}
3166 \end{LTXexample}
3167
3168 \pTeX のように現在の組方向に応じたボックスの寸法の取得・設定を行うには,
3169 代わりに次の命令を使用する.
3170
3171 \begin{cslist}
3172
3173  \item[\cs{ltjgetwd}\meta{num}\textrm{, }\cs{ltjgetht}\meta{num}\textrm{, }%
3174   \cs{ltjgetdp}\meta{num}]
3175 現在の組方向に応じたボックスの寸法の取得を行う.結果は内部長さであるため,
3176 \begin{lstlisting}
3177 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3178 \end{lstlisting}
3179 のように \cs{wd}\meta{num} の代わりとして扱うことができる.
3180 使用例は以下の通りである.
3181 \begin{LTXexample}[width=0.3\textwidth]
3182 \parindent0pt
3183 \setbox32767=\hbox{\yoko よこぐみ}
3184 \fboxsep=0mm\fbox{\copy32767}
3185 \vbox{\hsize=20mm
3186 \yoko YOKO \the\ltjgetwd32767, \\
3187   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3188 \vbox{\hsize=20mm\raggedleft
3189 \tate TATE \the\ltjgetwd32767, \\
3190   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3191 \vbox{\hsize=20mm\raggedleft
3192 \dtou DTOU \the\ltjgetwd32767, \\
3193   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3194 \end{LTXexample}
3195
3196  \item[\cs{ltjsetwd}\meta{num}=\meta{dimen}\textrm{, }\cs{ltjsetht}\meta{num}=\meta{dimen}\textrm{, }%
3197   \cs{ltjsetdp}\meta{num}=\meta{dimen}]
3198 現在の組方向に応じたボックスの寸法の設定を行う.\cs{afterassignment} を2回利用して
3199 実装しているので,次の4通りは全て同じ意味である.
3200 \begin{lstlisting}
3201 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3202 \end{lstlisting}
3203
3204 設定値は「横組」「縦組またはutod方向」「dtou方向」
3205 の3種ごとに独立して記録される.参考として,Gitリポジトリ内の
3206               \verb+test/test55-boxdim_diffdir.{tex,pdf}+ を挙げておく.
3207
3208 \end{cslist}
3209 %</ja>
3210
3211 %<*en>
3212 \subsection{Getting current direction}
3213 The \Param{direction} parameter returns the current direction, and
3214 the \Param{boxdir} parameter (with the argument \meta{num})
3215 returns the direction of a box register \cs{box}\meta{num}.
3216 The returned value of these parameters are a \emph{string}:
3217 \begin{center}
3218 \small
3219 \begin{tabular}{>{\bfseries}lccccc}
3220 \toprule
3221 Direction&\emph{yoko}&\emph{tate}&\emph{dtou}&\emph{utod}&(empty)\\
3222 \midrule
3223 Returned value&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3224 \bottomrule
3225 \end{tabular}
3226 \end{center}
3227 \begin{LTXexample}[width=0.3\textwidth]
3228 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3229 \hbox{\yoko \DIR}, \hbox{\tate\DIR},
3230 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3231 \hbox{\tate$\hbox{tate math: \DIR}$}
3232
3233 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3234 \end{LTXexample}
3235 %</en>
3236 %<*ja>
3237 \subsection{組方向の取得}
3238 「現在の組方向」や「\meta{num}番のボックスの組方向」は,
3239 \pTeX では \cs{ifydir} や \cs{ifybox}\meta{num} といった条件判断文を使って
3240 判断することができた.
3241 しかし,\LuaTeX-jaはあくまでも\TeX マクロとLuaコードで
3242 記述されており,それでは新たな条件判断命令を作るのは難しい.
3243
3244 \LuaTeX-jaでは,\Param{direction}パラメータで現在の組方向を,
3245 \Param{boxdir}パラメータ(と追加の引数\meta{num})によって
3246 \cs{box}\meta{num}の組方向をそれぞれ取得できるようにした.
3247 戻り値は文字列である:
3248 \begin{center}
3249 \small
3250 \begin{tabular}{>{\bfseries}lccccc}
3251 \toprule
3252 組方向&\emph{横組}&\emph{tate縦組}&\emph{dtou方向}&\emph{utod方向}&(未割り当て)\\
3253 \midrule
3254 戻り値&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3255 \bottomrule
3256 \end{tabular}
3257 \end{center}
3258
3259 \begin{LTXexample}[width=0.3\textwidth]
3260 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3261 \hbox{\yoko\DIR}, \hbox{\tate\DIR},
3262 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3263 \hbox{\tate$\hbox{tate math: \DIR}$}
3264
3265 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3266 \end{LTXexample}
3267
3268 これらを用いれば,例えば
3269 \pTeX の \cs{ifydir},~\cs{ifybox200} と同等の条件判断を
3270 \begin{lstlisting}
3271 \ifnum\ltjgetparameter{direction}=4
3272 \ifnum\ltjgetparameter{boxdir}{200}=4
3273 \end{lstlisting}
3274 のように行うことができる.
3275 \cs{iftdir} は少々面倒であるが,8で割った余りが3であるか否かを判断すれば良いから
3276 \begin{lstlisting}
3277 \ifnum\numexpr
3278   \ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8=3
3279 \end{lstlisting}
3280 とすればよい.
3281 %</ja>
3282
3283 %<*en>
3284 \section{Redefined primitives by \LuaTeX-ja}
3285 The following primitives are redefined by \LuaTeX-ja (using~\verb+\protected\def+),
3286 for supporting Japanese typesetting and multiple directions:
3287 \begin{cslist}[style=standard]
3288  \item[\cs{/}]
3289  \item[\cs{unhbox}\meta{num}\textrm{, }\cs{unvbox}\meta{num}\textrm{, }\cs{unhcopy}\meta{num}\textrm{, }\cs{unvcopy}\meta{num}]
3290  \item[\cs{vadjust}\{\meta{material}\}]
3291  \item[\cs{insert}\meta{number}\{\meta{material}\}]
3292  \item[\cs{lastbox}]
3293  \item[\cs{raise}\meta{dimen}\meta{box}\textrm{, }\cs{lower}\meta{dimen}\meta{box}\textrm{, }
3294    \cs{moveleft}\meta{dimen}\meta{box}\textrm{, }\cs{moveright}\meta{dimen}\meta{box}\textrm{, }]
3295  \item[\cs{split}\meta{number}to\meta{dimen}\textrm{, }\cs{vcenter}\{\meta{material}\}]
3296 \end{cslist}
3297
3298 On each primitive \cs{\meta{primitive}} in the list above,
3299 its meaning just before loading \LuaTeX-ja is backed up into \cs{ltj@@orig@\meta{primitive}},
3300 and the meaning after redefinition by \LuaTeX-ja is stored in \cs{ltj@@\meta{primitive}}.
3301 For example, \autoref{fig:primitive_meaning} shows the situation of \cs{vadjust} primitive.
3302 %</en>
3303 %<*ja>
3304 \section{プリミティブの再定義}
3305 \LuaTeX-jaでは和文組版や異なる組方向に対応するために,以下に挙げるプリミティブは
3306 \ \verb+\protected\def+ により再定義を行っている.
3307
3308 \begin{cslist}
3309  \item[\cs{/}]
3310  和文フォントに対するイタリック補正のサポートが追加されている.
3311  \item[\cs{unhbox}\meta{number}\textrm{, }\cs{unvbox}\meta{number}\textrm{, }\cs{unhcopy}\meta{number}\textrm{, }\cs{unvcopy}\meta{number}]
3312  ボックスの組方向が現在のリストと異なる場合は事前にエラーメッセージを出力する.
3313  \pTeX と異なり,エラーを無視して無理矢理 \cs{unhbox}, \cs{unvbox} 等を
3314  続行させることもできるが,その場合の組版結果は保証しない.
3315  \item[\cs{vadjust}\{\meta{material}\}] 一旦プリミティブ本来の挙動を行う.その後,\meta{material}の組方向が
3316  周囲の垂直リストの組方向と一致しない場合にエラーを出力し,
3317  該当の \cs{vadjust} を無効にする.
3318  \item[\cs{insert}\meta{number}\{\meta{material}\}]
3319  一旦プリミティブ本来の挙動を行い,その後\meta{material}内の各ボックス・罫線の直前に組方向を示
3320               すdirection whatsitを挿入する.
3321  \item[\cs{lastbox}] ボックスの「中身」を現在の組方向に合わせるためのノード
3322               (\textit{dir\_box}という)を必要ならば除去し,
3323  正しく「中身」のボックスが返されるように前処理をする.
3324  \item[\cs{raise}\meta{dimen}\meta{box}\textrm{, }\cs{lower}\meta{dimen}\meta{box}\textrm{, }
3325    \cs{moveleft}\meta{dimen}\meta{box}\textrm{, }\cs{moveright}\meta{dimen}\meta{box}\textrm{, }]
3326   \leavevmode\vspace{-\baselineskip}
3327  \item[\cs{split}\meta{number}to\meta{dimen}\textrm{, }\cs{vcenter}\{\meta{material}\}]
3328  これらのプリミティブについては必要に応じて\textit{dir\_box}を作成する前処理を追加している.
3329 \end{cslist}
3330
3331 上記の一覧中にあるプリミティブ\cs{\meta{primitive}}については,
3332 \LuaTeX-ja読み込み前の意味が\cs{ltj@@orig@\meta{primitive}}に,
3333 そして\LuaTeX-jaによる再定義後の意味が\cs{ltj@@\meta{primitive}}に保存される.
3334 例えば,\cs{vadjust}については\autoref{fig:primitive_meaning}のようになっている.
3335 %</ja>
3336 \begin{figure}
3337 \begin{LTXexample}[width=.55\textwidth]
3338 \makeatletter\scriptsize\ttfamily
3339 \meaning\vadjust        \\ % current
3340 \meaning\ltj@@vadjust   \\ % LuaTeX-ja
3341 \meaning\ltj@@orig@vadjust % original
3342 \end{LTXexample}
3343 \caption{Redefining \cs{vadjust} primitive by \LuaTeX-ja}
3344 \label{fig:primitive_meaning}
3345 \end{figure}
3346
3347 %<*en>
3348 \subsection{Suppressing redefinitions}
3349 Sometimes redefining primitives by \LuaTeX-ja causes a problem.
3350 For example, the \Pkg{breqn} package~(v0.98k) assumes that \cs{vadjust}~and~\cs{insert} have
3351 their primitive meanings.
3352 So, this package cannot by loaded after \LuaTeX-ja by default.
3353
3354 \LuaTeX-ja version~20210517.0 has features for that problem. Namely:
3355 \begin{itemize}
3356   \item Primitives which is listed in \cs{ltj@stop@overwrite@primitive} are 
3357   retain their meanings at just before loading \LuaTeX-ja.
3358   \item After loading \LuaTeX-ja,
3359   one can specify primitives to \cs{ltj@overwrite@primitive}, to redefine them by \LuaTeX-ja.
3360 \end{itemize}
3361 See \autoref{fig:primitive_overwrite} for an example.
3362 %</en>
3363 %<*ja>
3364 \subsection{再定義の抑制}
3365 場合によっては\LuaTeX-jaによるプリミティブの再定義が不都合を起こすこともある.
3366 たとえば,\Pkg{breqn}パッケージ(少なくともv0.98k, 2020\nobreakdash-09\nobreakdash-24))は
3367 読み込み時に\cs{vadjust}, \cs{insert}がプリミティブのままであることを要請するので,
3368 このままでは\LuaTeX-jaの後で読み込むことはできない.
3369
3370 この状況に対応するため,バージョン20210517.0以降では
3371 \begin{itemize}
3372   \item 制御綴\cs{ltj@stop@overwrite@primitive}内に並べられたプリミティブは,
3373   \LuaTeX-ja読み込み直前時の意味のままとなる.
3374   \item \LuaTeX-ja読み込み後に
3375   \cs{ltj@overwrite@primitive}に引数として与えたプリミティブを与えることで,
3376   それらを「\LuaTeX-jaによって再定義する」際の意味に再定義する
3377 \end{itemize}
3378 機能を導入した.使用例については\autoref{fig:primitive_overwrite}を参照.
3379 %</ja>
3380 \begin{figure}
3381 \begin{lstlisting}
3382 \makeatletter
3383 \def\ltj@stop@overwrite@primitive{\insert\vadjust\/\unhbox\vcenter\fontseries}
3384 \makeatother
3385   %% Keep the meaning of \insert, \vadjust, \/, \unhbox and \vcenter.
3386   %% \fontseries will still be redefined by \LuaTeX-ja, because it is not primitive.
3387 \usepackage{luatexja}
3388 ...
3389 \usepackage{breqn}
3390 ...
3391 \makeatletter
3392 \ltj@overwrite@primitive\expandafter{\insert\vadjust\/\unhbox\vcenter}
3393 \makeatother
3394   %% Redefine \insert, \vadjust, \/, \unhbox and \vcenter.
3395 \end{lstlisting}
3396 \caption{\cs{ltj@stop@overwrite@primitive} and \cs{ltj@overwrite@primitive}}
3397 \label{fig:primitive_overwrite}
3398 \end{figure}
3399
3400 %<en>\section{Font Metric and Japanese Font}
3401 %<ja>\section{フォントメトリックと和文フォント}
3402 %<en>\subsection{\cs{jfont}}
3403 %<ja>\subsection{\cs{jfont} 命令}
3404 \label{ssec:jfont}
3405
3406 %<*en>
3407 To load a font as a Japanese font (for horizontal direction), you must use the
3408 \cs{jfont} instead of~\cs{font}, while
3409 \cs{jfont} admits the same syntax used in~\cs{font}.
3410 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
3411 so TrueType/OpenType fonts with features can be used for Japanese fonts:
3412 %</en>
3413 %<*ja>
3414 フォントを(横組用)和文フォントとして読み込むためには,\cs{jfont} を
3415 \ \cs{font} プリミティブの代わりに用いる.
3416 \cs{jfont} の文法は \cs{font} と同じである.
3417 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
3418 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
3419 ことができる:
3420 %</ja>
3421 \begin{LTXexample}[width=0.25\textwidth]
3422 \jfont\tradmc={IPAexMincho:script=latn;%
3423   +trad;-kern;jfm=ujis} at 14pt
3424 \tradmc 当/体/医/区
3425 \end{LTXexample}
3426
3427 %<*en>
3428 It is required to specify a (horizontal) \emph{JFM} in at each calling of \cs{jfont}.
3429 A JFM is a Lua script which contains
3430 measurements of characters and glues/kerns that are automatically
3431 inserted for Japanese typesetting.
3432 The structure of JFM will be described in the next subsection.
3433 %</en>
3434 %<*ja>
3435 \cs{jfont}命令の実行ごとにどの(横組用)JFMを用いるのかを指定する必要がある.
3436 JFMは文字の寸法情報と和文組版で自動的に挿入される
3437 グルー/カーンの寸法情報を持っているLuaスクリプトで,その構造は次の節で述べる.
3438 %</ja>
3439
3440 %<*en>
3441 Note that the defined control sequence
3442 (\cs{tradmc} in the example above) using \cs{jfont} is not a
3443 \textit{font\_def} token,  but a macro.
3444 Hence the input like \verb+\fontname\tradmc+
3445 causes a error.  We denote control sequences which are defined in
3446 \cs{jfont} by \meta{jfont\_cs}.
3447 %</en>
3448 %<*ja>
3449 なお,\cs{jfont} で定義された制御綴(上の例だと \cs{tradmc})
3450 は\textit{font\_def}トークンではなくマクロである.従って,\verb+\fontname\tradmc+のような
3451 入力はエラーとなる.以下では \cs{jfont} で定義された
3452 制御綴を\meta{jfont\_cs}で表す.
3453 %</ja>
3454
3455 %<en>\paragraph{Specifying JFM}
3456 %<ja>\paragraph{JFMの指定}
3457 %<en> The general scheme for specifying a JFM is the following:
3458 %<ja> JFMの一般的な指定は次のようになっている:
3459 \begin{quote}
3460   \cs{jfont}\meta{jfont\_cs}\texttt{=...;jfm=}\meta{JFM name}[\texttt{/\{}\meta{JFM features}\texttt{\}}]%
3461   \texttt{;...;}[\texttt{jfmvar=}\meta{identifier}]\texttt{;...}
3462 \end{quote}
3463
3464 \begin{figure}
3465 \begin{LTXexample}[width=0.3\textwidth]
3466 \ltjsetparameter{differentjfm=both}
3467 \jfont\F=HaranoAjiMincho-Regular:jfm=ujis
3468 \jfont\G=HaranoAjiGothic-Medium:jfm=ujis
3469 \jfont\H=HaranoAjiGothic-Medium:jfm=ujis;jfmvar=hoge
3470 \F ){\G 【】}( % halfwidth space
3471    ){\H 『』}( % fullwidth space
3472
3473 ほげ,{\G 「ほげ」}(ほげ)\par
3474 ほげ,{\H 「ほげ」}(ほげ)% pTeX-like
3475
3476 \ltjsetparameter{differentjfm=paverage}
3477 \end{LTXexample}
3478 \caption{Example of \texttt{jfmvar} key}
3479 \label{fig:jfmvar}
3480 \end{figure}
3481
3482 %<*en>
3483 \begin{description}
3484 \item[\meta{JFM name}]
3485   The name of a (horizontal) JFM. \LuaTeX-ja searches and loads \texttt{jfm-\meta{JFM name}.lua}
3486   \footnote{When \LuaTeX-ja (version~20230409 or later)
3487     is used under \LaTeXe, \LuaTeX-ja searches a JFM also in directories
3488     which are specified in \cs{input@path}.}.
3489 \item[\meta{JFM features}]
3490   An optional comma-separated list of JFM options.
3491   Enclosing braces (\verb+{}+) are optional, but this does not escape any characters.
3492   The contents of this list can be accessed by a table \texttt{luatexja.jfont.jfm\_feature}
3493   from a JFM, at its loading. See \autoref{fig:jfmfeat} for an example.
3494
3495   Note that any JFM files which is shipped with \LuaTeX-ja does not use this feature.
3496 \item[\meta{identifier}]
3497   An optional string.
3498 \end{description}
3499
3500 LuaTeX-ja ``does not distinguish'' two Japanese fonts which uses same JFM and are the same size.
3501 Here ``uses same JFM'' means that all~of \meta{JFM name}, \meta{JFM features}~and~\meta{identifier} of two fonts
3502 agree.
3503
3504 For example, The first ``)'' and ``【'' in \autoref{fig:jfmvar} are typeset in different real fonts.
3505 However, because they use the same JFMs and their size are same,
3506 \LuaTeX-ja inserts penalties, glues and kerns as if these two character are typeset in a same font.
3507 Namely, the glue between these characters is halfwidth, as in ``)\nobreak【''.
3508 However, this does not applies with \cs{F}~and~\cs{H} in \autoref{fig:jfmvar},
3509 because their \meta{identifier} are different.
3510 %</en>
3511 %<*ja>
3512 \begin{description}
3513 \item[\meta{JFM name}]
3514   (横組用)JFMの名称.\LuaTeX-jaは\texttt{jfm-\meta{JFM name}.lua}というファイルを探索して読み込む
3515   \footnote{\LuaTeX-ja 20230409.0以降では,\LaTeXe 下で読み込まれた場合には
3516     \cs{input@path}で指定された箇所も加えてJFMを探索する.}.
3517 \item[\meta{JFM features}]
3518   省略可能なコンマ区切りリスト.全体を囲む \verb+{}+ は省略可能であるが,
3519   囲ったからといって\meta{JFM features}の中で使用可能な文字が増えるわけではない.
3520   \meta{JFM features}で指定された内容は,テーブル\texttt{luatexja.jfont.jfm\_feature}として
3521   JFM読み込み時に(JFMから)アクセス可能である.\autoref{fig:jfmfeat}に使用例を載せた.
3522
3523   なお,\LuaTeX-jaが標準で提供するJFMではこの機能は用いられていない.
3524 \item[\meta{identifier}]
3525   省略可能な文字列.
3526 \end{description}
3527
3528 \LuaTeX-jaはJFMとサイズが同じで,
3529   実フォントだけが異なる2つの和文フォントは「区別されない」.
3530 ここで「JFMが同じ」とは,両フォントの\meta{JFM name}, \meta{JFM features}, \meta{identifier}が
3531 全て一致することである.
3532
3533 例えば\autoref{fig:jfmvar}において,最初の「)」と「【」の実フォントは異なるが,
3534 JFMもサイズも同じなので,普通に「)\nobreak【」と入力した時と同じように組まれる,つまり両文字の間は半角空きとなる.
3535
3536 しかし,JFMとサイズが同じであっても,\texttt{jfmvar}キーの値\meta{identifier}の異なる
3537 2つの和文フォント,例えば\autoref{fig:jfmvar}で言う\cs{F}と\cs{H},
3538 は「区別される」.異なる和文フォントに異なる \texttt{jfmvar}キーを割り当て,
3539 かつ\Param{differentjfm}パラメータを\texttt{both}に設定すれば,
3540 \pTeX と似た状況で組版されることになる.
3541 %</ja>
3542
3543 \def\T#1{\texttt{#1}}
3544 \def\printjfmfeat#1{%
3545   \relax\texttt{\string#1}: 
3546   \directlua{%
3547     if myjfm then
3548     for i,v in pairs(myjfm) do
3549       tex.sprint('[\string\\T{' .. i .. '}]${}={}$')
3550       if type(v)=='string' then
3551         tex.sprint('``\string\\T{' .. tostring(v) .. "}'', ")
3552       else
3553         tex.sprint(tostring(v) ..', ')
3554       end
3555     end
3556     else tex.sprint('(nil)')
3557     end
3558   }\par
3559 }
3560 \begin{figure}
3561 \begin{LTXexample}[pos=t]
3562 \small\ltjsetparameter{differentjfm=both}\tabcolsep=.5\zw
3563   % \printjfmfeat is defined in the source of this document
3564 \jfont\A=HaranoAjiMincho-Regular:jfm=testf                   at 9pt \printjfmfeat\A
3565 \jfont\B=HaranoAjiMincho-Bold:jfm=testf/kern=0.5,-ps,+kana   at 9pt \printjfmfeat\B
3566 \jfont\C=HaranoAjiGothic-Regular:jfm=testf/kern=0.5,down=0.2 at 9pt \printjfmfeat\C
3567 \jfont\D=HaranoAjiGothic-Bold:jfm=testf/down=0.2,kern=0.5    at 9pt \printjfmfeat\D
3568 \def\TEST#1{\string#1&{#1あ漢}{\A イ字}&{#1あ漢}{\B イ字}&{#1あ漢}{\C イ字}&{#1あ漢}{\D イ字}}
3569 \vspace{-4\baselineskip}\hfill\ttfamily
3570 \begin{tabular}{lllll}
3571   &\string\A&\string\B&\string\C&\string\D\\\TEST\A\\\TEST\B\\\TEST\C\\\TEST\D\\
3572 \end{tabular}
3573   % No space between ``漢'' and ``イ'' iff two Japanese fonts uses same JFM
3574 \ltjsetparameter{differentjfm=paverage}
3575 \end{LTXexample}
3576
3577 \caption{Example of JFM features}
3578 \label{fig:jfmfeat}
3579 \end{figure}
3580
3581 %<en>\paragraph{Horizontal JFMs}
3582 %<ja>\paragraph{横組用JFM}
3583 \begin{table}[t]
3584 %<en>\caption{Differences between horizontal JFMs shipped with \LuaTeX-ja}
3585 %<ja>\caption{\LuaTeX-ja に同梱されている横組用JFMの違い}
3586 %<en>\medskip
3587 \label{tab-difjfm}
3588 \ltjsetparameter{jacharrange={+3}}
3589 \centering\small
3590 \def\r#1#2{%
3591   \hbox{\Large\vrule
3592   \parbox[b]{7\zw}{%
3593     \addjfontfeatures{YokoFeatures={JFM=#1}}\noindent
3594         \color{#2}\transparent{0.5}%
3595     ◆◆◆◆◆◆◆
3596     ある日モモちゃんがお使いで迷子になって泣きました.
3597   }\vrule}}
3598 \def\s#1#2{%
3599   \Large
3600   \parbox[b]{7\zw}{%
3601     \addjfontfeatures{YokoFeatures={JFM=#1}}\noindent
3602         \color{#2}\transparent{0.5}
3603     ちょっと!何
3604   }}
3605 \def\t#1#2#3{\hbox to 0pt{\hss%
3606   \setbox0=\hbox{\addjfontfeatures{YokoFeatures={JFM=#1}}\huge #3}%
3607   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3608   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3609   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3610   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3611   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3612 {\Large\tabcolsep0pt
3613 \begin{tabular}{m{8\zw}m{8\zw}m{8\zw}}
3614 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{jis}{black}&
3615 \leavevmode\hbox to 0pt{\r{jis}{black}\hss}\r{min}{red}&
3616 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{min}{red}\\
3617 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{jis}{black}&
3618 \leavevmode\hbox to 0pt{\s{jis}{black}\hss}\s{min}{red}&
3619 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{min}{red}\\
3620 \leavevmode\qquad\t{ujis}{blue}{漢}\t{jis}{black}{漢}\qquad
3621            \t{ujis}{blue}{っ}\t{jis}{black}{っ}&
3622 \leavevmode\qquad\t{jis}{black}{漢}\t{min}{red}{漢}\qquad
3623            \t{jis}{black}{っ}\t{min}{red}{っ}&
3624 \leavevmode\qquad\t{ujis}{blue}{漢}\t{min}{red}{漢}\qquad
3625            \t{ujis}{blue}{っ}\t{min}{red}{っ}\\
3626 \end{tabular}\par}
3627
3628 (\textcolor{blue}{Blue: \texttt{jfm-ujis.lua}},
3629 \textcolor{black}{Black: \texttt{jfm-jis.lua}},
3630 \textcolor{red}{Red: \texttt{jfm-min.lua}})
3631 \ltjsetparameter{jacharrange={-3}}
3632 \end{table}
3633
3634 %<en> The following horizontal JFMs are shipped with \LuaTeX-ja.
3635 %<ja> 以下の横組用JFMが\LuaTeX-jaには同梱されている:
3636 \begin{description}
3637 %<*en>
3638 \item[\texttt{jfm-ujis.lua}] A standard horizontal JFM of \LuaTeX-ja. This file is
3639   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
3640   is used in \upTeX. When you are going to use the \Pkg{luatexja-otf} package, you should use this JFM.
3641 %</en>
3642 %<*ja>
3643 \item[\texttt{jfm-ujis.lua}] \LuaTeX-jaの標準JFMファイルであり,このJFMは\upTeX で
3644   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
3645   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
3646 %</ja>
3647 %<*en>
3648 \item[\texttt{jfm-jis.lua}] A counterpart for \verb+jis.tfm+, ``JIS font
3649   metric'' which is widely used in \pTeX. A major difference between
3650   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
3651   most characters under \texttt{jfm-ujis.lua} are square-shaped,
3652   while that under \texttt{jfm-jis.lua} are horizontal
3653   rectangles.
3654 %</en>
3655 %<*ja>
3656 \item[\texttt{jfm-jis.lua}] \pTeX で広く用いられている「JISフォントメトリック」
3657   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua} とこの
3658   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
3659   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状であることと,
3660   \texttt{jfm-ujis.lua} では「?」「!」の直後に半角空白が挿入されることである.
3661 %</ja>
3662 %<*en>
3663 \item[\texttt{jfm-min.lua}] A counterpart for \verb+min10.tfm+, which is one
3664   of the default Japanese font metric shipped with \pTeX.
3665 %</en>
3666 %<*ja>
3667 \item[\texttt{jfm-min.lua}] \pTeX に同梱されているデフォルトの和文用TFM
3668 (\verb+min10.tfm+)に相当し,行末で文字が揃うようにするために「っ」など一部の文字幅が変わっ
3669            ている.\verb+min10.tfm+ については\cite{min10}が詳しい.
3670 %</ja>
3671 %<*en>
3672 \item[\texttt{jfm-prop.lua}] A JFM for proportional typesetting.
3673   This JFM doesn't have any information of character dimension (width, height, depth), nor glues/kerns information.
3674 %</en>
3675 %<*ja>
3676 \item[\texttt{jfm-prop.lua}] プロポーショナル組用のJFM.
3677   文字幅・高さ・深さの情報も自動挿入されるグルー・カーンの情報は持たない(つまりグリフの文字幅をそのまま採用する).
3678 %</ja>
3679 %<*en>
3680 \item[\texttt{jfm-propw.lua}] Another JFM for proportional typesetting.
3681   In contrast to \texttt{jfm-prop.lua}, this JFM has informations of character height and depth.
3682 %</en>
3683 %<*ja>
3684 \item[\texttt{jfm-propw.lua}] プロポーショナル組用のさらなるJFM.
3685   \texttt{jfm-prop.lua}と異なり,高さ・深さの情報は持っている.
3686 %</ja>
3687 \end{description}
3688 %<*en>
3689 See \autoref{tab-difjfm} for the difference among \texttt{jfm-ujis.lua}, \texttt{jfm-jis.lua},
3690 \texttt{jfm-min.lua}.
3691 %</en>
3692 %<*ja>
3693 \texttt{jfm-ujis.lua}, \texttt{jfm-jis.lua},
3694 \texttt{jfm-min.lua}の違いは\autoref{tab-difjfm}に示した.表中の文例の一部には,
3695 \cite{min10}の図3,~4のものを用いた.
3696 %</ja>
3697
3698 \begin{figure}
3699 \begin{LTXexample}[pos=t]
3700 \newcommand\test{\vrule ダイナミックダイクマ\vrule\\}
3701 \jfont\KMFW = HaranoAjiMincho-Regular:jfm=prop;-kern at 17.28pt
3702 \jfont\KMFK = HaranoAjiMincho-Regular:jfm=prop at 17.28pt % kern is activated
3703 \jfont\KMPW = HaranoAjiMincho-Regular:jfm=prop;script=dflt;+palt;-kern at 17.28pt
3704 \jfont\KMPK = HaranoAjiMincho-Regular:jfm=prop;script=dflt;+palt;+kern at 17.28pt
3705 \begin{multicols}{2}
3706 \ltjsetparameter{kanjiskip=0pt}
3707 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3708
3709 \ltjsetparameter{kanjiskip=3pt}
3710 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3711 \end{multicols}
3712 \end{LTXexample}
3713 \caption{Kerning information and \Param{kanjiskip}}
3714 \label{fig:kern-jfm}
3715 \end{figure}
3716
3717 %<en>\paragraph{Using kerning information in a font}
3718 %<ja>\paragraph{ペアカーニング情報の使用}
3719 \label{para-kern}
3720 %<*en>
3721 Some fonts have information for inter-glyph spacing.
3722 \LuaTeX-ja 20140324.0 or later treats kerning spaces like an italic correction;
3723 any glue and/or kern from the JFM and a kerning space from the font can coexist.
3724 See \autoref{fig:kern-jfm} for detail.
3725
3726 At version~20220411.0, defaults Japanese fonts which are defined
3727 at the loading of \LuaTeX-ja, \Pkg{ltjclasses},~and~\Pkg{ltjsclasses}
3728 do not insert font-derived kerning spaces by default.
3729 This is because standard JFMs do not expect font-derived kerning spaces
3730 between Japanese characters.
3731
3732 Also note that in \cs{setmainjfont} etc.\ which are provided by \Pkg{luatexja-fontspec}
3733 package, kerning option is set \emph{off} (\texttt{Kerning=Off}) by default.
3734 This means the following two lines have the same meaning:
3735 \begin{lstlisting}
3736 \setmainjfont{HaranoAjiMincho-Regular}
3737 \setmainjfont[Kerning=Off]{HaranoAjiMincho-Regular}
3738 \end{lstlisting}
3739
3740 %</en>
3741 %<*ja>
3742 いくつかのフォントはグリフ間のスペースについての情報を持っている.
3743 このカーニング情報は以前の\LuaTeX-ja とはあまり相性が良くなかったが,
3744 バージョン20140324.0以降ではカーニングによる空白はイタリック補正と同様に扱うことになっている.
3745 つまり,カーニング由来の空白とJFM由来のグルー・カーンは同時に入ることがある.
3746 \autoref{fig:kern-jfm}を参照.
3747 \begin{itemize}
3748  \item \emph{\cs{jfont} や,NFSS2用の命令(\ref{ssec:chgfnt}節,\ref{ssec:nfsspat}節)では,
3749 カーニング情報を使用する設定(OpenType機能\texttt{kern})はとくに指定しなくても有効になる}.
3750 すなわち,以下の2行目と3行目,5行目と6行目はそれぞれ等価である:
3751 \begin{lstlisting}[numbers=left]
3752 \jfont\hoge=hogem:jfm=ujis;-kern at 3.5mm % ==> kern 無効(明示)
3753 \jfont\hoge=hogem:jfm=ujis at 3.5mm       % ==> kern 有効(暗黙)
3754 \jfont\hoge=hogem:jfm=ujis;+kern at 3.5mm % ==> kern 有効(明示)
3755 \DeclareFontShape{JY3}{fuga}{m}{n}{<-> s*hogem:jfm=-ujis}{}    % ==> kern 無効(明示)
3756 \DeclareFontShape{JY3}{fuga}{m}{n}{<-> s*hogem:jfm=ujis}{}     % ==> kern 有効(暗黙)
3757 \DeclareFontShape{JY3}{fuga}{m}{n}{<-> s*hogem:jfm=ujis+kern}{}% ==> kern 有効(明示)
3758 \end{lstlisting}
3759
3760 \item バージョン20220411.0以降では,\LuaTeX-ja読み込み時や,\Pkg{ltjclasses}, \Pkg{ltjsclasses}において
3761   和文フォントを
3762 \begin{lstlisting}
3763 \jfont\tenmin=\ltj@stdmcfont:-kern;jfm=\ltj@stdyokojfm\space at 9.62216pt
3764 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[\ifdefined\Cjascale\Cjascale\else 0.962216\fi]
3765   \ltj@stdmcfont:-kern;jfm=\ltj@stdyokojfm}{}
3766 \end{lstlisting}
3767   とOpenType機能\texttt{kern}を明示的に無効化した状態で定義する.
3768   これは標準JFM(\texttt{jfm-ujis.lua}, \texttt{jfm-ujisv.lua})が
3769   フォント由来のカーニングが入ることを期待していないためである.
3770
3771  \item
3772 一方,\emph{\Pkg{luatexja-fontspec} の提供する \cs{setmainjfont}\
3773 などの命令の標準設定ではカーニング情報は使用しない}(\texttt{Kerning=Off}).
3774 すなわち,次の2行は等価である:
3775 \begin{lstlisting}
3776 \setmainjfont{HaranoAjiMincho-Regular}
3777 \setmainjfont[Kerning=Off]{HaranoAjiMincho-Regular}
3778 \end{lstlisting}
3779 これは前項目の理由の他に,以前のバージョンの\LuaTeX-jaとの互換性のためもある.
3780 \end{itemize}
3781 %</ja>
3782
3783 %<*ja>
3784 \paragraph{\texttt{extend}と\texttt{slant}}
3785 OpenType機能と見かけ上同じような形式で指定できるものに,
3786 \begin{description}
3787 \item[\texttt{extend=}\meta{extend}] 横方向に\meta{extend}倍拡大する.
3788 \item[\texttt{slant=}\meta{slant}] \meta{slant}に指定された割合だけ傾ける.
3789 \end{description}
3790 の2つがある.
3791 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
3792 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
3793 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
3794 正しくない:
3795 %</ja>
3796 %<*en>
3797 \paragraph{\texttt{extend} and \texttt{slant}}
3798 The following setting can be specified as OpenType font features:
3799 \begin{cslist}[style=standard]
3800 \item[\texttt{extend=}\meta{extend}] expand the font horizontally by \meta{extend}.
3801 \item[\texttt{slant=}\meta{slant}] slant the font.
3802 \end{cslist}
3803 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
3804 settings; one have to write new JFMs on purpose.
3805 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
3806 the letterspacing and the width of italic corrections are not correct:
3807 %</en>
3808 \begin{LTXexample}[width=0.3\textwidth]
3809 \jfont\E=HaranoAjiMincho-Regular:extend=1.5;jfm=ujis;-kern
3810 \jfont\S=HaranoAjiMincho-Regular:slant=1;jfm=ujis;-kern
3811 \E あいうえお \S あいう\/ABC
3812 \end{LTXexample}
3813
3814 %<*ja>
3815 \paragraph{\texttt{ltjksp}「機能」}
3816 \label{pg:ltjksp}
3817 \LuaTeX-ja標準では,
3818 JFM中における\texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
3819 \texttt{kanjiskip\_shrink}キー(\pageref{pg:ksp_nat}ページ)の使用によって,
3820 「JFM由来のグルーの他に,\Param{kanjiskip}の自然長/伸び量/縮み量の一部が
3821 同じ場所に挿入される」という状況が起こりうる.
3822 この機能を無効化し,バージョン20150922.0以前と同じような組版を得るためには,
3823 他のOpenType機能と同じように\>\mbox{\texttt{-ltjksp}}\>指定を行えば良い(\autoref{fig:ltjksp}参照).
3824 なお,
3825 \begin{lstlisting}
3826  \jfont\G=HaranoAjiMincho-Regular:jfm=ujis;-ltjksp;+ltjksp at \zw
3827 \end{lstlisting}
3828 のように\texttt{+ltjksp}指定を行った場合は,\texttt{kanjiskip\_natural}など
3829 3キーは再び有効化される.\texttt{-ltjksp}, \texttt{+ltjksp}を複数回指定した場合は,
3830 最後に指定したものが有効となる.
3831 %</ja>
3832 %<*en>
3833 \paragraph{\texttt{ltjksp} ``feature''}
3834 \label{pg:ltjksp}
3835 \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
3836 \texttt{kanjiskip\_shrink} keys (Page~\pageref{pg:ksp_nat}) makes tha
3837 \LuaTeX-ja inserts not only a glue which is specified by a JFM, and also
3838 the natural width/stretch part/shrink part of \Param{kanjiskip}.
3839 This functionality is disabled by \mbox{\texttt{-ltjksp}} specification,
3840 as shown in~\autoref{fig:ltjksp}.
3841 %</en>
3842 \begin{figure}
3843 \begin{LTXexample}[width=16\zw]
3844 \leavevmode
3845 \ltjsetparameter{kanjiskip=0pt plus 3\zw}
3846 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule\\
3847 \jfont\G=HaranoAjiMincho-Regular%
3848   :jfm=ujis;-ltjksp at \zw
3849 \G\leavevmode%
3850 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
3851 \end{LTXexample}
3852 \caption{\texttt{ltjksp} ``feature''}
3853 \label{fig:ltjksp}
3854 \end{figure}
3855
3856 %<*ja>
3857 \paragraph{\texttt{ltjpci}「機能」}
3858 \label{pg:ltjpci}
3859 \Pkg{luaotfload}~v3.19以降では,標準でUnicode(文字から作られるノードたち)がNFCに正規化される
3860 ようになっている.これにより,ソース中でたとえば「か」と合成用濁点(\texttt{U+3099})を続けて入力した場合,
3861 両者それぞれからノードが生成されるが,結果的には「が」を表す1ノードになるわけである.
3862
3863 しかし,NFCに正規化することで,
3864 たとえば「\UTF{FA19}」(\texttt{U+FA19})が「神」(\texttt{U+795E})にというふうに,
3865 CJK互換漢字がCJK統合漢字に変換されてしまうという問題がある.
3866 異体字セレクタを用いればこのようなことは起きないが,古くからあるフォントでは異体字セレクタをサポートしていない.
3867
3868 以上の事情に対応するため,\LuaTeX-jaでは,標準で
3869 \emph{CJK互換漢字・CJK互換漢字補助の文字には\Pkg{luaotfload}パッケージによる処理は働かない}ようにしている.
3870 この機能を無効化するには,他のOpenType機能と同じように\texttt{-ltjpci}指定を行えば良い(\autoref{fig:ltjpci}参照).
3871 \texttt{ltjksp}と同様に,\texttt{-ltjpci}, \texttt{+ltjpci}を複数回指定した場合は,
3872 最後に指定したものが有効となる.
3873 %</ja>
3874 %<*en>
3875 \paragraph{\texttt{ltjpci} ``feature''}
3876 \label{pg:ltjpci}
3877 By default, The \Pkg{luaotfload} package (since v3.19) normalizes Unicode sequences to NFC.
3878 However, this normalization converts CJK compatibility ideographs to their canonical equivalents,
3879 such as ``\UTF{FA19}''~(\texttt{U+FA19}) to ``神''. One can use variation selectors,
3880 but old fonts does not support them.
3881
3882 So, \emph{\LuaTeX-ja now protects CJK compatibility ideographs from processing
3883  by the \Pkg{luaotfload} package by defualt}.
3884 This functionality is disabled by \mbox{\texttt{-ltjpci}} specification,
3885 as shown in~\autoref{fig:ltjpci}.
3886 %</en>
3887 \begin{figure}
3888 \begin{LTXexample}[width=12\zw]
3889 \def\TEST{\leavevmode\char"FA10\char"FA12\char"FA15
3890   \char"FA19.か\char"3099.は\char"309A.\par}
3891 \jfont\A=HaranoAjiMincho-Regular:jfm=ujis; at 15pt
3892 \A\TEST % default
3893 \jfont\G=HaranoAjiMincho-Regular:jfm=ujis;-ltjpci at 15pt
3894 \G\TEST % ltjpci off
3895 \jfont\H=HaranoAjiMincho-Regular:jfm=ujis;-normalize at 15pt
3896 \H\TEST % normalization off
3897 \end{LTXexample}
3898 \caption{\texttt{ltjpci} ``feature''}
3899 \label{fig:ltjpci}
3900 \end{figure}
3901
3902 %<en>\subsection{\cs{tfont}}
3903 %<ja>\subsection{\cs{tfont} 命令}
3904 \label{ssec:tfont}
3905
3906 \begin{comment}
3907 \begin{table}[t]
3908 %<en>\caption{Differences between vertical JFMs shipped with \LuaTeX-ja}
3909 %<ja>\caption{\LuaTeX-ja に同梱されている縦組用 JFM の違い}
3910 %<en>\medskip
3911 \label{tab-difjfm-tate}
3912 \ltjsetparameter{jacharrange={+3}}
3913 \small
3914 \def\r#1#2{%
3915   \hbox{\tate\Large\vrule
3916   \parbox{7\zw}{%
3917     \addjfontfeatures{TateFeatures={JFM=#1}}\noindent
3918         \color{#2}\transparent{0.5}
3919     ◆◆◆◆◆◆◆
3920     ある日モモちゃんが「お使い」で迷子になって泣きました。
3921   }\vrule}}
3922 \def\s#1#2{%
3923   \hbox{\tate\Large
3924   \parbox{7\zw}{%
3925     \addjfontfeatures{TateFeatures={JFM=#1}}\noindent
3926         \color{#2}\transparent{0.5}
3927     ちょっと!何
3928   }}}
3929 \def\t#1#2#3{\hbox to 0pt{\hss%
3930   \setbox0=\hbox{\addjfontfeatures{TateFeatures={JFM=#1}}\huge #3}%
3931   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3932   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3933   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3934   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3935   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3936
3937 \begin{minipage}{.7\textwidth}
3938 \centering
3939 \leavevmode\hbox to 0pt{\r{ujisv}{blue}\hss}\r{tmin}{red}\quad
3940 \leavevmode\hbox to 0pt{\s{ujisv}{blue}\hss}\s{tmin}{red}\quad
3941 \raise4\zw\hbox{\tate\Large\t{ujisv}{black}{漢}\t{tmin}{red}{漢}\qquad
3942            \t{ujisv}{black}{っ}\t{tmin}{red}{っ}}
3943 \end{minipage}%
3944 \begin{minipage}{.3\textwidth}
3945 \textcolor{blue}{Blue: \texttt{jfm-ujisv.lua}}\\
3946 \textcolor{red}{Red: \texttt{jfm-tmin.lua}}
3947 \end{minipage}
3948 \ltjsetparameter{jacharrange={-3}}
3949 \end{table}
3950 \end{comment}
3951
3952 %<*en>
3953 \cs{tfont} loads a font as a Japanese font for vertical direction.
3954 This command admits the same syntax as in \cs{font}~and~\cs{jfont}.
3955 A font defined by~\cs{tfont} differs the following points from that by~\cs{jfont}:
3956 \begin{itemize}
3957  \item OpenType Feature~\texttt{vrt2}%
3958   \footnote{If the font does not define the \texttt{vrt2} feature,
3959         \texttt{vert} is used instead.} is automatically activated,
3960   unless \texttt{vert}~and//or~\texttt{vrt2} features are explicitly activated
3961   or deactivated (as the second line in the example below).
3962 \begin{lstlisting}
3963 \tfont\S=HaranoAjiMincho-Regular:jfm=ujisv % vrt2 is automatically activated
3964 \tfont\T=HaranoAjiMincho-Regular:jfm=ujisv;-vert % vert and vrt2 are not activated
3965 \tfont\U=file:ipaexm.ttf:jfm=ujisv
3966     % vert is automatically activated, since this font does not have vrt2
3967 \end{lstlisting}
3968  \item Sometimes \texttt{vert} and/or \texttt{vrt2} are not activated
3969  while one specified activation of these feature.
3970  This is because the font does not define these features in current combination of
3971  script~tag and language~system~identifier.
3972
3973  In this situation, \LuaTeX-ja performs all replacements which is defined in~\texttt{vert}
3974  feature for \emph{some} scripts for \emph{some} languages.
3975  \item \cs{tfont} uses a vertical JFM instead of a horizontal JFM.
3976 \LuaTeX-ja ships following vertical JFMs:
3977 \begin{description}
3978 \item[\texttt{jfm-ujisv.lua}] A standard vertical JFM in \LuaTeX-ja. This JFM is
3979   based on \verb+upnmlminr-v.tfm+, a metric for UTF/OTF package that
3980   is used in \upTeX.
3981 \item[\texttt{jfm-tmin.lua}] A counterpart for \verb+tmin10.tfm+, which is one
3982   of the default Japanese font metric shipped with \pTeX.
3983 \end{description}
3984 \begin{figure}[!tb]
3985 \begin{LTXexample}[pos=b]
3986 \jfont\X=[HaranoAjiMincho-Regular.otf]:jfm=ujis
3987 \tfont\U=[HaranoAjiMincho-Regular.otf]:jfm=ujisv
3988 \tfont\V=[HaranoAjiMincho-Regular.otf]:jfm=ujisv;jpotf
3989 \def\TEST#1#2{\leavevmode\hbox{#1#2\string#2 “引用,と句読点.”}}
3990 \ttfamily\centering\TEST\yoko\X \quad \TEST\tate\U \quad \TEST\tate\V
3991 \end{LTXexample}
3992 \caption{\texttt{jpotf} ``feature''}
3993 \label{fig:jpotf}
3994 \end{figure}
3995   
3996  \item If \texttt{vert}~and/or~\texttt{vrt2} features are activated,
3997   one can specify \texttt{jpotf} to additional substitutions.
3998   By default, it substitutes ideographic comma/period for fullwidth comma/period,
3999   and double prime quotation marks for double quotation marks
4000   (See~\autoref{fig:jpotf}).
4001   One can customize substitutions by lua~function \verb+luatexja.jfont.register_vert_replace+\ %
4002   (see Japanese version of this manual).
4003 \end{itemize}
4004 %</en>
4005 %<*ja>
4006 \cs{tfont} はフォントを縦組用の和文フォントとして読み込む命令であり,
4007 \cs{tfont}の構文は\cs{jfont}と同様である.
4008 \cs{tfont}で定義された縦組用和文フォントは,
4009 以下の点が\cs{jfont}による横組用和文フォントとは異なる:
4010 \begin{itemize}
4011  \item 明示的にOpenType機能\texttt{vert}, \texttt{vrt2}(のいずれか)の
4012   有効・無効を指定した場合を除き,自動的にOpenType機能\texttt{vrt2}の有効化が
4013   指定されたものとみなされる
4014  \footnote{もしフォントが\texttt{vrt2}を定義していなかった場合,代わりに
4015  \texttt{vert}を用いる.}.
4016 \begin{lstlisting}
4017 \tfont\S=HaranoAjiMincho-Regular:jfm=ujisv % vrt2 is automatically activated
4018 \tfont\T=HaranoAjiMincho-Regular:jfm=ujisv;-vert % vert and vrt2 are not activated
4019 \tfont\U=file:ipaexm.ttf:jfm=ujisv
4020     % vert is automatically activated, since this font does not have vrt2
4021 \end{lstlisting}
4022  \item \texttt{vert}, \texttt{vrt2}の少なくとも一つの有効を指定した場合にも関わらず,
4023   script tagとlanguage system identifierの値の組み合わせによって
4024   実際には有効にならなかった場合,\LuaTeX-jaは
4025  \begin{quote}
4026    どれかのscript,~languageで定義されている\texttt{vert}による
4027    (単一グリフから単一グリフへの)置換を全部適用する
4028  \end{quote}
4029   という挙動を取る\footnote{%
4030   例えば,Windows~7に付属しているSimHeiでは,\texttt{vert}はScriptが\texttt{hani},
4031   Languageが\texttt{CHN}という状況でのみ定義されている.しかし,\Pkg{luaotfload}では
4032   このscript,~languageの組み合わせを指定することはできないので,
4033   \Pkg{luaotfload}そのままでは\texttt{vert}を適用させることはできない.
4034  }.
4035  \item さらに,置換前と置換後のグリフがどちらも「UAX~\#50で``r''もしくは``Tr''と指定されている」ものは90度自動回転させる.
4036  \item \ref{ssec:math}節で述べる,数式中の和文フォントには縦組用和文フォントは指定できない.
4037  \item \meta{JFM name}には縦組用JFMを指定する.
4038 以下の縦組用JFMが\LuaTeX-jaには同梱されている.%おり,違いを\autoref{tab-difjfm-tate}に示した.
4039 \begin{description}
4040 \item[\texttt{jfm-ujisv.lua}] \LuaTeX-jaの標準縦組用JFMである.このJFMは\upTeX で
4041   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-v.tfm+ を
4042   元にしている.
4043 \item[\texttt{jfm-tmin.lua}] \pTeX に同梱されているデフォルトの和文用縦組TFM
4044   である \verb+tmin10.tfm+ に相当し,\texttt{min10.tfm} と同様に
4045   「っ」など一部の文字幅が狭められている.
4046 \end{description}
4047
4048 \begin{figure}[!tb]
4049 \begin{LTXexample}[pos=r,width=.4\textwidth]
4050 \jfont\X=[HaranoAjiMincho-Regular.otf]:jfm=ujis
4051 \tfont\U=[HaranoAjiMincho-Regular.otf]:jfm=ujisv
4052 \tfont\V=[HaranoAjiMincho-Regular.otf]:jfm=ujisv;jpotf
4053 \def\TEST#1#2{\leavevmode
4054   \hbox{#1#2\string#2 “引用,と句読点.”}}
4055 \ttfamily\centering
4056 \TEST\yoko\X\quad \TEST\tate\U\quad
4057 \TEST\tate\V
4058 \end{LTXexample}
4059 \caption{\texttt{jpotf} ``feature''}
4060 \label{fig:jpotf}
4061 \end{figure}
4062 \begin{table}[t]
4063   \def\D#1#2#3#4{%
4064         {\fboxsep0pt\fcolorbox{cyan}{white}%
4065     {\large\lower-\cdp\hbox{\tate\ltjjachar"#1#2#3#4}}}\ (\texttt{U+#1#2#3#4})%"
4066   }
4067   \caption{\texttt{jpotf}が指定された際に行われる追加の縦組形への置換}
4068   \label{tab:vert_replace_jpotf}\small\centering
4069   \begin{tabular}{*{2}{l@{}>{${}\longmapsto{}$}c@{}l}}
4070         \toprule
4071         \D FF0C&&\D 3001&\D FF0E&&\D 3002\\
4072         \D 201C&&\D 301D&\D 201D&&\D 301F\\
4073         \bottomrule
4074   \end{tabular}
4075 \end{table}
4076
4077  \item \texttt{vert}, \texttt{vrt2}の少なくとも片方が(明示的・自動的を問わず)
4078   有効になっていた場合,さらに\texttt{jpotf}を指定することで
4079   「通常では行わない縦組用字形への置換」を行うことができる.
4080   
4081   標準では,\autoref{tab:vert_replace_jpotf}に示した置換が登録されている
4082   \footnote{%
4083         \texttt{jpotf}という名前にしたのは,
4084         OTFパッケージの縦組用和文TFMでほぼ同じの処理(そちらではさらに一重引用符を
4085         「シングルミニュート」に置換する機能もあった)を行っていたことに由来する.
4086   }.実行例は\autoref{fig:jpotf}を参照.
4087
4088   ユーザ側で「置換」をカスタマイズしたい場合,
4089   \verb+luatexja.jfont.register_vert_replace+関数に変更内容を記したテーブルを渡す.
4090   例えば置換$i_1\longmapsto v_1$, $i_2\longmapsto v_2$,~$\dots$を登録する場合は
4091         \begin{lstlisting}[escapechar=\!]
4092 \directlua{luatexja.jfont.register_vert_replace{[!$i_1$!]=!$v_1$!, [!$i_2$!]=!$v_2$!, ...}}
4093         \end{lstlisting}
4094   を実行する.
4095   \verb+luatexja.jfont.register_vert_replace+による変更はこの関数の\emph{実行後}に定義される
4096   フォントについてのみ有効である.
4097   
4098 \end{itemize}
4099
4100 なお,\pTeX では,\cs{font},~\cs{jfont},~\cs{tfont}のどれでも欧文フォント・横組用和文フォン
4101 ト・縦組用和文フォントの定義が可能であったが,\LuaTeX-jaではそうでないので注意.
4102 %</ja>
4103
4104 %<en>\subsection{Default Japanese fonts and JFMs}
4105 %<ja>\subsection{標準和文フォント・JFMの変更}
4106 \label{ssec:cfg}
4107 %<*en>
4108 If following commands are defined at loading \LuaTeX-ja package, these change
4109 default Japanese fonts and JFMs for them:
4110 %</en>
4111 %<*ja>
4112 \LuaTeX-jaが読み込まれる前に以下の命令が定義されていた場合は,
4113 それらが標準和文フォントやそれらに用いるJFMとして使われる.
4114 %</ja>
4115
4116 \begin{cslist}[style=standard]
4117   \item[\cs{ltj@stdmcfont}] 
4118 %<en>The default Japanese font for the mincho family.
4119 %<ja>明朝体として用いるフォント.
4120   \item[\cs{ltj@stdgtfont}]
4121 %<en>The default Japanese font for the gothic family.
4122 %<ja>ゴシック体として用いるフォント.
4123   \item[\cs{ltj@stdyokojfm}]
4124 %<en>The default JFM for horizontal direction.
4125 %<ja>標準で用いる横組用JFM.
4126   \item[\cs{ltj@stdtatejfm}]
4127 %<en>The default JFM for vertical direction.
4128 %<ja>標準で用いる縦組用JFM.
4129 \end{cslist}
4130
4131 %<*en>
4132 For example,
4133 \begin{lstlisting}
4134 \def\ltj@stdmcfont{IPAMincho}
4135 \def\ltj@stdgtfont{IPAGothic}
4136 \end{lstlisting}
4137 makes that IPA~Mincho and IPA~Gothic will be used as default Japanese fonts, instead of
4138 Harano Aji fonts.
4139 %IPAex~Mincho and IPAex~Gothic.
4140
4141 This feature is intended for classes which use special JFMs%
4142 \footnote{This is because commands has \texttt{@} in their names.}.
4143 It is recommended to use \cs{luatexja-preset}~or~\cs{luatexja-fontspec} package
4144 to select standard fonts in ordinary \LaTeX\ sources.
4145 %</en>
4146 %<*ja>
4147 例えば
4148 \begin{lstlisting}
4149 \def\ltj@stdmcfont{IPAMincho}
4150 \def\ltj@stdgtfont{IPAGothic}
4151 \end{lstlisting}
4152 と記述しておけば,標準和文フォントがIPA明朝・IPAゴシックへと変
4153 更される.
4154
4155 この機能は,特別のJFMを用いるクラス
4156 \footnote{例えば阿部紀行氏によるjlreqがそれにあたる.}%
4157 などでの使用を意図しており,命令名に\texttt{@}が含まれることから
4158 通常の\TeX/\LaTeX 文書での使用は意図していない.
4159 通常の\LaTeX 文書では\Pkg{luatexja-preset}や\Pkg{luatexja-fontspec}などで
4160 使用フォントを選択することを推奨する.
4161 %</ja>
4162
4163 %<*en>
4164 For compatibility with earlier versions,
4165 \LuaTeX-ja reads  \texttt{luatexja.cfg} automatically if it is found by \LuaTeX.
4166 One should not overuse this \texttt{luatexja.cfg}; it will overwrite
4167 the definition of \cs{ltj@stdmcfont} and others.
4168 %</en>
4169 %<*ja>
4170 旧バージョンとの互換性のため,
4171 \LuaTeX から見える位置に\texttt{luatexja.cfg}があれば,\LuaTeX-jaはそれを読み込む.
4172 しかし,\texttt{luatexja.cfg}内で\cs{ltj@stdmcfont}等が定義されていた場合はそちらが
4173 優先されるので,もはや\texttt{luatexja.cfg}は使わないほうが良いだろう.
4174 %</ja>
4175
4176 %<en>\subsection{Prefix \texttt{psft}}
4177 %<ja>\subsection{\texttt{psft}プリフィックス}
4178 \label{ssec:psft}
4179 %<*en>
4180 Besides ``\texttt{file}''\ and ``\texttt{name}''\ prefixes which
4181 are introduced in the \Pkg{luaotfload} package,
4182 \LuaTeX-ja adds ``\texttt{psft}''\ prefix in \cs{jfont} (and~\cs{font}),
4183 to specify a ``name-only'' Japanese font which
4184 will not be embedded to PDF.
4185 Note that these non-embedded fonts under current \LuaTeX\ has Identity-H encoding,
4186 and this violates the standard ISO32000-1:2008~(\cite{pdfstd}).
4187
4188 \emph{OpenType font features, such as ``\texttt{+jp90}'',
4189 have no meaning in name-only fonts using ``\texttt{psft}''\ prefix,
4190 because we can't expect what fonts are actually used by the PDF reader.}
4191 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
4192 with \texttt{psft} prefix, because they are only simple linear transformations.
4193 %</en>
4194 %<*ja>
4195 \Pkg{luaotfload}で使用可能になった
4196 \texttt{file}\ と \texttt{name}\ のプリフィックスに加えて,
4197 \cs{jfont}(と \cs{font} プリミティブ)では
4198 \texttt{psft}\ プリフィックスを用いることができる.
4199 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
4200 和文フォントを指定することができる.
4201 なお,現行の\LuaTeX で非埋め込みフォントを作成するとPDF内でのエンコーディングが
4202 Identity-Hとなり,PDFの標準規格ISO32000-1:2008~(\cite{pdfstd})に非準拠になってしまう
4203 ので注意してほしい.
4204
4205 \emph{\texttt{psft} プリフィックスの下では
4206 \texttt{+jp90} などのOpenType機能の効力はない.
4207 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
4208 表示に用いられるか予測できないからである.}\
4209 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
4210 \texttt{psft} プリフィックスでも使用可能である.
4211 %</ja>
4212
4213 %<en>\paragraph{\texttt{cid} key}
4214 %<ja>\paragraph{\texttt{cid}キー}
4215 \label{para-cid}
4216
4217 %<*en>
4218 The default font defined by using \texttt{psft} prefix is for Japanese typesetting;
4219 it is Adobe-Japan1-7 CID-keyed font.
4220 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
4221 for Chinese or Korean typesetting.
4222 %</en>
4223 %<*ja>
4224 標準で\texttt{psft}\ プリフィックスで定義されるフォントは日本語用のもので
4225 あり,Adobe-Japan1-7のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
4226 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
4227 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
4228
4229 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
4230 %</ja>
4231 \begin{lstlisting}[numbers=left]
4232 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-7;jfm=jis}    % Japanese
4233 \jfont\testD={psft:Ryumin-Light:jfm=jis}                       % default: Adobe-Japan1-7
4234 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-7;jfm=jis}% Traditional Chinese
4235 \jfont\testG={psft:SimSun:cid=Adobe-GB1-6;jfm=jis}             % Simplified Chinese
4236 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}          % Korean
4237 \jfont\testKR={psft:SourceHanSerifAKR9:cid=Adobe-KR-9;jfm=jis} % Korean
4238 \end{lstlisting}
4239 %<*en>
4240 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
4241 as JFM for Chinese and Korean fonts.
4242 %</en>
4243 %<*ja>
4244 上のコードでは中国語・韓国語用フォントに対してもJFMに
4245 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
4246 %</ja>
4247
4248 %<*en>
4249 At present, \LuaTeX-ja supports only 5 values written in the sample code above.
4250 Specifying other values, e.g.,
4251 %</en>
4252 %<*ja>
4253 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた5つの値しかサポートしていない.
4254 %</ja>
4255 \begin{lstlisting}
4256 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
4257 \end{lstlisting}
4258 %<*en>
4259 produces the following error:
4260 %</en>
4261 %<*ja>
4262 のようにそれら以外の値を指定すると,エラーが発生する:
4263 %</ja>
4264 \begin{lstlisting}[numbers=left]
4265 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
4266
4267 See the luatexja package documentation for explanation.
4268 Type  H <return>  for immediate help.
4269 <to be read again>
4270                    \par
4271 l.78
4272
4273 ? h
4274 I couldn't find any non-embedded font information for the CID
4275 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
4276 Please contact the LuaTeX-ja project team.
4277 ?
4278 \end{lstlisting}
4279
4280 %<en>\subsection{Structure of a JFM file}
4281 %<ja>\subsection{JFMファイルの構造}
4282 \label{ssec:jfm-str}
4283 %<en>A JFM file is a Lua script which has only one function call:
4284 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
4285 \begin{lstlisting}
4286 luatexja.jfont.define_jfm { ... }
4287 \end{lstlisting}
4288 %<*en>
4289 Real data are stored in the table which indicated above by
4290 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
4291 structure of this table.  Note that all lengths in a JFM file are
4292 floating-point numbers in design-size unit.
4293 %</en>
4294 %<*ja>
4295 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
4296 以下ではこのテーブルの構造について記す.
4297 なお,JFMファイル中の長さは全てdesign sizeを単位とする浮動小数点数であることに
4298 注意する.
4299 %</ja>
4300
4301 \begin{cslist}[style=standard]
4302
4303 \item[version=\meta{version}]
4304 %<en>(optional, default value is~1)
4305 %<ja>(任意,既定値は1)
4306
4307 %<*en>
4308 The version JFM. Currently 1,~2,~and,~3 are supported
4309 %</en>
4310 %<*ja>
4311 JFMのバージョン.1,~2,~3がサポートされる.
4312 %</ja>
4313   
4314 \item[dir=\meta{direction}]
4315 %<en>(required)
4316 %<ja>(必須)
4317
4318 %<*en>
4319 The direction of JFM. \texttt{'yoko'}~(horizontal)
4320 or \texttt{'tate'}~(vertical) are supported.
4321 %</en>
4322 %<*ja>
4323 JFMの書字方向.\texttt{'yoko'}(横組)と \texttt{'tate'}(縦組)がサポートされる.
4324 %</ja>
4325
4326 \item[zw=\meta{length}]
4327 %<en>(required)
4328 %<ja>(必須)
4329
4330 %<en>The amount of the length of the ``full-width''.
4331 %<*ja>
4332 「全角幅」の長さ.この量が \cs{zw} の長さとなる.\pTeX では
4333 「全角幅」\texttt{1zw} は「文字クラス0の文字」の幅と決められていたが,
4334 \LuaTeX-jaではここで指定する.
4335 %</ja>
4336
4337 \item[zh=\meta{length}]
4338 %<en>(required)
4339 %<ja>(必須)
4340
4341 %<en>The amount of the ``full-height'' (height + depth).
4342 %<*ja>
4343 「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
4344 \pTeX では 「全角高さ」\texttt{1zh} は「文字クラス0の文字」の高さと深さの和と決められていたが,
4345 \LuaTeX-jaではここで指定する.
4346 %</ja>
4347
4348 \item[kanjiskip=\{\meta{natural}, \meta{stretch}, \meta{shrink}\}]
4349 %<en>(optional)
4350 %<ja>(任意)
4351
4352 %<*en>
4353 This field specifies the ``ideal'' amount of \Param{kanjiskip}. As noted
4354              in Subsection~\ref{subs-kskip}, if the parameter
4355              \Param{kanjiskip} is \cs{maxdimen}, the value specified
4356              in this field is actually used (if this field is not specified in
4357              JFM, it is regarded as 0\,pt). Note that \meta{stretch} and \meta{shrink}
4358              fields are in design-size unit too.
4359 %</en>
4360 %<*ja>
4361 理想的な\Param{kanjiskip}の量を指定する.\ref{subs-kskip}節で述べたように,
4362 もし\Param{kanjiskip}が \cs{maxdimen} の値ならば,このフィールドで指定された
4363 値が実際には用いられる(指定なしは0\,ptとして扱われる).\meta{stretch}と\meta{shrink}のフィールドもdesign size
4364 が単位であることに注意せよ.
4365 %</ja>
4366
4367 \item[xkanjiskip=\{\meta{natural}, \meta{stretch}, \meta{shrink}\}]
4368 %<en>(optional)
4369 %<ja>(任意)
4370
4371 %<*en>
4372 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
4373              amount of \Param{xkanjiskip}.
4374 %</en>
4375 %<*ja>
4376 \texttt{kanjiskip}フィールドと同様に,\Param{xkanjiskip}の理想的な量を
4377 指定する.
4378 %</ja>
4379 \end{cslist}
4380
4381 %<*en>
4382 \paragraph{Character classes}
4383 Besides from above fields, a JFM file have several sub-tables those
4384 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
4385 information of \emph{character class}~$i$. At least, the character class~0 is
4386 always present, so each JFM file must have a sub-table whose index is
4387 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
4388 the following fields:
4389 %</en>
4390 %<*ja>
4391 \paragraph{文字クラス}
4392 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
4393 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
4394 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
4395 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
4396 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
4397 %</ja>
4398
4399 \begin{cslist}[style=standard]
4400 \item[chars=\{\meta{character}, ...\}]
4401 %<en>(required except character class~0)
4402 %<ja>(文字クラス0を除いて必須)
4403
4404 %<*en>
4405 This field is a list of characters which are in this character
4406              type~$i$. This field is optional if $i=0$, since all
4407              \textbf{JAchar} which do not belong  any character classes other
4408              than 0 are in the character class 0
4409              (hence, the character class~0 contains most of
4410              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
4411 \begin{itemize}
4412 \item a Unicode code point
4413 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
4414 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
4415 \item several ``imaginary'' characters (We will describe these later.)
4416 \end{itemize}
4417 %</en>
4418 %<*ja>
4419 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
4420 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
4421 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
4422 \begin{itemize}
4423 \item Unicode におけるコード番号
4424 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
4425 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
4426 \item いくつかの「仮想的な文字」(後に説明する)
4427 \end{itemize}
4428 %</ja>
4429
4430 \item[width=\meta{length}, height=\meta{length}, depth=\meta{length}, italic=\meta{length}]
4431 %<en>(required)
4432 %<ja>(必須)
4433
4434 %<*en>
4435 \begin{table}[t]
4436  \centering
4437 \begin{tabular}{llr}
4438 \toprule
4439 Direction of JFM&\textbf{\texttt{'yoko'} (horizontal)}&\multicolumn{1}{l}{\textbf{\texttt{'tate'} (vertical)}}\\
4440 \midrule
4441 \texttt{width} field&\multicolumn{2}{c}{the width of the ``real'' glyph}\\
4442 \texttt{height} field&the height of the ``real'' glyph&0.0\\
4443 \texttt{depth} field&the depth of the ``real'' glyph&0.0\\
4444 \midrule
4445 \texttt{italic} field&\multicolumn{2}{c}{0.0}\\
4446 \bottomrule
4447 \end{tabular}
4448 \caption{Default values of \texttt{width} field and other fields}
4449 \label{tab-wid}
4450 \end{table}
4451 Specify the width of characters in character class~$i$, the height, the depth and
4452 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
4453 as values of these fields. The default values are shown in \autoref{tab-wid}.
4454 %</en>
4455 %<*ja>
4456 \begin{table}[t]
4457  \centering
4458 \begin{tabular}{llr}
4459 \toprule
4460 JFM書字方向&\emph{\texttt{'yoko'}(横組)}&\multicolumn{1}{l}{\emph{\texttt{'tate'}(縦組)}}\\
4461 \midrule
4462 \texttt{width}&\multicolumn{2}{c}{「実際のグリフ」の幅}\\
4463 \texttt{height}&「実際のグリフ」の高さ&0.0\\
4464 \texttt{depth}&「実際のグリフ」の深さ&0.0\\
4465 \midrule
4466 \texttt{italic}&\multicolumn{2}{c}{0.0}\\
4467 \bottomrule
4468 \end{tabular}
4469 \caption{\texttt{width} フィールド等の標準値}
4470 \label{tab-wid}
4471 \end{table}
4472 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
4473 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
4474 値であるものとして扱われる.省略時や,数でない値を指定した時には表\nobreak\ref{tab-wid}に
4475              示されている値を用いる.例えば,横組用JFMで \texttt{width} フィールドには数値以外の値を指
4476              定した場合,文字の幅はその「実際の」グリフの幅となる.OpenTypeの \texttt{prop} featureと併用
4477              すれば,これによってプロポーショナル組を行うことができる.
4478 %</ja>
4479
4480 \item[left=\meta{length}, down=\meta{length}, align=\meta{align}]\
4481
4482 %<*en>
4483 These fields are for adjusting the position of the ``real'' glyph. Legal
4484              values of \texttt{align} field are \texttt{'left'},
4485              \texttt{'middle'}, and \texttt{'right'}. If one of these
4486              3~fields are omitted, \texttt{left} and \texttt{down} are
4487              treated as~0, and \texttt{align} field is treated as
4488              \texttt{'left'}.
4489 The effects of these 3~fields are indicated in
4490 \autoref{fig:pos}~and~\autoref{fig:pos-tate}.
4491 %</en>
4492 %<*ja>
4493 これらのフィールドは実際のグリフの位置を調整するためにある.
4494 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
4495 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
4496 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
4497 \ \texttt{'left'} であるものとして扱われる.
4498 これら3つのフィールドの意味については\autoref{fig:pos}(横組用和文フォント),
4499 \autoref{fig:pos-tate}(縦組用和文フォント)で説明する.
4500 %</ja>
4501
4502 %<*en>
4503 In most cases, \texttt{left} and \texttt{down} fields are~0, while
4504 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
4505 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
4506 when the current character class is the class for opening delimiters'.
4507 %</en>
4508 %<*ja>
4509 多くの場合,\texttt{left}と\texttt{down}は0である一方,
4510 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
4511 珍しいことではない.
4512 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
4513 文字クラスが開き括弧類であるときに実際必要である.
4514 %</ja>
4515
4516 \begin{figure}[!tb]
4517 \begin{minipage}{0.4\textwidth}%
4518 \begin{center}\unitlength=10pt\small
4519 \begin{picture}(15,12)(-1,-4)
4520 \color{b_gray}% jfm
4521 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
4522
4523 \color{b_pink}% step1
4524 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4525
4526 \color{red}% real glyph
4527 \thicklines
4528 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4529 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
4530 \put(-1,5.5){\line(1,0){6}}
4531 \put(-1,-4){\line(1,0){6}}
4532
4533 \color{b_green}% real glyph
4534 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4535
4536 \color{black}% jfm
4537 \thicklines
4538 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
4539 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
4540 \put(0,8){\line(1,0){12}}
4541 \put(0,-3){\line(1,0){12}}
4542 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
4543 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
4544 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
4545
4546 \color{green}% step1
4547 \thicklines
4548 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4549 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
4550 \put(3,7){\line(1,0){6}}
4551 \put(3,-2.5){\line(1,0){6}}
4552 \newsavebox{\eqdist}
4553 \savebox{\eqdist}(0,0)[b]{%
4554   \thinlines
4555   \put(-0.08,0.2){\line(0,-1){0.4}}%
4556   \put(0.08,0.2){\line(0,-1){0.4}}}
4557 \put(1.5,0){\usebox{\eqdist}}
4558 \put(10.5,0){\usebox{\eqdist}}
4559
4560 \color{blue}% shifted
4561 \thicklines
4562 \put(3,-1.5){\vector(-1,0){4}}
4563 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
4564 \put(3,0){\vector(0,-1){1.5}}
4565 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
4566 \end{picture}
4567 \end{center}
4568 \end{minipage}%
4569 \begin{minipage}{0.6\textwidth}%
4570 %<*en>
4571 Consider a  Japanese character node which belongs to
4572 a character class whose the \texttt{align}
4573 field is \texttt{'middle'}.
4574 %</en>
4575 %<*ja>
4576 \texttt{align}フィールドの値が \texttt{'middle'} であるような文字クラスに属する
4577 和文文字ノードを考えよう.
4578 %</ja>
4579 \begin{itemize}
4580 \item
4581 %<*en>
4582 The black rectangle is the imaginary body of the node.
4583 Its width, height, and depth are specified by JFM.
4584 %</en>
4585 %<*ja>
4586 黒色の長方形はノードの枠であり,
4587 その幅,高さ,深さはJFMによって指定されている.
4588 %</ja>
4589 \item
4590 %<*en>
4591 Since the \texttt{align} field is \texttt{'middle'},
4592 the ``real'' glyph is centered horizontally (the green rectangle) first.
4593 %</en>
4594 %<*ja>
4595 \texttt{align}フィールドは \texttt{'middle'} なので,
4596 実際のグリフの位置はまず水平方向に中央揃えしたものとなる(緑色の長方形).
4597 %</ja>
4598 \item
4599 %<*en>
4600 Furthermore, the glyph is shifted according to values of fields
4601       \texttt{left} and \texttt{down}. The ultimate position of the real
4602       glyph is indicated by the red rectangle.
4603 %</en>
4604 %<*ja>
4605 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
4606 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
4607 %</ja>
4608 \end{itemize}
4609 \end{minipage}
4610 \medskip
4611
4612 \caption{%
4613 %<en>The position of the real glyph (horizontal Japanese fonts)
4614 %<ja>横組和文フォントにおける「実際の」グリフの位置
4615 }
4616 \label{fig:pos}
4617 \end{figure}
4618 \begin{figure}[!tb]
4619 \begin{minipage}{0.4\textwidth}%
4620 \begin{center}\unitlength=10pt\small
4621 \begin{picture}(15,12)(-6,0)
4622 \color{b_gray}% jfm
4623 \put(-6,0){\vrule width 12\unitlength height 11\unitlength}
4624
4625 \color{b_pink}% real glyph
4626 \put(-6.5,5.5){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4627
4628 \color{red}% real glyph
4629 \thicklines
4630 \put(-6.5,5.5){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4631 \put( 1.5,5.5){\line(0,1){6}\line(0,-1){3}}
4632 \put(-6.5,11.5){\line(1,0){8}}
4633 \put(-6.5,2.5){\line(1,0){8}}
4634
4635 \color{b_green}% step1
4636 \put(-4,3){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4637
4638 \color{black}% jfm
4639 \thicklines
4640 \put(0,11){\vector(1,0){6}\vector(-1,0){6}\vector(0,-1){11}}
4641 \put(0,0){\line(1,0){6}\line(-1,0){6}}
4642 \put(-6,0){\line(0,1){11}}
4643 \put( 6,0){\line(0,1){11}}
4644 \put( 3,10.8){\makebox(0,0)[t]{\texttt{height}}}
4645 \put(-3,10.8){\makebox(0,0)[t]{\texttt{depth}}}
4646 \put(0.2,5.5){\makebox(0,0)[l]{\texttt{width}}}
4647
4648 \color{green}% step1
4649 \thicklines
4650 \put(-4,3){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4651 \put( 4,3){\line(0,1){6}\line(0,-1){3}}
4652 \put(-4,9){\line(1,0){8}}
4653 \put(-4,0){\line(1,0){8}}
4654 \savebox{\eqdist}(0,0)[b]{%
4655   \thinlines
4656   \put(-0.08,0.2){\line(0,-1){0.4}}%
4657   \put(0.08,0.2){\line(0,-1){0.4}}}
4658 \put(2,9){\usebox{\eqdist}}
4659 \put(-2,9){\usebox{\eqdist}}
4660
4661
4662 \color{blue}% shifted
4663 \thicklines
4664 \put(-4,3){\vector(0,1){2.5}}
4665 \put(-3.8,4.25){\makebox(0,0)[l]{\texttt{left}}}
4666 \put(-4,5.5){\vector(-1,0){2.5}}
4667 \put(-5.,5.7){\makebox(0,0)[b]{\texttt{down}}}
4668 \end{picture}
4669 \end{center}
4670 \end{minipage}%
4671 \begin{minipage}{0.6\textwidth}%
4672 %<*en>
4673 (\dots)
4674 %</en>
4675 %<*ja>
4676 \texttt{align}フィールドの値が \texttt{'right'} であるような文字クラスに属する
4677 和文文字を考えよう.
4678 \begin{itemize}
4679 \item
4680 実際のグリフの「垂直位置」は,まずベースラインが文字の物理的な左右方向の中央を通る
4681 位置となる.
4682 \item
4683 また,この場合 \texttt{align} フィールドは \texttt{'right'} なので,
4684 「水平位置」は字送り方向に「右寄せ」したものとなる(緑色の長方形).
4685 \item
4686 その後さらに \texttt{left} と \texttt{down} の値に従ってシフトされる
4687 のは横組用和文フォントと変わらない.
4688 \end{itemize}
4689 %</ja>
4690 \end{minipage}
4691 \medskip
4692
4693 \caption{%
4694 %<en>The position of the real glyph (vertical Japanese fonts)
4695 %<ja>縦組和文フォントにおける「実際の」グリフの位置
4696 }
4697 \label{fig:pos-tate}
4698 \end{figure}
4699
4700 \item[kern={\{[$j$]=\meta{kern}, [$j'$]=\{\meta{kern}, [ratio=\meta{ratio}]\}, ...\}}]
4701 \nopagebreak
4702 \item[glue={\{[$j$]=\{\meta{width}, \meta{stretch}, \meta{shrink}, [ratio=\meta{ratio}, ...]\}, ...\}}]\leavevmode
4703 %<*ja>
4704
4705 文字クラス$i$の文字と$j$の文字の間に挿入されるカーンやグルーの量を指定する.
4706
4707 \meta{ratio}は,グルーの自然長のうちどれだけの割合が「後の文字」由来かを示す量で,
4708 $0$から$+1$の実数値をとる.省略時の値は$0.5$である.
4709 このフィールドの値は\Param{differentjfm}の値が
4710 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
4711
4712 例えば,\cite{x4051}では,句点と中点の間には,
4713 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
4714 \begin{itemize}
4715 \item \meta{width}には$0.5+0.25=0.75$を指定する.
4716 \item \meta{ratio}には$0.25/(0.5+0.25)=1/3$を指定する.
4717 \end{itemize}
4718 %</ja>
4719 %<*en>
4720 \
4721
4722 Specifies the amount of kern or glue which will be inserted
4723 between characters in character class~$i$ and those in character class~$j$.
4724
4725 \meta{ratio} specifies how much the glue is originated in the ``right'' character.
4726 It is a real number between 0 and 1, and treated as 0.5 if omitted. For example,
4727 The width of a glue between an ideographic full stop ``。''
4728 and a fullwidth middle dot ``・'' is three-fourth of fullwidth,
4729 namely halfwidth from the ideographic full stop, and
4730 quarter-width from the fullwidth middle dot.  In this case,
4731 we specify \meta{ratio} to $0.25/(0.5+0.25)=1/3$.
4732 %</en>
4733
4734 %<*ja>
4735 グルーの指定においては,上記に加えて各 \texttt{[$j$]} の各サブテーブル内に
4736 次のキーを指定できる,
4737 \begin{cslist}[style=standard]
4738 \item[priority=\meta{priority}]
4739              \Pkg{luatexja-adjust}による優先順位付き
4740              行長調整(\ref{ssec:adj}節)において,このグルーの優先度を指定する.許される値は以下の通り:
4741   \begin{description}
4742     \item[バージョン1] $-4$から$+3$の間の整数
4743     \item[バージョン2以降] $-4$から$+3$の間の整数の2つ組\texttt{\{\meta{stretch}, \meta{shrink}\}}か,
4744     または$-4$から$+3$の間の整数.\meta{stretch}, \meta{shrink}はそれぞれこのグルーが伸びるときの優先度,縮むときの
4745     優先度であり,単に整数$i$が指定された場合は\texttt{\{$i$, $i$\}}であると解釈される.
4746   \end{description}
4747   ここで指定する値は,大きい値ほど「先に伸ばされる」「先に縮ませる」ことを意味しており,省略時の値
4748              は0である.範囲外の値が指定されたときの動作は未定義である.
4749 \item[kanjiskip\_natural=\meta{num}\textrm{, }%
4750   kanjiskip\_stretch=\meta{num}\textrm{, }kanjiskip\_shrink=\meta{num}]\leavevmode
4751   \label{pg:ksp_nat}
4752
4753 JFMによって本来挿入されるグルーの他に
4754 \Param{kanjiskip}分の空白を自然長(\texttt{kanjiskip\_natural}),伸び量(\texttt{kanjiskip\_stretch}),
4755 縮み量(\texttt{kanjiskip\_shrink})ごとに挿入する
4756 %  \footnote{本来\Param{xkanjiskip}が挿入される場所においては\Param{xkanjiskip}分の空白を自然長・伸び量・縮み量ごとに}%
4757 ための指定である.いずれも省略された場合のデフォルト値は0(追加しない)である.
4758
4759 例えば,\LuaTeX-jaの横組標準JFMの \texttt{jfm-ujis.lua} では,
4760 \begin{itemize}
4761  \item 通常の文字「あ」と開き括弧類の間に入るグルーは,自然長・縮み量半角,伸び量0のグルー
4762 となっているが,さらに\Param{kanjiskip}の伸び量に \texttt{kanjiskip\_stretch}(ここでは1)を掛け
4763        た分だけ伸びることが許される.
4764  \item 同様に,閉じ括弧類(全角コンマ「,」も含む)と和文文字「う」「え」,
4765   閉じ括弧類と「f」の間も自然長・縮み量半角,伸び量0のグルー
4766 となっているが,さらに\Param{kanjiskip}の伸び量に \texttt{kanjiskip\_stretch}(ここでは1)を掛け
4767        た分だけ伸びることが許される.
4768  \item 一方,開き括弧類と通常の文字の間,また通常の文字と閉じ括弧類の間は
4769   自然長・縮み量・伸び量0のグルーだが,\Param{kanjiskip}の縮み量に
4770   \texttt{kanjiskip\_shrink}(ここでは1)を掛けた分だけ縮むことが許される.
4771 \end{itemize}
4772 となっている.従って,以下のような組版結果を得る.
4773
4774 \medskip
4775 \begin{LTXexample}[width=18\zw]
4776 \leavevmode\let\V=\vrule
4777 \ltjsetparameter{kanjiskip=0pt plus 5\zw}
4778 \ltjsetparameter{xkanjiskip=0pt plus 0.5\zw}
4779 \V\hbox spread 7\zw{aあ「い」う,えお」f}\V
4780
4781 \vrule\hbox{ああ「い」う,えお」f}\V\par
4782 \ltjsetparameter{kanjiskip=0pt minus \zw}
4783 \V\hbox spread -2.5\zw{aあ「い」う,えお」f}\V
4784 \end{LTXexample}
4785 \end{cslist}
4786 %</ja>
4787 %<*en>
4788 In case of glue, one can specify following additional keys in each \texttt{[$j$]}
4789              subtable:
4790 \begin{cslist}[style=standard]
4791 \item[priority=\meta{priority}]
4792 An integer in $[-4,3]$ (treated as 0 if omitted), or
4793 a pair of these integers \texttt{\{\meta{stretch}, \meta{shrink}\}} (version 2~or~later).
4794 This is
4795 used only in line adjustment with priority by \Pkg{luatexja-adjust}
4796 (see Subsection~\ref{ssec:adj}). Higher value means the glue is easy to stretch,
4797 and is also easy to shrink. 
4798 \item[kanjiskip\_natural=\meta{num}\textrm{, }%
4799   kanjiskip\_stretch=\meta{num}\textrm{, }kanjiskip\_shrink=\meta{num}]\leavevmode
4800
4801 These keys specifies the amount of the natural width of \Param{kanjiskip}%
4802 (the stretch/shrink part, respectively) which will be inserted
4803 in addition to the original JFM glue. Default values of them are all 0.
4804
4805 As an example, in \texttt{jfm-ujis.lua}, the standard JFM in horizontal writing, we have
4806 \begin{itemize}
4807  \item Between an ordinal letter ``あ'' and an ideographic opening bracket, we have
4808 a glue whose natural part and shrink part are both half-width, while its stretch part is
4809        zero. However, this glue also can be stretched
4810        as much as the stretch part of \Param{kanjiskip} times the value of
4811        \texttt{kanjiskip\_stretch} key (1 in this case).
4812  \item Between an ideographic closeing brackets (including the ideographic comma ``,'')
4813        and an ordinal letter (including an \textbf{ALchar} ``f\/''), we have the same glue.
4814        Again, this glue also can be stretched
4815        as much as the stretch part of \Param{kanjiskip} times the value of
4816        \texttt{kanjiskip\_stretch} key (1 in this case).
4817  \item Between an ideographic opening bracket and an ordinal letter
4818   and between an ordinal letter and an ideographic closing bracket,
4819   we have a glue whose natural part and stretch part are both zero, while its shrink part as much as
4820   the shrink part of \Param{kanjiskip}.
4821 \end{itemize}
4822 Hence we have the following result:
4823
4824 \medskip
4825 \begin{LTXexample}[width=18\zw]
4826 \leavevmode\let\V=\vrule
4827 \ltjsetparameter{kanjiskip=0pt plus 5\zw}
4828 \ltjsetparameter{xkanjiskip=0pt plus 0.5\zw}
4829 \V\hbox spread 7\zw{aあ「い」う,えお」f}\V
4830
4831 \vrule\hbox{aあ「い」う,えお」f}\V\par
4832 \ltjsetparameter{kanjiskip=0pt minus \zw}
4833 \V\hbox spread -2.5\zw{aあ「い」う,えお」f}\V
4834 \end{LTXexample}
4835
4836 \end{cslist}
4837 %</en>
4838   
4839 \item[end\_stretch=\meta{kern}, end\_shrink=\meta{kern}]
4840 %<*ja>
4841 (任意,バージョン1のみ)
4842
4843 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
4844              末に来た時に,行長を詰める調整・伸ばす調整のた
4845              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
4846 %</ja>
4847 %<*en>
4848 (optional, version~1 only)
4849 %</en>
4850
4851   \item[end\_adjust=\{\meta{kern}, \meta{kern}, ...\}]
4852 %<*ja>
4853 (任意,バージョン2以降)
4854
4855 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が
4856   行末に来た時に,この文字と行末の間には指定された値のいずれかの大きさのカーンが
4857   挿入される(\autoref{ssec:adj}参照).
4858
4859 バージョン1における
4860 \begin{lstlisting}[escapechar=\$]
4861     end_stretch = $a$, end_shrink = $b$
4862 \end{lstlisting}
4863 という指定は,バージョン2以降では次の指定と同じになる.
4864 \begin{lstlisting}[escapechar=\$]
4865     end_adjust = {$-b$, 0.0, $a$}
4866 \end{lstlisting}
4867 もし真ん中の \texttt{0.0} がない場合は,$a$か$-b$かいずれかのカーンが常に行末に追加される.
4868 %</ja>
4869 %<*en>
4870 (optional, version~2 or~later)
4871 %</en>
4872
4873   \item[round\_threshold=\meta{float}]
4874 %<*ja>
4875 (任意,バージョン3以降,文字クラス0のみ)
4876
4877 「実際のグリフの幅に合わせて文字幅を整数倍する」際のしきい値を指定する.
4878 より正確に述べると,次のようになる.このフィールドに正の数$r$が指定されていたとし,
4879 JFM中で「文字クラス0の文字幅」と指定されている値が$w$,文字クラス0に属する文字のあるグリフの実際の幅が$w'$であったとする.
4880 $n=\nint(w'/w)$とした
4881 \footnote{ここで,$\nint(a)=\lfloor a+0.5\rfloor$は$a$に「もっとも近い整数」を表す.}
4882 とき,もし$w'>w$かつ$\lvert w'/w-n\rvert \char`<r$であれば,JFMで文字幅$nw$が指定されたものとして扱う.
4883
4884 この機能は,ほとんど源ノ明朝・源ノ角ゴシックにおける2倍角・3倍角ダッシュの合字のために実装されたと
4885 言ってもよい(この場合$w'=2$,~$3$である).これらのグリフは\LuaTeX 内部ではUnicodeの私用領域に割り当てられるので,
4886 JFM側で番号を指定することができない.
4887 %</ja>
4888 %<*en>
4889 (optional, version~3 or~later, only available in character class~0)
4890 %</en>
4891
4892
4893 \end{cslist}
4894
4895 %<*ja>
4896 \paragraph{文字クラスの決定}
4897 文字からその文字の属する文字クラスを算出する過程について,
4898 次の内容を含んだ \texttt{jfm-test.lua} を用いて説明する.
4899 %</ja>
4900 %<*en>
4901 \paragraph{Character to character classes}
4902 We explain how the character class of a character is determined,
4903 using  \texttt{jfm-test.lua} which contains the following:
4904 %</en>
4905 \begin{lstlisting}
4906    [0] = {
4907       chars = { '漢' },
4908       align = 'left', left = 0.0, down = 0.0,
4909       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
4910    },
4911    [2000] = {
4912       chars = { '。', 'ヒ' },
4913       align = 'left', left = 0.0, down = 0.0,
4914       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
4915    },
4916 \end{lstlisting}
4917 %<ja>ここで,次のような入力とその実行結果を考える:
4918 %<en>Now consider the following input/output:
4919 \begin{LTXexample}[width=0.3\textwidth]
4920 \jfont\a=IPAexMincho:jfm=test;+hwid
4921 \setbox0\hbox{\a ヒ漢}\the\wd0
4922 \end{LTXexample}
4923 %<*en>
4924 Now we look why the above source outputs 15\,pt.
4925 \begin{enumerate}
4926 \item The character ``ヒ'' is converted to its half width  form ``ヒ'' by \verb+hwid+ feature.
4927 \item According to the JFM, the character class of ``ヒ'' is 2000, hence its width is halfwidth.
4928 \item The character class of ``漢'' is zero,  hence its width is fullwidth.
4929 \item Hence the width of \cs{hbox} equals to 15\,pt.
4930 \end{enumerate}
4931 This example shows that the character class of a character is generally determined \emph{after
4932 applying font features by \Pkg{luaotfload}}.
4933 %</en>
4934 %<*ja>
4935 上記の出力結果が,15\,ptとなっているのは理由によるものである:
4936 \begin{enumerate}
4937 \item \verb+hwid+ featureによって「ヒ」が半角幅のグリフ「ヒ」と置き換わる(\Pkg{luaotfload} による処理).
4938 \item JFMによれば,この「ヒ」のグリフの文字クラスは2000である.
4939 \item 以上により文字クラス2000とみなされるため,結果として「ヒ」の幅は半角だと認識される.
4940 \end{enumerate}
4941 この例は,\emph{文字クラスの決定はOpenType機能の適用によるグリフ置換の結果に基づく}ことを
4942 示している.
4943 %</ja>
4944
4945 %<*en>
4946 However, if the class determined by the glyph after application of features is zero,
4947 \LuaTeX-ja adopts the class determined by the glyph \emph{before} application of features.
4948 The following input is an example.
4949 %</en>
4950 %<*ja>
4951 但し,JFMによって決まる置換後のグリフの文字クラスが0である場合は,置換前の文字クラスを採用する.
4952 %</ja>
4953 \begin{LTXexample}[width=0.3\textwidth]
4954 \jfont\a=HaranoAjiMincho-Regular:jfm=test;+vert
4955 \a 漢。\inhibitglue 漢
4956 \end{LTXexample}
4957 %<*en>
4958 Here, the character class of the ideographic full stop ``。''~(\texttt{U+3002}) is determined
4959 as follows:
4960 \begin{enumerate}
4961 \item As the case of ``ヒ'', the ideographic full stop ``。'' is converted to its vertical
4962       form ``\char"FE12''~(\texttt{U+FE12}) by \verb+vert+ feature.%"
4963 \item The character class of ``\char"FE12'', according to the JFM  is \emph{zero}.
4964 \item However, \LuaTeX-ja remembers that this ``\char"FE12'' is obtained from ``。'' by
4965       font features. The character class of ``。'' is \emph{non-zero value}, namely, 2000.
4966 \item Hence the ideographic full stop ``。'' in above belongs the character class~2000.
4967 \end{enumerate}
4968 %</en>
4969 %<*ja>
4970 ここで,句点「。」(\texttt{U+3002})の文字クラスは,以下のようにして決まる.
4971 \begin{enumerate}
4972 \item \Pkg{luaotfload}によって縦組用句点のグリフに置き換わる.
4973 \item 置換後のグリフは \texttt{U+FE12} であり,JFMに従えば文字クラスは\emph{0}と判定される.
4974 \item この場合,置換前の横組用句点のグリフによって文字クラスを判定する.
4975 \item 結果として,上の出力例中の句点の文字クラスは2000となる.
4976 \end{enumerate}
4977 %</ja>
4978
4979
4980 %<ja>\paragraph{仮想的な文字}
4981 %<en>\paragraph{Imaginary characters}
4982 %<*en>
4983 As described before, one can specify several ``imaginary characters'' in
4984 \texttt{chars} field. The most of these characters are regarded as the
4985 characters of class 0 in \pTeX.
4986 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
4987 The following is the list of imaginary characters:
4988 %</en>
4989 %<*ja>
4990 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
4991 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
4992 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
4993 い組版調整ができるようになっている.以下でその一覧を述べる:
4994 %</ja>
4995
4996 \begin{cslist}
4997 %%\item['diffmet']
4998 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
4999 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
5000
5001 \item['boxbdd']
5002 %<*en>
5003 The beginning/ending of a hbox, and the beginning of a noindented (i.e., began by \cs{noindent}) paragraph.
5004 If a hbox~$b$ begins (resp.~ends) a glue or kern between this ``charater'' and a \textbf{JAchar},
5005 \textbf{JAglue} won't be inserted before(resp.~after) the hbox~$b$.
5006 \Param{kanjiskip}~and~\Param{xkanjiskip} around a hbox.
5007 %</en>
5008 %<*ja>
5009 hboxの先頭と末尾,及びインデントされていない(\cs{noindent} で開始された)段落の先頭を表す.
5010 この「文字」との間に設定したグルー・カーンがボックス$b$の先頭(もしくは末尾)に来た場合,
5011   そのボックス$b$の直前(もしくは直後)には和文処理グルーは入らない.
5012 %</ja>
5013
5014 \item['parbdd']
5015 %<en>The beginning of an (indented) paragraph.
5016 %<ja>通常の(\cs{noindent} で開始されていない)段落の先頭.
5017
5018 \item['jcharbdd']
5019 %<en>A boundary between \textbf{JAchar} and anything else.
5020 %<*ja>
5021 \textbf{JAchar}と「その他のもの」との境界.
5022
5023 バージョン2以前では\textbf{ALchar},箱,罫線(rule),glue,~kernなどいろいろなものと\textbf{JAchar}の境界に対して
5024 本特殊文字が用いられていたが,
5025 バージョン3以降では\ \texttt{'jcharbdd'}, \texttt{'alchar'}, \texttt{'nox\_alchar'},
5026 \texttt{'glue'} と細分化され,
5027 \texttt{'jcharbdd'} は主に\textbf{JAchar}とボックスや罫線(rule)との境界に使われるようになった.
5028 %</ja>
5029   
5030 \item['alchar', 'nox\_alchar']
5031 %<*en>
5032 (version 3~or~later) A boundary between \textbf{JAchar} and \textbf{ALchar}.
5033 %</en>
5034 %<*ja>
5035 (バージョン3以降)\textbf{JAchar}と\textbf{ALchar}との境界.
5036 \textbf{JAchar}と\textbf{ALchar}の間に\Param{xkanjiskip}が入ることが可能な場合は
5037 \ \texttt{'alchar'}\ が,そうでない場合は\ \texttt{'nox\_alchar'}\ が用いられる
5038 (この区別は\textbf{ALchar}側の\Param{alxspmode}の値によってのみ行われる).
5039 %</ja>
5040
5041 \item['glue']
5042 %<en>(version 3~or~later) A boundary between \textbf{JAchar}, and, a glue or kern.
5043 %<ja>(バージョン3以降)\textbf{JAchar}とglue,kernとの境界.
5044
5045 \item[$-1$]
5046 %<en>The left/right boundary of an inline math formula.
5047 %<ja>行中数式と地の文との境界.
5048 \end{cslist}
5049
5050 %<en>\paragraph{Porting JFM from \pTeX}
5051 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
5052
5053 % ToDo: English version.
5054
5055 %<*en>
5056 See Japanese version of this manual.
5057 %</en>
5058
5059 %<*ja>
5060 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
5061 \begin{itemize}
5062 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
5063 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
5064       トメトリック等を移植する場合は,次のようにするべきである:
5065 \begin{itemize}
5066 \item JFM中の全ての数値を$1/0.962216$倍しておく.
5067 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
5068       \LaTeX でのフォント宣言なら,例えば次のように:
5069 \begin{lstlisting}
5070 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
5071 \end{lstlisting}
5072 \end{itemize}
5073 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
5074       (JFM中に単に書かなければよい).
5075 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
5076       文字クラスに関してはグルー/カーンの設定はしない.
5077
5078 これは,\pTeX では,
5079       hboxの先頭・末尾とインデントされていない(\cs{noindent} で開始さ
5080       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
5081 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
5082
5083 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
5084       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
5085       は,段落の最初に手動で \cs{inhibitglue} を追加するか,あるいは
5086       \ \cs{everypar} のハックを行い,それを自動化させるしかなかった.
5087
5088 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
5089 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
5090 \texttt{'parbdd'}を入れれば全角下がりとなる.
5091
5092 \begin{LTXexample}[width=0.4\textwidth]
5093 \jfont\g=HaranoAjiMincho-Regular:jfm=test \g
5094 \parindent1\zw\noindent{}◆◆◆◆◆
5095 \par 「◆◆←二分下がり
5096 \par 【◆◆←全角下がり
5097 \par 〔◆◆←全角二分下がり
5098 \end{LTXexample}
5099 \end{itemize}
5100
5101 但し,\cs{everypar} を利用している場合にはこの仕組みは正しく動かない.
5102 そのような例としては箇条書き中の \cs{item} で始まる段落があり,\Pkg{ltjsclasses}では
5103 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
5104 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
5105 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
5106 %</ja>
5107
5108
5109 %<en>\subsection{Math font family}
5110 %<ja>\subsection{数式フォントファミリ}
5111 \label{ssec:math}
5112
5113 %<*en>
5114 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
5115 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
5116 an external package is needed to support this in plain \TeX\ and
5117 \LaTeX.}, and each family has three fonts:
5118 \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}.
5119 %</en>
5120 %<*ja>
5121 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
5122   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
5123   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
5124   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
5125 \cs{textfont}, \cs{scriptfont} そして \cs{scriptscriptfont} である.
5126 %</ja>
5127
5128 %<*en>
5129 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
5130 \autoref{tab-math} shows counterparts to \TeX's primitives for math
5131 font families. There is no relation between the value of
5132 \cs{fam} and that of \cs{jfam}; with appropriate settings,
5133 one can set both \cs{fam} and \cs{jfam} to the same value.
5134 Here \meta{jfont\_cs} in the argument of \Param{jatextfont} etc.\ is
5135 a control sequence which is defined by \cs{jfont}, i.e.,
5136 a \emph{horizontal} Japanese font.
5137 %</en>
5138 %<*ja>
5139 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
5140 \autoref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
5141 ものを示している.\cs{fam} と \cs{jfam} の値の間には関係はなく,
5142 適切な設定の下では \cs{fam} と \cs{jfam} の両方に同じ値を設定することができる.
5143 \Param{jatextfont} 他の第2引数\meta{jfont\_cs}は,\cs{jfont} で定義された
5144 \emph{横組用}和文フォントである.\cs{tfont} で定義された
5145 \emph{縦組用}和文フォントを指定することは想定していない.
5146 %</ja>
5147
5148 \begin{table}[!tb]
5149 %<en>\caption{Commands for Japanese math fonts}
5150 %<ja>\caption{和文数式フォントに対する命令}
5151 \label{tab-math}
5152 %<en>\medskip
5153 \centering
5154 \def\{{\char`\{}\def\}{\char`\}}\small
5155 \begin{tabular}{ll}
5156 \toprule
5157 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
5158 %<ja>\bf 和文フォント&\bf 欧文フォント\\
5159 \midrule
5160 \cs{jfam}${}\in [0,256)$&\cs{fam}\\
5161 \ttfamily\Param{jatextfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}&\ttfamily\cs{textfont}\meta{fam}=\meta{font\_cs}\\
5162 \ttfamily\Param{jascriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}&\ttfamily\cs{scriptfont}\meta{fam}=\meta{font\_cs}\\
5163 \ttfamily\Param{jascriptscriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}&\ttfamily\cs{scriptscriptfont}\meta{fam}=\meta{font\_cs}\\
5164 \bottomrule
5165 \end{tabular}
5166 \end{table}
5167
5168 %<en>\subsection{Callbacks}
5169 %<ja>\subsection{コールバック}
5170
5171 %<*en>
5172 \LuaTeX-ja also has several callbacks. These callbacks can
5173 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
5174 %</en>
5175 %<*ja>
5176 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
5177 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
5178 関数などを用いることでアクセスすることができる.
5179 %</ja>
5180 \begin{description}[font=\bfseries, style=nextline]
5181 %<en>\item[\texttt{luatexja.load\_jfm} callback]
5182 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
5183 %<*en>
5184 With this callback, one can overwrite JFMs.
5185 This callback is called when a new JFM is loaded.
5186 %</en>
5187 %<*ja>
5188 このコールバックを用いることでJFMを上書きすることができる.
5189 このコールバックは新しいJFMが読み込まれるときに呼び出される.
5190 %</ja>
5191
5192 \begin{lstlisting}[numbers=left]
5193 function (<table> jfm_info, <string> jfm_name)
5194   return <table> new_jfm_info
5195 end
5196 \end{lstlisting}
5197
5198 %<*en>
5199 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
5200 this argument has \texttt{chars} field which contains character codes
5201              whose character class is not~0.
5202 %</en>
5203 %<*ja>
5204 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
5205 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
5206 %</ja>
5207
5208 %<*en>
5209 An example of this callback is the \texttt{ltjarticle} class, with
5210              forcefully assigning character class~0 to \texttt{'parbdd'}
5211              in the JFM \texttt{jfm-min.lua}.
5212 %</en>
5213 %<*ja>
5214 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
5215 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
5216 %</ja>
5217
5218 %<en>\item[\texttt{luatexja.define\_jfont} callback]
5219 %<ja>\item[\texttt{luatexja.define\_jfont}コールバック]
5220 %<*en>
5221 This callback and the next callback form a pair, and you can assign characters
5222  which do not have fixed code points in Unicode to non-zero character classes.
5223 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
5224 %</en>
5225 %<*ja>
5226 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
5227 番号を持たない文字を非零の文字クラスに割り当てることができる.
5228 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
5229 %</ja>
5230
5231 \begin{lstlisting}[numbers=left]
5232 function (<table> jfont_info, <number> font_number)
5233   return <table> new_jfont_info
5234 end
5235 \end{lstlisting}
5236 %<*en>
5237 \verb+jfont_info+ has the following fields,
5238 \emph{which may not overwritten by a user}:
5239 \begin{description}
5240 \item[\texttt{size}]
5241 The font size specified at \cs{jfont} in scaled points ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$).
5242 \item[\texttt{zw}, \texttt{zh}, \texttt{kanjiskip}, \texttt{xkanjiskip}]
5243 These are scaled value of those specified by the JFM, by the font size.
5244 \item[\texttt{jfm}]
5245 The internal number of the JFM.
5246 \item[\texttt{var}]
5247 The value of \texttt{jfmvar}~key, which is specified at \cs{jfont}.
5248 The default value is the empty string.
5249 \item[\texttt{chars}]
5250 The mapping table from character codes to its character classes.\\
5251 The specification \texttt{[i].chars=\{\meta{character}, ...\}} in the JFM will be  stored in this
5252            field as \texttt{chars=\{[\meta{character}]=\,$i$, ...\}}.
5253 \item[\texttt{char\_type}]
5254 For $i\in\omega$, \texttt{char\_type[$i$]} is information of characters whose class is
5255            $i$, and has the following fields:
5256 \begin{itemize}
5257  \item \texttt{width},~\texttt{height}, \texttt{depth},
5258   \texttt{italic}, \texttt{down},~\texttt{left}\ are just
5259        scaled value of those specified by the JFM, by the font size.
5260  \item \texttt{align} is a number which is determined from \texttt{align}~field in the JFM:
5261 \[
5262  \begin{cases*}
5263   1&(\texttt{'right'} in JFM),\\
5264   0.5&(\texttt{'middle'} in JFM),\\
5265   0&(otherwise).
5266  \end{cases*}
5267 \]
5268 \end{itemize}
5269 For $i$,~$j\in \omega$, \texttt{char\_type[$i$][$j$]} stores a kern or a glue which will be inserted
5270 between character class~$i$ and class~$j$.
5271 \end{description}
5272 %</en>
5273 %<*ja>
5274 \verb+jfont_info+ は最低限以下のフィールドを持つが,これらを書き換えてはならない:
5275 \begin{cslist}
5276 \item[size]
5277 実際に使われるフォントサイズ(sp単位).$1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$.
5278 \item[zw\textrm{, }zh\textrm{, }kanjiskip\textrm{, }xkanjiskip]
5279 JFMファイルで指定されているそれぞれの値をフォントサイズに合わせてスケーリングしたものを
5280 sp単位で格納している.
5281 \item[jfm]
5282 利用されているJFMを識別するための番号.
5283 \item[var]
5284 \cs{jfont},~\cs{tfont} で指定された \texttt{jfmvar} キーの値(未指定のときは空文字列).
5285 \item[chars]
5286 文字コードから文字クラスへの対応が記述されたテーブル.\\
5287 JFM内の \texttt{[i].chars=\{\meta{character}, ...\}} という指定は\
5288 \texttt{chars=\{[\meta{character}]=\,$i$, ...\}} という形式に変換されている.
5289 \item[char\_type]
5290 $i\in\omega$に対して,\texttt{char\_type[$i$]} は文字クラス$i$の文字の寸法を格納しており,
5291 以下のフィールドを持つ.
5292 \begin{itemize}
5293  \item \texttt{width},~\texttt{height}, \texttt{depth},
5294   \texttt{italic}, \texttt{down},~\texttt{left}\ は
5295 JFMで指定されているそれぞれの値をスケーリングしたものである.
5296  \item \texttt{align} はJFMで指定されている値によって,
5297 \[
5298  \begin{cases*}
5299   1&(\texttt{'right'} in JFM),\\
5300   0.5&(\texttt{'middle'} in JFM),\\
5301   0&(otherwise).
5302  \end{cases*}
5303 \]
5304 のいずれかの値をとる.
5305 \end{itemize}
5306 $i$,~$j\in \omega$に対して,\texttt{char\_type[$i$][$j$]} は
5307 文字クラス$i$の文字と$j$の文字の間に挿入されるグルーやカーンの情報を格納している.
5308
5309 間に入るものがカーンであれば,この値は%
5310 \texttt{[$j$]=\{\meta{kern}, ratio=\meta{ratio}\}}であり,
5311 \meta{kern}はカーンの値をsp単位で表したものである.
5312   
5313 一方,間に入るものがグルーであれば,この値は以下のキーを持つテーブルである.
5314 \begin{description}
5315   \item[{[1], [2], [3]}]
5316   グルーのそれぞれ自然長,伸び量,縮み量をsp単位で表したもの.
5317   \item[\texttt{priority}] (バージョン2以降の)JFMでの指定 \texttt{\{\meta{stretch},\meta{shrink}\}} を
5318   \[
5319     (\text{\meta{stretch}}+4)\cdot 8+\text{\meta{shrink}}+4
5320   \]
5321   として0--63の整数にパックしたもの.
5322   \item[\texttt{ratio}, \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch}, \texttt{kanjiskip\_shrink}]
5323   JFM中の同名のフィールドの値がそのまま使われている.
5324 \end{description}
5325 \item[chars\_cbcache]
5326 文字クラス決定の処理で.キャッシュとして使われる.
5327 \end{cslist}
5328 %</ja>
5329
5330 %<*en>
5331 The returned table \verb+new_jfont_info+ also should include these fields, but
5332 you are free to add more fields (to use them in the \texttt{luatexja.find\_char\_class} callback).
5333 The \verb+font_number+ is a font number.
5334 %</en>
5335 %<*ja>
5336 戻り値の \verb+new_jfont_info+ テーブルも上に述べたフィールドをそのまま含まなければならないが,
5337 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
5338 \verb+font_number+ はフォント番号である.
5339 %</ja>
5340
5341 %<*en>
5342 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
5343              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
5344              CID characters in a JFM. This callback doesn't replace any
5345              code of \LuaTeX-ja.
5346 %</en>
5347 %<*ja>
5348 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
5349 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
5350 用いられている.
5351 %</ja>
5352
5353 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
5354 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
5355 %<*en>
5356 This callback is called just when \LuaTeX-ja is trying to determine which
5357              character class a character \verb+chr_code+ belongs.
5358 A function used in this callback should be in the following form:
5359 %</en>
5360 %<*ja>
5361 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
5362 属するかを決定しようとする際に呼び出される.
5363 このコールバックで呼び出される関数は次の形をしていなければならない:
5364 %</ja>
5365 \begin{lstlisting}[numbers=left]
5366 function (<number> char_class, <table> jfont_info, <number> char_code)
5367   if char_class~=0 then return char_class
5368   else
5369     ....
5370     return (<number> new_char_class or 0)
5371   end
5372 end
5373 \end{lstlisting}
5374
5375 %<*en>
5376 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
5377              routine or previous function calls in this callback, hence
5378              this argument may not be 0. Moreover, the returned
5379              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
5380              is not~0, otherwise you will overwrite the \LuaTeX-ja's
5381              default routine.
5382 %</en>
5383 %<*ja>
5384 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
5385 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
5386 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
5387 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
5388 デフォルトルーチンを書き換えることになる.
5389 %</ja>
5390
5391 %<en>\item[\texttt{luatexja.set\_width} callback]
5392 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
5393 %<*en>
5394 This callback is called when \LuaTeX-ja is trying to encapsule a
5395              \textbf{JAchar} \textit{glyph\_node}, to adjust its
5396              dimension and position.
5397 %</en>
5398 %<*ja>
5399 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
5400 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
5401 %</ja>
5402 \begin{lstlisting}[numbers=left]
5403 function (<table> shift_info, <table> jfont_info, <table> char_type)
5404   return <table> new_shift_info
5405 end
5406 \end{lstlisting}
5407
5408 %<*en>
5409 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
5410 \texttt{down} and \texttt{left} fields, which are the amount of shifting
5411              down/left the character in a scaled point.
5412 %</en>
5413 %<*ja>
5414 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
5415 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
5416 文字の下/左へのシフト量(sp単位)である.
5417 %</ja>
5418
5419 %<*en>
5420 A good example is \Pkg{test/valign.lua}.
5421 After loading this file, the vertical position of glyphs is automatically
5422 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
5423 to be that of letters in the character class~0. For example, suppose that
5424 \begin{itemize}
5425 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
5426   (the standard values of Japanese OpenType fonts);
5427 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
5428   (the standard values of Japanese TrueType fonts).
5429 \end{itemize}
5430 Then, the position of glyphs is shifted up by
5431 %</en>
5432 %<*ja>
5433 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
5434              JFM内で規定された文字クラス0の文字における$(\hbox{高
5435              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
5436              下位置が自動調整される.例えば,
5437 \begin{itemize}
5438 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
5439 (和文OpenTypeフォントの標準値)
5440 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
5441 \end{itemize}
5442 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にずらされることとなる:
5443 %</ja>
5444 \[
5445  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
5446 \]
5447 \end{description}
5448
5449 %<en>\section{Parameters}
5450 %<ja>\section{パラメータ}
5451 \subsection{\cs{ltjsetparameter}}
5452 \label{ssec:param}
5453
5454 %<*en>
5455 As described before, \cs{ltjsetparameter} and \cs{ltjgetparameter} are
5456 commands for accessing most parameters of \LuaTeX-ja. One of the main
5457 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
5458 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
5459 is the position of \verb+hpack_filter+ callback in the source
5460 of \LuaTeX, see Section~\ref{sec-para}.
5461 %</en>
5462 %<*ja>
5463 先に述べたように,\LuaTeX-jaの内部パラメータにアクセスするには
5464 \cs{ltjsetparameter}(または \cs{ltjglobalsetparameter})と \cs{ltjgetparameter} を用いる.
5465 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
5466 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
5467 コールバックの位置にある.\ref{sec-para}章を参照.
5468 %</ja>
5469
5470 %<*en>
5471 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} are commands
5472 for assigning parameters. These take one argument which is a key-value list.
5473 The difference between these two commands is the
5474 scope of assignment;
5475 \cs{ltjsetparameter} does a local assignment and
5476 \cs{ltjglobalsetparameter} does a global one by default.
5477 They also obey the value of \cs{globaldefs}, like other assignments.
5478 %</en>
5479 %<*ja>
5480 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} はパラメータを
5481 指定するための命令で,key-valueリストを
5482 引数としてとる.両者の違いはスコープであり,標準では
5483 \cs{ltjsetparameter} はローカルな設定を行うのに対し,
5484 \cs{ltjglobalsetparameter} はグローバルな設定を行う.
5485 また,他のパラメータ指定と同様に \cs{globaldefs} の値にも従う.
5486 %</ja>
5487
5488 %<*en>
5489 The following is the list of parameters which can be specified by the
5490 \cs{ltjsetparameter} command. [\cs{cs}] indicates the counterpart
5491 in \pTeX, and symbols beside each parameter has the following meaning:
5492 %</en>
5493 %<*ja>
5494 以下は \cs{ltjsetparameter} に指定することができるパラメータの一覧である.
5495 [\cs{cs}]は\pTeX における対応物を示す.
5496 また,それぞれのパラメータの右上の記号には次の意味がある:
5497 %</ja>
5498 \begin{itemize}
5499 %<*en>
5500 \item ``$\ast$'' : values at the end of a paragraph or a hbox are
5501 adopted in the whole paragraph or the whole hbox.
5502 %</en>
5503 %<*ja>
5504 \item ``$\ast$'':段落やhboxの終端での値がその段落/hbox全体で用いられる.
5505 %</ja>
5506 %<*en>
5507 \item ``\dagger'': assignments are always global.
5508 %</en>
5509 %<*ja>
5510 \item ``\dagger'':指定は常にグローバルになる.
5511 %</ja>
5512 \end{itemize}
5513
5514 \begin{cslist}[style=standard]
5515 \item[\DParam{jcharwidowpenalty}\,=\meta{penalty}$^\ast$] [\cs{jcharwidowpenalty}]\
5516
5517 %<*en>
5518 Penalty value for suppressing orphans. This penalty is inserted just
5519              after the last \textbf{JAchar} which is not regarded as a
5520              (Japanese) punctuation mark.
5521 %</en>
5522 %<*ja>
5523 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
5524 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
5525 挿入される.
5526 %</ja>
5527
5528 \item[\DParam{kcatcode}\,=\{\meta{char\_code},\meta{natural number}\}$^\ast$]\
5529
5530 %<*en>
5531 An additional attributes which each character whose character code is \meta{char\_code} has.
5532 At version~20120506.0 or later, the lowermost bit of \meta{natural number} indicates
5533              whether the character is considered as a punctuation mark
5534              (see the description of \Param{jcharwidowpenalty} above).
5535 %</en>
5536 %<*ja>
5537 文字コードが\meta{char\_code}の文字が持つ付加的な属性値.
5538 バージョン20120506.0以降では,\meta{natural number}の最下位ビットが,その文字が句読点と
5539 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
5540 %</ja>
5541
5542 \item[\DParam{prebreakpenalty}\,=\{\meta{char\_code},\meta{penalty}\}$^\ast$] [\cs{prebreakpenalty}]\
5543
5544 %<*ja>
5545 文字コード\meta{char\_code}の\textbf{JAchar}が行頭にくることを抑止するために,
5546              この文字の前に挿入/追加されるペナルティの量を指定する.
5547
5548 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
5549 \begin{lstlisting}
5550 \ltjsetparameter{prebreakpenalty={`〙,10000}}
5551 \end{lstlisting}
5552 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
5553              うわけではないができれば行頭にはきて欲しくない場合に,0と
5554              10000の間の値を指定するのも有用であろう.
5555
5556 \pTeX では,\cs{prebreakpenalty}, \cs{postbreakpenalty}において,
5557 \begin{itemize}
5558 \item 一つの文字に対して,pre, postどちらか一つしか指定することができない%
5559   \footnote{後から指定した方で上書きされる.}
5560 \item pre, post合わせて256文字分の情報を格納することしかできない
5561 \end{itemize}
5562 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
5563 %</ja>
5564 %<*en>
5565 Set a penalty which is inserted automatically before the character \meta{char\_code},
5566 to prevent a line starts from this character. For example, a line cannot started
5567 with one of closing brackets ``〗'', so \LuaTeX-ja sets
5568 \begin{lstlisting}
5569 \ltjsetparameter{prebreakpenalty={`〙,10000}}
5570 \end{lstlisting}
5571 by default.
5572
5573 \pTeX\ has following restrictions on \cs{prebreakpenalty} and \cs{postbreakpenalty},
5574 but they don't exist in \LuaTeX-ja:
5575 \begin{itemize}
5576  \item Both \cs{prebreakpenalty} and \cs{postbreakpenalty} cannot be set
5577 for the same character.
5578  \item We can set \cs{prebreakpenalty} and \cs{postbreakpenalty} up to 256~characters.
5579 \end{itemize}
5580 %</en>
5581
5582 \item[\DParam{postbreakpenalty}\,=\{\meta{char\_code},\meta{penalty}\}$^\ast$]
5583            [\cs{postbreakpenalty}]\
5584
5585 %<*ja>
5586 文字コード\meta{char\_code}の\textbf{JAchar}が行末にくることを抑止するために,
5587              この文字の後に挿入/追加されるペナルティの量を指定する.
5588 %</ja>
5589 %<*en>
5590 Set a penalty which is inserted automatically after the character \meta{char\_code},
5591 to prevent a line ends with this character.
5592 %</en>
5593
5594 \item[\DParam{jatextfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}$^\ast$]
5595 %<en>[\cs{textfont} in \TeX]
5596 %<ja>[\TeX の \cs{textfont}]
5597 \item[\DParam{jascriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}$^\ast$]
5598 %<en>[\cs{scriptfont} in \TeX]
5599 %<ja>[\TeX の \cs{scriptfont}]
5600 \item[\DParam{jascriptscriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}$^\ast$]
5601 %<en>[\cs{scriptscriptfont} in \TeX]
5602 %<ja>[\TeX の \cs{scriptscriptfont}]
5603 \item[\DParam{yjabaselineshift}\,=\meta{dimen}]\
5604 \item[\DParam{yalbaselineshift}\,=\meta{dimen}] [\cs{ybaselineshift}]
5605 \item[\DParam{tjabaselineshift}\,=\meta{dimen}]\
5606 \item[\DParam{talbaselineshift}\,=\meta{dimen}] [\cs{tbaselineshift}]
5607
5608 \item[\DParam{jaxspmode}\,=\{\meta{char\_code},\meta{mode}\}$^\ast$]\
5609
5610 %<*en>
5611 Set whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is \meta{char\_code}.
5612 The followings are allowed for \meta{mode}:
5613 %</en>
5614 %<*ja>
5615 文字コードが\meta{char\_code}の\textbf{JAchar}の前/後ろに\Param{xkanjiskip}の
5616 挿入を許すかどうかの設定.
5617 以下の\meta{mode}が許される:
5618 %</ja>
5619 \begin{description}
5620 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5621 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5622 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5623 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5624 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5625 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5626 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
5627 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5628 \end{description}
5629 %<*en>
5630 This parameter is similar to the \cs{inhibitxspcode} primitive of \pTeX, but not compatible with \cs{inhibitxspcode}.
5631 %</en>
5632 %<*ja>
5633 このパラメータは\pTeX の \cs{inhibitxspcode} プリミティブと似ているが,
5634 互換性はない.
5635 %</ja>
5636 \item[\DParam{alxspmode}\,=\{\meta{char\_code},\meta{mode}\}$^\ast$] [\cs{xspcode}]\
5637
5638 %<*en>
5639 Set whether inserting \Param{xkanjiskip} is allowed before/after a
5640              \textbf{ALchar} whose character code is \meta{char\_code}.
5641              The followings are allowed for \meta{mode}:
5642 %</en>
5643 %<*ja>
5644 文字コードが\meta{char\_code}の\textbf{ALchar}の前/後ろに\Param{xkanjiskip}の
5645 挿入を許すかどうかの設定.
5646 以下の\meta{mode}が許される:
5647 %</ja>
5648 \begin{description}
5649 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5650 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5651 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5652 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5653 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5654 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5655 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
5656 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5657 \end{description}
5658 %<*en>
5659 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
5660 %</en>
5661 %<*ja>
5662 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
5663 これら2つのパラメータは互いの別名となっていることに注意する.
5664 %</ja>
5665
5666 \item[\DParam{autospacing}\,=\meta{bool}] [\cs{autospacing}]
5667 \item[\DParam{autoxspacing}\,=\meta{bool}] [\cs{autoxspacing}]
5668 \item[\DParam{kanjiskip}\,=\meta{skip}$^\ast$] [\cs{kanjiskip}]\
5669
5670 %<*ja>
5671 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
5672 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
5673 しかし,自然長が \cs{maxdimen} の場合は,例外的に和文フォントのJFM側で指定されている
5674 値を採用(こちらはフォントサイズに比例)することになっている.
5675 %</ja>
5676 %<*en>
5677 The default glue which inserted between two \textbf{JAchar}s.
5678 Changing current Japanese font does not alter this parameter, as \pTeX.
5679
5680 If the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5681 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec:jfm-str}).
5682 %</en>
5683
5684 \item[\DParam{xkanjiskip}\,=\meta{skip}$^\ast$] [\cs{xkanjiskip}]\
5685
5686 %<*ja>
5687 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
5688 \Param{kanjiskip}と同じように,通常ではフォントサイズに比例して変わることはないが,
5689 自然長が \cs{maxdimen} の場合が例外である.
5690 %</ja>
5691 %<*en>
5692 The default glue which inserted between a \textbf{JAchar} and an
5693       \textbf{ALchar}.
5694 Changing current font does not alter this parameter, as \pTeX.
5695
5696 As \Param{kanjiskip}, if the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5697 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec:jfm-str}).
5698 %</en>
5699
5700
5701 \item[\DParam{differentjfm}\,=\meta{mode}$^\dagger$]\
5702
5703 %<*en>
5704 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
5705 The allowed arguments are the followings:
5706 %</en>
5707 %<*ja>
5708 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
5709 入れるかを指定する.
5710 許される値は以下の通り:
5711 %</ja>
5712 \begin{quote}
5713 \texttt{average},
5714 \texttt{both},
5715 \texttt{large},
5716 \texttt{small},
5717 \texttt{pleft},
5718 \texttt{pright},
5719 \texttt{paverage}
5720 \end{quote}
5721 %<*en>
5722 The default value is \texttt{paverage}. \dots
5723 %</en>
5724 %<*ja>
5725 デフォルト値は \texttt{paverage} である.
5726 各々の値による差異の詳細は\ref{ssec:cluster-wa}節の「『右空白』の算出」を参照してほしい.
5727 %</ja>
5728
5729 \item[\DParam{jacharrange}\,=\meta{ranges}]
5730 \item[\DParam{kansujichar}\,=\{\meta{digit}, \meta{char\_code}\}$^\ast$] [\cs{kansujichar}]
5731
5732 \item[\DParam{direction}\,=\meta{dir}\ \hbox{\normalfont\rmfamily (always local)}]\
5733
5734 %<*en>
5735 Assigning to this parameter has the same effect as
5736 \cs{yoko}~(if $\hbox{\meta{dir}}=4$), \cs{tate}~(if $\hbox{\meta{dir}}=3$),
5737 \cs{dtou}~(if $\hbox{\meta{dir}}=1$) or \cs{utod}~(if $\hbox{\meta{dir}}=11$).
5738 If the argument \meta{dir} is not one of 4,~3, 1~nor~11,
5739 the behavior of this assignment is undefined.
5740 %</en>
5741 %<*ja>
5742 組方向を変更する \cs{yoko}~(if $\hbox{\meta{dir}}=4$), \cs{tate}~(if $\hbox{\meta{dir}}=3$),
5743 \cs{dtou}~(if $\hbox{\meta{dir}}=1$), \cs{utod}~(if $\hbox{\meta{dir}}=11$) と同じ役割を持つ.
5744 利用可能な状況もこれら4命令と同一である.引数\meta{dir}が4,~3, 1,~11のいずれでも無いときの
5745 動作は未定義である.
5746 %</ja>
5747
5748 \end{cslist}
5749
5750
5751 \subsection{\cs{ltjgetparameter}}
5752 \label{ssec:getpar}
5753 %<*en>
5754 \cs{ltjgetparameter} is a control sequence for acquiring parameters. It
5755 always takes a parameter name as first argument.
5756 %</en>
5757 %<*ja>
5758 \cs{ltjgetparameter} はパラメータの値を取得するための命令であり,
5759 常にパラメータの名前を第一引数にとる.
5760 %</ja>
5761 \begin{LTXexample}
5762 \ltjgetparameter{differentjfm},
5763 \ltjgetparameter{autospacing},
5764 \ltjgetparameter{kanjiskip},
5765 \ltjgetparameter{prebreakpenalty}{`)}.
5766 \end{LTXexample}
5767
5768 %<*en>
5769 \emph{The return value of\/ \cs{ltjgetparameter} is
5770 always a string}, which is outputted by \texttt{tex.write()}.
5771 Hence any character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
5772 12~(other), while the space has 10~(space).
5773 %</en>
5774 %<*ja>
5775 \emph{\cs{ltjgetparameter} の戻り値は常に文字列である.}
5776 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
5777 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
5778 一方,空白のカテゴリーコードは10~(space)である.
5779 %</ja>
5780
5781 \begin{itemize}
5782 \item
5783 %<*en>
5784 If first argument is one of the
5785 following, no  additional argument is needed.
5786 %</en>
5787 %<*ja>
5788 第1引数が次のいずれかの場合には,追加の引数は必要ない.
5789 %</ja>
5790 \begin{quote}
5791 \sffamily
5792 jcharwidowpenalty, yjabaselineshift, yalbaselineshift, autospacing, autoxspacing,\\
5793 kanjiskip, xkanjiskip, differentjfm, direction
5794 \end{quote}
5795 %<*en>
5796 Note that \verb+\ltjgetparameter{autospacing}+~and~\verb+\ltjgetparameter{autoxspacing}+
5797 returns 1 or 0, not
5798 \texttt{true}~nor~\texttt{false}.
5799 %</en>
5800 %<*ja>
5801 \verb+\ltjgetparameter{autospacing}+ と \verb+\ltjgetparameter{autoxspacing}+ は,
5802 \texttt{true}や\texttt{false}を返すの\emph{ではなく},
5803 1か0のいずれかを返すことに注意,
5804 %</ja>
5805
5806 \item
5807 %<*en>
5808 If first argument is one of the
5809 following, an additional argument---a character code, for example---is needed.
5810 %</en>
5811 %<*ja>
5812 第1引数が次のいずれかの場合には,さらに文字コードを第2引数としてとる.
5813 %</ja>
5814 \begin{quote}
5815 \sffamily
5816 kcatcode, prebreakpenalty, postbreakpenalty, jaxspmode, alxspmode
5817 \end{quote}
5818 %<*en>
5819 \verb+\ltjgetparameter{jaxspmode}{...}+~and~\verb+\ltjgetparameter{alxspmode}{...}+
5820 returns 0,~1, 2,~or~3, instead of \texttt{preonly} etc.
5821 %</en>
5822 %<*ja>
5823 \verb+\ltjgetparameter{jaxspmode}{...}+ や \verb+\ltjgetparameter{alxspmode}{...}+\
5824 は,\texttt{preonly} などといった文字列ではなく,0から3までの値を返す.
5825 %</ja>
5826
5827 \item
5828 %<*en>
5829 \verb+\ltjgetparameter{jacharrange}{+\meta{range}\verb+}+ returns \texttt{0}
5830 if ``characters which belong to the character range~\meta{range} are \textbf{JAchar}'',
5831 \texttt{1} if ``\dots~are \textbf{ALchar}''.
5832 Although there is no character range~$-1$, specifying $-1$ to \meta{range} does not cause an
5833       error (returns 1).
5834 %</en>
5835 %<*ja>
5836 \verb+\ltjgetparameter{jacharrange}{+\meta{range}\verb+}+ は,\meta{range}が\textbf{JAchar}達の
5837 範囲ならば0を,そうでなければ1を返す.「$-1$番の文字範囲」は存在しないが,\meta{range}に$-1$を
5838 指定してもエラーは発生しない(1を返す).
5839 %</ja>
5840
5841 \item
5842 %<*en>
5843 For an integer~\meta{digit} between 0~and~9,
5844      \verb+\ltjgetparameter{kansujichar}{+\meta{digit}\verb+}+ returns the character code
5845 of the result of \cs{kansuji}\meta{digit}.
5846 %</en>
5847 %<*ja>
5848 0--9の数\meta{digit}に対して,
5849 \verb+\ltjgetparameter{kansujichar}{+\meta{digit}\verb+}+ は,\cs{kansuji}\meta{digit}で出力され
5850      る文字の文字コードを返す.
5851 %</ja>
5852
5853 \item
5854 %<*en>
5855 \verb+\ltjgetparameter{adjustdir}+ returns a integer which represents
5856 the direction of the surrounding vertical list.
5857 As \Param{direction}, the return value 1 means \emph{dtou} direction,
5858 3 means \emph{tate} direction (vertical typesetting),
5859 and 4 means \emph{yoko} direction (horizontal typesetting).
5860 %</en>
5861 %<*ja>
5862 \verb+\ltjgetparameter{adjustdir}+ は,周囲のvboxの組方向(言い換えれば,
5863 \cs{vadjust} で用いられる組方向)を表す数値を返す.
5864 \Param{direction}と同様に,1は \cs{dtou} 方向を,
5865 3は縦組みを,4は横組みを表す.
5866 %</ja>
5867
5868 \item
5869 %<*en>
5870 For an integer~\meta{register} between 0~and~65535,
5871 \verb+\ltjgetparameter{boxdir}{+\meta{register}\verb+}+ returns the direction of
5872 \cs{box}\meta{register}. If this box register is void, the returned value is zero.
5873 %</en>
5874 %<*ja>
5875 0--65535の数\meta{register}に対して,
5876 \verb+\ltjgetparameter{boxdir}{+\meta{register}\verb+}+ は,\cs{box}\meta{register}に
5877 格納されているボックスの組方向を表す.もしこのレジスタが空の場合は,0が返される.
5878 %</ja>
5879
5880 \item
5881 %<*en>
5882 The following parameter names \emph{cannot be specified} in \cs{ltjgetparameter}.
5883 %</en>
5884 %<*ja>
5885 次のパラメータ名を \cs{ltjgetparameter} に指定することはできない.
5886 %</ja>
5887 \begin{quote}
5888 \sffamily
5889 jatextfont, jascriptfont, jascriptscriptfont, jacharrange
5890 \end{quote}
5891
5892 \item
5893 %<*en>
5894 \verb+\ltjgetparameter{chartorange}{+\meta{char\_code}\verb+}+ returns
5895 the range number which \meta{char\_code} belongs to
5896 (although there is no parameter named ``chartorange'').
5897
5898 If \meta{char\_code} is between 0 and 127, this \meta{char\_code} does not belong to
5899 any character range. In this case,
5900       \verb+\ltjgetparameter{chartorange}{+\meta{char\_code}\verb+}+
5901 returns $-1$.
5902
5903 Hence, one can know whether \meta{char\_code} is \textbf{JAchar} or not
5904 by the following:
5905 %</en>
5906 %<*ja>
5907 \verb+\ltjgetparameter{chartorange}{+\meta{char\_code}\verb+}+ によって
5908 \meta{char\_code}の属する文字範囲の番号を知ることができる.
5909
5910 \meta{char\_code}に0--127の値を指定した場合(このとき,\meta{char\_code}が属する
5911 文字範囲は存在しない)は$-1$が返る.
5912
5913 そのため,\meta{char\_code}が\textbf{JAchar}か\textbf{ALchar}かは
5914 次で知ることができる:
5915 %</ja>
5916 \begin{quote}
5917 \ttfamily \verb+\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{+%
5918   \meta{char\_code}\verb+}}+\\\null\hfill\verb+% 0 if JAchar, 1 if ALchar+
5919 \end{quote}
5920
5921 %<*en>
5922 \item Because the returned value is string, the following conditionals do not work
5923 if \Param{kanjiskip} (or~\Param{xkanjiskip}) has the stretch part or the shrink part.
5924 \begin{lstlisting}
5925 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5926 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5927 \end{lstlisting}
5928 The correct way is using a temporary register.
5929 \begin{lstlisting}
5930 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5931 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5932 \end{lstlisting}
5933 %</en>
5934 %<*ja>
5935 \item 返り値が文字列であることから,\Param{kanjiskip}や\Param{xkanjiskip}を直接
5936 \ \cs{ifdim} を使って比較することは望ましくない.伸び量や縮み量を持っている時には,
5937 次はエラーを発生させる:
5938 \begin{lstlisting}
5939 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5940 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5941 \end{lstlisting}
5942 レジスタに一旦代入するのが良い:
5943 \begin{lstlisting}
5944 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5945 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5946 \end{lstlisting}
5947 %</ja>
5948
5949 \end{itemize}
5950
5951
5952 %<*en>
5953 \subsection{Alternative Commands to \cs{ltjsetparameter}}
5954 The basic method to set parameters of \LuaTeX-ja is to use
5955 \cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}.
5956 However, these commands are slow, because they parse a key-value list,
5957 so several alternative commands are used in \LuaTeX-ja.
5958 \emph{This subsection is not for general \LuaTeX-ja users.}
5959
5960 \paragraph{Setting \Param{kanjiskip}~or~\Param{xkanjiskip}}
5961 In \Pkg{ltjsclasses}, every size-changing command such as \cs{Large}
5962 changes \cs{kanjiskip}~and~\cs{xkanjiskip}.
5963 But a simple implementation, as the code below, is slow since
5964 two key-value lists are parsed by \cs{ltjsetparameter}:
5965 \begin{lstlisting}
5966   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
5967   \@tempskipa=\ltjgetparameter{xkanjiskip}
5968   \ifdim\@tempskipa>\z@
5969     \if@slide
5970       \ltjsetparameter{xkanjiskip=0.1em}
5971     \else
5972       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
5973     \fi
5974   \fi
5975 \end{lstlisting}
5976
5977 Hence, \LuaTeX-ja defines more primitive commands, namely \cs{ltj@setpar@global},
5978 \cs{ltjsetkanjiskip}, and~\cs{ltjsetxkanjiskip}. Here
5979 \begin{quote}
5980   \lstinline+\ltj@setpar@global\ltjsetkanjiskip 10pt+
5981 \end{quote}
5982 and \lstinline+\ltjsetparameter{kanjiskip=10pt}+ has the same effect.
5983 The actual code of \Pkg{ltjsclasses} is shown below:
5984 \begin{lstlisting}
5985   \ltj@setpar@global
5986   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
5987   \@tempskipa=\ltjgetparameter{xkanjiskip}
5988   \ifdim\@tempskipa>\z@
5989     \if@slide
5990       \ltjsetxkanjiskip.1em
5991     \else
5992       \ltjsetxkanjiskip.25em plus .15em minus .06em
5993     \fi
5994   \fi
5995 \end{lstlisting}
5996
5997 Note that using \cs{ltjsetkanjiskip}~or~\cs{ltjsetxkanjiskip} alone,
5998 that is, without executing \cs{ltj@setpar@global} in advance, is \emph{not} supported.
5999 %</en>
6000
6001 %<*ja>
6002 \subsection{\cs{ltjsetparameter} の代替}
6003 原則として各種内部パラメータの設定には \cs{ltjsetparameter} もしくは
6004 \ \cs{ltjglobalsetparameter}\ を用いることになるが,
6005 \cs{ltjsetparameter} の実行には時間がかかるという難点があり,
6006 \LuaTeX-ja の内部ではより高速に実行できる別の形式を用いている.
6007 \emph{本節は一般利用者むけの内容ではない.}
6008
6009 \paragraph{\Param{kanjiskip}, \Param{xkanjiskip}の設定}
6010 \pLaTeXe 新ドキュメントクラスでは,
6011 \begin{lstlisting}
6012 \def\@setfontsize#1#2#3{%
6013   ...
6014   \kanjiskip=0zw plus .1zw minus .01zw
6015   \ifdim\xkanjiskip>\z@
6016     \if@slide \xkanjiskip=0.1em \else
6017       \xkanjiskip=0.25em plus 0.15em minus 0.06em
6018     \fi
6019   \fi}
6020 \end{lstlisting}
6021 と,フォントサイズを変更するごとに \cs{kanjiskip}, \cs{xkanjiskip} を変更している.
6022 この \cs{@setfontsize} は文書の中で多数回実行されるので.
6023 \LuaTeX-ja 用に素直に書き換えた
6024 \begin{lstlisting}
6025   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
6026   \@tempskipa=\ltjgetparameter{xkanjiskip}
6027   \ifdim\@tempskipa>\z@
6028     \if@slide
6029       \ltjsetparameter{xkanjiskip=0.1em}
6030     \else
6031       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
6032     \fi
6033   \fi
6034 \end{lstlisting}
6035 としたのではタイプセットが遅くなってしまう.
6036 そこで,\cs{ltjsetparameter} の中で
6037 \begin{itemize}
6038 \item \cs{globaldefs} の値を読み取る \cs{ltj@setpar@global}
6039 \item \Param{kanjiskip} の設定を行う \cs{ltjsetkanjiskip}
6040 \item \Param{xkanjiskip} の設定を行う \cs{ltjsetxkanjiskip}
6041 \end{itemize}
6042 を独立させ,\Pkg{ltjsclasses}では,
6043 \begin{lstlisting}
6044   \ltj@setpar@global
6045   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
6046   \@tempskipa=\ltjgetparameter{xkanjiskip}
6047   \ifdim\@tempskipa>\z@
6048     \if@slide
6049       \ltjsetxkanjiskip.1em
6050     \else
6051       \ltjsetxkanjiskip.25em plus .15em minus .06em
6052     \fi
6053   \fi
6054 \end{lstlisting}
6055 としている.
6056 \cs{ltj@setpar@global}を直前に実行せず,単独で
6057 \cs{ltjsetkanjiskip}, \cs{ltjsetxkanjiskip}を実行することは想定されていないので注意.
6058
6059 %</ja>
6060
6061
6062 %<en>\section{Other Commands for plain \TeX\ and \LaTeXe}
6063 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
6064 %<en>\subsection{Commands for compatibility with \pTeX}
6065 %<ja>\subsection{\pTeX 互換用命令}
6066
6067 %<*en>
6068 The following commands are implemented for compatibility with \pTeX.
6069 Note that the former five commands don't support JIS~X~0213, but only JIS~X~0208.
6070 The last \cs{kansuji} converts an integer into its Chinese numerals.
6071 %</en>
6072 %<*ja>
6073 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
6074 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
6075 %</ja>
6076 \begin{center}
6077 \cs{kuten}, \cs{jis}, \cs{euc}, \cs{sjis}, \cs{ucs}, \cs{kansuji}
6078 \end{center}
6079 %<*en>
6080 These six commands takes an internal integer, and returns a \emph{string}.
6081 %</en>
6082 %<*ja>
6083 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
6084 %</ja>
6085 \begin{LTXexample}
6086 \newcount\hoge
6087 \hoge="2423 %"
6088 \the\hoge, \kansuji\hoge\\
6089 \jis\hoge, \char\jis\hoge\\
6090 \kansuji1701
6091 \end{LTXexample}
6092
6093 %<*en>
6094 To change characters of Chinese numerals for each digit, set \Param{kansujichar} parameter:
6095 \begin{LTXexample}
6096 \ltjsetparameter{kansujichar={1,`壹}}
6097 \ltjsetparameter{kansujichar={7,`漆}}
6098 \ltjsetparameter{kansujichar={0,`零}}
6099 \kansuji1701
6100 \end{LTXexample}
6101 %</en>
6102
6103
6104 \subsection{\cs{inhibitglue}, \cs{disinhibitglue}}
6105 %<*en>
6106 \cs{inhibitglue} suppresses the insertion of a glue/kern soecified in JFM at the place.
6107 The following is an example, using a special JFM that there will be a glue between
6108 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
6109 %</en>
6110 %<*ja>
6111 \cs{inhibitglue} は発行箇所でのJFM由来グルー/カーンの挿入を抑制する.
6112 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
6113 ある.
6114 %</ja>
6115
6116 \begin{LTXexample}[width=0.4\textwidth]
6117 \jfont\g=HaranoAjiMincho-Regular:jfm=test \g
6118 \fbox{\hbox{あウあ\inhibitglue ウ}}
6119 \inhibitglue\par\noindent あ1
6120 \par\inhibitglue\noindent あ2
6121 \par\noindent\inhibitglue あ3
6122 \par )4)\inhibitglue 5
6123 \par\hrule\noindent あoff\inhibitglue ice
6124 \end{LTXexample}
6125
6126 %<*en>
6127 With the help of this example, we remark the specification of \cs{inhibitglue}:
6128 %</en>
6129 %<*ja>
6130 この例を援用して,\cs{inhibitglue} の仕様について述べる.
6131 %</ja>
6132 \begin{itemize}
6133 %<*en>
6134 \item The call of \cs{inhibitglue} in the (internal) vertical mode is
6135       simply ignored.
6136 %</en>
6137 %<*ja>
6138 \item \emph{\cs{inhibitglue} の垂直モード中での呼び出しは意味を持たない}\footnote{%
6139   この点は\TeX~Live~2014での\pTeX における \cs{inhibitglue} の仕様変更と同じである.
6140 }.
6141 4行目の入力で有効にならないのは,\cs{inhibitglue} の時点では垂直モードであり,
6142 \cs{noindent} の時点で水平モードになるからである.
6143 %</ja>
6144
6145 %<*en>
6146 \item \cs{inhibitglue} does \emph{not} suppress \Param{kanjiskip} or \cs{xkanjiskip}.
6147 %</en>
6148 %<*ja>
6149 \item \cs{inhibitglue}は\Param{kanjiskip}, \Param{xkanjiskip}の挿入は抑制しない.
6150   例えば上の例の6行目では,「)」と「5」の間には本来はJFM由来の半角空きが挿入されるはずだが,
6151   それが\cs{inhibitglue}で無効になったため,\Param{xkanjiskip}が代わりに挿入されている.
6152 %</ja>
6153
6154 %<*en>
6155 \item The call of \cs{inhibitglue} in the (restricted) horizontal
6156       mode is only effective on the spot; does not get over boundary of
6157       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
6158       kernings, as shown in the last line of above example.
6159 %</en>i
6160 %<*ja>
6161 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
6162   有効であり,段落の境界を乗り越えない.
6163   さらに,\cs{inhibitglue} は上の例の最終行のように(欧文における)リガチャとカーニングを
6164   打ち消す.これは,\cs{inhibitglue} が内部的には「現在のリスト中にwhatsitノードを
6165   追加する」ことを行なっているからである.
6166 %</ja>
6167
6168 %<*en>
6169 \item The call of \cs{inhibitglue} in math mode is just ignored.
6170 %</en>
6171 %<*ja>
6172 \item \cs{inhibitglue} を数式モード中で呼び出した場合はただ無視される.
6173 %</ja>
6174
6175 %<*ja>
6176 \item \LaTeX で\LuaTeX-ja を使用する場合は,
6177 \cs{inhibitglue} の代わりとして \verb+\<+ を使うことができる.
6178 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
6179 注意すること.
6180 %</ja>
6181 \end{itemize}
6182
6183 %<*en>
6184 \cs{disinhibitglue} suppresses the effect of \cs{inhbitglue}.
6185 In other words, \cs{disinhibitglue} allows the insertion of a glue/kern specified by JFM.
6186 If \cs{inhibitglue}~and~\cs{disinhibitglue} both specified at the same time,
6187 the latest one is effective.
6188 This commans is added in the version 20201224.0.
6189
6190 Note that \cs{disinhibitglue} also cancels ligatures and kernings.
6191 %</en>
6192 %<*ja>
6193 \cs{disinhibitglue}は\cs{inhibitglue}の効果を無効化する.
6194 言い換えれば,(\cs{inhibitglue}で抑制されたはずの))JFM由来グルー/カーンの挿入を許可する.
6195 同じ箇所に\cs{inhibitglue}と\cs{disinhibitglue}が両方ある場合は,後ろの指定が有効になる.
6196 この命令はバージョン20201224.0で追加された.
6197
6198 なお,\cs{disinhibitglue}もリガチャやカーニングを打ち消すことに注意されたい.これは
6199 (\cs{inhibitglue}と同様に)whatsitノードを使って実装されていることによる.
6200 %</ja>
6201
6202 \subsection{\cs{ltjfakeboxbdd}, \cs{ltjfakeparbegin}}
6203 %<*en>
6204 Sometimes \texttt{'parbdd'}~and~\texttt{'boxbdd'} specifications~look like ``fail'',
6205 especially in paragraphs inside list environments.
6206 This is because \cs{everypar} inserts some nodes such as boxes and kerns, so
6207 the ``first letter'' in a paragraph is in fact not the first letter.
6208 %</en>
6209 %<*ja>
6210 リスト環境内での\cs{item}で始まる各項目などでは,
6211 「段落最初の鍵括弧が余計に半角字下げされる」など,
6212 JFMにある\texttt{'parbdd'}, \texttt{'boxbdd'}の指定が見かけ上破綻していることがある.
6213
6214 これは\TeX が\cs{everypar}を用いて段落開始時に記号類や空白などを挿入してしまっているため,
6215 段落最初の鍵括弧が実際には段落最初のノードではないことに起因する.以下に例を示した.
6216 %</ja>
6217 \begin{LTXexample}[width=0.3\textwidth]
6218 \parindent1\zw
6219 \noindent ああああああああ\par % for comparison
6220 「ああああああ \par            % normal paragraph
6221
6222 \everypar{\null}
6223 「ああああああ \par            % ???
6224 \end{LTXexample}
6225 %<*en>
6226 \cs{ltjfakeboxbdd}~and~\cs{ltjfakeparbegin} primitives resolve this situation.
6227 \begin{itemize}
6228   \item \cs{ltjfakeparbegin} creates a node which indicates
6229   ``beginning of an indented paragraph'' to the insertion process of \textbf{JAglue}.
6230  \item \cs{ltjfakeboxbdd} creates a node which indicates
6231   ``beginning/ending of a box'' to the insertion process of \textbf{JAglue}.
6232 \end{itemize}
6233 As an example, the example above can be improved as follows:
6234 %</en>
6235 %<*ja>
6236 \cs{ltjfakeboxbdd}, \cs{ltjfakeparbegin}はこの状況を改善する命令である.
6237 実際には\cs{everypar}の末尾にこれらを追加するという使い方がほとんどになるだろう.
6238 \begin{itemize}
6239   \item \cs{ltjfakeparbegin}は,実行された箇所が「インデントあり段落の開始」であると\LuaTeX-jaの
6240   和文処理グルー挿入処理に認識させる.この命令の直前に\textbf{JAchar}があった場合,
6241   この文字の後ろに入るグルー等の処理については未定義である
6242   \footnote{%
6243     この命令と同等の内容は,\cs{dirrctlua}の形で\Pkg{ltjsclasses}内で以前から使われていた.
6244     一般ユーザでも利用しやすくするため,バージョン20170505.0で新たに命令として定義した.
6245   }.
6246   \item \cs{ltjfakeboxbdd}は,実行された箇所が「ボックスの先頭と末尾」であると\LuaTeX-jaの
6247   和文処理グルー挿入処理に認識させる.
6248 \end{itemize}
6249 例えば,先ほどの例に対して適用すると,次のようになる.
6250 %</ja>
6251 \begin{LTXexample}[width=0.3\textwidth]
6252 \parindent1\zw
6253 \noindent ああああああああ\par % for comparison
6254 「ああああああ \par            % normal paragraph
6255
6256 \everypar{\null\ltjfakeparbegin}
6257 「ああああああ \par
6258 \end{LTXexample}
6259
6260
6261 \subsection{\cs{insertxkanjiskip}, \cs{insertkanjiskip}}
6262 %<*en>
6263 There are some situations which one wants to insert \Param{xkanjiskip} manually.
6264 A simple approach is to use \cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}, but this approach has
6265 several weak points. To cope with these weak points, \LuaTeX-ja defines a command \cs{insertxkanjiskip} which
6266 inserts \Param{xkanjiskip} glue manually, from the version 20201224.0.
6267 \begin{itemize}
6268   \item ``\cs{insertxkanjiskip}'' (without any keyword) uses the value of \Param{xkanjiskip} at the place.
6269   \item ``\cs{insertxkanjiskip late}'' (with ``\texttt{late}''~keyword) uses the value of \Param{xkanjiskip}
6270   at the end of a paragraph/hbox.
6271 \end{itemize}
6272 See the example below.
6273 %</en>
6274 %<*ja>
6275 \TeX で日本語の文章を作成していると,
6276 しばしば「手動で和欧文間空白\Param{xkanjiskip}を挿入したい」という状況に遭遇する.
6277 このような場合,\cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}\+とするのがよくある対応であったが,これらには
6278 次のような難点がある:
6279 \begin{itemize}
6280   \item \cs{xkanjiskip}は「段落やhboxでの終端での値がその段落/hbox全体で用いられる」となっているため,
6281   \cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}\+以降に\Param{xkanjiskip}の値が変わる場合に対応できない.
6282   \item \LuaTeX-jaでは,\cs{xkanjiskip}の自然長が$\cs{maxdimen}=(2^{30}-1)\,\mbox{sp}$であった場合,
6283   JFMで指定された値を実際に利用することになっているが,それに対応できていない.
6284   \item \Pkg{luatexja-adjust}(\ref{ssec:adj}節)による優先度行長調整では,
6285   \cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}\+は手動で挿入したグルーであるから,
6286   自動で挿入された\Param{xkanjiskip}とは
6287   伸縮の優先順序が異なってしまう.
6288 \end{itemize}
6289
6290 これらの難点に対処した,\Param{xkanjiskip}をグルーとして手動挿入する命令が\cs{insertxkanjiskip}である.
6291 これはバージョン20201224.0で追加された.
6292 以下の実行例に示すように,
6293 \begin{itemize}
6294   \item 単独で\cs{insertxkanjiskip}とした場合は,その時点での\Param{xkanjiskip}の値を使用する
6295   \item 「\cs{insertxkanjiskip~late}」と\texttt{late}キーワードを後置した場合は,
6296   段落/hbox終了時にそのときの\Param{xkanjiskip}の値に自動設定される
6297   (段落/hbox途中での値は未定義)
6298   \item どちらであっても,実行箇所に本来なら自動挿入されるはずのJFM由来グルー/カーンは挿入されない
6299 \end{itemize}
6300 となっている.
6301 %</ja>
6302 \begin{LTXexample}[width=0.3333\textwidth]
6303 \ltjsetparameter{xkanjiskip=0.25\zw}
6304 あ(%                        0.5\zw  (from JFM)
6305 あ\insertxkanjiskip (%      0.25\zw (xkanjiskip at here)
6306 あ\insertxkanjiskip late (% 0.25\zw (xkanjiskip at EOP)
6307 あa%                         1.25\zw (xkanjiskip at EOP)
6308 \\%
6309 \ltjsetparameter{xkanjiskip=1.25\zw}
6310 あ\insertxkanjiskip (%      1.25\zw (xkanjiskip at here)
6311 あa%                         1.25\zw (xkanjiskip at EOP)
6312 %% At the end of the paragraph (EOP), xkanjiskip is 1.25\zw.
6313 \end{LTXexample}
6314
6315 %<*en>
6316 There is a similar command \cs{insertkanjiskip} (\Param{kanjiskip} instead~of \Param{xkanjiskip}) is also defined.
6317 Note that any shorthand form of \cs{insert}[\texttt{x}]\texttt{kanjiskip} are not defined by \LuaTeX-ja.
6318 %</en>
6319 %<*ja>
6320 \cs{insertxkanjiskip}(または\texttt{late}つき)の短縮形
6321 \footnote{ちょうど\cs{inhibitglue}の短縮形\cs{\ltjalchar`\<}\+に対応するもの.}は
6322 \LuaTeX-jaでは定義していない.短縮形を使いたい人は,面倒でも各自で
6323 \begin{lstlisting}
6324  \protected\def\+{\insertxkanjiskip late}
6325 \end{lstlisting}
6326 などと定義してほしい.
6327
6328 最後になるが,以上の説明の\Param{xkanjiskip}をすべて標準の和文間空白\Param{kanjiskip}に置き換えた
6329 \cs{insertkanjiskip}命令も準備されている.
6330 %</ja>
6331
6332 \subsection{\cs{ltjdeclarealtfont}}
6333 \label{ssec:altfont}
6334 %<*en>
6335 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
6336 This \cs{ltjdeclarealtfont} uses in the following form:
6337 \begin{quote}
6338 \ttfamily \textbackslash ltjdeclarealtfont\meta{base\_font\_cs}\meta{alt\_font\_cs}\{\meta{range}\}
6339 \end{quote}
6340 where  \meta{base\_font\_cs}~and~\meta{alt\_font\_cs} are defined by \cs{jfont}.
6341 Its meaning is
6342 \begin{quote}
6343 If the current Japanese font is \meta{base\_font\_cs}, characters which belong to \meta{range}
6344 is typeset by another Japanese font \meta{alt\_font\_cs}, instead of \meta{base\_font\_cs}.
6345 \end{quote}
6346 Here \meta{range} is a comma-separated list of character codes, but also accepts negative integers:
6347 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
6348 by \meta{base\_font\_cs}. Note that characters which do not exist in \meta{alt\_font\_cs} are
6349 ignored.
6350
6351 For example, if \cs{hoge} uses \texttt{jfm-ujis.lua}, the standard JFM of \LuaTeX-ja,
6352 then
6353 \begin{lstlisting}
6354 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
6355 \end{lstlisting}
6356 does
6357 \begin{quote}
6358 If the current Japanese font is \cs{hoge}, \texttt{U+3000}--\texttt{U+30FF}
6359 and characters in class~1 (ideographic opening brackets)
6360 are typeset by \cs{piyo}.
6361 \end{quote}
6362
6363 Note that specifying negative numbers needs specification like \verb+{-1}-{-1}+,
6364 because simple ``\texttt{-1}'' is treated as the range between 0~and~1.
6365 %</en>
6366 %<*ja>
6367 \cs{jfont} の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
6368 使用出来る「実際のフォント」は1つである.
6369 しかし,\cs{ltjdeclarealtfont} を用いると,この原則から外れることができる.
6370
6371 \cs{ltjdeclarealtfont} は以下の書式で使用する:
6372 \begin{quote}
6373 \ttfamily \textbackslash ltjdeclarealtfont\meta{base\_font\_cs}\meta{alt\_font\_cs}\{\meta{range}\}
6374 \end{quote}
6375 これは「現在の和文フォント」が\meta{base\_font\_cs}であるとき,
6376 \meta{range}に属する文字は\meta{alt\_font\_cs}を用いて組版される,という意味である.
6377 \begin{itemize}
6378  \item \meta{base\_font\_cs}, \meta{alt\_font\_cs}は
6379 \cs{jfont} によって定義された和文フォントである.
6380  \item \meta{range}は文字コードの範囲を表すコンマ区切りのリストであるが,
6381    例外として負数$-n$は「\meta{base\_font\_cs}のJFMの文字クラス$n$に属する全ての文字」
6382    を意味する.
6383
6384 \meta{range}中に\meta{alt\_font\_cs}中に実際には存在しない文字が指定された場合は,
6385 その文字に対する設定は無視される.
6386 \end{itemize}
6387
6388 例えば,\cs{hoge} のJFMが\LuaTeX-ja標準の
6389 \ \texttt{jfm-ujis.lua} であった場合,
6390 \begin{lstlisting}
6391 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
6392 \end{lstlisting}
6393 は「\cs{hoge} を利用しているとき,
6394 \texttt{U+3000}--\texttt{U+30FF}と
6395 文字クラス1(開き括弧類)中の文字だけは \cs{piyo} を用いる」
6396 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
6397 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
6398 マクロの都合による.
6399 %</ja>
6400
6401 %<*ja>
6402 \subsection{\cs{ltjalchar} と \cs{ltjjachar}}
6403 文字コードが$\text{\meta{char\_code}}~(\geq 128=\mathtt{0x80})$の文字を
6404 \ \cs{char} プリミティブを使い \cs{char}\meta{char\_code} として出力させると,
6405 その文字の属する文字範囲(\ref{ssec:setrange}節参照)によって
6406 \textbf{ALchar}か\textbf{JAchar}か,つまり欧文フォントで出力されるか和文フォントで出力され
6407 るかが決まる.
6408
6409 文字範囲の設定を無視し,文字コードが\meta{char\_code}の文字を強制的に
6410 \textbf{ALchar}, \textbf{JAchar}で出力する命令がそれぞれ
6411 \ \cs{ltjalchar},~\cs{ltjjachar} である.使用方法は \cs{char} と同じく
6412 \ \cs{ltjalchar}\meta{char\_code}, \cs{ltjjachar}\meta{char\_code}とすればよい.
6413 \LuaTeX-ja~20190926.0から,\meta{char\_code}が127以下の場合でも\cs{ltjjachar}\meta{char\_code}が
6414 \textbf{JAchar}として出力されるようになっている.
6415
6416 以下は\ref{ssec:setrange}節に載せた例に,\cs{char} の動作などを追加したものである.
6417 %</ja>
6418 \begin{LTXexample}[width=0.25\textwidth]
6419 \gtfamily\large
6420 ¶,\char`¶,\ltjalchar`¶,\ltjjachar`¶\\     % default: ALchar
6421 α,\char`α,\ltjalchar`α,\ltjjachar`α\\ % default: JAchar
6422 g,\char`g,\ltjalchar`g,\ltjjachar`g       % ALchar unless \ltjjachar
6423 \end{LTXexample}
6424
6425 %<en>\section{Commands for \LaTeXe}
6426 %<ja>\section{\LaTeXe 用の命令}
6427
6428 %<*en>
6429 \subsection{Loading Japanese fonts in \LaTeXe}
6430 \label{ssec:ltx-jfm}
6431 From version~20190107, 
6432 \emph{\LuaTeX-ja does not load Japanese fonts for horizontal direction and
6433   that for vertical direction at same time},
6434 to reduce the number of loaded fonts.
6435 This will save time for typesetting and memory consumption of Lua side (\cite{tc18ltja}).
6436
6437 \begin{itemize}
6438   \item \cs{selectfont} loads (and chooses) only the Japanese font for the current direction,
6439   and does not load the Japanese font for other direction
6440   (\LuaTeX-ja only detects its size and JFM, to calculate the amount of shifting the baseline).
6441
6442   \item Direction changing commands (\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod}) are patched to
6443   include the following process:
6444   \begin{quote}
6445         If the Japanese font for new direction is not loaded,
6446         \LuaTeX-ja loads it automatically.
6447   \end{quote}
6448   Original commands are saved as \cs{ltj@@orig@yoko} etc.
6449   
6450   \item Specifying Japanese font command which is
6451   defined by \cs{jfont},~\cs{tfont}, or~\cs{DeclareFixedFont} directly
6452   actually loads (and selects) the Japanese font.
6453   For example, \textbf{JAchar}s in \cs{box0} will be typeset in \cs{HOGE},
6454   in the following code:
6455 \begin{lstlisting}
6456   % in horizontal direction (\yoko)
6457   \DeclareFixedFont\HOGE{JT3}{gt}{m}{n}{12} % JT3: for vertical direction
6458   \HOGE
6459   \setbox0=\hbox{\tate あいう}
6460 \end{lstlisting}
6461   \end{itemize}
6462 %</en>
6463
6464 %<*ja>
6465 \subsection{\LaTeXe 下での和文フォントの読み込み}
6466 \label{ssec:ltx-jfm}
6467 バージョン20190107以降では,\LaTeXe の下で\LuaTeX-jaを使用した際に,
6468 \emph{横組用和文フォントと縦組み用和文フォントを両方一度に読み込み・選択せずに,
6469   実際にそれぞれを使う組方向になったときに行う}という方針にした.
6470 これは実際に読み込むフォント数を削減することで,
6471 タイプセットにかかる時間と(主にLuaの)メモリ消費を削減するためである(\cite{tc18ltja}).
6472
6473 \begin{itemize}
6474   \item \cs{selectfont}は横組用・縦組用和文フォントのうち,現在の組方向で使う方を
6475   実際に読み込み(・選択し),そうでない方は「フォントサイズとJFMのみ\LuaTeX-jaが把握している状態」
6476   (以下,\emph{JFM把握状態})とする.
6477
6478   \item 組方向変更命令\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod}には
6479   \begin{quote}
6480         新たな組方向での和文フォントが読み込まれていない(JFM把握状態)ならば,
6481         現在のエンコーディング・ファミリ・シリーズ・シェイプから改めて読み込む(または選択する)
6482   \end{quote}
6483   処理が付け加えられている.
6484   もとの「組方向を変更するだけ」の命令は\cs{ltj@@orig@yoko}のように\texttt{ltj@@orig@}が前についた
6485   命令に保存されている.
6486   
6487   \item \cs{jfont},~\cs{tfont},~\cs{DeclareFixedFont}で定義された和文フォントは
6488   その時点で実際にフォントが読み込まれる.すなわち,以下のコードにおいて,
6489   \cs{box0}中の\textbf{JAchar}は\cs{HOGE}でタイプセットされる.
6490 \begin{lstlisting}
6491   % in horizontal direction (\yoko)
6492   \DeclareFixedFont\HOGE{JT3}{gt}{m}{n}{12} % JT3: for vertical direction
6493   \HOGE
6494   \setbox0=\hbox{\tate あいう}
6495 \end{lstlisting}
6496   \end{itemize}
6497 %</ja>
6498
6499 %<en>\subsection{Patch for NFSS2}
6500 %<ja>\subsection{NFSS2へのパッチ}
6501 \label{ssec:nfsspat}
6502
6503 %<*en>
6504 Japanese patch for NFSS2 in \LuaTeX-ja
6505 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
6506 We will describe
6507 commands which are not described in Subsection~\ref{ssec:chgfnt}.
6508 %</en>
6509 %<*ja>
6510 \LuaTeX-jaのNFSS2への日本語パッチは
6511 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
6512 和文エンコーディングの管理等をLuaで書きなおしたものである.
6513 ここでは\ref{ssec:chgfnt}節で述べていなかった命令について
6514 記述しておく.
6515 %</ja>
6516
6517 \begin{cslist}%
6518 \item[\normalfont\bfseries %
6519 %<ja>追加の長さ変数達
6520 %<en>additonal dimensions
6521 ]
6522 %<*en>
6523 Like \pLaTeXe, \LuaTeX-ja defines the following dimensions
6524 for information of current Japanese font:
6525 %</en>
6526 %<*ja>
6527 \pLaTeXe と同様に,\LuaTeX-jaは「現在の和文フォントの情報」を格納する長さ変数
6528 %</ja>
6529 \begin{quote}
6530  \cs{cht}~(height), \cs{cdp}~(depth), \cs{cHT}~(sum of former two),\\
6531  \cs{cwd}~(width), \cs{cvs}~(lineskip), \cs{chs}~(equals to \cs{cwd})
6532 \end{quote}
6533 %<en>and its \cs{normalsize} version:
6534 %<ja>と,その \cs{normalsize} 版である
6535 \begin{quote}
6536  \cs{Cht}~(height), \cs{Cdp}~(depth),
6537  \cs{Cwd}~(width), \\\cs{Cvs}~(equals to \cs{baselineskip}),
6538  \cs{Chs}~(equals to \cs{cwd})%
6539 %<en>.
6540 \end{quote}
6541 %<*ja>
6542 を定義している.なお,\cs{cwd} と \cs{zw},また
6543 \cs{cHT} と \cs{zh} は一致しない可能性がある.なぜなら,
6544 \cs{cwd},~\cs{cHT} は文字クラス0の和文文字の寸法から決定されるのに対し,
6545 \cs{zw} と \cs{zh} はJFMに指定された値に過ぎないからである.
6546 %</ja>
6547 %<*en>
6548 Note that \cs{cwd}~and~\cs{cHT} may  differ from \cs{zw}~and~\cs{zh}
6549 respectively.
6550 On the one hand the former dimensions are determined from
6551 a character whose character class is zero,
6552 but on the other hand \cs{zw}~and~\cs{zh} are specified by JFM.
6553 %</en>
6554
6555
6556 \item[\cs{DeclareYokoKanjiEncoding}\{\meta{encoding}\}\{\meta{text-settings}\}\{\meta{math-settings}\}]
6557 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6558 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6559 \item[\cs{DeclareTateKanjiEncoding}\{\meta{encoding}\}\{\meta{text-settings}\}\{\meta{math-settings}\}]
6560
6561 %<*en>
6562 In NFSS2 under \LuaTeX-ja, distinction between alphabetic fonts
6563              and Japanese fonts are only made by their
6564              encodings. For example, encodings OT1 and T1 are encodings for
6565              alphabetic fonts, and Japanese fonts cannot
6566              have these encodings. These command define a new encoding
6567              scheme for Japanese font families.
6568 %</en>
6569 %<*ja>
6570 \LuaTeX-jaのNFSS2においては,欧文フォントと和文フォントは
6571 そのエンコーディングによってのみ区別される.
6572 例えば,OT1とT1のエンコーディングは欧文フォントのエンコーディングであり,
6573 和文フォントはこれらのエンコーディングを持つことはできない.
6574 これらコマンドは横組用・縦組用和文フォントのための新しいエンコーディングを
6575 それぞれ定義する.
6576 %</ja>
6577
6578 \item[\cs{DeclareKanjiEncodingDefaults}\{\meta{text-settings}\}\{\meta{math-settings}\}]
6579 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6580 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6581 \item[\cs{DeclareKanjiSubstitution}\{\meta{encoding}\}\{\meta{family}\}\{\meta{series}\}\{\meta{shape}\}]
6582 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6583 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6584 \item[\cs{DeclareErrorKanjiFont}\{\meta{encoding}\}\{\meta{family}\}\{\meta{series}\}\{\meta{shape}\}\{\meta{size}\}]
6585
6586 %<*en>
6587 The above 3~commands are just the counterparts for \cs{DeclareFontEncodingDefaults} and~others.
6588 %</en>
6589 %<*ja>
6590 上記3つのコマンドはちょうどNFSS2 の \cs{DeclareFontEncodingDefaults} などに対応するものである.
6591 %</ja>
6592
6593 \item[\cs{reDeclareMathAlphabet}\{\meta{unified-cmd}\}\{\meta{al-cmd}\}\{\meta{ja-cmd}\}]
6594
6595 % ToDo: en
6596 %<*ja>
6597 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
6598 具体的には,欧文数式用フォントファミリ変更の命令\meta{al-cmd}(\cs{mathrm} 等)と,和文数式用フォ
6599              ントファミリ変更の命令\meta{ja-cmd}(\cs{mathmc} 等)の2つを同時に行う命令として
6600              \meta{unified-cmd}を(再)定義する.実際の使用では\meta{unified-cmd}と
6601              \meta{al-cmd}に同じものを指定する,すなわち,\meta{al-cmd}で和文側も変
6602              更させるようにするのが一般的と思われる.
6603
6604 本命令は
6605 \begin{center}
6606 \meta{unified-cmd}\texttt{\{}\meta{arg}\texttt{\}}\quad$\longrightarrow$\quad
6607 (\meta{al-cmd}の1段展開結果)\texttt{\{}\meta{ja-cmd}の1段展開結果)\texttt{\{\meta{arg}\}\}}
6608 \end{center}
6609 と定義を行うので,使用には注意が必要である:
6610 %<en>\vspace{-\medskipamount}
6611 \begin{itemize}
6612 \item \meta{al-cmd},~\meta{ja-cmd}は既に定義されていなければならない.
6613       \cs{reDeclareMathAlphabet}\\の後に
6614 両命令の内容を再定義しても,\meta{unified-cmd}の内容にそれは反映されない.
6615 \item \meta{al-cmd},~\meta{ja-cmd}に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
6616 \end{itemize}
6617 %</ja>
6618
6619 \item[\cs{DeclareRelationFont}\{\meta{ja-encoding}\}\{\meta{ja-family}\}\{\meta{ja-series}\}\{\meta{ja-shape}\}\\*
6620   \null\hfill\{\meta{al-encoding}\}\{\meta{al-family}\}\{\meta{al-series}\}\{\meta{al-shape}\}]
6621 %<*en>
6622 This command sets the ``accompanied'' alphabetic font (given by the latter 4~arguments)
6623 with respect to a Japanese font given by the former 4~arguments.
6624 %</en>
6625 %<*ja>
6626 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントに対して,
6627 そのフォントに対応する「従属欧文」のフォントを後半の4引数により与える.
6628 %</ja>
6629 \item[\cs{SetRelationFont}]
6630 %<*en>
6631 This command is almost same as \cs{DeclareRelationFont}, except that this command does a local
6632 assignment, where \cs{DeclareRelationFont} does a global assignment.
6633 %</en>
6634 %<*ja>
6635 このコマンドは \cs{DeclareRelationFont} とローカルな指定であることを除いて
6636 ほとんど同じである(\cs{DeclareRelationFont} はグローバル).
6637 %</ja>
6638
6639 \item[\cs{userelfont}]
6640 %<*en>
6641 (Only)~at the next call of \cs{selectfont},
6642   change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
6643   font family with respect to current Japanese font family,
6644   which was set by
6645   \cs{DeclareRelationFont} or \cs{SetRelationFont}.
6646
6647   The following is an example of \cs{SetRelationFont} and \cs{userelfont}:
6648 %</en>
6649 %<*ja>
6650 次回(のみ)の\cs{selectfont}の実行時に,現在の欧文フォントのエンコーディング/ファミリ/…… を,
6651 \cs{DeclareRelationFont} か \cs{SetRelationFont} で指定された
6652 現在の和文フォントに対応する「従属欧文」フォントに変更する.
6653
6654   以下に \cs{SetRelationFont} と \cs{userelfont} の例を
6655 紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
6656 Latin Modern Sans Serif (TU/lmss/m/n) に変わっていることがわかる.
6657 %</ja>
6658 \begin{LTXexample}[width=0.3\textwidth]
6659 \makeatletter
6660 \SetRelationFont{JY3}{\k@family}{m}{n}{TU}{lmss}{m}{n}
6661   % \k@family: current Japanese font family
6662 \userelfont\selectfont あいうabc
6663 \end{LTXexample}
6664
6665 \item[\cs{adjustbaseline}]
6666 %<*en>
6667 In \pLaTeXe, \cs{adjustbaseline} sets \cs{tbaselineshift}
6668 to match the vertical center of ``M'' and that of ``漢''  in vertical typesetting:
6669 \[
6670 \text{\cs{tbaselineshift}} \leftarrow
6671 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{漢}}+d_{\text{漢}})}2
6672   + d_{\text{漢}} - d_{\text{M}},
6673 \]
6674 where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively.
6675 In \LuaTeX-ja, this \cs{adjustbaseline} does similar task, namely setting the
6676              \Param{talbaselineshift} parameter
6677 (a Japanese character whose character class is zero is used, instead of `漢' ).
6678 %</en>
6679 %<*ja>
6680 \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「漢」の中心線を一致させるために,
6681 \cs{tbaselineshift} を設定する役割を持っている:
6682 \[
6683 \text{\cs{tbaselineshift}} \leftarrow
6684 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{漢}}+d_{\text{漢}})}2
6685   + d_{\text{漢}} - d_{\text{M}},
6686 \]
6687 ここで,$h_{a}$,~$d_{a}$はそれぞれ「$a$」の高さ・深さを表す.
6688 \LuaTeX-jaにおいても,同じように\cs{adjustbaseline}は\Param{talbaselineshift}パラメータの調整処
6689              理を行っている(但し「漢」でなく「文字クラス0の和文文字」を用いる).
6690
6691 \pLaTeXe では,\cs{adjustbaseline}で(本節の最初に述べた,小文字で始まる)\cs{cht}, \cs{cwd}%の
6692   設定処理も行っていたが,\LuaTeX-jaでも全く同様である.
6693 %</ja>
6694
6695 \item[\cs{fontfamily}\{\meta{family}\}]
6696 %<*en>
6697 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
6698 to \meta{family}. See Subsection~\ref{ssec:fontfamilycmd} for detail.
6699 %</en>
6700 %<*ja>
6701 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
6702 和文,\emph{もしくは両方})を\meta{family}に変更する.詳細は\ref{ssec:fontfamilycmd}節を参照すること.
6703 %</ja>
6704
6705 \item[\cs{fontshape}\{\meta{shape}\}\textrm{, }\cs{fontshapeforce}\{\meta{shape}\}]
6706 %<*en>
6707 As in \LaTeXe, this command changes current alphabetic font shape
6708 according to shape change rules.
6709
6710 Traditionally, \cs{fontshape} changes also current Japanese font shape always.
6711 However, this leads a lot of \LaTeX\ font warning like
6712 \begin{verbatim}
6713     Font shape `JY3/mc/m/it' undefined
6714     using `JY3/mc/m/n' instead on ....
6715 \end{verbatim}
6716 when \cs{itshape} is called,
6717 because almost all Japanese fonts only have shape ``\texttt{n}'', and \cs{itshape} calls \cs{fontshape}.
6718
6719 \LuaTeX-ja~20200323.0 change the behavior. Namely,
6720 \cs{fontshape\{\meta{shape}\}}~and~\cs{fontshapeforce\{\meta{shape}\}} change current Japanese font shape, only if
6721 the required shape (according to shape changing rules) or \meta{shape} is avaliable in current Japanese font family/series.
6722 When this is not the case, an info such as
6723 \begin{verbatim}
6724     Kanji font shape JY3/mc/m/it' undefined
6725     No change on ...
6726 \end{verbatim}
6727 is issued instead of a warning.
6728 %</en>
6729 %<*ja>
6730 元々の\LaTeXe におけるものと同様に,このコマンドは現在の欧文フォントシェイプを
6731 \cs{DeclareFontShapeChangeRule}によるシェイプ更新規則によって変更する.
6732
6733 伝統的には,\cs{fontshape}は無条件に和文フォントシェイプも変更した.しかし,例えば多くの和文フォントは
6734 シェイプが``\texttt{n}''しか持たないことと\cs{itshape}が\cs{fontshape}を呼び出すことから,
6735 \begin{verbatim}
6736     Font shape `JY3/mc/m/it' undefined
6737     using `JY3/mc/m/n' instead on ....
6738 \end{verbatim}
6739 といった警告をもたらしてしまっていた.
6740
6741 一方,\LuaTeX-ja 20200323.0以降では,
6742 \cs{fontshape\{\meta{shape}\}}, \cs{fontshapeforce\{\meta{shape}\}}が和文フォントシェイプを更新するのは,
6743 シェイプ更新規則に基づいた値や\meta{shape}の少なくとも一つが現在の和文フォントファミリ・シリーズで利用可能なときに限られる.
6744 どちらでもなく,和文フォントシェイプが変更されなかった場合には
6745 \begin{verbatim}
6746     Kanji font shape JY3/mc/m/it' undefined
6747     No change on ...
6748 \end{verbatim}
6749 というinfo(警告でなく)を出力する.
6750 %</ja>
6751
6752 \item[\cs{kanjishape}\{\meta{shape}\}\textrm{, }\cs{kanjishapeforce}\{\meta{shape}\}]
6753 %<*en>
6754 \cs{kanjishape\{\meta{shape}\}} changes current Japanese font shape according to shape change rules, and
6755 \cs{kanjishapeforce\{\meta{shape}\}} changes current Japanese font shape to \meta{shape}, regardless of the rules.
6756 Hence \cs{kanjishape\{it\}} produces a warning
6757 \begin{verbatim}
6758     Font shape `JY3/mc/m/it' undefined
6759     using `JY3/mc/m/n' instead on ....
6760 \end{verbatim}
6761 which is not produced by \cs{fontshape\{it\}}.
6762 %</en>
6763 %<*ja>
6764   ...
6765 %</ja>
6766
6767
6768 \begin{figure}[!tb]
6769 \begin{LTXexample}[pos=b]
6770 \DeclareKanjiFamily{JY3}{edm}{}
6771 \DeclareFontShape{JY3}{edm}{m}{n}   {<-> s*HaranoAjiMincho-Regular:jfm=ujis}{}
6772 \DeclareFontShape{JY3}{edm}{m}{fb}  {<-> s*HaranoAjiGothic-Regular:jfm=ujis;color=003FFF}{}
6773 \DeclareFontShape{JY3}{edm}{m}{fb2} {<-> s*HaranoAjiGothic-Regular:jfm=ujis;color=FF1900}{}
6774 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{fb}{ "4E00-"67FF,{-2}-{-2}}
6775 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{fb2}{"6800-"9FFF}
6776 {\kanjifamily{edm}\selectfont
6777 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
6778 \end{LTXexample}
6779 %<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
6780 %<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
6781 \label{fig:altkanji}
6782 \end{figure}
6783
6784 \item[\cs{DeclareAlternateKanjiFont}\\
6785   \{\meta{base-encoding}\}\{\meta{base-family}\}\{\meta{base-series}\}\{\meta{base-shape}\}\\
6786   \{\meta{alt-encoding}\}\{\meta{alt-family}\}\{\meta{alt-series}\}\{\meta{alt-shape}\}\{\meta{range}\}]
6787 %<*ja>
6788 \ref{ssec:altfont}節の\
6789 \cs{ltjdeclarealtfont} と同様に,前半の4引数の
6790 和文フォント(基底フォント)のうち\meta{range}中の文字を
6791 第5から第8引数の和文フォントを使って組むように指示する.
6792 使用例を図\nobreak\ref{fig:altkanji}に載せた.
6793
6794 \begin{itemize}
6795  \item
6796 \cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
6797              ないといけない(その代わり即時発効)たが,
6798 \cs{DeclareAlternateKanjiFont} の設定が
6799 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
6800 あるいは(これらを含むが)\cs{selectfont} が実行された時である.
6801  \item
6802 段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
6803 \meta{range}に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
6804 と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
6805 \end{itemize}%
6806 %</ja>
6807 %<*en>
6808 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec:altfont}),
6809 characters in \meta{range} of the Japanese font (we say the \emph{base font})
6810 which specified by first 4 arguments are typeset
6811 by the Japanese font which specified by fifth to eighth arguments
6812 (we say the \emph{alternate font}).
6813 An example is shown in \autoref{fig:altkanji}.
6814
6815 \begin{itemize}
6816  \item
6817 In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
6818 But this \cs{DeclareAlternateKanjiFont} is not so.
6819 In other words, \cs{DeclareAlternateKanjiFont} is effective only after
6820 current Japanese font is changed, or only after \cs{selectfont} is executed.
6821  \item \dots
6822 \end{itemize}%
6823 \vspace{-\medskipamount}
6824 %</en>
6825 \end{cslist}
6826
6827
6828 %<*en>
6829 Furthermore, \LuaTeX-ja applies patches which enables NFSS2 commands,
6830 such~as \cs{DeclareSymbolFont}~and~\cs{SetSymbolFont}, to specify
6831 Japanee fonts as math fonts.
6832
6833 Specifying \texttt{disablejfam} option in \cs{usepackage} prevents
6834 applying these patches.
6835 Hence one cannot write Japanese Characters in math mode directly
6836 if \texttt{disablejfam} option is specified.
6837 The code below does not work either:
6838 \begin{lstlisting}
6839 \DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
6840 \DeclareSymbolFontAlphabet{\mathmc}{mincho}
6841 \end{lstlisting}
6842 %</en>
6843 %<*ja>
6844 この他にも,標準では
6845 \cs{DeclareSymbolFont}, \cs{SetSymbolFont} などの命令で
6846 (NFSS2の枠組みで)数式フォントとして日本語フォントを使えるようにするためのパッチを当てている.
6847
6848 一方,\texttt{disablejfam}オプション指定時には,これらのパッチを当てないので
6849 \begin{lstlisting}
6850 \DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
6851 \DeclareSymbolFontAlphabet{\mathmc}{mincho}
6852 \end{lstlisting}
6853 のように設定しても,数式モード中に直に日本語を記述することはできない.
6854 \verb|$\mathmc{あ}$| のように \cs{mathmc} で囲んでもできない.
6855 %</ja>
6856
6857 %<en>\subsection{Detail of \cs{fontfamily} command}
6858 %<ja>\subsection{\cs{fontfamily}コマンドの詳細}
6859 \label{ssec:fontfamilycmd}
6860 %<*en>
6861 In this subsection, we describe when \cs{fontfamily}\meta{family} changes current
6862 Japanese/alphabetic font family. Basically, current Japanese fotn family is changed to
6863 \meta{family} if it is recognized as a Japanese font family, and similar with alphabetic font
6864 family. There is a case that current Japanese/alphabetic font family are both changed to
6865 \meta{family}, and another case that \meta{family} isn't recognized as a Japanese/alphabetic font
6866 family either.
6867
6868 \paragraph{Recognition as Japanese font family}
6869 First, Whether Japanese font family will be changed is determined in following order.
6870 This order is very similar to \cs{fontfamily} in \pLaTeXe, but we re-implemented in Lua.
6871 We use an auxiliary list~$N_{\mathrm{J}}$.
6872 %</en>
6873 %<*ja>
6874 本節では,\cs{fontfamily}\meta{family} がいつ和文/欧文フォントファミリを変更するかについて解説
6875 する.基本的には,\meta{family}が和文フォントファミリだと認識されれば和文側が,欧文フォントファ
6876 ミリだと認識されれば欧文側が変更される.どちらとも認識されれば和文・欧文の両方が変わるこ
6877 とになるし,当然どちらとも認識されないこともある.
6878
6879 \paragraph{和文フォントファミリとしての認識}
6880 まず,\meta{family}が和文フォントファミリとして認識されるかは以下の順序で決定される.
6881 これは\pLaTeXe の \cs{fontfamily} にとても似ているが,ここではLuaによって実装している.
6882 補助的に「和文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{J}}$を用いる.
6883 %</ja>
6884 \begin{enumerate}
6885 %<*en>
6886 \item If the family~\meta{family} has been defined already by \cs{DeclareKanjiFamily},
6887       \meta{family} is recognized as a  Japanese font family.
6888       Note that \meta{family} need not be defined under \emph{current} Japanese font encoding.
6889 %</en>
6890 %<*ja>
6891 \item ファミリ\meta{family}が既に \cs{DeclareKanjiFamily} によって定義されている場合,
6892       \meta{family}は和文フォントファミリであると認識される.
6893       ここで,\meta{family}は現在の和文フォントエンコーディングで定義されていなくてもよい.
6894 %</ja>
6895 %<*en>
6896 \item If the family~\meta{family} has been listed in a list~$N_{\mathrm{J}}$, this means
6897       that \meta{family} is not a Japanese font family.
6898 %</en>
6899 %<*ja>
6900 \item ファミリ\meta{family}がリスト$N_{\mathrm{J}}$に既に含まれていれば,それは
6901       \meta{family}が和文フォントファミリではないことを意味する.
6902 %</ja>
6903 %<*en>
6904 \item If the \Pkg{luatexja-fontspec} package is loaded, we stop here, and \meta{family} is not
6905       recognized as a Japanese font family.
6906
6907       If the \Pkg{luatexja-fontspec} package is \emph{not} loaded,
6908 now \LuaTeX-ja looks whether there exists a Japanese font encoding~\meta{enc} such that
6909       a font definition named \texttt{\meta{enc}\meta{family}.fd} (the file name is
6910       all lowercase) exists. If so, \meta{family} is recognized as a  Japanese font family (the font definition file won't be loaded here).
6911       If not, \meta{family} is not a Japanese font family, and
6912       \meta{family} is appended to the list~$N_{\mathrm{J}}$.
6913 %</en>
6914 %<*ja>
6915 \item もし\Pkg{luatexja-fontspec}パッケージが読み込まれていれば,ここで終了であり,
6916 \meta{family}は和文フォントファミリとして認識されないことになる.
6917
6918 もし\Pkg{luatexja-fontspec}パッケージが読み込まれていなければ,和文エンコーディング\meta{enc}で
6919 フォント定義ファイル\texttt{\meta{enc}\meta{family}.fd}(ファイル名は全て小文字)が存在するようなも
6920       のがあるかどうかを調べる.
6921 存在すれば,\meta{family}は和文フォントファミリと認識される(フォント定義ファイルは読み込まれな
6922       い).
6923 存在しなければ,\meta{family}は和文フォントファミリでないと認識され,リスト$N_{\mathrm{J}}$に\meta{family}を追加することでそれを記憶する.
6924
6925 %</ja>
6926 \end{enumerate}
6927
6928 %<*en>
6929 \paragraph{Recognition as alphabetic font family}
6930 Next, whether alphabetic font family will be changed is determined in following order.
6931 We use auxiliary lists $F_{\mathrm{A}}$~and~$N_{\mathrm{A}}$,
6932 %</en>
6933 %<*ja>
6934 \paragraph{欧文フォントファミリとしての認識}
6935 同様に,\meta{family}が和文フォントファミリとして認識されるかは以下の順序で決定される.
6936 補助的に「欧文フォントファミリと既に認識された」ファミリのリスト$F_{\textrm{A}}$と,
6937 「欧文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{A}}$を用いる.
6938 %</ja>
6939
6940 \begin{enumerate}
6941 %<*en>
6942 \item If the family~\meta{family} has been listed in a list~$F_{\mathrm{A}}$,
6943       \meta{family} is recognized as an alphabetic font family.
6944 %</en>
6945 %<*ja>
6946 \item ファミリ\meta{family}がリスト$F_{\mathrm{A}}$に既に含まれていれば,
6947       \meta{family}は欧文フォントファミリと認識される.
6948 %</ja>
6949 %<*en>
6950 \item If the family~\meta{family} has been listed in a list~$N_{\mathrm{A}}$, this means
6951       that \meta{family} is not  an alphabetic font family.
6952 %</en>
6953 %<*ja>
6954 \item ファミリ\meta{family}がリスト$N_{\mathrm{A}}$に既に含まれていれば,それは
6955       \meta{family}が欧文フォントファミリではないことを意味する.
6956 %</ja>
6957 %<*en>
6958 \item If there exists an alphabetic font encoding such that the family~\meta{family} has been
6959       defined under it, \meta{family} is recognized as an alphabetic font family, and
6960       to memorize this, \meta{family} is appended to the list~$F_{\mathrm{A}}$.
6961 %</en>
6962 %<*ja>
6963 \item ある欧文フォントエンコーディング下でファミリ\meta{family}が定義されていれば,
6964       \meta{family}は欧文フォントファミリと認識され,リスト$F_{\mathrm{A}}$に\meta{family}を追加することでこのことを記憶する.
6965 %</ja>
6966 %<*en>
6967 \item Now \LuaTeX-ja looks whether there exists an alphabetic font encoding~\meta{enc} such that
6968       a font definition named \texttt{\meta{enc}\meta{family}.fd} (the file name is
6969       all lowercase) exists. If so, current alphabetic font family will be changed to
6970       \meta{family}~(the font definition file won't be loaded here).
6971       If not, current alphabetic font family won't be changed, and
6972       \meta{family} is appended to the list~$N_{\mathrm{A}}$.
6973 %</en>
6974 %<*ja>
6975 \item 最終段階では,欧文エンコーディング\meta{enc}で
6976 フォント定義ファイル\texttt{\meta{enc}\meta{family}.fd}(ファイル名は全て小文字)が存在するようなも
6977       のがあるかどうかを調べる.
6978 存在すれば,\meta{family}は欧文フォントファミリと認識される(フォント定義ファイルは読み込まれない).
6979 存在しなければ,\meta{family}は欧文フォントファミリと認識されないので,リスト$N_{\mathrm{A}}$に
6980       \meta{family}を追加してそのことを記憶する.
6981 %</ja>
6982 \end{enumerate}
6983
6984 %<*en>
6985 Also, each call of \cs{DeclareFontFamily} \emph{after} loading of \LuaTeX-ja makes
6986 the second argument (family) is appended to the list~$F_{\mathrm{A}}$.
6987 %</en>
6988 %<*ja>
6989 また,\cs{DeclareFontFamily}が\LuaTeX-jaの読み込み後に実行された場合は,
6990 第2引数(ファミリ名)が自動的に$F_{\mathrm{A}}$に追加される.
6991 %</ja>
6992
6993 %<*en>
6994 The above order is very similar to \cs{fontfamily} in \pLaTeXe, but more complicated (clause~3.).
6995 This is because  \pLaTeXe\ is a \emph{format} however \LuaTeX-ja is not,
6996 hence \LuaTeX-ja does not know calls of \cs{DeclareFontFamily} \emph{before} itself is
6997 loaded.
6998 %</en>
6999 %<*ja>
7000 以上の方針は\pLaTeXe における \cs{fontfamily} にやはり類似しているが,3.が加わり若干複雑になっている.
7001 それは\pLaTeXe がフォーマットであるのに対し\LuaTeX-jaはそうでないため,
7002 \LuaTeX-jaは自身が読み込まれる前にどういう\cs{DeclareFontFamily}の呼び出しがあったか
7003 把握できないからである.
7004 %</ja>
7005
7006 %<en>\paragraph{Remarks}
7007 %<ja>\paragraph{注意}
7008 %<*en>
7009 Of course, there is a case that \meta{family} is not recognized as a Japanese font family,  nor
7010 an alphabetic font family.
7011 In this case, \LuaTeX-ja treats ``the argument \meta{family} is wrong'', so
7012 set both current alphabetic and Japanese font family to \meta{family},
7013 to use the default family for font substitution.
7014 %</en>
7015 %<*ja>
7016 さて,引数によっては,「和文フォントファミリとも欧文フォントファミリも認識されなかった」
7017 という事態もあり得る.
7018   この場合,引数\meta{family}は不正だった,ということになるので,
7019 和文・欧文の両方のフォントファミリを\meta{family}に設定し,代用フォントが使われるに任せることにする.
7020 %</ja>
7021
7022 %<*en>
7023 \subsection{Notes on \cs{DeclareTextSymbol}}
7024 From \LaTeX~2017/01/01, the standard encoding of \LuaLaTeX\ is changed to the \texttt{TU}
7025 encoding. This menas that symbols defined by \texttt{T1}~and~\texttt{TS1} encodings can be used
7026 without loading any package. To produces these symbols in alphabetic fonts in \LuaTeX-ja,
7027 \LuaTeX-ja patches \cs{DeclareTextSymbol}, and reloads \texttt{tuenc.def}.
7028
7029 Under original definition of \cs{DeclareTextSymbol},
7030 internal commands which is defined by \cs{DeclareTextSymbol} (such as \cs{T1\cs{textquotedblleft}})
7031 are \textit{chardef} tokens. However, this no longer holds in \LuaTeX-ja;
7032 for example, the meaning of \cs{TU\cs{textquotedblleft}} is \cs{ltjalchar8220\ltjalchar"2423 }.
7033 %</en>
7034 %<*ja>
7035 \subsection{\cs{DeclareTextSymbol}使用時の注意}
7036 \LaTeX~(2017/01/01)以降では,\texttt{TU}エンコーディングが標準となり,特に何もしなくても
7037 \texttt{T1},~\texttt{TS1}エンコーディングで定義されていた記号類が
7038 使えるようになった.\LuaTeX-jaではこれらの命令によって記号が欧文フォントで出力されるようにするため,
7039 \cs{DeclareTextSymbol}命令を改変し,そして\texttt{TU}エンコーディングの定義である
7040 \texttt{tuenc.def}を再読込している.
7041
7042 従来は \cs{DeclareTextSymbol} で内部的に定義された\cs{T1\cs{textquotedblleft}}といった命令は
7043 \textit{chardef}トークンであった.しかし前段落で述べた改変によりもはやそうではなくなっており,例えば
7044 \cs{TU\cs{textquotedblleft}}は \cs{ltjalchar8220\ltjalchar"2423 } という定義になっている.%"
7045 %</ja>
7046
7047 \begin{table}[t]
7048   \centering\small
7049   \caption{strut}\label{tab:strutbox}\medskip
7050   \begin{tabular}{llcccl}
7051     \toprule
7052     \textbf{box}&\textbf{direction}&\textbf{width}&\textbf{height}&\textbf{depth}
7053     &\textbf{user command}\\
7054     \midrule
7055   \cs{ystrutbox}&yoko&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{ystrut}\\\midrule
7056   \cs{tstrutbox}&tate, utod&0&0.5\cs{baselineskip}&0.5\cs{baselineskip}&\cs{tstrut}\\\midrule
7057   \cs{dstrutbox}&dtou&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{dstrut}\\\midrule
7058   \cs{zstrutbox}&---&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{zstrut}\\\bottomrule
7059   \end{tabular}
7060 \end{table}
7061 %<*en>
7062 \subsection{\cs{strutbox}}
7063 As \pLaTeX~(2017/04/08 or later), \cs{strutbox} is \emph{a macro} which is expanded to one of
7064 \cs{ystrutbox},~\cs{tstrutbox},~and~\cs{dstrutbox}
7065 (all of them are shown in \autoref{tab:strutbox}), according to the current direction.
7066 Similarly, \cs{strut} now uses one of these boxes.
7067 %</en>
7068 %<*ja>
7069 \subsection{\cs{strutbox}}
7070 \pLaTeX~2017/04/08以降と同じように,
7071 \cs{strutbox}は現在の組方向によって\cs{ystrutbox}, \cs{tstrutbox}, \cs{dstrutbox}の
7072 いずれかに展開される\emph{マクロ}となっている(これらについては\autoref{tab:strutbox}参照).
7073 同様に\cs{strut}もこの3\nobreak ボックスのいずれかを組方向によって使い分けるようになっている.
7074
7075 \cs{zstrutbox}はutod方向(\pTeX でいう縦数式ディレクション)で使われる支柱ボックスであるが,
7076 実際に使われるのは\cs{zstrut}が明示的に発行された時,そして
7077 \Pkg{lltjext}パッケージで追加される組方向指定で \texttt{<u>} を指定した時,および
7078 周囲が縦組の状況で \texttt{<z>} を指定した時に限られている.
7079 %</ja>
7080
7081 %<*en>
7082 \section{expl3 interface}
7083 This section describes expl3 interfaces provided by \LuaTeX-ja.
7084 All of them belong to te \texttt{platex} module, since they are provided for compatibility with Japanese \pLaTeX.
7085 Note that commands which are marked with dagger (``\dagger'') are additions by \LuaTeX-ja.
7086 %</en>
7087 %<*ja>
7088 \section{expl3形式の命令}
7089 expl3の文法に沿った組方向変更命令や組方向による条件判断文である.
7090 これらは\pLaTeX との互換性の為に用意されているので,\texttt{platex}モジュールとして定義されている.
7091 なお,``\dagger''がついている命令は\LuaTeX-ja独自のものである.
7092 %</ja>
7093 \begin{cslist}
7094   \item[\cs{platex\_direction\_yoko:}\textrm{, }\cs{platex\_direction\_tate:}\textrm{, }\cs{platex\_direction\_dtou:}]
7095 %<ja>  それぞれ\cs{yoko},~\cs{tate},~\cs{dtou}と同義.
7096 %<en>  Synonyms for \cs{yoko},~\cs{tate}~and~\cs{dtou}, respectively.
7097   \item[\cs{platex\_if\_direction\_yoko\_p:}]
7098 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7099 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7100   \item[\cs{platex\_if\_direction\_yoko:\underline{\textsl{TF}}} \{\meta{true code}\} \{\meta{false code}\}]
7101 %<ja>  現在の組方向が横組であるか否かをテストする.
7102 %<en>  Tests if the current direction is \emph{yoko} (horizontal writing).
7103   \item[\cs{platex\_if\_direction\_tate\_nomath\_p:}$^\dagger$]
7104 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7105 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7106   \item[\cs{platex\_if\_direction\_tate\_nomath:\underline{\textsl{TF}}}$^\dagger$ \{\meta{true code}\} \{\meta{false code}\}]
7107 %<ja>  現在の組方向が縦組であるか否かをテストする.
7108 %<en>  Tests if the current direction is \emph{tate} (vertical writing).
7109   \item[\cs{platex\_if\_direction\_tate\_math\_p:}$^\dagger$]
7110 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7111 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7112   \item[\cs{platex\_if\_direction\_tate\_math:\underline{\textsl{TF}}}$^\dagger$ \{\meta{true code}\} \{\meta{false code}\}]
7113 %<ja>  現在の組方向がutod方向(\pTeX でいう「縦数式ディレクション」)であるか否かをテストする.
7114 %<en>  Tests if the current direction is \emph{utod}.
7115   \item[\cs{platex\_if\_direction\_tate\_p:}]
7116 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7117 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7118   \item[\cs{platex\_if\_direction\_tate:\underline{\textsl{TF}}} \{\meta{true code}\} \{\meta{false code}\}]
7119 %<ja>  現在の組方向が縦組またはutod方向であるか否かをテストする.
7120 %<en>  Tests if the current direction is \emph{tate}~or~\emph{utod}.
7121   \item[\cs{platex\_if\_direction\_dtou\_p:}]
7122 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7123 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7124   \item[\cs{platex\_if\_direction\_dtou:\underline{\textsl{TF}}} \{\meta{true code}\} \{\meta{false code}\}]
7125 %<ja>  現在の組方向がdtou方向であるか否かをテストする.
7126 %<en>  Tests if the current direction is \emph{dtou}.
7127   \item[\cs{platex\_if\_box\_yoko\_p:N} \meta{box}]
7128 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7129 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7130   \item[\cs{platex\_if\_box\_yoko:N\underline{\textsl{TF}}} \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7131 %<ja>  ボックス\meta{box}の組方向が横組であるか否かをテストする.
7132 %<en>  Tests if the direction of \meta{box} is \emph{yoko}.
7133   \item[\cs{platex\_if\_box\_tate\_nomath\_p:N}$^\dagger$ \meta{box}]
7134 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7135 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7136   \item[\cs{platex\_if\_box\_tate\_nomath:N\underline{\textsl{TF}}}$^\dagger$ \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7137 %<ja>  ボックス\meta{box}の組方向が縦組であるか否かをテストする.
7138 %<en>  Tests if the direction of \meta{box} is \emph{tate}.
7139   \item[\cs{platex\_if\_box\_tate\_math\_p:N}$^\dagger$ \meta{box}]
7140 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7141 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7142   \item[\cs{platex\_if\_box\_tate\_math:N\underline{\textsl{TF}}}$^\dagger$ \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7143 %<ja>  ボックス\meta{box}の組方向がutod方向であるか否かをテストする.
7144 %<en>  Tests if the direction of \meta{box} is \emph{utod}.
7145   \item[\cs{platex\_if\_box\_tate\_p:N} \meta{box}]
7146 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7147 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7148   \item[\cs{platex\_if\_box\_tate:N\underline{\textsl{TF}}} \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7149 %<ja>  ボックス\meta{box}の組方向が縦組またはutod方向であるか否かをテストする.
7150 %<en>  Tests if the direction of \meta{box} is \emph{tate}~or~\emph{utod}.
7151   \item[\cs{platex\_if\_box\_dtou\_p:N} \meta{box}]
7152 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7153 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7154 \item[\cs{platex\_if\_box\_dtou:N\underline{\textsl{TF}}} \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7155 %<ja>    ボックス\meta{box}の組方向がdtou方向であるか否かをテストする.
7156 %<en>  Tests if the direction of \meta{box} is \emph{dtou}.
7157 \end{cslist}
7158
7159
7160 %<*en>
7161 \section{Addon packages}
7162 \LuaTeX-ja has several addon packages.
7163 These addons are written as \LaTeX\ packages, but
7164 \Pkg{luatexja-otf} and~\Pkg{luatexja-adjust} can be loaded in plain \LuaTeX\
7165 by \cs{input}.
7166 %</en>
7167 %<*ja>
7168 \section{拡張パッケージ}
7169 \LuaTeX-jaには(動作には必須ではないが)自由に読み込める拡張が付属している.
7170 これらは\LaTeX のパッケージとして制作しているが,
7171 \Pkg{luatexja-otf}と\Pkg{luatexja-adjust}についてはplain \LuaTeX でも\
7172 \cs{input} で読み込み可能である.
7173 %</ja>
7174 \subsection{\Pkg{luatexja-fontspec}}
7175 \label{ssec:fontspec2}
7176 %<*en>
7177 As described in Subsection~\ref{ssec:fontspec}, this optional package
7178 provides the counterparts for several commands defined in the
7179 \Pkg{fontspec} package (requires \Pkg{fontspec}~v2.4).
7180 In addition to OpenType font features in the original \Pkg{fontspec},
7181 the following ``font features'' specifications are allowed for
7182 the commands of Japanese version:
7183 %</en>
7184 %<*ja>
7185 \ref{ssec:fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}%
7186 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
7187
7188 \Pkg{fontspec}パッケージで指定可能な各種OpenType機能に加えて,和文版のコマンドには
7189 以下の「フォント機能」を指定することができる:
7190 %</ja>
7191
7192
7193 \begin{cslist}
7194 \item[CID=\meta{name}\textrm{, }JFM=\meta{name}\textrm{, }JFM-var=\meta{name}]
7195
7196 %<*en>
7197 These 3 keys correspond to \texttt{cid}, \texttt{jfm} and
7198 \texttt{jfmvar} keys for \cs{jfont}~and~\cs{tfont} respectively.
7199 See Subsections~\ref{ssec:jfont} and \ref{ssec:psft} for details
7200  of \texttt{cid}, \texttt{jfm} and
7201 \texttt{jfmvar} keys.
7202
7203 The \texttt{CID} key is effective only when with \texttt{NoEmbed}
7204 described below. The same JFM cannot be used in both horizontal Japanese fonts and
7205              vertical Japanese fonts, hence the \texttt{JFM} key
7206 will be actually used in \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
7207 %</en>
7208 %<*ja>
7209 これら3つのキーはそれぞれ \cs{jfont},~\cs{tfont}に対する
7210 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
7211 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec:jfont}節
7212              と\ref{ssec:psft}節を参照.
7213
7214 \texttt{CID} キーは下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
7215 また,横組用JFMと縦組用JFMは共用できないため,実際に \texttt{JFM} キーを用いる際は
7216 後に述べる\ \texttt{YokoFeatures} キーや \texttt{TateFeatures}\ の中で用いる
7217 ことになる.
7218 %</ja>
7219
7220 \item[NoEmbed]
7221 %<*en>
7222 By specifying this key, one can use ``name-only'' Japanese font which
7223 will not be embedded in the output PDF file. See Subsection~\ref{ssec:psft}.
7224 %</en>
7225 %<*ja>
7226 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
7227 できる.\ref{ssec:psft}節を参照.
7228 %</ja>
7229
7230 \begin{figure}[!tb]
7231 \begin{LTXexample}[width=0.25\textwidth]
7232 \jfontspec[
7233   YokoFeatures={Color=FF1900}, TateFeatures={Color=003FFF},
7234   TateFont=HaranoAjiGothic-Regular
7235 ]{HaranoAjiMincho-Regular}
7236 \hbox{\yoko 横組のテスト}\hbox{\tate 縦組のテスト}
7237 \addjfontfeatures{Color=00AF00}
7238 \hbox{\yoko 横組}\hbox{\tate 縦組}
7239 \end{LTXexample}
7240 %<ja>\caption{\texttt{TateFeatures} 等の使用例}
7241 %<en>\caption{An example of \texttt{TateFeatures} etc.}
7242 \label{fig:yokotate-fontspec}
7243 \end{figure}
7244
7245 \item[Kanjiskip=\meta{bool}]
7246 %<*ja>
7247 \pageref{pg:ltjksp}ページで説明した \verb+\jfont+ 中での \texttt{ltjksp} 指定と
7248 同一の効力を持ち,
7249 JFM中における \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
7250 \texttt{kanjiskip\_shrink}キー(\pageref{pg:ksp_nat}ページ)の有効/無効を切り替える.
7251 標準値は \texttt{true} である.
7252 %</ja>
7253
7254 \item[TateFeatures=\{\meta{features}\}\textrm{, }TateFont=\meta{font}]
7255 %<*en>
7256 The \texttt{TateFeatures} key specifies font features which are only turned~on in
7257 vertical writing, such as \texttt{Style=VerticalKana}~(\texttt{vkna} feature).
7258 Similarly, the \texttt{TateFont} key specifies the Japanese font which will be used only
7259              in vertical writing.
7260 A demonstrarion is shown in \autoref{fig:yokotate-fontspec}.
7261 %</en>
7262 %<*ja>
7263 縦組において使用されるフォントや,縦組においてのみ適用されるフォント機能達を
7264 指定する.使用例は\autoref{fig:yokotate-fontspec}参照.
7265 %</ja>
7266
7267 \item[YokoFeatures=\{\meta{features}\}]
7268 %<*en>
7269 The \texttt{YokoFeatures} key specifies font features which are only turned~on in
7270 horizontal writing,.
7271 A demonstrarion is shown in \autoref{fig:yokotate-fontspec}.
7272 %</en>
7273 %<*ja>
7274 同様に,横組においてのみ適用されるフォント機能達を
7275 指定する.使用例は\autoref{fig:yokotate-fontspec}参照.
7276 %</ja>
7277
7278
7279 \begin{figure}[!tb]
7280 \begin{LTXexample}[pos=b]
7281 \jfontspec[
7282   AltFont={
7283     {Range="4E00-"67FF, Font=HaranoAjiGothic-Regular, Color=003FFF},
7284     {Range="6800-"9EFF, Color=FF1900},
7285     {Range="3040-"306F, Font=HaranoAjiGothic-Regular, Color=35A16B},
7286   }
7287 ]{HaranoAjiMincho-Regular}
7288 日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
7289 諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
7290 \end{LTXexample}
7291 %<ja>\caption{\texttt{AltFont} の使用例}
7292 %<en>\caption{An example of \texttt{AltFont}}
7293 \label{fig:altkanji-fontspec}
7294 \end{figure}
7295
7296 \item[AltFont]
7297
7298 %<*en>
7299 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec:altfont}) and
7300 \cs{DeclareAlternateKanjiFont}~(Subsection~\ref{ssec:nfsspat}),
7301 with this key, one can typeset some Japanese characters
7302 by a different font and/or using different features.
7303 The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
7304 as the following:
7305 %</en>
7306 %<*ja>
7307 \ref{ssec:altfont}節の \cs{ltjdeclarealtfont} や,
7308 \ref{ssec:nfsspat}節の \cs{DeclareAlternateKanjiFont} と同様に,
7309 このキーを用いると一部の文字を異なったフォントや機能たちを使って組むことができる.
7310 \texttt{AltFont} キーに指定する値は,次のように二重のコンマ区切りリストである:
7311 %</ja>
7312 \begin{lstlisting}[escapechar=\#]
7313 AltFont = {
7314   ...
7315   { Range=#\meta{range}#, #\meta{features}#},
7316   { Range=#\meta{range}#, Font=#\meta{font~name}#, #\meta{features}# },
7317   { Range=#\meta{range}#, Font=#\meta{font~name}># },
7318   ...
7319 }
7320 \end{lstlisting}
7321 %<*en>
7322 Each sublist should have the \texttt{Range} key
7323 (sublist which does not contain \texttt{Range} key is simply ignored).
7324 A demonstrarion is shown in \autoref{fig:altkanji-fontspec}.
7325 %</en>
7326 %<*ja>
7327 各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
7328 単純に無視される).指定例は\autoref{fig:altkanji-fontspec}に示した.
7329 %</ja>
7330 \end{cslist}
7331
7332 %<*ja>
7333 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
7334 \texttt{\meta{ja-enc}\meta{family}.fd}は全く参照されなくなる.
7335 %</ja>
7336
7337
7338 %<*en>
7339 \paragraph{Remark on \texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} keys}
7340 \leavevmode\par
7341 In \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures} keys,
7342 one cannot specify per-shape settings such as \texttt{BoldFeatures}.
7343 For example,
7344 \begin{lstlisting}
7345 AltFont = {
7346   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
7347     Range="3000-"30FF, BoldFeatures={Color=FF1900} }
7348 }
7349 \end{lstlisting}
7350 does \emph{not} work. Instead, one have to write
7351 \begin{lstlisting}
7352 UprightFeatures = {
7353   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
7354 },
7355 BoldFeatures = {
7356   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=FF1900 } },
7357 }
7358 \end{lstlisting}
7359
7360 On the other hand, \texttt{YokoFeatures}, \texttt{TateFeatures} and  \texttt{TateFont}
7361 keys can be specified in each list in the \texttt{AltFont} key. Also,
7362 one can specify \texttt{AltFont} inside \texttt{YokoFeatures},~\texttt{TateFeatures}.
7363
7364 Note that features which are specified in \texttt{YokoFeatures}~and~\texttt{TateFeatures}
7365 are always interpreted \emph{after} other ``direction-independent'' features.
7366 This explains why \cs{addjfontfeatures} at~line~6 in~\autoref{fig:yokotate-fontspec}
7367 has no effect, because a color specification is already done in
7368 \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
7369 %</en>
7370 %<*ja>
7371 \paragraph{\texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} 等の制限}
7372 \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures}の各キーは
7373 シェイプ別に指定されるべきものであり,
7374 内部では \texttt{BoldFeatures} などのシェイプ別の指定は行うことが出来ない.
7375 例えば.
7376 \begin{lstlisting}
7377 AltFont = {
7378   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
7379     Range="3000-"30FF, BoldFeatures={Color=FF1900} }
7380 }
7381 \end{lstlisting}
7382 のように指定することは出来ず,
7383 \begin{lstlisting}
7384 UprightFeatures = {
7385   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
7386 },
7387 BoldFeatures = {
7388   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=FF1900 } },
7389 }
7390 \end{lstlisting}
7391 のように指定しなければならない.
7392
7393 一方,\texttt{AltFont} キー内の各リストでは
7394 \ \texttt{YokoFeatures},~\texttt{TateFeatures} 及び \texttt{TateFont} キーを
7395 指定することは可能であり.また\ \texttt{YokoFeatures},~\texttt{TateFeatures} キーの
7396 中身に \texttt{AltFont} を指定することができる.
7397
7398 また,\autoref{fig:yokotate-fontspec}後半部では6行目の疑似太字無効化の指定が効かず,
7399 2行目で指定した\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による疑似太字の指定が有効になっ
7400 たままである.これは\emph{\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による
7401 OpenType機能指定は
7402 組方向に依存しないOpenType機能の指定より後に解釈される}からである.
7403
7404 %</ja>
7405
7406
7407 \subsection{\Pkg{luatexja-otf}}
7408 \label{ssec:ltjotf}
7409 %<*en>
7410 This optional package supports typesetting glyphs
7411 by specifying a CID number.
7412 The package \Pkg{luatexja-otf} offers the following 2~low-level
7413 commands:
7414 %</en>
7415 %<*ja>
7416 この追加パッケージはCID番号による文字の出力をサポートする.
7417 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
7418 %</ja>
7419 \begin{cslist}
7420 \item[\cs{CID}\{\meta{number}\}]
7421 %<*en>
7422 Typeset a glyph whose CID number is \meta{number}.
7423 If the Japanese font is neither Adobe-Japan1,~Adobe-GB1, Adobe-CNS1,
7424 Adobe-Korea1,~nor~Adobe-KR CID-keyed font,
7425 \LuaTeX-ja treats that \meta{number} is a CID number of Adobe-Japan1 character collection,
7426 and tries to typeset a ``most suitable glyph''.
7427
7428 Note that if the Japanese font is loaded using the HarfBuzz library, this \cs{CID}
7429 command does not work.
7430 %</en>
7431 %<*ja>
7432 CID番号が\meta{number}の文字を出力する.
7433 もし現在の和文フォントがAdobe-Japan1,~Adobe-GB1, Adobe-CNS1, Adobe-Korea1,~Adobe-KRの
7434   いずれのCID-keyed fontでもない場合,\meta{number}はAdobe-Japan1のCID番号であると解釈し
7435   「適切なグリフ」\footnote{%
7436   特に縦組用グリフのCID番号を指定した場合は(LuaTeX-ja 20190504.0以降では若干改良されているが)
7437   意図しない結果になる可能性が高い.
7438   なお,バージョン20190708.0以降では,CIDからグリフへの選択にグリフ名の情報を使用していない.
7439   また,フォントにAdobe-Japan1のIVSが含まれていれば,その情報を用いて
7440   グリフを選択する.
7441 }を出力する.
7442
7443 なお,現在の和文フォントがHarfBuzzを用いて読み込まれた場合には,\cs{CID}は正しく動作しない.
7444 %</ja>
7445
7446 \item[\cs{UTF}\{\meta{hex\_number}\}]
7447 %<*en>
7448 Typeset a character whose character code is \meta{hex\_number} (in hexadecimal).
7449 This command is similar to \verb+\char"+\meta{hex\_number},\ %"
7450 but please remind remarks below.
7451 %</en>
7452 %<*ja>
7453 文字コードが(16進で)\meta{hex\_number}の文字を出力する.
7454 このコマンドは \verb+\char"+\meta{hex\_number}と似ているが,下の注意を参照すること.%"
7455 %</ja>
7456 \end{cslist}
7457
7458 %<*ja>
7459 このパッケージは,マクロ集 \texttt{luatexja-ajmacros.sty}\footnote{\Pkg{otf}パッケージ付属の井上浩一氏によるマクロ集
7460 \texttt{ajmacros.sty} に対して
7461 漢字コードをUTF-8にしたり,plain \LuaTeX でも利用可能にするという
7462 修正を加えたものである.}\ も自動的に読み込む.
7463 \texttt{luatexja-ajmacros.sty} は,
7464 そのため,\Pkg{luatexja-otf} を読みこめば \texttt{ajmacros.sty} マクロ集にある \cs{aj半角} などのマクロもそのまま使うことができる.
7465 %</ja>
7466 %<*en>
7467 This package automatically loads \texttt{luatexja-ajmacros.sty}, which is slightly
7468 modified version of \texttt{ajmacros.sty}\footnote{Useful macros by iNOUE Koich!, for the
7469 \Pkg{japanese-otf} package.}.
7470 Hence one can use macros which sre defined in \texttt{ajmacros.sty}, such as~\cs{aj半角}.
7471 %</en>
7472
7473 %<en>\paragraph{Remarks}
7474 %<ja>\paragraph{注意}
7475 %<*en>
7476 Characters by \cs{CID} and \cs{UTF} commands are different from
7477 ordinary characters in the following points:
7478 %</en>
7479 %<*ja>
7480 \cs{CID} と \cs{UTF} コマンドによって出力される文字は
7481 以下の点で通常の文字と異なる:
7482 %</ja>
7483 \begin{itemize}
7484 %<*en>
7485 \item Always treated as \textbf{JAchar}s.
7486 %</en>
7487 %<*ja>
7488 \item 常に\textbf{JAchar}として扱われる.
7489 %</ja>
7490 %<*en>
7491 \item In vertical direction, \texttt{vert}/\texttt{vrt2} feature are automatically applied to
7492       characters by \cs{UTF}, regardless these feature are not activated in current Japanese font.
7493 %</en>
7494 %<*ja>
7495 \item 縦組時には,現在の縦組用和文フォントで \texttt{vert}/\texttt{vrt2} 機能が
7496   有効か無効かを問わず,\cs{UTF} で出力される文字にはこれらのOpenType機能が働いた字形になる.
7497 %</ja>
7498 %<*en>
7499 \item Processes for supporting other OpenType features (for example,
7500       glyph replacement and kerning) by the \Pkg{luaotfload} package
7501       is not performed to these characters.
7502 %</en>
7503 %<*ja>
7504 \item その他のOpenType機能(例えばグリフ置換やカーニング)をサポートするための
7505   \Pkg{luaotfload}パッケージによる処理はこれらの文字には働かない.
7506 %</ja>
7507 \end{itemize}
7508
7509 %<en>\paragraph{Additional syntax of JFM}
7510 %<ja>\paragraph{JFMへの記法の追加}
7511
7512 %<*en>
7513 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
7514 chars} table in JFM now allows a string in the form
7515 \verb+'AJ1-xxx'+, which stands for the character
7516 whose CID number in Adobe-Japan1 is \verb+xxx+.
7517
7518 This extended notation is used in the standard JFM \texttt{jfm-ujis.lua}
7519 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
7520 %</en>
7521 %<*ja>
7522 \Pkg{luatexja-otf}パッケージを読み込むと,
7523 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
7524 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
7525
7526 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
7527 正しく半角幅で組むために利用されている.
7528 %</ja>
7529
7530 \subsection{\Pkg{luatexja-adjust}}
7531 \label{ssec:adj}
7532 \begin{figure}[t]
7533 \def\sq{%
7534   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
7535    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
7536   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
7537 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
7538   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
7539   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
7540 \newbox\gridbox
7541 \def\outbox#1{{\Large%
7542   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
7543   \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}%
7544   \hbox{\textcolor{cyan}{\copy\gridbox}\hskip-20\zw%
7545   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
7546 }}
7547
7548 {\centering
7549 \begin{tabular}{lc}
7550 \toprule
7551 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
7552 without priority&%
7553 \ltjdisableadjust
7554 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
7555 \ltjenableadjust\\
7556 with priority&%
7557 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
7558 %<en>\ltjdisableadjust
7559 \\
7560 \bottomrule
7561 \end{tabular}\par}
7562 \medskip
7563
7564 \fakefn{}{The value of
7565 \Param{kanjiskip} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
7566 for making the difference obvious.}
7567 %<ja>\caption{行長調整}\label{fig:adj}
7568 %<en>\caption{Line adjustment}\label{fig:adj}
7569 \end{figure}
7570
7571
7572 %<*en>
7573 (see Japanese version of this manual)
7574 %</en>
7575 %<*ja>
7576 この追加パッケージは以下の機能を提供する.詳細な仕様については\ref{sec-adjspec}章を参照してほしい.
7577 \begin{description}
7578  \item[行末文字の位置調整]
7579   \pTeX では,(是非はともかく)「行末の読点はぶら下げか二分取りか全角取りのいずれかに」のように
7580   行末文字と実際の行末の位置関係を2通り以上にすることは面倒であった.
7581   和文フォントメトリックだけでは「常に行末の読点はぶら下げ」といったことしかできず,
7582   前の文に書いたことを実現するには
7583   \begin{lstlisting}
7584 \def\。{%
7585   \penalty10000 % 禁則ペナルティ
7586   \hbox to0pt{。\hss}\penalty0 % ぶら下げの場合
7587   \kern.5\zw\penalty0 % 二分取りの場合
7588   \kern.5\zw\penalty0 % 全角取りの場合
7589 }
7590 \end{lstlisting}
7591   のような命令を定義し,文中の全ての句点を \lstinline+\。+ で書くことが必要だった.
7592
7593   \Pkg{luatexja-adjust}パッケージは,上で述べた行末文字と実際の行末との位置関係を
7594   2通り以上から自動的に選択する機能を提供する.
7595   \pdfTeX と同じように,「\TeX による行分割の後で行末文字の位置を補正する」方法と
7596   「行分割の過程で行末文字の位置を考慮に入れる」方法を選べるようにした
7597   (\Pkg{luatexja-adjust}パッケージの既定では前者).
7598   
7599  \item[優先順位付きの行長調整]
7600   \pTeX では,行長調整において優先度の概念が存在しなかったため,図
7601   \ref{fig:adj}上段における半角分の半端は,\autoref{fig:adj}中段のように,鍵
7602   括弧周辺の空白と和文間空白(\Param{kanjiskip})の両方によって負担される.し
7603   かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
7604   ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
7605   文字はベタ組で組まれる(\autoref{fig:adj}下段)ことになっている.
7606   \Pkg{luatexja-adjust}パッケージの提供する第2の機能は,
7607   \cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
7608   の行長調整である.
7609   \begin{itemize}
7610    \item 優先度付き行長調整は,段落を行分割した後に個々の行について行われるものである.
7611         そのため,行分割の位置は変化することはない.
7612         
7613         \verb+\hbox{...}+ といった「途中で改行できない水平ボックス」では(たとえ幅が指定されていても)無効である.
7614    \item 優先度付き行長調整を行うと,和文処理グルーの自然長は変化しないが,伸び量や縮み量は
7615         一般に変化する.そのため,既に組まれた段落を \cs{unhbox} などを利用して組み直す処理を
7616         行う場合には注意が必要である.
7617   \end{itemize}
7618   
7619  \item[「中身までみた」行送り計算]
7620   複数行に渡る文章を組版するときには行間に空きが入ることが普通である.
7621   \TeX では各行が一つずつの水平ボックスをなしていることを思い出すと,隣り合った
7622   2つの行(つまり水平ボックス)の間の空きは次のようにして決まるのだった:
7623   \begin{itemize}
7624    \item 「通常に組んだときの行間」$d$を,\cs{baselineskip}から
7625         「前の行」の深さと「次の行」の高さを加えたものを引いた値とする.
7626    \item $d\ge\cs{lineskiplimit}$の場合,
7627         標準の行送り\cs{baselineskip}で組んでも十分な間隔があると判断され,
7628         2行の間には長さ$d$の空白が挿入される.つまり行送りは\cs{baselineskip}.
7629    \item $d<\cs{lineskiplimit}$の場合,
7630         2行の間には長さ\cs{lineskip}の空白が挿入される.
7631         そのため(設定値によるが,多くの場合)行送りは\cs{baselineskip}より広がる.
7632   \end{itemize}
7633
7634   \begin{figure}[t]
7635         \noindent\centering
7636         \begin{minipage}[b]{18\zw}
7637           \ltjenableadjust[profile=false, linestep=false]
7638           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7639           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7640           これを②式に代入すると……
7641           \par\vskip\abovecaptionskip
7642           \ltjenableadjust[profile=false, linestep=false]
7643           \par\centering\leavevmode{\small (a)}
7644         \end{minipage}%
7645         \kern2\zw
7646         \begin{minipage}[b]{18\zw}
7647           \ltjenableadjust[profile]
7648           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7649           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7650           これを②式に代入すると……
7651           \par\vskip\abovecaptionskip
7652           \ltjenableadjust[profile=false, linestep=false]
7653           \par\centering\leavevmode{\small (b)}
7654         \end{minipage}\par
7655           \caption{高い行が連続したときの状況}\label{fig:linegap1}
7656   \end{figure}
7657
7658   ここで,\TeX は行送りの決定で「高さ・深さを取っているものが
7659   行のどの水平位置にあるか」は一切考慮しないことに注意してほしい.そのため,
7660   \autoref{fig:linegap1}~(a)のように「必要以上に行間が空いて見える」状況が起こることがある.
7661
7662   \Pkg{luatexja-adjust}パッケージでは,「通常に組んだときの行間」$d$を
7663   各行の中身の文字・グルー・ボックスの寸法を勘案して計算するという方法を
7664   利用できるようにした.この機能を使うと,\autoref{fig:linegap1}~(b)のように
7665   行間の空きが必要以上に大きくなることを避けることができる.
7666   \begin{itemize}
7667         \item 段落中の隣り合った二行だけでなく,行間の空きは
7668         新たに水平ボックス$h$を(内部・外部問わず)垂直モードで追加した時にも自動で挿入される.
7669         その場合には,前段落で述べた「中身までみる」処理は
7670         \begin{itemize}
7671          \item 現在のリストにおける最後のノード
7672           \footnote{最後のノードが\cs{parskip}によるグルーであった場合のみ
7673                 さらに一つ前のノードを参照する.}が水平ボックス$h'$であり,かつ
7674           \item \cs{prevdepth}の値とその$h'$の深さの値が一致している
7675         \end{itemize}
7676         場合にのみ発動するようにしている.
7677         \item 行の中身に水平ボックス$h''$が入ってくることもあるが,その場合は$h''$の中身の高さ・深さまでは
7678         参照せず,あくまでも$h''$自身の高さ・深さのみを参照する.
7679         参照するようにしてしまうと,\cs{smash}など手動で行った高さ・深さ調整の意味がなくなってしまうからである.
7680   \end{itemize}
7681   なお,現在の実装では,「中身までみる行間調整」は,外部垂直モードにおける
7682   前の段落の最終行と次の段落の先頭行との間では
7683   満足に動作しないことがある.これについては今後の課題である.
7684
7685   \begin{figure}[t]
7686         \noindent\centering
7687         \begin{minipage}[b]{16\zw}
7688           \ltjenableadjust[profile]
7689           ……だから,①より$\dfrac{a^2}{b}= \dfrac{1+\sqrt{5}}2$.\\
7690           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7691           これを②式に代入すると……
7692           \par\vskip\abovecaptionskip
7693           \ltjenableadjust[profile=false, linestep=false]
7694           \par\centering\leavevmode{\small (a): 無効}
7695         \end{minipage}%
7696         \kern2\zw
7697         \begin{minipage}[b]{16\zw}
7698           \ltjsetparameter{linestep_factor=0.25}
7699           \ltjenableadjust[profile, linestep]
7700           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7701           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7702           これを②式に代入すると……
7703           \par\vskip\abovecaptionskip
7704           \ltjenableadjust[profile=false, linestep=false]
7705           \par\centering\leavevmode{\small (b): $0.25$\cs{baselineskip}刻み}
7706         \end{minipage}\par\medskip
7707         \begin{minipage}[b]{16\zw}
7708           \ltjsetparameter{linestep_factor=0.5}
7709           \ltjenableadjust[profile, linestep]
7710           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7711           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7712           これを②式に代入すると……
7713           \par\vskip\abovecaptionskip
7714           \ltjenableadjust[profile=false, linestep=false]
7715           \par\centering\leavevmode{\small (c): 0.5\cs{baselineskip}刻み}
7716         \end{minipage}%
7717         \kern2\zw
7718         \begin{minipage}[b]{16\zw}
7719           \ltjsetparameter{linestep_factor=1}
7720           \ltjenableadjust[profile, linestep]
7721           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7722           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7723           これを②式に代入すると……
7724           \par\vskip\abovecaptionskip
7725           \ltjenableadjust[profile=false, linestep=false]
7726           \par\centering\leavevmode{\small (d): \cs{baselineskip}刻み}
7727         \end{minipage}\par
7728           \caption{段階的な行送り増加}\label{fig:linegap2}
7729   \end{figure}
7730
7731  \item[段階的な行送り調整]
7732   既に述べたように,
7733   「通常に組んだときの行間」$d$が\cs{lineskiplimit}より小さい場合,\TeX 標準では
7734   行間は\cs{lineskip}となるのだった.
7735   このとき行送りは「前の行の深さ」,「次の行の高さ」,\cs{lineskip}の3つの和になるわけだが,
7736   場合によっては行送りを「\cs{baselineskip}の整数倍」などと切りのいい値に揃えたいという状況が
7737   考えられなくもない.
7738   
7739   \Pkg{luatexja-adjust}パッケージでは,$d<\cs{lineskiplimit}$のときに
7740   行送りを\cs{baselineskip}の\Param{linestep\_factor}倍ずつ増減させて
7741   \begin{quote}
7742         行間が\cs{lineskip}以上となるような,
7743         最小の$(1+k\cdot \Param{linestep\_factor})\cs{baselineskip}$($k$は整数)の値
7744   \end{quote}
7745   とする機能を利用できるようにした.
7746   \autoref{fig:linegap2}の(a)がこの機能を無効にした状況で,(b),~(c),~(d)が
7747   それぞれ\Param{linestep\_factor}を0.25,~0.5,~1とした状況である.
7748
7749   なお,この機能は表組時(\cs{halign},~\cs{valign})には無効である.
7750   \LaTeX における表組環境(tabular, arrayなど)では,\cs{baselineskip},~\cs{lineskip}はどちらも0に設定されているので
7751   (代わりに各行に\cs{@arstrut}という支柱が入る)ために意味がないことと,
7752   数式を内部で表組を使って組むalign環境などではかえって行間が不揃いになってしまうからである.
7753 \end{description}
7754
7755 \Pkg{luatexja-adjust}パッケージは,上記で述べた4機能を有効化/無効化するための
7756 以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
7757
7758 \begin{cslist}
7759 \item[\cs{ltjenableadjust[...]}]
7760 \verb+...+ に指定したkey-valueリストに従い,「行末文字の位置調整」「優先順位付きの行長調整」
7761   「『中身までみた』行送り計算」「段階的な行送り調整」%「濁点・半濁点付き仮名文字の正規化」
7762   を有効化/無効化する.
7763 指定できるキーは以下の通り.
7764 \begin{description}
7765   \item[\texttt{lineend=[false,true,extended]}]
7766   行末文字の位置調整の機能を無効化(\texttt{false}),「行分割後に調整」の形で有効化(\texttt{true}),
7767   「行分割の過程で考慮」の形で有効化(\texttt{extended})する.
7768   \item[\texttt{priority=[false,true]}]
7769   優先順位付きの行長調整を無効化(\texttt{false}),または有効化(\texttt{true}).
7770   \item[\texttt{profile=[false,true]}]
7771   「中身までみた」行送り計算を無効化(\texttt{false}),または有効化(\texttt{true}).
7772   \item[\texttt{linestep=[false,true]}]
7773   段階的な行送り調整を無効化(\texttt{false}),または有効化(\texttt{true}).
7774 %  \item[\texttt{composekana=[false,true]}]
7775 %  濁点・半濁点付き仮名文字の正規化を無効化(\texttt{false}),または有効化(\texttt{true}).
7776 \end{description}
7777 どのキーともキー名のみを指定した場合は値として\texttt{true}が指定されたものと扱われる.
7778
7779 互換性の為,オプション無しでただ\cs{ltjenableadjust}が呼び出された場合は,
7780 \begin{lstlisting}
7781 \ltjenableadjust[lineend=true,priority=true]
7782 \end{lstlisting}
7783 と扱われる.
7784   
7785 \item[\cs{ltjdisableadjust}]
7786 \Pkg{luatexja-adjust}パッケージの機能を無効化する.
7787 \begin{lstlisting}
7788 \ltjenableadjust[lineend=false,priority=false,profile=false,linestep=false]
7789 \end{lstlisting}
7790 と同義.
7791 \end{cslist}
7792
7793 また,次のパラメータが\cs{ltjsetparameter}内で
7794 追加される.いずれもグローバルに効力を発揮する.
7795 \begin{cslist}[style=standard]
7796 \item[\DParam{stretch\_priority}\,=\{\meta{list}\}]
7797 \Param{kanjiskip}, \Param{xkanjiskip},および「\textbf{JAglue}以外のグルー」を,
7798 「行を自然長より伸ばす」場合の調整に用いる優先度を指定する.
7799
7800 指定方法は,\meta{list}の中にkey-value listの形で
7801 \begin{lstlisting}
7802 stretch_priority={kanjiskip=-35,xkanjiskip=-25,others=50}
7803 \end{lstlisting}
7804 のようにして行う.キー名\texttt{kanjiskip},~\texttt{xkanjiskip}については
7805 そのままの意味であり,
7806 \texttt{others}キーが「\textbf{JAglue}以外のグルー」を表す.
7807 各キーの値は,JFMグルーにおける「優先度$i$」を$10i$に対応させた整数値であり,
7808   大きい方が先に伸ばされることを意味している.
7809   初期値は
7810 \begin{lstlisting}
7811 {kanjiskip=-35,xkanjiskip=-25,others=50}
7812 \end{lstlisting}
7813 であり,「優先度$-4$」と指定されているJFMグルーが最も伸びにくいようになっている.
7814
7815 \item[\DParam{shrink\_priority}\,=\{\meta{list}\}]
7816 同様に,「行を自然長より縮める」場合の調整に用いる優先度を指定する.
7817 それ以外は\Param{stretch\_priority}と指定の形式は変わらない(初期値も変わらない).
7818
7819  \item[\DParam{linestep\_factor}\,=\meta{float}]
7820   段階的な行送り調整の際,\cs{baselineskip}の自然長の何倍単位で行送りを変えるかを指定する.
7821   0を指定すると無効になるのと変わらない.また負数を指定すると,
7822   その絶対値が指定されたかのように扱われる.
7823   初期値は0.5(つまり半行単位)である.
7824
7825   \item[\DParam{profile\_hgap\_factor}\,=\meta{float}]
7826   「中身まで見た」行送り計算の際,
7827   前の行にある深さが大きいものと次の行にある高さが大きいものが
7828   水平方向にどれだけ離れていないといけないかを
7829   「\cs{lineskip}の自然長の何倍か」で指定する.
7830   負数を指定すると,その絶対値が指定されたかのように扱われる.
7831   初期値は1(つまり\cs{lineskip}(の自然長))である.
7832 \end{cslist}
7833
7834 さらに,バージョン20220211.0以降では次の命令が提供される.
7835 \begin{cslist}
7836   \item[\cs{ltjghostbeginjachar}]
7837   \LuaTeX-ja本体が提供している\cs{ltjfakeparbegin}, \cs{ltjfakeboxbdd}と類似の命令である.
7838   実行された箇所が(限定・非限定を問わず)水平モードであった場合に,実行された箇所は
7839   「文字クラス0の\textbf{JAchar}」の直前であると,
7840   \LuaTeX-jaの和文処理グルー挿入処理に認識させる.以下の実行例を参照.
7841
7842 \medskip
7843 \begin{LTXexample}[width=18\zw]
7844 \ltjsetparameter{kanjiskip=14pt,xkanjiskip=50pt}
7845 \let\LG=\ltjghostbeforejachar
7846 A\LG  B   \par% ==> ALchar--(xkanjiskip)--\LG
7847 A\LG  字  \par% ==> ALchar--(xkanjiskip)--\LG
7848 漢\LG B   \par% ==> JAchar--(kanjiskip)--\LG
7849 漢\LG 字  \par% ==> JAchar--(kanjiskip)--\LG
7850 \end{LTXexample}
7851
7852   \item[\cs{ltjghostafterjachar}]
7853   \cs{ltjghostbeginjachar}と対を成す命令で,実行された箇所は
7854   「文字クラス0の\textbf{JAchar}」の直後であると,
7855   \LuaTeX-jaの和文処理グルー挿入処理に認識させる.以下の実行例を参照.
7856
7857 \medskip
7858 \begin{LTXexample}[width=18\zw]
7859 \ltjsetparameter{kanjiskip=14pt,xkanjiskip=50pt}
7860 \let\LG=\ltjghostafterjachar
7861 A\LG  B   \par% ==> \LG--(xkanjiskip)--ALchar
7862 漢\LG B   \par% ==> \LG--(xkanjiskip)--ALchar
7863 A\LG  字  \par% ==> \LG--(kanjiskip)--JAchar
7864 漢\LG 字  \par% ==> \LG--(kanjiskip)--JAchar
7865 \end{LTXexample}
7866 \end{cslist}
7867 なお,バージョン20220207.0で追加された\cs{ltjghostjachar}は実装にバグがあったのと「両側」
7868 という点が扱いづらかったので,将来は削除する予定である.
7869
7870 両命令の主な仕様用途は和文ゴーストでの使用である.\Pkg{BXghost}パッケージ(\cite{bxghost})などでは
7871 伝統的に全角空白(\texttt{U+3000})と\verb+\kern-1\zw+を組み合わせた方法が使われてきたが,
7872 \LuaTeX-jaでは全角空白を使っただけではうまくいかない可能性があるため,新たに命令が用意された.
7873
7874 %</ja>
7875
7876 \subsection{\Pkg{luatexja-ruby}}
7877 %<*en>
7878 This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
7879 using callbacks of \LuaTeX-ja.
7880 There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
7881 (Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
7882 %</en>
7883 %<*ja>
7884 この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
7885 前後の文字種に応じた前後への自動進入や,
7886 行頭形・行中形・行末形の自動的な使い分けが特徴である.
7887
7888 ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
7889 使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
7890 この節では簡単な使用方法のみ述べる.
7891 %</ja>
7892
7893 \begin{description}
7894 %<*en>
7895  \item[Group-ruby]
7896 By default, ruby characters (the second argument of \cs{ruby})
7897 are attached to base characters (the first argument), as one object.
7898 This type of ruby is called \emph{group-ruby}.
7899 %</en>
7900 %<*ja>
7901  \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
7902 第2引数にルビを記述する.
7903 %</ja>
7904 \begin{LTXexample}[width=0.3\textwidth]
7905 東西線\ruby{妙典}{みようでん}駅は……\\
7906 東西線の\ruby{妙典}{みようでん}駅は……\\
7907 東西線の\ruby{妙典}{みようでん}という駅……\\
7908 東西線\ruby{葛西}{かさい}駅は……
7909 \end{LTXexample}
7910 %<*en>
7911 As the above example, ruby hangover is allowed on the Hiragana before/after
7912 its base characters.
7913 %</en>
7914 %<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
7915
7916 %<*en>
7917 \item[Mono-ruby]
7918 To attach ruby characters to each base characters (\emph{mono-ruby}),
7919 one should use \cs{ruby} multiple times:
7920 %</en>
7921 %<*ja>
7922  \item[モノルビ] 親文字を1文字にするとモノルビとなる.
7923 2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
7924 その数だけ \cs{ruby} を書く必要がある.
7925 %</ja>
7926 \begin{LTXexample}[width=0.3\textwidth]
7927 東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
7928 \end{LTXexample}
7929
7930 %<*en>
7931  \item[Jukugo-ruby]
7932 Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
7933 %</en>
7934 %<*ja>
7935  \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
7936 複数グループのルビは熟語ルビとして組まれる.
7937 \cite{x4051}にあるように,
7938 どのグループでも「親文字」が対応するルビ以上の長さの場合は
7939 各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
7940 \cite{jlreq}で規定されている組み方とは異なるので注意.
7941 %</ja>
7942 \begin{LTXexample}
7943 \ruby{妙|典}{みよう|でん}\
7944 \ruby{葛|西}{か|さい}\
7945 \ruby{神楽|坂}{かぐら|ざか}
7946 \end{LTXexample}
7947 %<*en>
7948 If there are multiple groups in one \cs{ruby} call,
7949 A linebreak between two groups is allowed.
7950 %</en>
7951 %<ja> 複数ルビではグループとグループの間で改行が可能である.
7952 \begin{LTXexample}[width=0.3\textwidth]
7953 \vbox{\hsize=6\zw\noindent
7954   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7955   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7956   \hbox to   3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7957 }
7958 \end{LTXexample}
7959 \end{description}
7960
7961 %<*en>
7962 If the width of ruby characters are longer than that of base characters,
7963 \cs{ruby} automatically selects the appropriate form
7964 among the line-head form, the line-middle form, and the line-end form.
7965 %</en>
7966 %<*ja>
7967 また,ルビ文字のほうが親文字よりも長い場合は,自動的に
7968 行頭形・行中形・行末形のいずれか適切なものを選択する.
7969 %</ja>
7970 \begin{LTXexample}[width=0.3\textwidth]
7971 \vbox{\hsize=8\zw\noindent
7972 \null\kern3\zw ……を\ruby{承}{うけたまわ}る
7973      \kern1\zw ……を\ruby{承}{うけたまわ}る\\
7974 \null\kern5\zw ……を\ruby{承}{うけたまわ}る
7975 }
7976 \end{LTXexample}
7977
7978
7979 %<*ja>
7980 \subsection{\Pkg{lltjext}}
7981 \pLaTeX では縦組用の拡張として \Pkg{plext} パッケージが用意されていたが,
7982 それを\LuaTeX-ja用に書きなおしたものが本追加パッケージ \Pkg{lltjext} である.
7983
7984 従来の \Pkg{plext} パッケージとの違いは,
7985 \begin{itemize}
7986  \item 組方向オプション \texttt{<y>}(横組),\texttt{<t>}(縦組),
7987 \texttt{<z>}\ の他に\ \texttt{<d>}(dtou方向),\texttt{<u>}(utod方向)を追加した.
7988 \texttt{<z>} と \texttt{<u>} の違いは,\texttt{<z>} が(\Pkg{plext} パッケージと同様に)
7989 周囲の組方向が縦組のときにしか意味を持たない
7990   \footnote{%
7991     周囲の組方向が縦組以外のときは,\texttt{<z>} を指定しても中身の組方向は周囲の組方向と変わらない.
7992   }%
7993 のに対し,\texttt{<u>} にはそのような制限がないことである.
7994  \item 連数字用命令 \cs{rensuji} における位置合わせオプション \texttt{[l]}, \texttt{[c]},
7995        \texttt{[r]} の挙動を若干変更した.
7996 \end{itemize}
7997
7998 %</ja>
7999 %<*en>
8000 \subsection{\texttt{lltjext.sty}}
8001 \pLaTeX\ supplies additional macros for vertical writing in the \Pkg{plext} package.
8002 The \Pkg{lltjext} package which we want to describe here is the \LuaTeX-ja
8003 counterpart of the \Pkg{plext} package.
8004 %</en>
8005
8006 %<*ja>
8007 念の為,本 \Pkg{lltjext} パッケージで追加・変更している命令の一覧を載せておく.
8008 \begin{cslist}
8009 \item[tabular\textrm{, }array\textrm{, }minipage環境]
8010 これらの環境は,
8011 \begin{lstlisting}
8012 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
8013 \begin{array}<dir>[pos]{table spec}   ... \end{array}
8014 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
8015 \end{lstlisting}
8016 のように,組方向オプション \texttt{\<dir\>} が拡張されている.
8017 既に述べたように,組方向オプションに指定できる値は以下の5つであり,
8018 それ以外を指定した時や無指定時は周囲の組方向と同じ組方向になる.
8019 \begin{description}
8020  \item[y] 横組(\cs{yoko})
8021  \item[t] 縦組(\cs{tate})
8022  \item[z] 周囲が縦組の時はutod方向,それ以外はそのまま
8023  \item[d] dtou方向
8024  \item[u] utod方向
8025 \end{description}
8026 \item[\cs{parbox}<\meta{dir}>{[\meta{pos}]}\{\meta{width}\}\{\meta{contents}\}]
8027 \cs{parbox} 命令も同様に,組方向の指定ができるように拡張されている.
8028
8029 \item[\cs{pbox}<\meta{dir}>{[\meta{width}][\meta{pos}]}\{\meta{contents}\}]
8030 組方向\meta{dir}で\meta{contents}の中身をLRモードで組む命令である.
8031 \meta{width}が正の値であるときは,ボックス全体の幅がその値となる.
8032 その際,中身は\meta{pos}の値に従い,左寄せ(\texttt{l}),右揃え(\texttt{r}),
8033 中央揃え(それ以外)される.
8034 \item[picture環境]
8035 図表作成に用いる\texttt{picture}環境も,
8036 \begin{lstlisting}
8037 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
8038   ...
8039 \end{picture}
8040 \end{lstlisting}
8041 と組方向が指定できるように拡張されている.
8042 $x$成分の増加方向は字送り方向,$y$成分の増加方向は行送り方向の\emph{反対方向}となる.
8043 \Pkg{plext} パッケージと同様に
8044 内部ではベースライン補正(\Param{yalbaselineshift}パラメータなど)の影響を受けないように,
8045 \cs{put},~\cs{line}, \cs{vector}, \cs{dashbox}, \cs{oval},~\cs{circle}も
8046 ベースライン補正を受けないように再定義されている.
8047
8048 \item[\cs{rensuji}{[\meta{pos}]}\{\meta{contents}\}\textrm{, }\cs{rensujiskip}]
8049
8050 \item[\cs{Kanji}\{\meta{counter\_name}\}]
8051
8052 \item[\cs{kasen}\{\meta{contents}\}\textrm{, }\cs{bou}\{\meta{contents}\}\textrm{,
8053                      }\cs{boutenchar}]
8054
8055 \item[参照番号]
8056 \end{cslist}
8057 %</ja>
8058 %<*en>
8059 \begin{cslist}
8060 \item[tabular\textrm{, }array\textrm{, }minipage\textrm{ environments}]
8061 These environments are extended by \texttt{\<dir\>}, which specifies the direction,
8062 as follows:
8063 \begin{lstlisting}
8064 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
8065 \begin{array}<dir>[pos]{table spec}   ... \end{array}
8066 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
8067 \end{lstlisting}
8068 This option permits one of the following five values. If none of them is specified,
8069 the direction inside the environment is same as that outside the enviromnent.
8070 \begin{description}
8071  \item[y] \emph{yoko} direction (horizontal writing)
8072  \item[t] \emph{tate} direction (vertical writing)
8073  \item[z] \emph{utod} direction if direction outside the env.\ is \emph{tate}.
8074  \item[d] \emph{dtou} direction
8075  \item[u] \emph{utod} direction
8076 \end{description}
8077 \item[\cs{parbox}<\meta{dir}>{[\meta{pos}]}\{\meta{width}\}\{\meta{contents}\}]
8078 \cs{parbox} command is also extended by \texttt{<\meta{dir}>}.
8079
8080 \item[\cs{pbox}<\meta{dir}>{[\meta{width}][\meta{pos}]}\{\meta{contents}\}]
8081 This commands typeset \meta{contents} in LR-mode, in \meta{dir} direction.
8082 If \meta{width} is positive, the width of the box becomes this \meta{width}.
8083 In this case, \meta{contents} will be aligned to left (when \meta{pos} is \texttt{l}),
8084 center (\texttt{c}), or~right (\texttt{r}).
8085   
8086 \item[picture\textrm{\ environment}]
8087 \texttt{picture} environment also extended by \texttt{<\meta{dir}>}, as follows:
8088 \begin{lstlisting}
8089 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
8090   ...
8091 \end{picture}
8092 \end{lstlisting}
8093
8094 \item[\cs{rensuji}{[\meta{pos}]}\{\meta{contents}\}\textrm{, }\cs{rensujiskip}]
8095
8096 \item[\cs{Kanji}\{\meta{counter\_name}\}]
8097
8098 \item[\cs{kasen}\{\meta{contents}\}\textrm{, }\cs{bou}\{\meta{contents}\}\textrm{,
8099                      }\cs{boutenchar}]
8100
8101 \item[参照番号]
8102 \end{cslist}
8103 %</en>
8104
8105 %<*ja>
8106 \paragraph{表組他の揃え位置}
8107 表組(\texttt{array}, \texttt{tabular}環境),\cs{parbox}命令,\cs{minipage}環境の
8108 揃え位置については\autoref{tab:lltjext_dir}を参照.\pLaTeX~2017-07-29と
8109 できるだけ同じ挙動になるようにしている.\autoref{tab:lltjext_dir}中のA--Dの意味は次の通り.
8110
8111 \begin{table}
8112   \caption{\Pkg{lltjext}パッケージにおける表組・\cs{parbox}命令他の揃え位置}
8113   \label{tab:lltjext_dir}
8114   {\centering
8115     \begin{tabular}{lcccc}
8116       \toprule
8117       ↓中身\周囲→&\cs{yoko}&\cs{tate}&\cs{utod}&\cs{dtou}\\
8118       \midrule
8119       \cs{yoko}&A&B&B&B\\
8120       \cs{tate}&B&A&D&C\\
8121       \cs{utod}&B&D&A&C\\
8122       \cs{dtou}&B&C&C&A\\
8123       \bottomrule
8124     \end{tabular}\par}
8125 \end{table}
8126
8127 \begin{description}
8128  \item[A] 周囲の組方向と中身の組方向が同じ場合.
8129   \begin{itemize}
8130    \item \texttt{[t]}指定のとき:
8131     中身の先頭行のベースラインが周囲のベースラインと一致する.
8132     表組で先頭行の上に罫線があった場合は,それがベースラインの位置
8133     \footnote{\LuaTeX-jaでは和文側のベースラインの位置も上下移動できることに注意.
8134       そのため「和文ベースライン」の位置に来るとは限らない.}となる.
8135    \item \texttt{[c]}指定のとき:
8136     中身の上下の中心が周囲の数式の軸を通る.
8137    \item \texttt{[b]}指定のとき:
8138     中身の最終行のベースラインが周囲のベースラインと一致する.
8139     表組で最終行の下に罫線があった場合は,それがベースラインの位置となる.
8140   \end{itemize}
8141  \item[B] 周囲の組方向と中身の組方向が90度ずれている場合.
8142   \begin{itemize}
8143    \item \texttt{[t]}指定のとき:
8144     表組においては,上端が周囲のベースラインと一致する.
8145     \cs{parbox}や\cs{minipage}環境においては,上端が周囲の和文文字の上端と一致する.
8146    \item \texttt{[c]}指定のとき:
8147     中身の上下の中心が周囲の数式の軸を通る.
8148    \item \texttt{[b]}指定のとき:
8149     表組においては,下端が周囲のベースラインと一致する.
8150     \cs{parbox}や\cs{minipage}環境においては,下端が周囲の和文文字の下端と一致する.
8151   \end{itemize}
8152  \item[C] 周囲の組方向と中身の組方向が180度ずれている場合.
8153   \cs{parbox}や\cs{minipage}環境においては,上のBの場合と同じ挙動である.表組においては,
8154   Aで\texttt{[t]}と\texttt{[b]}を入れ替えた
8155   \begin{itemize}
8156    \item \texttt{[t]}指定のとき:
8157     中身の最終行のベースラインが周囲のベースラインと一致する.
8158     最終行の下に罫線があった場合は,それがベースラインの位置となる.
8159    \item \texttt{[c]}指定のとき:
8160     中身の上下の中心が周囲の数式の軸を通る.
8161    \item \texttt{[b]}指定のとき:
8162     中身の先頭行のベースラインが周囲のベースラインと一致する.
8163     表組で先頭行の上に罫線があった場合は,それがベースラインの位置となる.
8164   \end{itemize}
8165  \item[D] 通常の縦組(\cs{tate})と「縦数式ディレクション」に相当する\cs{utod}方向が絡んだ場合.
8166   \cs{parbox}や\cs{minipage}環境においては,上のBの場合と同じ挙動である.表組においては,
8167   \begin{itemize}
8168    \item \texttt{[t]}指定のとき:
8169     中身の先頭行の欧文ベースラインが周囲の欧文ベースラインと一致する.
8170    \item \texttt{[c]}指定のとき:
8171     中身の上下の中心が周囲の数式の軸を通る.
8172    \item \texttt{[b]}指定のとき:
8173     中身の最終行の欧文ベースラインが周囲の欧文ベースラインと一致する.
8174   \end{itemize}
8175 \end{description}
8176 %</ja>
8177
8178 \subsection{\Pkg{luatexja-preset}}
8179 \label{ssec:preset}
8180
8181 %<*en>
8182 As described in Subsection~\ref{ssec:preset-abst},
8183 One can load the \Pkg{luatexja-preset}
8184 package to use several ``presets'' of Japanese fonts.
8185 This package provides functions in a part of \Pkg{japanese-otf} package (changing fonts)
8186 and a part of \Pkg{PXchfon} package (presets) by Takayuki Yato.
8187
8188 Options which are given in \cs{usepackage} but not described in this~subsection
8189 are simply passed to the \Pkg{luatexja-fontspec}\footnote{if \texttt{nfssonly} option is
8190 \emph{not} specified; in this case these options are simply ignored.}.
8191 For example, the line~5 in below example is equivalent to lines 1--3.
8192 %</en>
8193 %<*ja>
8194 \ref{ssec:preset-abst}節で述べたように,よく使われている和文フォント設定を一行で指定できるようにしたのが
8195 \Pkg{luatexja-preset}パッケージである.このパッケージは,
8196 \Pkg{otf}パッケージの一部(多書体化)と八登崇之氏による\Pkg{PXchfon}パッケージの一部(プリセット指定)
8197 とを合わせたような格好をしている.
8198
8199 パッケージ読み込み時に渡されたオプションのうち,
8200 本節にないものを指定した場合,それらはそのまま
8201 \Pkg{luatexja-fontspec}パッケージに渡される\footnote{\texttt{nfssonly} オプションが
8202 指定されていた場合は,\Pkg{luatexja-fontspec}パッケージは読み込まれないので単純に無視され
8203 る.}.例えば,下の1--3行目は5行目のように一行にまとめることができる.
8204 %</ja>
8205 \begin{lstlisting}
8206 \usepackage[no-math]{fontspec}
8207 \usepackage[match]{luatexja-fontspec}
8208 \usepackage[kozuka-pr6n]{luatexja-preset}
8209 %%--------
8210 \usepackage[no-math,match,kozuka-pr6n]{luatexja-preset}
8211 \end{lstlisting}
8212
8213 %<en>\subsubsection{General Options}
8214 %<ja>\subsubsection{一般的なオプション}
8215 \label{sssec:ltjpreset-general}
8216
8217 \begin{cslist}[before*=]
8218 \item[fontspec%
8219 %<en>\textrm{~(enabled by default)}
8220 %<ja>\emph{\gtfamily (既定)}
8221 ]
8222 %<*en>
8223 With this option, Japanese fonts are selected using functionality of
8224 the \Pkg{luatexja-fontspec} package. This means that the \Pkg{fontspec} package is
8225              automatically loaded by this package.
8226
8227 If you need to pass some options to \Pkg{fontspec}, you can load \Pkg{fontspec} manually
8228 before \Pkg{luatexja-preset}:
8229 %</en>
8230 %<*ja>
8231 \Pkg{luatexja-fontspec}パッケージの機能を用いて和文フォントを選択する.
8232 これは,\Pkg{fontspec}パッケージが自動で読み込まれることを意味する.
8233
8234 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
8235 \footnote{例えば,数式フォントまで置換されてしまい,\cs{mathit}によってギリシャ文字の
8236 斜体大文字が出なくなる,など.}場合は,
8237 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
8238 %</ja>
8239 \begin{lstlisting}
8240 \usepackage[no-math]{fontspec}
8241 \usepackage[...]{luatexja-preset}
8242 \end{lstlisting}
8243
8244 \item[nfssonly]
8245 %<*en>
8246 With this option, selecting Japanese fonts won't be performed using the functionality of
8247              the \Pkg{fontspec} package, but only standard NFSS2 (hence without
8248              \cs{addjfontfeatures} etc.).
8249 This option is ignored when \Pkg{luatexja-fontspec} package is loaded.
8250
8251 When this option is specified, \Pkg{fontspec}~and~\Pkg{luatexja-fontspec} are
8252 \emph{not} loaded by default. Nevertheless,
8253 the package\Pkg{fontspec} can coexist with the option, as the following:
8254 \begin{lstlisting}
8255 \usepackage{fontspec}
8256 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
8257 \end{lstlisting}
8258 In this case, one can use \cs{setmainfont} etc.\ to select \emph{alphabetic} fonts.
8259 %</en>
8260 %<*ja>
8261 \LaTeX 標準のフォント選択機構(NFSS2)を用いて
8262 \texttt{ltjpm}$n$(明朝),\texttt{ltjpg}$n$(ゴシック),
8263 それに後に述べる\texttt{deluxe}オプションが指定された場合には
8264 \texttt{ltjpmg}$n$(丸ゴシック)という
8265 和文フォントファミリを定義%
8266 \footnote{%
8267   $n$は自然数であり,\cs{ltjapplypreset}の実行(この命令は\Pkg{luatexja-preset}パッケージ
8268   読み込み時に自動的に実行される)ごとに増加していく.
8269 }し,これらを用いる.
8270
8271 本オプション指定時には\Pkg{fontspec}・\Pkg{luatexja-fontspec}パッケージは
8272 自動では読み込まれない,しかし,
8273 \begin{lstlisting}
8274 \usepackage{fontspec}
8275 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
8276 \end{lstlisting}
8277 のようにすれば,このオプションを指定すれば
8278 欧文フォントを\Pkg{fontspec}パッケージの機能を使って指定することができる.
8279
8280 一方,\Pkg{luatexja-preset}パッケージ読み込み時に
8281 既に\Pkg{luatexja-fontspec}パッケージが読み込まれている場合は
8282 \texttt{nfssonly}オプションは無視される.
8283 %</ja>
8284
8285 \item[match]
8286 %<*en>
8287 If this option is specified, usual family-changing commands such as
8288 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
8289 This option is passed to \Pkg{luatexja-fontspec}, if \texttt{fontspec}
8290 option is specifed.
8291 %</en>
8292
8293 %<*ja>
8294 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
8295 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
8296 欧文フォントだけでなく和文フォントも変更するようになる.
8297 \ \texttt{fontspec}\
8298 オプションが有効になっている場合は,このオプションは \Pkg{luatexja-fontspec} パッケージへと渡される.
8299 %</ja>
8300
8301
8302 \item[nodeluxe%
8303 %<en>\textrm{~(enabled by default)}
8304 %<ja>\emph{\gtfamily (既定)}
8305 ]
8306 %<*en>
8307 The nagation of \texttt{deluxe} option.
8308 Use one-weighted \textit{mincho} and \textit{gothic} font families.
8309 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and
8310 \verb+\gtfamily\mdseries+ use the same font.
8311 %</en>
8312 %<*ja>
8313 \texttt{deluxe}オプションの否定.
8314 \LaTeXe 環境下の標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
8315 より具体的に言うと,この設定の下では
8316 \ \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+,
8317 \verb+\gtfamily\mdseries+はみな同じフォントとなる.
8318 %</ja>
8319 \item[deluxe]
8320 %<*en>
8321 Use the mincho family with three weights (light, medium, and~bold),
8322 the gothic family with three weights (medium, bold, and extra~bold), and \textit{rounded gothic}%
8323 \footnote{Provided by \cs{mgfamily} and \cs{textmg},
8324 because ``rounded gothic'' is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
8325 Mincho light and gothic extra~bold can be by
8326 \cs{mcfamily}\cs{ltseries}~and~\cs{gtfamily}\cs{ebseries}, respectively.
8327
8328 \begin{itemize}
8329  \item Some presets do not have the light weight of mincho.
8330   In this case, we substitute the medium weight for the light weight.
8331  \item \Pkg{luatexja-preset} does not produce an error (only produces a warning), even if
8332   (one of) fonts for \cs{mcfamily}\cs{ltseries}, \cs{gtfamily}\cs{ebseries}, \cs{mgfamily}
8333   do not exist.
8334 \end{itemize}
8335 %</en>
8336 %<*ja>
8337 明朝体・ゴシック体各3ウェイトと,
8338 丸ゴシック体 (\cs{mgfamily}, \verb+\textmg{...}+) を利用可能にする.
8339 明朝体は細字・中字・太字の3ウェイトがあり,
8340 明朝体の細字は \cs{mcfamily}\cs{ltseries} で利用できる.
8341 また,ゴシック体は中字・太字・極太の3ウェイトがあり,
8342 ゴシック体の極太は \cs{gtfamily}\cs{ebseries} で利用できる%
8343 \footnote{過去との互換性のため,\cs{gtebfamily}, \cs{textgteb\{...\}} も
8344  依然として利用可能である.}.
8345
8346 \begin{itemize}
8347   \item プリセット設定によっては明朝体細字が用意されていないものもある.その場合は
8348   明朝体中字が代用される.
8349   \item 明朝体細字,ゴシック体極太,丸ゴシック体の3フォントについては
8350   実際にフォントをロードする前に存在するかチェックを行う.
8351   存在しなかったものについては警告を発し,
8352   それぞれ明朝体中字.ゴシック体太字,ゴシック体太字で代用する.
8353 \end{itemize}
8354 %</ja>
8355 \item[expert]
8356 %<*en>
8357 Use horizontal/vertical kana alternates, and define a command \cs{rubyfamily} to use kana
8358 characters designed for ruby.
8359 %</en>
8360 %<*ja>
8361 横組・縦組専用仮名を用いる.また,\cs{rubyfamily} でルビ用仮名が使用可能となる\footnote{%
8362   \cs{rubyfamily}とはいいつつ,実際にはフォントファミリを切り替えるのではない(通常では
8363   OpenType機能の有効化であり,\texttt{nfssonly} 指定時にはシェイプを \texttt{rb} に切り替える).
8364 }.
8365 %</ja>
8366 \item[bold]
8367 %<*en>
8368 Substitute bold series of gothic for medium series of gothic and bold series of mincho.
8369 If \texttt{nodeluxe} option is enabled, medium series of gothic is also changed,
8370 since we use same font for both series of gothic.
8371 %</en>
8372 %<*ja>
8373 \texttt{nodeluxe}オプション指定時には,「明朝の太字」をゴシック体と同じフォントにする.
8374 \texttt{deluxe}オプション指定時には,「明朝の太字」「ゴシック体の中字」をゴシック体の太字と同じフォントにする.
8375 %</ja>
8376 \item[jis90\textrm{,~}90jis]
8377 %<en>Use JIS~X~0208:1990 glyph variants if possible.
8378 %<ja>出来る限りJIS~X~0208:1990の字形を使う.
8379 \item[jis2004\textrm{,~}2004jis]
8380 %<en>Use JIS~X~0213:2004 glyph variants if possible.
8381 %<ja>出来る限りJIS~X~0213:2004の字形を使う.
8382 \item[jfm\_yoko=\meta{jfm}]
8383 %<*en>
8384 Use the JFM \texttt{jfm-\meta{jfm}.lua} for horizontal direction, instead of \texttt{jfm-ujis.lua}~(default JFM).
8385 %</en>
8386 %<*ja>
8387 横組用和文フォントで用いるJFMを\texttt{jfm-\meta{jfm}.lua}にする.このオプションがない時は
8388 \LuaTeX\nobreakdash -ja標準の\texttt{jfm-ujis.lua}が用いられる.
8389 %</ja>
8390 \item[jfm\_tate=\meta{jfm}]
8391 %<*en>
8392 Use the JFM \texttt{jfm-\meta{jfm}.lua} for vertical direction, instead of \texttt{jfm-ujisv.lua}~(default JFM).
8393 %</en>
8394 %<*ja>
8395 縦用和文フォントで用いるJFMを\texttt{jfm-\meta{jfm}.lua}にする.このオプションがない時は
8396 \LuaTeX-ja標準の\texttt{jfm-ujisv.lua}が用いられる.
8397 %</ja>
8398
8399 \item[jis]
8400 %<en>Same as \texttt{jfm\_yoko=jis}.
8401 %<ja>\texttt{jfm\_yoko=jis}と同じ.ここで用いるJFM~\texttt{jfm-jis.lua}はJISフォントメトリックを元にしたものである.
8402
8403 \end{cslist}
8404 %<*en>
8405 Note that \texttt{jis90},~\texttt{90jis}, \texttt{jis2004}~and~\texttt{2004jis} only affect with mincho,
8406 gothic (and, possibly rounded gothic) families defined by this package.
8407 We didn't taken account of when more than one options among them are specified.
8408 %</en>
8409 %<*ja>
8410 \texttt{jis90},~\texttt{90jis}, \texttt{jis2004},~\texttt{2004jis}については本パッケージで定義された
8411 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.
8412 これら4オプションのうち複数が同時に指定された場合の動作については全く考慮していない.
8413 %</ja>
8414
8415 %<en>\subsubsection{Presets which support multi weights}
8416 %<ja>\subsubsection{多ウェイト用プリセットの一覧}
8417 \label{sssec:ltjpreset-multi}
8418
8419 %<*en>
8420 Besides \texttt{bizud}, \texttt{haranoaji}, \texttt{morisawa-pro},~and~\texttt{morisawa-pr6n} presets,
8421 fonts are specified by font name, not by file name.
8422 In following tables, starred fonts (e.g.~KozGo\dots-Regular) are used for medium series of \textit{gothic},
8423 \emph{if and only if \texttt{deluxe} option is specified}.
8424 %</en>
8425 %<*ja>
8426 \texttt{bizud}, \texttt{haranoaji}, \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
8427 (ファイル名でなく)フォント名で行われる.
8428 以下の表において,*\,つきのフォント(e.g.,~KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション指定時に}
8429 ゴシック体中字として用いられるものを示している.
8430 %</ja>
8431 \begin{cslist}[style=standard]
8432  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
8433 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8434  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
8435 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8436  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
8437
8438 %<*en>
8439 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
8440 There is not rounded gothic family in Kozuka fonts.
8441 %</en>
8442 %<*ja>
8443 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
8444 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
8445 %</ja>
8446 \begin{center}\small
8447 \begin{tabular}{lllll}
8448 \toprule
8449 \bfseries family&\bfseries series&\ttfamily kozuka-pro&\ttfamily kozuka-pr6&\ttfamily kozuka-pr6n\\
8450 \midrule
8451  &light&KozMinPro-Light&KozMinProVI-Light&KozMinPr6N-Light\\
8452 %<en>\textit{mincho}%
8453 %<ja>\textgt{明朝}%
8454  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
8455  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
8456 \midrule
8457  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
8458  &\smash{\raisebox{1.5ex}{medium}}
8459  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
8460 \cmidrule(l){2-5}
8461 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8462 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8463  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
8464  &extra bold&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
8465 \midrule
8466 %<en>\textit{rounded gothic}
8467 %<ja>\textgt{丸ゴシック}
8468 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
8469 \bottomrule
8470 \end{tabular}
8471 \end{center}
8472
8473  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
8474 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8475  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
8476
8477 %<*en>
8478 Hiragino fonts (except Hiragino~Mincho~W2) are bundled with Mac OS~X 10.5 or later.
8479 Note that fonts for gothic extra~bold (HiraKakuStd[N]-W8) only contains characters in
8480 Adobe-Japan1-3 character collection, while others contains those in
8481 Adobe-Japan1-5 character collection.
8482 %</en>
8483 %<*ja>
8484 極太ゴシック体として用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
8485 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
8486
8487 なお,明朝体細字として用いるヒラギノ明朝体W2はOS~Xにはバンドルされておらず,
8488 別途購入する必要がある.
8489 %</ja>
8490 \begin{center}\small
8491 \begin{tabular}{llll}
8492 \toprule
8493 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
8494 \midrule
8495  &light&Hiragino~Mincho~Pro~W2&Hiragino~Mincho~ProN~W2\\
8496 %<en>\textit{mincho}%
8497 %<ja>\textgt{明朝}%
8498  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
8499  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
8500 \midrule
8501  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
8502  &\smash{\raisebox{1.5ex}{medium}}
8503  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
8504 \cmidrule(l){2-4}
8505 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8506 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8507  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
8508  &extra bold&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
8509 \midrule
8510 %<en>\textit{rounded gothic}
8511 %<ja>\textgt{丸ゴシック}
8512 &&Hiragino~Maru~Gothic~Pro~W4&Hiragino~Maru~Gothic~ProN~W4\\
8513 \bottomrule
8514 \end{tabular}
8515 \end{center}
8516
8517 \item[bizud] BIZ UD fonts (by Morisawa Inc.) bundled with
8518   Windows~10 October 2018 Update.
8519 \begin{center}\small
8520 \begin{tabular}{ll>{\ttfamily}l}
8521 \toprule
8522 \textbf{family}&\textbf{series}\\
8523 \midrule
8524 %<en>\textit{mincho}
8525 %<ja>\textgt{明朝}%
8526  &&BIZ-UDMinchoM.ttc\\
8527 \midrule
8528  &medium&BIZ-UDGothicR.ttc\\
8529 \cmidrule(l){2-3}
8530 %<en>\textit{gothic}%
8531 %<ja>\textgt{ゴシック}
8532  &bold&BIZ-UDGothicB.ttc\\
8533  &extra bold&BIZ-UDGothicB.ttc\\
8534 \midrule
8535 %<en>\textit{rounded gothic}
8536 %<ja>\textgt{丸ゴシック}
8537 &&BIZ-UDGothicB.ttc\\
8538 \bottomrule
8539 \end{tabular}
8540 \end{center}
8541
8542 %<en>\newpage
8543
8544  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
8545 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8546  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
8547 \begin{center}\footnotesize
8548 \begin{tabular}{ll>{\tt}l>{\tt}l}
8549 \toprule
8550 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
8551 \midrule
8552  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
8553 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
8554 %<ja>\smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8555  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
8556 \midrule
8557  &medium
8558  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
8559 %<en>\textit{gothic}%
8560 %<ja>\textgt{ゴシック}
8561  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
8562  &extra bold&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
8563 \midrule
8564 %<en>\textit{rounded gothic}
8565 %<ja>\textgt{丸ゴシック}
8566 &&A-OTF-Jun101Pro-Light.otf&A-OTF-ShinMGoPr6N-Light.otf\\
8567 \bottomrule
8568 \end{tabular}
8569 \end{center}
8570
8571
8572  \item[yu-win]  Yu fonts bundled with Windows~8.1.
8573 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8574  \item[yu-win10]  Yu fonts bundled with Windows~10.
8575 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8576  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks.
8577 \begin{center}\small
8578 \begin{tabular}{lllll}
8579 \toprule
8580 \bf family&\bf series&\texttt{yu-win}&\texttt{yu-win10}&\texttt{yu-osx}\\
8581 \midrule
8582  &light&YuMincho-Light&YuMincho-Light&(YuMincho~Medium)\\
8583 %<en>\textit{mincho}%
8584 %<ja>\textgt{明朝}%
8585  &medium&YuMincho-Regular&YuMincho-Regular&YuMincho~Medium\\
8586  &bold&YuMincho-Demibold&YuMincho-Demibold&YuMincho~Demibold\\
8587 \midrule
8588  &&YuGothic-Regular*&YuGothic-Regular*&YuGothic~Medium*\\
8589  &\smash{\raisebox{1.5ex}{medium}}%
8590         &YuGothic-Regular&YuGothic-Medium&YuGothic~Medium\\
8591 \cmidrule(l){2-5}
8592 %<en>\textit{gothic}%
8593 %<ja>\textgt{ゴシック}
8594  &bold&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
8595  &extra bold&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
8596 \midrule
8597 %<en>\textit{rounded gothic}
8598 %<ja>\textgt{丸ゴシック}
8599 &&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
8600 \bottomrule
8601 \end{tabular}
8602 \end{center}
8603
8604 \item[moga-mobo]  MogaMincho, MogaGothic, and MoboGothic.
8605 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8606 \item[moga-mobo-ex]  MogaExMincho, MogaExGothic, and MoboExGothic.
8607 %<en>\par These fonts can be downloaded from \url{http://yozvox.web.fc2.com/}.
8608 %<ja>これらのフォントは \url{http://yozvox.web.fc2.com/} からダウンロードできる.
8609 \begin{center}\small
8610 \begin{tabular}{llll}
8611 \toprule
8612 \bf family&\bf series&\bf default, \texttt{90jis}~option&\bf \texttt{jis2004} option\\
8613 \midrule
8614  &medium&Moga90Mincho&MogaMincho\\
8615 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
8616 %<ja>\smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8617  &bold&Moga90Mincho Bold&MogaMincho Bold\\
8618 \midrule
8619  &medium&Moga90Gothic&MogaGothic\\
8620 %<en>\textit{gothic}%
8621 %<ja>\textgt{ゴシック}
8622  &bold&Moga90Gothic Bold&MogaGothic Bold\\
8623  &extra bold&Moga90Gothic Bold&MogaGothic Bold\\
8624 \midrule
8625 %<en>\textit{rounded gothic}
8626 %<ja>\textgt{丸ゴシック}
8627 &&Mobo90Gothic&MoboGothic\\
8628 \bottomrule
8629 \end{tabular}
8630 \end{center}
8631 %<en>When \texttt{moga-mobo-ex} is specified, the font ``MogaEx90Mincho'' etc.\ are used.
8632 %<ja>\texttt{moga-mobo-ex}オプション指定時にはMogaEx90MinchoなどのExが名前についたフォントが使われる.
8633
8634 \item[ume]  Ume Mincho and Ume Gothic.
8635 %<en>\par These fonts can be downloaded from\\\hfill \url{https://ja.osdn.net/projects/ume-font/wiki/FrontPage}.
8636 %<ja>これらのフォントは \url{https://ja.osdn.net/projects/ume-font/wiki/FrontPage} からダウンロードできる.
8637 \begin{center}\small
8638 \begin{tabular}{lll}
8639 \toprule
8640 \bf family&\bf series&\bf default\\
8641 \midrule
8642  &medium&Ume Mincho\\
8643 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
8644 %<ja>\smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8645  &bold&Ume Mincho\\
8646 \midrule
8647  &&Ume Gothic*\\
8648  &\smash{\raisebox{1.5ex}{medium}}&Ume Gothic O5\\
8649 \cmidrule(l){2-3}
8650 %<en>\textit{gothic}%
8651 %<ja>\textgt{ゴシック}
8652  &bold&Ume Gothic O5\\
8653  &extra bold&Ume Gothic O5\\
8654 \midrule
8655 %<en>\textit{rounded gothic}
8656 %<ja>\textgt{丸ゴシック}
8657 &&Ume Gothic O5\\
8658 \bottomrule
8659 \end{tabular}
8660 \end{center}
8661
8662 %<en>\newpage
8663  \item[sourcehan]  Source Han Serif and Source Han Sans fonts (Language-specific OTF \textit{or} OTC)
8664 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8665  \item[sourcehan-jp]  Source Han Serif JP and Source Han Sans JP fonts (Region-specific Subset OTF)
8666 \begin{center}\small
8667 \def\AD#1#2{Source Han #1 #2&Source Han #1 JP #2}%
8668 \begin{tabular}{lllll}
8669 \toprule
8670 \bf family&\bf series&\texttt{sourcehan}&\texttt{sourcehan-jp}\\
8671 \midrule
8672  &light&\AD{Serif}{Light}\\
8673 %<en>\textit{mincho}%
8674 %<ja>\textgt{明朝}%
8675  &medium&\AD{Serif}{Regular}\\
8676  &bold&\AD{Serif}{Bold}\\
8677 \midrule
8678  &&\AD{Sans}{Regular*}\\
8679  &\smash{\raisebox{1.5ex}{medium}}
8680  &\AD{Sans}{Medium}\\
8681 \cmidrule(l){2-4}
8682 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8683 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8684  &bold&\AD{Sans}{Bold}\\
8685  &extra bold&\AD{Sans}{Heavy}\\
8686 \midrule
8687 %<en>\textit{rounded gothic}
8688 %<ja>\textgt{丸ゴシック}
8689 &&\AD{Sans}{Medium}\\
8690 \bottomrule
8691 \end{tabular}
8692 \end{center}
8693
8694
8695  \item[noto-otc]  Noto Serif CJK and Noto Sans CJK fonts (OTC)
8696 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8697  \item[noto-otf\textrm{, }noto]  Noto Serif CJK and Noto Sans CJK fonts (Language-specific OTF)
8698 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8699  \item[noto-jp]  Noto Serif CJK and Noto Sans CJK fonts (Region-specific subset OTF)
8700 \begin{center}\small
8701 \def\AD#1#2{Noto #1 CJK #2&Noto #1 CJK JP #2&Noto #1 JP #2}%
8702 \begin{tabular}{lllll}
8703 \toprule
8704 \bf family&\bf series&\texttt{noto-otc}&\texttt{noto-otf}, \texttt{noto}&\texttt{noto-jp}\\
8705 \midrule
8706  &light&\AD{Serif}{Light}\\
8707 %<en>\textit{mincho}%
8708 %<ja>\textgt{明朝}%
8709  &medium&\AD{Serif}{Regular}\\
8710  &bold&\AD{Serif}{Bold}\\
8711 \midrule
8712  &&\AD{Sans}{Regular*}\\
8713  &\smash{\raisebox{1.5ex}{medium}}
8714  &\AD{Sans}{Medium}\\
8715 \cmidrule(l){2-5}
8716 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8717 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8718  &bold&\AD{Sans}{Bold}\\
8719  &extra bold&\AD{Sans}{Black}\\
8720 \midrule
8721 %<en>\textit{rounded gothic}
8722 %<ja>\textgt{丸ゴシック}
8723 &&\AD{Sans}{Medium}\\
8724 \bottomrule
8725 \end{tabular}
8726 \end{center}
8727
8728 \item[haranoaji]  Harano Aji Fonts.
8729 %<en>\par These fonts can be downloaded from\\\hfill \url{https://github.com/trueroad/HaranoAjiFonts}.
8730 %<ja>これらのフォントは \url{https://github.com/trueroad/HaranoAjiFonts} からダウンロードできる.
8731 %<*en>
8732 There is not rounded gothic family in Harano Aji Fonts.
8733 %</en>
8734 %<*ja>
8735 「原ノ味丸ゴシック」は存在しないので,便宜的に原ノ味角ゴシックHeavyによって代用している.
8736 %</ja>
8737 \begin{center}\small
8738 \begin{tabular}{lll}
8739 \toprule
8740 \bf family&\bf series&\texttt{haranoaji}\\
8741 \midrule
8742  &light&HaranoAjiMincho-Light.otf\\
8743 %<en>\textit{mincho}%
8744 %<ja>\textgt{明朝}%
8745  &medium&HaranoAjiMincho-Regular.otf\\
8746  &bold&HaranoAjiMincho-Bold.otf\\
8747 \midrule
8748  &&HaranoAjiGothic-Regular.otf*\\
8749  &\smash{\raisebox{1.5ex}{medium}}
8750  &HaranoAjiGothic-Medium.otf\\
8751 \cmidrule(l){2-3}
8752 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8753 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8754  &bold&HaranoAjiGothic-Bold.otf\\
8755  &extra bold&HaranoAjiGothic-Heavy.otf\\
8756 \midrule
8757 %<en>\textit{rounded gothic}
8758 %<ja>\textgt{丸ゴシック}
8759 &&HaranoAjiGothic-Medium.otf\\
8760 \bottomrule
8761 \end{tabular}
8762 \end{center}
8763 \end{cslist}
8764
8765 %<en>\subsubsection{Presets which do not support multi weights}
8766 %<ja>\subsubsection{単ウェイト用プリセット一覧}
8767 \label{sssec:ltjpreset-single}
8768
8769 %<*en>
8770 Next, we describe settings for using only single weight.
8771 %</en>
8772 %<*ja>
8773 次に,単ウェイト用の設定を述べる.この4設定では
8774 明朝体太字・丸ゴシック体はゴシック体と同じフォントが用いられる.
8775 %</ja>
8776 \par\nobreak\medskip
8777 {\centering\small
8778 \begin{tabular}{lllll}
8779 \toprule
8780 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
8781 \midrule
8782 %<*en>
8783 \it mincho&Ryumin-Light (non-embedded)
8784 &IPA Mincho&IPAex Mincho&MS Mincho\\
8785 \it gothic&GothicBBB-Medium (non-embedded)
8786 &IPA Gothic&IPAex Gothic&MS Gothic\\
8787 %</en>
8788 %<*ja>
8789 \gtfamily 明朝&Ryumin-Light(非埋込)
8790 &IPA明朝&IPAex明朝&MS明朝\\
8791 \gtfamily ゴシック&GothicBBB-Medium(非埋込)
8792 &IPAゴシック&IPAexゴシック&MSゴシック\\
8793 %</ja>
8794 \bottomrule
8795 \end{tabular}\par\medskip}
8796
8797 %<en>\subsubsection{Presets which use HG fonts}
8798 %<ja>\subsubsection{HGフォントを使うプリセット}
8799 \label{sssec:ltjpreset-hg}
8800 %<*en>
8801 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
8802 In the table below, starred fonts (e.g., IPA~Gothic*) are used
8803 only if \texttt{jis2004} or \texttt{nodeluxe} option is spefified.
8804 %</en>
8805 %<*ja>
8806 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
8807 多ウェイト化した設定もある.以下の表では,*~付きのフォント(例:IPAゴシック*)は
8808 \texttt{jis2004}と\texttt{nodeluxe}のいずれかのオプションが有効になっているときに使われる.
8809 %</ja>
8810 \par\nobreak\medskip
8811 {\centering\small
8812 \begin{tabular}{lllll}
8813 \toprule
8814 \textbf{family}&\textbf{series}&\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
8815 \midrule
8816 %<*en>
8817 &medium&IPA Mincho&IPAex Mincho&MS Mincho\\
8818 \smash{\raisebox{1.5ex}{\textit{mincho}}}%
8819 &bold&HG Mincho E&HG Mincho E&HG Mincho E\\\midrule
8820 &&IPA Gothic*&IPAex Gothic*&MS Gothic*\\
8821 &\smash{\raisebox{1.5ex}{medium}}%
8822 &HG Gothic M&HG Gothic M&HG Gothic M\\\cmidrule{2-5}
8823 \textit{gothic}&bold&HG Gothic E&HG Gothic E&HG Gothic E\\\cmidrule{2-5}
8824 &extra bold&HG Soei Kaku Gothic UB&HG Soei Kaku Gothic UB&HG Soei Kaku Gothic UB\\\midrule
8825 \textit{rounded gothic}&&
8826 HG MaruGothic M PRO&HG MaruGothic M PRO&HG MaruGothic M PRO\\
8827 %</en>
8828 %<*ja>
8829 &medium&IPA明朝&IPAex明朝&MS明朝\\
8830 \smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8831 &bold&HG明朝E&HG明朝E&HG明朝E\\\midrule
8832 &&IPAゴシック*&IPAexゴシック*&MSゴシック*\\
8833 &\smash{\raisebox{1.5ex}{medium}}%
8834 &HGゴシックM&HGゴシックM&HGゴシックM\\\cmidrule{2-5}
8835 \textgt{ゴシック}&bold&HGゴシックE&HGゴシックE&HGゴシックE\\\cmidrule{2-5}
8836 &extra bold&HG創英角ゴシックUB&HG創英角ゴシックUB&HG創英角ゴシックUB\\\midrule
8837 \textgt{丸ゴシック}&&
8838 HG丸ゴシックM-PRO&HG丸ゴシックM-PRO&HG丸ゴシックM-PRO\\
8839 %</ja>
8840 \bottomrule
8841 \end{tabular}\par\medskip}
8842
8843 %<*en>
8844 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
8845 are internally specified by:
8846 \begin{description}
8847 \item[default] by font name (\texttt{HGMinchoE}, etc.).
8848 \item[\texttt{jis90}, \texttt{90jis}] by file name (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
8849 \item[\texttt{jis2004}, \texttt{2004jis}] by file name (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
8850 \end{description}
8851 %</en>
8852 %<*ja>
8853 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
8854 \begin{description}
8855 \item[標準] フォント名(\texttt{HGMinchoE} など)
8856 \item[\texttt{jis90}, \texttt{90jis}指定時] ファイル名 (%
8857 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
8858 \item[\texttt{jis2004}, \texttt{2004jis}指定時] ファイル名 (%
8859 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
8860 \end{description}
8861 として指定を行っているので注意すること.
8862 %</ja>
8863
8864 %<en>\subsubsection{Define/Use Custom Presets}
8865 %<ja>\subsubsection{新たなプリセットの定義}
8866
8867 %<*ja>
8868 バージョン20170904.0以降では,自分で新たなプリセットを定義することが出来るようになった.
8869 以下に説明する2命令はプリアンブルでしか実行できない.
8870 %</ja>
8871 %<*en>
8872 From version~20170904.0, one can define new presets using \cs{ltjnewpreset},
8873 and use them by \cs{ltjapplypreset}. These two commands can only be used in the preamble.
8874 %</en>
8875 \begin{cslist}
8876  \item[\cs{ltjnewpreset}\{\meta{name}\}\{\meta{specification}\}]
8877 %<*ja>
8878   新たに\meta{name}という名称のプリセットを定義する.この名称は,
8879   すでに定義されているプリセット名や,
8880   \ref{sssec:ltjpreset-general}で定義されているオプション,さらに
8881   次の13個と重複してはならない.
8882   \begin{quote}
8883         \ttfamily
8884         mc mc-l mc-m mc-b mc-bx gt gt-u gt-d gt-m gt-b gt-bx gt-eb mg-m
8885   \end{quote}
8886
8887   \meta{specification}は,プリセット名や以下のキー達のコンマ区切りリストを指定する:
8888   \begin{description}
8889    \item[\ttfamily mc-l=\meta{font}] 明朝体細字(\cs{mcfamily}\cs{ltseries})
8890    \item[\ttfamily mc-m=\meta{font}] 明朝体中字(\cs{mcfamily}\cs{mdseries})
8891    \item[\ttfamily mc-b=\meta{font}] 明朝体太字(\cs{mcfamily}\cs{bfseries})
8892    \item[\ttfamily mc-bx=\meta{font}] \texttt{mc-b=\meta{font}}と同義.
8893    \item[\ttfamily gt-u=\meta{font}] \texttt{deluxe}オプション未指定時のゴシック体(\cs{gtfamily})・明朝体太字
8894    \item[\ttfamily gt-d=\meta{font}] \texttt{deluxe}オプション指定時のゴシック体中字(\cs{gtfamily}\cs{mdseries})
8895    \item[\ttfamily gt-m=\meta{font}] \texttt{deluxe}オプションの指定の有無に関係なく
8896     ゴシック体中字(\cs{gtfamily}\cs{mdseries})を指定する.「\texttt{gt-u=\meta{font}, gt-d\meta{font}}」と同義.
8897    \item[\ttfamily gt-b=\meta{font}] ゴシック体太字(\cs{gtfamily}\cs{bfseries})\\
8898     なお,パッケージ読み込み時に\texttt{bold}オプションが指定された場合は,\texttt{mc-b=\meta{font}}を指定したことにもなる.
8899    \item[\ttfamily gt-bx=\meta{font}] \texttt{gt-b=\meta{font}}と同義.
8900    \item[\ttfamily gt-eb=\meta{font}] ゴシック体太字(\cs{gtfamily}\cs{ebseries})
8901    \item[\ttfamily mg-m=\meta{font}] 丸ゴシック体(\cs{mgfamily})
8902    \item[\ttfamily mc=\meta{font}] 明朝体の細字・中字・太字全部を設定.
8903         以下を指定したことと同じである:
8904         \begin{quote}
8905           \ttfamily mc-l=\meta{font}, mc-m=\meta{font}, mc-b=\meta{font}
8906         \end{quote}
8907    \item[\ttfamily gt=\meta{font}] ゴシック体の中字・太字・極太全部を設定.
8908         以下を指定したことと同じである:
8909         \begin{quote}
8910           \ttfamily gt-u=\meta{font}, gt-d=\meta{font}, gt-b=\meta{font}, gt-eb=\meta{font}
8911         \end{quote}
8912   \end{description}
8913 %</ja>
8914 %<*en>
8915   Define new preset~\meta{name}. This <name> cannot be same as other presets,
8916   options described in Subsubsection~\ref{sssec:ltjpreset-general}, nor
8917   following 13~strings:
8918   \begin{quote}
8919         \ttfamily
8920         mc mc-l mc-m mc-b mc-bx gt gt-u gt-d gt-m gt-b gt-bx gt-eb mg-m
8921   \end{quote}
8922
8923   \meta{specification} is a comma-separated list which consists of
8924   other presets and/or the following keys:
8925   \begin{description}
8926    \item[\ttfamily mc-l=\meta{font}] mincho light
8927    \item[\ttfamily mc-m=\meta{font}] mincho medium
8928    \item[\ttfamily mc-b=\meta{font}] mincho bold
8929    \item[\ttfamily mc-bx=\meta{font}] synonym for \texttt{mc-b=\meta{font}}
8930    \item[\ttfamily gt-u=\meta{font}] gothic, when \texttt{deluxe}~option is not specified.
8931    \item[\ttfamily gt-d=\meta{font}] gothic medium, when \texttt{deluxe}~option is specified.
8932    \item[\ttfamily gt-m=\meta{font}] gothic medium. This key is equivalent to ``\texttt{gt-u=\meta{font}, gt-d\meta{font}}''.
8933    \item[\ttfamily gt-b=\meta{font}] gothic bold\\
8934     Note that this key also specifies mincho bold if \texttt{bold} option is specified.
8935    \item[\ttfamily gt-bx=\meta{font}] synonym for \texttt{gt-b=\meta{font}}
8936    \item[\ttfamily gt-eb=\meta{font}] gothic extra~bold
8937    \item[\ttfamily mg-m=\meta{font}] rounded gothic
8938    \item[\ttfamily mc=\meta{font}] Equivalent to
8939         \begin{quote}
8940           \ttfamily mc-l=\meta{font}, mc-m=\meta{font}, mc-b=\meta{font}
8941         \end{quote}
8942    \item[\ttfamily gt=\meta{font}] Equivalent to
8943         \begin{quote}
8944           \ttfamily gt-u=\meta{font}, gt-d=\meta{font}, gt-b=\meta{font}, gt-eb=\meta{font}
8945         \end{quote}
8946   \end{description}
8947 %</en>
8948  \item[\cs{ltjnewpreset}*\{\meta{name}\}\{\meta{specification}\}]
8949 %<*ja>
8950   \cs{ltjnewpreset}とほぼ同じであるが,こちらはすでに定義されているプリセット名
8951   を\meta{name}に指定した場合にはエラーを出さずに定義を置き換える.
8952 %</ja>
8953 %<*en>
8954   Almost same as \cs{ltjnewpreset}. However, if \meta{name} matches a preset which already defined,
8955   this command simply overwrite it.
8956 %</en>
8957  \item[\cs{ltjapplypreset}\{\meta{name}\}]
8958 %<ja> \meta{name}で指定されたプリセットを使って和文フォントを設定する.
8959 %<en> Set Japanese font families using preset~\meta{name}.
8960 \end{cslist}
8961
8962 %<*ja>
8963 なお,\cs{ltjnewpreset}の第二引数\meta{specification}に含まれる
8964 プリセット名は\cs{ltjnewpreset}の時点で定義されている必要はなく,
8965 \cs{ltjapplypreset}で実際に使うときに定義されていれば良い.
8966 そのため,次のような記述も可能である:
8967 \begin{lstlisting}
8968   \ltjnewpreset{hoge}{piyo,mc-b=HiraMinProN-W6}
8969   \ltjnewpreset{piyo}{mg-m=HiraMaruProN-W4}
8970   \ltjapplypreset{hoge}
8971 \end{lstlisting}
8972
8973 \paragraph{注意}
8974 \cs{ltjnewpreset}で定義したプリセットには以下の制限がある.
8975 \begin{itemize}
8976   \item 非埋め込みのフォントを指定することはできない.
8977   \item \texttt{ipa-hg}などのいくつかのプリセットでは
8978   「\texttt{90jis}, \texttt{jis2004}が指定されているか否かでフォントの指定を変える」処理が
8979   行われていたが,\cs{ltjnewpreset}で定義したプリセットではこの処理は働かない.
8980   HGフォントやモガ明朝などを使うプリセットを定義する場合には注意すること.
8981 \end{itemize}
8982 %</ja>
8983 %<*en>
8984 Note that \cs{ltjnewpreset} does not ``expand'' the definition to define a preset.
8985 This means that one can write as the following:
8986 \begin{lstlisting}
8987   \ltjnewpreset{hoge}{piyo,mc-b=HiraMinProN-W6}
8988   \ltjnewpreset{piyo}{mg-m=HiraMaruProN-W4}
8989   \ltjapplypreset{hoge}
8990 \end{lstlisting}
8991
8992 \paragraph{Restrictions}
8993 Presets which are defined by \cs{ltjnewpreset} have following restrictions:
8994 \begin{itemize}
8995   \item One cannot specify non-embedded fonts (such as Ryumin-Light).
8996   \item Some presets, such as \texttt{ipa-hg}, have a feature that
8997   fonts are changed according to whether \texttt{90jis}~or~\texttt{jis2004} is speified.
8998   This feature is not usable in presets which are defined by \cs{ltjnewpreset}.
8999 \end{itemize}
9000 %</en>
9001
9002
9003 \clearpage
9004 %<en>\part{Implementations}
9005 %<ja>\part{実装}
9006 \label{part-imp}
9007 %<en>\section{Storing Parameters}
9008 %<ja>\section{パラメータの保持}
9009 \label{sec-para}
9010 %<en>\subsection{Used dimensions, attributes and whatsit nodes}
9011 %<ja>\subsection{\LuaTeX-jaで用いられるレジスタとwhatsitノード}
9012
9013 %<*en>
9014 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
9015 %</en>
9016 %<*ja>
9017 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
9018 リストである.
9019 %</ja>
9020 \begin{list}{}{%
9021 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
9022 \def\dim#1{\item[\textbackslash #1\ \textrm{(dimension)}]}
9023 \def\cnt#1{\item[\textbackslash #1\ \textrm{(counter)}]}
9024 \def\attr#1{\item[\textbackslash #1\ \textrm{(attribute)}]}
9025 }
9026
9027 \dim{jQ}
9028 %<*en>
9029 \cs{jQ} is equal to
9030                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
9031                         a unit used in Japanese phototypesetting.
9032 So one should not change the value of this dimension.
9033 %</en>
9034 %<*ja>
9035 \cs{jQ} は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
9036 (「級」とも書かれる)に等しい.したがって,
9037 この寸法レジスタの値を変更してはならない.
9038 %</ja>
9039
9040 \dim{jH}
9041 %<*en>
9042 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
9043                          used in Japanese phototypesetting.
9044 This \cs{jH} is the same \cs{dimen} register as \cs{jQ}.
9045 %</en>
9046 %<*ja>
9047 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
9048 等しい.この \cs{jH} は \cs{jQ} と同じ寸法レジスタを指す.
9049 %</ja>
9050
9051 \dim{ltj@dimen@zw}
9052 %<*en>
9053 A temporal register for the ``full-width'' of current Japanese font.
9054 The command \cs{zw} sets this register to the correct value, and
9055 ``return'' this register itself.
9056 %</en>
9057 %<*ja>
9058 現在の和文フォントの「全角幅」を保持する一時レジスタ.
9059 \cs{zw} 命令は,このレジスタを適切な値に設定した後,
9060 「このレジスタ自体を返す」.
9061 %</ja>
9062
9063 \dim{ltj@dimen@zh}
9064 %<*en>
9065 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
9066 The command \cs{zh} sets this register to the correct value, and
9067 ``return'' this register itself.
9068 %</en>
9069 %<*ja>
9070 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
9071 \cs{zh} 命令は,このレジスタを適切な値に設定した後,
9072 「このレジスタ自体を返す」.
9073 %</ja>
9074
9075 \attr{jfam}
9076 %<*en>
9077 Current number of Japanese font family for math formulas.
9078 %</en>
9079 %<*ja>
9080 数式用の和文フォントファミリの現在の番号.
9081 %</ja>
9082
9083 \attr{ltj@curjfnt}
9084 %<*en>
9085 If this attribute is a positive number, it stores the font number of current Japanese font for horizontal direction.
9086 If this attribute is negative, it means that the Japanese font for horizontal direction is
9087 not loaded---\LuaTeX-ja only knows its size and JFM.
9088 %</en>
9089 %<*ja>
9090 基本的には現在の横組用和文フォントのフォント番号を格納しているが,
9091 \LaTeX 下で使用する場合は($-2$以下の)負数となることがある.
9092   負数の場合は「横組用和文フォントは実際には読み込まれておらず,そのフォントサイズとJFMだけが
9093   \LuaTeX-jaが把握している」状態を表す.
9094 %</ja>
9095
9096 \attr{ltj@curtfnt}
9097 %<*en>
9098 Similar to \cs{ltj@curjfnt}, but with current Japanese font for vertical direction.
9099 %</en>
9100 %<*ja>
9101 縦組用和文フォントに関する\cs{ltj@curjfnt}と同様の値.
9102 %</ja>
9103
9104 \attr{ltj@charclass}
9105 %<*en>
9106 The character class of a \textbf{JAchar}. This attribute is only set on a
9107                          \textit{glyph\_node} which contains a \textbf{JAchar}.
9108 %</en>
9109 %<*ja>
9110 \textbf{JAchar}の文字クラス.\textbf{JAchar}が格納された\textit{glyph\_node}でのみ使われる.
9111 %</ja>
9112
9113 \attr{ltj@yablshift}
9114 %<*en>
9115 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
9116 ``unset'' means zero.
9117 %</en>
9118 %<*ja>
9119 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
9120 この属性が「未設定」(\texttt{-"7FFFFFFF})のときは0であるとみなされる.\cs{ltj@ykblshift}他も同様.
9121 %</ja>
9122
9123 \attr{ltj@ykblshift}
9124 %<*en>
9125 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
9126 %</en>
9127 %<*ja>
9128 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
9129 %</ja>
9130
9131 \attr{ltj@tablshift}
9132 \attr{ltj@tkblshift}
9133
9134 \attr{ltj@autospc}
9135 %<*en>
9136 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
9137 0 means ``not allowed'', and the other value (including ``unset'') means ``allowed''.
9138 %</en>
9139 %<*ja>
9140 そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
9141 0は「許可しない」,0以外の値(「未設定」も含む)は「許可する」.
9142 %</ja>
9143
9144 \attr{ltj@autoxspc}
9145 %<*en>
9146 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
9147 0 means ``not allowed'', and the other value (including ``unset'') means ``allowed''.
9148 %</en>
9149 %<*ja>
9150 そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
9151 0は「許可しない」,0以外の値(「未設定」も含む)は「許可する」.
9152 %</ja>
9153
9154 \attr{ltj@icflag}
9155 %<*en>
9156 An attribute for distinguishing ``kinds'' of a node. One of the following value is
9157 assigned to this attribute:
9158 %</en>
9159 %<*ja>
9160 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
9161 %</ja>
9162 \begin{description}
9163 \item[\textit{italic} (1)]
9164 %<*en>
9165 Kerns from italic correction (\verb+\/+), or from kerning information of a Japanese font.
9166 These kerns are ``ignored'' in the insertion process of \textbf{JAglue},
9167 unlike explicit \cs{kern}.
9168 %</en>
9169 %<*ja>
9170 イタリック補正(\verb+\/+)によるカーン,
9171 または \Pkg{luaotfload} によって挿入されたフォントのカーニング情報由来のカーン.
9172 これらのカーンは通常の \cs{kern} とは異なり,
9173 \textbf{JAglue}の挿入処理においては透過する.
9174 %</ja>
9175
9176 \item[\textit{packed} (2)]
9177
9178 \item[\textit{kinsoku} (3)]
9179 %<*en>
9180 Penalties inserted for the word-wrapping process (\emph{kinsoku shori}) of Japanese characters.
9181 %</en>
9182 %<ja>禁則処理のために挿入されたペナルティ.
9183 \item[\mathversion{bold}$\textit{from\_jfm}$--$(\textit{from\_jfm}+63)$~(4--67)]
9184 %<en>Glues/kerns from JFM.
9185 %<ja>JFM由来のグルー/カーン.
9186 \item[\textit{kanji\_skip}~(68), \textit{kanji\_skip\_jfm}~(69)]
9187 %<en>Glues from \Param{kanjiskip}.
9188 %<ja>和文間空白\Param{kanjiskip}を表すグルー.
9189 \item[\textit{xkanji\_skip}~(70), \textit{xkanji\_skip\_jfm}~(71)]
9190 %<en>Glues from \Param{xkanjiskip}.
9191 %<ja>和欧文間空白\Param{xkanjiskip}を表すグルー.
9192 \item[\textit{processed} (73)]
9193 %<en>Nodes which is already processed by \ldots.
9194 %<ja>\LuaTeX-ja の内部処理によって既に処理されたノード.
9195 \item[\textit{ic\_processed} (74)]
9196 %<*en>
9197 Glues from an italic correction, but already processed in the insertion process of \textbf{JAglue}s.
9198 %</en>
9199 %<ja>イタリック補正に由来するグルーであって,既に \textbf{JAglue} 挿入処理にかかったもの.
9200 \item[\textit{boxbdd} (75)]
9201 %<en>Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
9202 %<ja>hboxか段落の最初か最後に挿入されたグルー/カーン.
9203 \item[\textit{special\_jaglue} (76)]
9204 %<en>Glues from \cs{insert}[\texttt{x}]\texttt{kanjiskip}.
9205 %<ja>\cs{insert}[\texttt{x}]\texttt{kanjiskip}由来のグルー.
9206 \end{description}
9207
9208 %<*ja>
9209 また,挿入処理の結果であるリストの最初のノードでは,\verb+\ltj@icflag+ の値に
9210 \textit{processed\_begin\_flag}~(4096)が追加される.これによって,\cs{unhbox} が
9211 連続した場合でも「ボックスの境界」が識別できるようになっている.
9212 %</ja>
9213
9214 \attr{ltj@kcat\,$i$}
9215 %<*en>
9216 Where $i$~is a natural number which is less than~7.
9217 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
9218 %</en>
9219 %<*ja>
9220 $i$は7より小さい自然数.
9221 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
9222 扱われるかを示すビットベクトルを格納する.
9223 %</ja>
9224
9225 \attr{ltj@dir}
9226 %<*ja>
9227 \textit{direction}~whatsit(後述)において組方向を示すために,あるいは\textit{dir\_box}の
9228                          組方向を用いる.\textit{direction}~whatsitにおいては値は
9229 \begin{quote}
9230  \textit{dir\_dtou} (1), \textit{dir\_tate} (3),
9231  \textit{dir\_yoko} (4), \textit{dir\_utod} (11)
9232 \end{quote}
9233 のいずれかであり,\textit{dir\_box}ではこれらに次を加えた値をとる(\ref{sec-dir-imp}章参照).
9234 %</ja>
9235 \begin{description}
9236 \item[\textit{dir\_node\_auto} (128)]
9237 %<ja> 異なる組方向に配置するために自動的に作られたボックス.
9238 \item[\textit{dir\_node\_manual} (256)]
9239 %<ja> \cs{ltjsetwd} によって「ボックスの本来の組方向とは異なる組方向での寸法」を
9240 %<ja> 設定したときに,それを記録するためのボックス.
9241 \end{description}
9242 %<ja> \TeX 側から見える値,つまり \verb+\the\ltj@dir+ の値は常に0である.
9243
9244 \cnt{ltjlineendcomment}
9245 %<*ja>
9246   \LuaTeX-jaは\textbf{JAchar}で入力行が終了した場合,その直後にコメント文字を
9247   おくことで余計な空白が挿入されることを防いでいる.
9248   \cs{ltjlineendcomment}はその際のコメント文字のUnicodeにおける符号位置を指定する
9249   (詳細は\ref{ssec:lineend}節を参照).
9250
9251   \LuaTeX-jaにおける既定値は$\texttt{"FFFFF}=1048575$であり,
9252   ユーザは内部動作を熟知していない限りこのカウンタの値を変更してはならない.
9253   \cs{ltjlineendcomment}の値がUnicodeの範囲外(負や,$\texttt{"10FFFF}=1114111$を超えた場合)
9254   にくることは想定されていない.
9255 %</ja>
9256 \end{list}
9257
9258 %<*en>
9259 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
9260 internal processing. All those nodes except \emph{direction} whatsits
9261 store a natural number (hence its \texttt{type} is 100).
9262 \emph{direction} whatsits store a node list, hence its \texttt{type} is 110.
9263 Their \texttt{user\_id} (used for distinguish user-defined whatsits)
9264 are allocated by \texttt{luatexbase.newuserwhatsitid}.
9265 %</en>
9266 %<*ja>
9267 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
9268 \textit{direction} whatsitはノードリストを格納するが,
9269 それ以外のwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
9270 user-defined whatsitを識別するための \texttt{user\_id} は\
9271 \texttt{luatexbase.newuserwhatsitid} により確保されており,
9272 下の見出しは単なる識別用でしかない.
9273 %</ja>
9274 \begin{description}
9275 \item[\textit{inhibitglue}]
9276 %<*en>
9277 Nodes for indicating that \cs{inhibitglue} is
9278            specified. The \texttt{value} field of these nodes doesn't matter.
9279 %</en>
9280 %<*ja>
9281 \cs{inhibitglue} が指定されたことを示すノード.これらのノードの\
9282 \texttt{value} フィールドは意味を持たない.
9283 %</ja>
9284
9285 \item[\textit{stack\_marker}]
9286 %<*en>
9287 Nodes for \LuaTeX-ja's stack system (see the next
9288            subsection). The \texttt{value} field of these nodes is
9289            current group level.
9290 %</en>
9291 %<*ja>
9292 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
9293 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
9294 %</ja>
9295
9296 \item[\textit{char\_by\_cid}]
9297 %<*en>
9298 Nodes for \textbf{JAchar} which processes by \Pkg{luaotfload} won't be applied,
9299        and the character code is
9300            stored in the \texttt{value} field. Each node of this type are
9301            converted to a \textit{glyph\_node} \emph{after}
9302            processes by luaotfload.
9303 Nodes of this type is used in \cs{CID}~and~\cs{UTF}.
9304 %</en>
9305 %<*ja>
9306 \Pkg{luaotfload}による処理が適用されない\textbf{JAchar}のためのノードで,
9307 \texttt{value} フィールドに文字コードが格納されている.
9308 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
9309 \emph{後で}\textit{glyph\_node}に変換される.
9310 \cs{CID}, \cs{UTF}でこの種類のノードが利用されている.
9311 %</ja>
9312
9313 \item[\textit{replace\_vs}]
9314 %<*en>
9315 Similar to \textit{char\_by\_cid} whatsits above.
9316 These nodes are for \textbf{ALchar} which the callback process of
9317            \Pkg{luaotfload} won't be applied.
9318 %</en>
9319 %<*ja>
9320 上の\textit{char\_by\_cid}と同様に,
9321 これらのノードは\Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{ALchar}のた
9322            めものである.
9323 %</ja>
9324
9325 \item[\textit{begin\_par}]
9326 %<*en>
9327 Nodes for indicating beginning of a paragraph.
9328 A paragraph which is started by \cs{item} in list-like environments has a horizontal box
9329 for its label before the actual contents. So \dots
9330 %</en>
9331 %<*ja>
9332 「段落の開始」を意味するノード.
9333 \texttt{list}環境,\texttt{itemize}環境などにおいて,\cs{item} で始まる各項目は……
9334 %</ja>
9335
9336 \item[\textit{direction}]
9337
9338 \end{description}
9339
9340 %<*en>
9341 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
9342 %</en>
9343 %<*ja>
9344 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
9345 %</ja>
9346
9347 %<en>\subsection{Stack system of \LuaTeX-ja}
9348 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
9349 \label{ssec:stack}
9350
9351 %<en>\paragraph{Background}
9352 %<ja>\paragraph{背景}
9353 %<*en>
9354 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
9355 are stored in it. To clarify the reason, imagine the parameter
9356 \Param{kanjiskip} is stored by a skip, and consider the following
9357 source:
9358 %</en>
9359 %<*ja>
9360 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
9361 これを用いて保持されている.その理由を明らかにするために,
9362 \Param{kanjiskip}パラメータがスキップレジスタで保持されているとし,
9363 以下のコードを考えてみよう:
9364 %</ja>
9365 \begin{LTXexample}
9366 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
9367 \setbox0=\hbox{%
9368   \ltjsetparameter{kanjiskip=5pt}ほげほげ}
9369 \box0.ぴよぴよ\par
9370 \end{LTXexample}
9371
9372 %<*en>
9373 As described in Subsection~\ref{ssec:param}, the only effective value of
9374 \Param{kanjiskip} in an hbox is the latest value, so the value of
9375 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
9376 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
9377 known from any callbacks.  In the \texttt{tex/packaging.w}, which is a
9378 file in the source of \LuaTeX, there are the following codes:
9379 %</en>
9380 %<*ja>
9381 \ref{ssec:param}節で述べたように,あるhboxの中で効力を持つ
9382 \Param{kanjiskip}の値は最後に現れた値のみであり,したがってボックス全体に適用される
9383 \Param{kanjiskip}は5\,ptであるべきである.しかし,\LuaTeX の実
9384 装を観察すると,この5\,ptという長さはどのコールバックからも知ることはできないことがわかる.
9385 \LuaTeX のソースファイルの1つ \texttt{tex/packaging.w} の中に,
9386 以下のコードがある:
9387 %</ja>
9388 \begin{lstlisting}[numbers=left,firstnumber=1226]
9389 void package(int c)
9390 {
9391     scaled h;                   /* height of box */
9392     halfword p;                 /* first node in a box */
9393     scaled d;                   /* max depth */
9394     int grp;
9395     grp = cur_group;
9396     d = box_max_depth;
9397     unsave();
9398     save_ptr -= 4;
9399     if (cur_list.mode_field == -hmode) {
9400         cur_box = filtered_hpack(cur_list.head_field,
9401                                  cur_list.tail_field, saved_value(1),
9402                                  saved_level(1), grp, saved_level(2));
9403         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
9404 \end{lstlisting}
9405 %<*en>
9406 Notice that \texttt{unsave()} is executed \emph{before}
9407 \texttt{filtered\_hpack()}, where \texttt{hpack\_filter} callback is
9408 executed) here. So ``5\,pt'' in the above source is orphaned at
9409 \texttt{unsave()}, and hence it can't be accessed from \texttt{hpack\_filter}
9410 callback.
9411 %</en>
9412 %<*ja>
9413 \texttt{unsave()} が \texttt{filtered\_hpack()}(これは \texttt{hpack\_filter} コールバックが
9414 実行されるところである)の\emph{前に}実行されていることに注意する.
9415 したがって,上記ソース中で5\,ptは \texttt{unsave()} のところで捨てられ,
9416 \texttt{hpack\_filter} コールバックからはアクセスすることができない.
9417 %</ja>
9418
9419 %<en>\paragraph{Implementation}
9420 %<ja>\paragraph{解決法}
9421
9422 %<*en>
9423 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
9424 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
9425 %</en>
9426 %<*ja>
9427 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{%
9428 \texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
9429 ベースにしている.
9430 %</ja>
9431
9432 %<*en>
9433 These are two \TeX\ count registers for maintaining information:
9434 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
9435 the \TeX's group level when the last assignment was done.  Parameters
9436 are stored in one big table named \texttt{charprop\_stack\_table}, where
9437 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
9438 a new stack level is created by \cs{ltjsetparameter}, all data of the
9439 previous level is copied.
9440 %</en>
9441 %<*ja>
9442 情報を保持するために,2つの\TeX の整数レジスタを用いている:
9443 \verb+\ltj@@stack+ にスタックレベル,\verb+\ltj@@group@level+ に最後の代入が
9444 なされた時点での\TeX のグループレベルを保持している.
9445 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
9446 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
9447 データを格納している.もし新しいスタックレベルが \cs{ltjsetparameter} によって
9448 生成されたら,前のレベルの全てのデータがコピーされる.
9449 %</ja>
9450
9451 %<*en>
9452 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
9453 another trick. When the stack level is about to be increased, a whatsit
9454 node whose type, subtype and value are 44~(\textit{user\_defined}),
9455 \textit{stack\_marker} and the current group level respectively is appended to the current
9456 list (we refer this node by \textit{stack\_flag}). This enables us to
9457 know whether assignment is done just inside a hbox. Suppose that the
9458 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
9459 group, then:
9460 %</en>
9461 %<*ja>
9462 上の「背景」で述べた問題を解決するために,\LuaTeX-jaでは次の手法を用いる:
9463 スタックレベルが増加するするとき,type, subtype, valueがそれぞれ
9464 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
9465 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
9466 これにより,あるhboxの中で代入がなされたかどうかを知ることが可能
9467 となる.スタックレベルを$s$,そのhbox groupの直後の\TeX のグループレベルを
9468 $t$とすると:
9469 %</ja>
9470 \begin{itemize}
9471 %<*en>
9472 \item If there is no \textit{stack\_flag} node in the list of the contents of the hbox, then
9473       no assignment was occurred inside the hbox. Hence values of
9474       parameters at the end of the hbox are stored in the stack
9475       level~$s$.
9476 %</en>
9477 %<*ja>
9478 \item もしそのhboxの中身を表すリストの中に\textit{stack\_flag}ノードがなければ,
9479   hboxの中では代入は起こらなかったということになる.
9480   したがって,そのhboxの終わりにおけるパラメータの値はスタックレベル$s$に
9481   格納されている.
9482 %</ja>
9483
9484 %<*en>
9485 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
9486       an assignment was occurred just inside the hbox group. Hence
9487       values of parameters at the end of the hbox are stored in the
9488       stack level~$s+1$.
9489 %</en>
9490 %<*ja>
9491 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
9492   hboxの中で代入が起こったことになる.
9493   したがって,hboxの終わりにおけるパラメータの値はスタックレベル$s+1$に
9494   格納されている.
9495 %</ja>
9496
9497 %<*en>
9498 \item If there are \textit{stack\_flag} nodes but all of their values
9499       are more than~$t+1$, then an assignment was occurred in the box,
9500       but it is done in more internal group. Hence values of
9501       parameters at the end of the hbox are stored in the stack
9502       level~$s$.
9503 %</en>
9504 %<*ja>
9505 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
9506   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
9507   起こったということになる.したがって,hboxの終わりでのパラメータの
9508   値はスタックレベル$s$に格納されている.
9509 %</ja>
9510 \end{itemize}
9511
9512 %<*en>
9513 Note that to work this trick correctly, assignments to
9514 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
9515 regardless the value of \cs{globaldefs}.
9516 To solve this problem, we use another trick: the assignment
9517 \hbox{\verb+\directlua{tex.globaldefs=0}+} is always local.
9518 %</en>
9519 %<*ja>
9520 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
9521 代入は \cs{globaldefs} の値によらず常にローカルでなければならないことに注意する.
9522 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
9523 用いることで解決している.
9524 %</ja>
9525
9526 %<*en>
9527 \subsection{Lua functions of the stack system}
9528 In this subsection, we will see how a user use \LuaTeX-ja's stack system to
9529 store some data which obeys the grouping of \TeX.
9530 %</en>
9531 %<*ja>
9532 \subsection{スタックシステムで使用される関数}
9533 本節では,ユーザが\LuaTeX-jaのスタックシステムを使用して,
9534 \TeX のグルーピングに従うような
9535 独自のデータを取り扱う方法を述べる.
9536 %</ja>
9537
9538 %<*en>
9539 The following function can be used to store data into a stack:
9540 \begin{lstlisting}
9541 luatexja.stack.set_stack_table(index, <any> data)
9542 \end{lstlisting}
9543 Any values which except \texttt{nil}~and~NaN are usable as \textit{index}.
9544 However, a user should use only negative integers or strings as \textit{index},
9545 since natural numbers are used by \LuaTeX-ja itself.
9546 Also, whether \textit{data} is stored locally or globally
9547 is determined by \texttt{luatexja.isglobal}
9548 (stored globally if and only if \texttt{luatexja.isglobal == 'global'}).
9549 %</en>
9550 %<*ja>
9551 スタックに値を設定するには,以下のLua関数を呼び出せば良い:
9552 \begin{lstlisting}
9553 luatexja.stack.set_stack_table(<any> index, <any> data)
9554 \end{lstlisting}
9555 直感的には,スタックテーブル中のインデックス\textit{index}の値を\textit{data}にする,という意味である.
9556 \textit{index}の値としては \texttt{nil} とNaN以外の任意の値を使えるが,
9557 自然数は\LuaTeX-jaが使用する(将来の拡張用も含む)ので,
9558 ユーザが使用する場合は負の整数値か文字列の値にすることが望ましい.
9559 また,ローカルに設定されるかグローバルに設定されるかは,\texttt{luatexja.isglobal} の値に依存する
9560 (グローバルに設定されるのは,\texttt{luatexja.isglobal == 'global'} であるちょうどその時).
9561 %</ja>
9562
9563 %<*en>
9564 Stored data can be obtained as the return value of
9565 \begin{lstlisting}
9566 luatexja.stack.get_stack_table(index, <any> default, <number> level)
9567 \end{lstlisting}
9568 where \textit{level} is the stack level, which is usually the value of \verb+\ltj@@stack+,
9569 and \textit{default} is the default value which will be returned if no values are stored
9570 in the stack table whose level is \textit{level}.
9571 %</en>
9572 %<*ja>
9573 スタックの値は,
9574 \begin{lstlisting}
9575 luatexja.stack.get_stack_table(<any> index, <any> default, <number> level)
9576 \end{lstlisting}
9577 の戻り値で取得できる.\textit{level}はスタックレベルであり,
9578 通常は \verb+\ltj@@stack+ の値を指定することになるだろう.
9579 \textit{default}はレベル\textit{level}のスタックに値が設定されていなかった場合に
9580 返すデフォルト値である.
9581 %</ja>
9582
9583 \begin{figure}[tb]
9584 \begin{lstlisting}[numbers=left, firstnumber=380]
9585 \protected\def\ltj@setpar@global{%
9586   \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
9587     \else\directlua{luatexja.isglobal=''}\fi
9588 }
9589 \protected\def\ltjsetparameter#1{%
9590   \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
9591 \protected\def\ltjglobalsetparameter#1{%
9592   \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
9593     \else\directlua{luatexja.isglobal='global'}\fi%
9594   \setkeys[ltj]{japaram}{#1}\ignorespaces}
9595 \end{lstlisting}
9596 %<ja>\caption{パラメータ設定命令の定義}
9597 %<en>\caption{Definiton of parameter setting commands}
9598 \label{fig:setpar-def}
9599 \end{figure}
9600
9601 %<*en>
9602 \subsection{Extending Parameters}
9603 Keys for \cs{ltjsetparameter}~and~\cs{ltjgetparameter} can be extended,
9604 as in \Pkg{luatexja-adjust}.
9605 %</en>
9606 %<*ja>
9607 \subsection{パラメータの拡張}
9608 ここでは,\Pkg{luatexja-adjust}で行なっているように,
9609 \cs{ltjsetparameter},~\cs{ltjgetparameter}に指定可能なキーを追加する方法
9610 を述べる.
9611 %</ja>
9612
9613 %<*en>
9614 \paragraph{Setting parameters}
9615 \autoref{fig:setpar-def} shows the \emph{most outer} definition of
9616 two commands,
9617 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter}.
9618 Most important part is the last \cs{setkeys},
9619 which is offered by the \Pkg{xkeyval} package.
9620
9621 Hence, to add a key in \cs{ltjsetparameter}, one only have to add a key
9622 whose prefix is \texttt{ltj} and whose family is \texttt{japaram}, as the following.
9623 \begin{lstlisting}
9624 \define@key[ltj]{japaram}{...}{...}
9625 \end{lstlisting}
9626
9627 \cs{ltjsetparameter}~and~\cs{ltjglobalsetparameter} automatically sets
9628 \texttt{luatexja.isglobal}. Its meaning is the following.
9629 \begin{align}
9630  \texttt{luatexja.isglobal} =
9631 \begin{cases*}
9632  \texttt{'global'}&(global assignment),\\
9633  \texttt{''}&(local assignment).
9634 \end{cases*}
9635 \end{align}
9636 This is determined not only by command name
9637 (\cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}),
9638 but also by the value of \cs{globaldefs}.
9639 %</en>
9640 %<*ja>
9641 \paragraph{パラメータの設定}
9642 \cs{ltjsetparameter}と,\cs{ltjglobalsetparameter}の定義は\autoref{fig:setpar-def}の
9643 のようになっている.
9644 本質的なのは最後の\cs{setkeys}で,これは\Pkg{xkeyval}パッケージの提供する命令である.
9645
9646 このため,\cs{ltjsetparameter}に指定可能なパラメータを追加するには,
9647 \meta{prefix}を\texttt{ltj},\meta{family}を\texttt{japaram}としたキーを
9648 \begin{lstlisting}
9649 \define@key[ltj]{japaram}{...}{...}
9650 \end{lstlisting}
9651 のように定義すれば良いだけである.
9652 なお,パラメータ指定がグローバルかローカルかどうかを示す\texttt{luatexja.isglobal}が,
9653 \begin{align}
9654  \texttt{luatexja.isglobal} =
9655 \begin{cases*}
9656  \texttt{'global'}&(パラメータ設定はグローバル),\\
9657  \texttt{''}&(パラメータ設定はローカル).
9658 \end{cases*}
9659 \end{align}
9660 として自動的にセットされる\footnote{命令が\cs{ltjglobalsetparameter}かどうかだけでは
9661 なく,実行時の\cs{globaldefs}の値にも依存して定まる.}.
9662 %</ja>
9663
9664 %<*en>
9665 \paragraph{Getting parameters}
9666 \cs{ltjgetparameter} is implemented by a Lua script.
9667
9668 For parameters that do not need additional arguments, one only have to
9669 define a function in the table \verb+luatexja.unary_pars+.
9670 For example, with the following function,
9671 \verb+\ltjgetparameter{hoge}+ returns a \emph{string} \texttt{42}.
9672 \begin{lstlisting}[numbers=left]
9673 function luatexja.unary_pars.hoge (t)
9674   return 42
9675 end
9676 \end{lstlisting}
9677 Here the argument of \verb+luatexja.unary_pars.hoge+ is
9678 the stack level of \LuaTeX-ja's stack system (see Subsection~\ref{ssec:stack}).
9679
9680 On the other hand, for parameters that need an additional argument
9681 (this must be an integer), one have to define a function in
9682 \verb+luatexja.binary_pars+ first. For example,
9683 \begin{lstlisting}[numbers=left]
9684 function luatexja.binary_pars.fuga (c, t)
9685   return tostring(c) .. ', ' .. tostring(42)
9686 end
9687 \end{lstlisting}
9688 Here the first argument $t$ is the stack level, as before.
9689 The second argument $c$ is just the second argument of \cs{ltjgetparameter}.
9690
9691 For parameters that need an additional argument, one also have to
9692 execute the \TeX\ code like
9693 \begin{lstlisting}
9694 \ltj@@decl@array@param{fuga}
9695 \end{lstlisting}
9696 to indicate that ``the parameter \texttt{fuga} needs an additional argument''.
9697 %</en>
9698 %<*ja>
9699 \paragraph{パラメータの取得}
9700 一方,\cs{ltjgetparameter} はLuaスクリプトによって実装されている.
9701 値を取得するのに追加引数の要らないパラメータについては,\verb+luatexja.unary_pars+\
9702 内に処理内容を記述した関数を定義すれば良い.例えば,Luaスクリプトで
9703 \begin{lstlisting}[numbers=left]
9704 function luatexja.unary_pars.hoge (t)
9705   return 42
9706 end
9707 \end{lstlisting}
9708 を実行すると,\verb+\ltjgetparameter{hoge}+ は \texttt{42} という\emph{文字列}を返す.
9709 関数 \verb+luatexja.unary_pars.hoge+ の引数$t$は,\ref{ssec:stack}節で述べた
9710 \LuaTeX-jaのスタックシステムにおけるスタックレベルである.
9711 戻り値はいかなる値であっても,最終的には文字列として出力されることに注意.
9712
9713 一方,追加引数(\emph{数値しか許容しない})が必要なパラメータについては,
9714 まずLuaスクリプトで処理内容の本体を記述しておく:
9715 \begin{lstlisting}[numbers=left]
9716 function luatexja.binary_pars.fuga (c, t)
9717   return tostring(c) .. ', ' .. tostring(42)
9718 end
9719 \end{lstlisting}
9720 引数$t$は,先に述べた通りのスタックレベルである.一方,引数$c$は\
9721 \cs{ltjgetparameter} の第2引数を表す数値である.
9722 しかしこれだけでは駄目で,
9723 \begin{lstlisting}
9724 \ltj@@decl@array@param{fuga}
9725 \end{lstlisting}
9726 を実行し,\TeX インターフェース側に
9727 「\verb+\ltjgetparameter{fuga}+ は追加引数が必要」ということを通知する必要がある.
9728 %</ja>
9729
9730 %<en>\section{Linebreak after a Japanese Character}
9731 %<ja>\section{和文文字直後の改行}
9732 \label{sec-lbreak}
9733 %<en>\subsection{Reference: behavior in \pTeX}
9734 %<ja>\subsection{参考:\pTeX の動作}
9735 %<*en>
9736 In~\pTeX, a line break after a Japanese character doesn't emit a space,
9737 since words are not separated by spaces in Japanese writings. However,
9738 this feature isn't fully implemented in \LuaTeX-ja due to the
9739 specification of callbacks in~\LuaTeX. To clarify the difference between
9740 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
9741 this subsection.
9742
9743 \pTeX's input processor can be described in terms of a finite state
9744 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
9745 internal states are as follows:
9746 \begin{itemize}
9747 \item State~$N$: new line
9748 \item State~$S$: skipping spaces
9749 \item State~$M$: middle of line
9750 \item State~$K$: after a Japanese character
9751 \end{itemize}
9752 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
9753 processor.  State~$K$ is similar to state~$M$, and is entered after
9754 Japanese characters.  The diagram of state transitions are indicated in
9755 \autoref{fig:ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
9756 after ``beginning/ending of a group'' characters.
9757 %</en>
9758
9759 %<*ja>
9760 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
9761 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
9762 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
9763
9764 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
9765 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
9766 以下に述べるような4状態を持っている.
9767
9768 \begin{itemize}
9769 \item State~$N$: 行の開始.
9770 \item State~$S$: 空白読み飛ばし.
9771 \item State~$M$: 行中.
9772 \item State~$K$: 行中(和文文字の後).
9773 \end{itemize}
9774 また,状態遷移は,\autoref{fig:ptexipro}のようになっており,図中の数字は
9775 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
9776 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
9777 じものになる.
9778
9779 この図から分かることは,
9780 \begin{quote}
9781 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
9782 \end{quote}
9783 ということである.
9784 %</ja>
9785
9786 \begin{figure}[!tb]
9787 \let\sp\textvisiblespace\small
9788 \begin{minipage}{.6\textwidth}%
9789 \begin{center}
9790 \unitlength=6.5mm\sf\mathversion{bold}
9791 \begin{tikzpicture}[
9792   ->, auto, shorten >=1pt
9793 ]
9794 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
9795 \node [shape=circle,draw, fill=b_cyan] (newline) at (4,7) {$N$};
9796 \node [shape=circle,draw, fill=b_cyan] (midline) at (4,4) {$M$};
9797 \node [shape=circle,draw, fill=b_cyan] (skipspc) at (8,7) {$S$};
9798 \node [shape=circle,draw, fill=b_pink]  (kanji) at (8,4) {$K$};
9799 \node [shape=rectangle,draw, fill=b_green] (scanacs) at (6,8) {scan a c.s.};
9800 \node (endk) at (8,2.5) {} ;
9801 \node (endm) at (4,2.5) {} ;
9802 \node (ends) at (8,8.5) {} ;
9803 \node (endn) at (4,8.5) {} ;
9804 \begin{scope}[font=\scriptsize]
9805 \path (newline) edge [bend right]    node [left]{G, O} (midline)
9806       (init)    edge                 node {} (newline)
9807       (midline) edge [bend right=10] node {10} (skipspc)
9808       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
9809       (skipspc) edge [loop right]    node {10} (skipspc)
9810       (newline) edge [loop right]    node {10} (newline)
9811       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
9812       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
9813       (midline) edge                 node {5\ [\sp]} (endm)
9814       (midline) edge [loop left]     node {G, O} (midline)
9815       (skipspc) edge                 node [right] {5} (ends)
9816       (newline) edge                 node {5 [\cs{par}]} (endn);
9817 \begin{scope}[red]
9818 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
9819       (midline) edge                 node [below]{J} (kanji)
9820       (kanji)   edge [bend left]     node {O} (midline)
9821       (kanji)   edge                 node {10} (skipspc)
9822       (kanji)   edge [loop right]    node {G, J} (kanji)
9823       (skipspc) edge [bend left]     node {J} (kanji)
9824       (kanji)   edge                 node {5} (endk)
9825 ;
9826 \end{scope}
9827 \end{scope}
9828 \end{tikzpicture}
9829 \end{center}
9830 \end{minipage}%
9831 \begin{minipage}{.4\textwidth}
9832 \begin{description}
9833 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
9834  and ending of group (usually \verb+}+).
9835 \item[\textsf{J}] Japanese characters.
9836 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
9837 \item[\textsf{10}] space (usually \sp).
9838 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
9839 \item[\textsf{[\sp]}, \textsf{[\cs{par}]}]
9840 emits a space, or~\cs{par}.
9841 \end{description}
9842 \end{minipage}
9843 \begin{itemize}
9844 \item We omitted about category codes
9845 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
9846 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
9847 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
9848 the input processor scans a control sequence (\textsf{scan a c.s.}).
9849 These paths are not shown in the above diagram.
9850
9851 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
9852 to State~$M$ (middle of line) sometimes.
9853 \end{itemize}
9854 %<en>\caption{State transitions of \pTeX's input processor}
9855 %<ja>\caption{\pTeX の入力処理部の状態遷移}
9856 \label{fig:ptexipro}
9857 \end{figure}
9858
9859
9860 %<en>\subsection{Behavior in \LuaTeX-ja}
9861 %<ja>\subsection{\LuaTeX-jaの動作}
9862   \label{ssec:lineend}
9863 %<*en>
9864 States in the input processor of \LuaTeX\ is the same as that of \TeX,
9865 and they can't be customized by any callbacks. Hence, we can only use
9866 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
9867 suppress a space by a line break which is after Japanese characters.
9868
9869 However, \verb+token_filter+ callback cannot be used either, since a
9870 character in category code 5~(\textit{end-of-line}) is converted into an space
9871 token \emph{in the input processor}.  So we can use only the
9872 \verb+process_input_buffer+ callback.  This means that suppressing a
9873 space must be done \emph{just before} an input line is read.
9874
9875 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
9876 \begin{quote}
9877 A character whose character code is \cs{ltjlineendcomment}%
9878 \footnote{Its default value is \texttt{"FFFFF}, so  \texttt{U+FFFFF} is used.
9879 The category code of \texttt{U+FFFFF} is set to 14~(\textit{comment}) by
9880 \LuaTeX-ja.} is appended to an input line, \emph{before \LuaTeX\ actually
9881 process it}, if and only if the following three conditions are satisfied:
9882 \begin{enumerate}
9883 \item The category code of \cs{endlinechar}%
9884 \footnote{Usually, it is $\langle$\textit{return}$\rangle$
9885       (whose character code is 13).} is 5~(\textit{end-of-line}).
9886 \item The category code of \cs{ltjlineendcomment} itself is 14~(\textit{comment}).
9887 \item The input line matches the following ``regular expression'':
9888 \[
9889   (\text{any char})^*(\textbf{JAchar})
9890   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
9891 \]
9892 \end{enumerate}
9893 \end{quote}
9894
9895 \paragraph{Remark}
9896 The following example shows the major difference from the behavior of \pTeX.
9897 \begin{LTXexample}
9898 \fontspec[Ligatures=TeX]{Linux Libertine O}
9899 \ltjsetparameter{autoxspacing=false}
9900 \ltjsetparameter{jacharrange={-6}}xあ
9901 y\ltjsetparameter{jacharrange={+6}}zい
9902 u
9903 \end{LTXexample}
9904 It is not strange that ``あ'' does not printed in the above output.
9905 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because
9906 ``あ'' in line~3 is considered as an \textbf{ALchar}.
9907
9908 Note that there is no space before ``y'' in the output, but
9909 there is a space before ``u''. This follows from following reasons:
9910 \begin{itemize}
9911 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
9912 ``あ'' is considered as an \textbf{JAchar}.
9913 Since  line~3 ends with an \textbf{JAchar},
9914 the comment character (whose character code is \cs{ltjlineendcomment}) is appended to this line,
9915 and hence the linebreak immediately after this line is ignored.
9916 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
9917 ``い'' is considered as an \textbf{ALchar}.
9918 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
9919 emits a space.
9920 \end{itemize}
9921 %</en>
9922
9923 %<*ja>
9924 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
9925 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
9926 きそうなコールバックとしては,\verb+process_input_buffer+や
9927 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
9928 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
9929 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
9930 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
9931 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
9932
9933 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
9934 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
9935 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
9936
9937 \begin{quote}
9938 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
9939 以下の3条件が満たされている場合,\LuaTeX-jaは\cs{ltjlineendcomment}番の文字
9940 \footnote{\cs{ltjlineendcomment}の既定値は\texttt{"FFFFF}であるので,
9941   既定では\texttt{U+FFFFF}が使われることになる.この文字はコメント文字として扱われるように
9942   \LuaTeX-ja内部で設定をしている.}%
9943 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
9944 \begin{enumerate}
9945 \item \cs{endlinechar}の文字\footnote{普通は,改行文字(文字コード13番)である.}
9946 のカテゴリーコードが5~(\textit{end-of-line})である.
9947 \item \cs{ltjlineendcomment}のカテゴリーコードが14~(\textit{comment})である.
9948 \item 入力行は次の「正規表現」にマッチしている:
9949 \[
9950   (\text{any char})^*(\textbf{JAchar})
9951   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
9952 \]
9953 \end{enumerate}
9954 \end{quote}
9955
9956 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
9957 \texttt{lstlisting}系環境などの日本語対応マクロを書かなくてすませるためのものである.
9958
9959 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
9960 次のように,\textbf{JAchar}の範囲を変更したちょうどその行においては挙動が異なる:
9961 \begin{LTXexample}
9962 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
9963 \ltjsetparameter{autoxspacing=false}
9964 \ltjsetparameter{jacharrange={-6}}xあ
9965 y\ltjsetparameter{jacharrange={+6}}zい
9966 u
9967 \end{LTXexample}
9968 上ソース中の「あ」は\textbf{ALchar}(欧文扱い)であり.
9969 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
9970 よって,出力に「あ」は現れないことは不思議ではない.
9971 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
9972 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
9973 上のように異なる挙動となっているが,それは以下の理由による:
9974 \begin{itemize}
9975 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
9976       「あ」は\textbf{JAchar}(和文扱い)である.よって3行目は\textbf{JAchar}で終わることになり,
9977       \cs{ltjlineendcomment}番のコメント文字が追加される.
9978       よって,直後の改行文字は無視されることになり,空白は入らない.
9979 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
9980       「い」は\textbf{ALchar}である.よって4行目は\textbf{ALchar}で終わることになり,
9981       直後の改行文字は空白に置き換わる.
9982 \end{itemize}
9983 このため,トラブルを避けるために,\textbf{JAchar}の範囲を\cs{ltjsetparameter}で編集した場合,
9984 その行はそこで改行するようにした方がいいだろう.
9985 %</ja>
9986
9987 %<*ja>
9988 \subsection{濁点・半濁点付き仮名の正規化→\Pkg{luaotfload}~v3.19以降ではそちらで}
9989 \TeX~Live~2016以降の(u)\pTeX では,合成用濁点(\texttt{U+3099})・合成用半濁点(\texttt{U+309A})を用いて
9990 表現された平仮名・片仮名を合成済み文字に変換するという処理を行っている.
9991 この処理を行っている要因としては,
9992 \begin{itemize}
9993   \item 無用なトラブルを避けるため.
9994   濁点・半濁点付きの仮名文字が「合成用濁点・半濁点を使って入力されているか」「最初から合成済み文字で入力されているか」を
9995   見た目から判別することは難しい.
9996   \item \pTeX との互換性のため.\pTeX は内部コードがJIS~X~0208の範囲に限られるため,
9997   合成用濁点・半濁点は利用できない.そのため上記の変換処理はさらに前から行われていた.
9998 \end{itemize}
9999
10000 \LuaTeX(-ja)では入力の変換は基本的に行わず,
10001 文字の合成は使用しているフォントのOpenType機能に委ねるという立場であったが,
10002 \Pkg{luaotfload}~v3.19以降では,標準でNFCへのUnicode正規化を行っている.
10003 そのため,バージョン2023****.0以降では,\LuaTeX-jaによる自前の変換\footnote{バージョン20220103.0で実装した.}は
10004 行わないようにしている.
10005 %</ja>
10006
10007 %<*ja>
10008 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
10009 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
10010 \label{sec-jfmglue}
10011 %<en>\subsection{Overview}
10012 %<ja>\subsection{概要}
10013
10014 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
10015 \pTeX では次のような仕様であった:
10016 \begin{itemize}
10017 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)\meta{char\_node}を
10018 追加する過程で行われる.
10019 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
10020 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
10021 「和文文字を表す2つの\meta{char\_node}の間には\Param{kanjiskip}がある」ものとみなされる.
10022 \end{itemize}
10023 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
10024 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
10025 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
10026 カーニング処理がノードベースになったことに対応する変更である.
10027
10028 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
10029 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
10030 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
10031 であり,2つのクラスタの間には,ペナルティ,\cs{vadjust},whatsitなど,行組版
10032 には関係しないものがある.
10033
10034
10035 %<en>\subsection{Definition of a Cluster}
10036 %<ja>\subsection{「クラスタ」の定義}
10037
10038 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
10039 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
10040 \def\NA{$\text{\sf N}_{\text{\sf A}}$}
10041 \def\NB{$\text{\sf N}_{\text{\sf B}}$}
10042 \begin{defn}
10043 %<*en>
10044 A \emph{cluster} is consecutive nodes in one of the following forms,
10045 with the \textit{id} of it:
10046 %</en>
10047 %<*ja>
10048 \emph{クラスタ}は以下の形のうちのどれかひとつをとるノードのリストである:
10049 %</ja>
10050 \begin{enumerate}
10051 %<*en>
10052 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
10053       nodes come from a hbox which is already packaged, by unpackaging
10054       (\cs{unhbox}).
10055       The \textit{id} of the cluster is \textit{id\_pbox}.
10056 %</en>
10057 %<*ja>
10058 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
10059   これらのノードはある既にパッケージングされたhboxから \cs{unhbox} で
10060   アンパックされたものである.
10061   この場合,クラスタの\textit{id}は\textit{id\_pbox}である.
10062 %</ja>
10063
10064 %<*en>
10065 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
10066       The \textit{id} of the cluster is \textit{id\_math}.
10067 %</en>
10068 %<*ja>
10069 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
10070   この場合,クラスタの\textit{id}は\textit{id\_math}である.
10071 %</ja>
10072
10073 %<*en>
10074 \item A \textit{glyph\_node}~$p$, which represents a \textbf{JAchar}, with nodes which relate with it:
10075 %</en>
10076 %<*ja>
10077 \item \textbf{JAchar}を表す\textit{glyph\_node}~$p$とそれに関係するノード:
10078 %</ja>
10079 \begin{enumerate}
10080 %<*en>
10081 \item[(a)] A kern for the italic correction of~$p$.
10082 %</en>
10083 %<*ja>
10084 \item[(a)] $p$のイタリック補正のためのカーン.
10085 %</ja>
10086
10087 %<*en>
10088 \item[(b)] An accent attached to $p$ by \cs{accent}.
10089 %</en>
10090 %<*ja>
10091 \item[(b)] \cs{accent} による$p$に付随したアクセント.
10092 %</ja>
10093 \end{enumerate}
10094 \[
10095 \overbrace{%
10096  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
10097 \left\{\begin{array}{c}
10098 \Node{glyph}{accent}\\\noalign{\medskip}
10099 \Node{hbox}{accent (shifted vert.)}
10100 \end{array}\right\}\longrightarrow
10101 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(b)}}
10102 \longrightarrow
10103 \Node{glyph}{$p$}\longrightarrow
10104 \overbrace{%
10105 \Node{kern}{italic corr.}}^{\text{(a)}}
10106 \]
10107
10108 %<*en>
10109 In this case, the \textit{id} is \textit{id\_jglyph}.
10110 %</en>
10111 %<*ja>
10112 この場合の\textit{id}は\textit{id\_jglyph}である.
10113 %</ja>
10114
10115 %<*en>
10116 \item A list which begins from a \textit{glyph\_node} which represents a \textbf{ALchar},
10117       and consists of \textbf{ALchar} \textit{glyph\_node}s,
10118       kerns for adjusting accents~(its subtype is 2), kerns for italic corrections and
10119       kerns which are automatically inserted by \LuaTeX~or~luaotfload.
10120       In this case, the \textit{id} is \textit{id\_glyph}.
10121 %</en>
10122 %<*ja>
10123 \item \textbf{ALchar}を表す\textit{glyph\_node},\cs{accent} によるアクセント位置補正用の
10124       カーン(subtypeが2),そしてイタリック補正・カーニングによって挿入されたカーン達が連続
10125       したもの.この場合の\textit{id}は\textit{id\_glyph}である.
10126 %</ja>
10127
10128 %<*en>
10129 \item An box-like node, that is, an hbox, a vbox, a rule (\cs{vrule}) and an \textit{unset\_node}.
10130 The \textit{id} of the cluster is \textit{id\_hlist} if the node is an
10131       hbox which is not shifted vertically, or \textit{id\_box\_like}
10132       otherwise.
10133 %</en>
10134 %<*ja>
10135 \item 水平ボックス(hbox),垂直ボックス,罫線 (\cs{vrule}),
10136   そして\textit{unset\_node}.
10137   クラスタの\textit{id}は垂直に移動していないhboxならば\textit{id\_hlist},
10138   そうでなければ\textit{id\_box\_like}となる.
10139 %</ja>
10140
10141 %<*en>
10142 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
10143 The \textit{id} of the cluster is \textit{id\_glue}, \textit{id\_kern}
10144       and \textit{id\_disc}, respectively.
10145 %</en>
10146 %<*ja>
10147 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そしてdiscretionary break.
10148   その\textit{id} of the clusterはそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
10149   \textit{id\_disc}である.
10150 %</ja>
10151 \end{enumerate}
10152 %<*en>
10153 We use \textit{Np}, \textit{Nq} and \textit{Nr} to denote a cluster.
10154 %</en>
10155 %<*ja>
10156 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
10157 %</ja>
10158 \end{defn}
10159
10160 \paragraph{\textit{id}の意味}
10161 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
10162 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
10163 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
10164 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
10165 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
10166 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
10167
10168 \begin{description}
10169 \item[\textit{id\_jglyph}] \textbf{JAchar}(和文文字).\\
10170 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その\textbf{JAchar}を表している
10171 \textit{glyph\_node}そのものである.
10172 \item[\textit{id\_glyph}] \textbf{JAchar}(和文文字)以外のものを表す\textit{glyph\_node}~$p$.\\
10173 多くの場合,$p$は\textbf{ALchar}(欧文文字)を格納しているが,「ffi」などの合字によって作られた
10174 \textit{glyph\_node}である可能性もある.
10175 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
10176 一方,後者の場合,
10177 \begin{itemize}
10178 \item $\mathit{Np}.\mathit{head}$は,
10179 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
10180 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
10181 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
10182 \end{itemize}
10183 \item[\textit{id\_math}] インライン数式.\\
10184 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
10185 「文字コード$-1$の欧文文字」とおく.
10186 \item[\textit{id\_hlist}] 縦方向にシフトされていないhbox.\\
10187 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
10188 先頭・末尾のノードである.
10189 \medskip
10190 \begin{itemize}
10191 \item 状況によっては,\TeX ソースで言うと
10192 \begin{lstlisting}
10193 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
10194 \end{lstlisting}
10195 のように,$p$の内容が別のhboxで開始・終了している可能性も十分あり得る.そのような場合,
10196 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
10197 \emph{垂直方向にシフトされていない}hboxの
10198 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
10199 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされたhbox,
10200 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
10201 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
10202 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
10203 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
10204 と同様に再帰的に構成要素をたどっていく.
10205 \end{itemize}
10206 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
10207 まとめて1つのクラスタとして取り扱うだけである.
10208 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
10209 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
10210 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
10211 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
10212 全く考慮に入れない.
10213 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
10214 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
10215 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
10216 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
10217 \end{description}
10218
10219 \paragraph{クラスタの別の分類}
10220 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
10221 挿入処理では2つの隣り合ったクラスタの間に
10222 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
10223 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
10224 \begin{description}
10225 \item[和文A] リスト中に直接出現している\textbf{JAchar}.
10226 \textit{id}が\textit{id\_jglyph}であるか,\\
10227 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
10228
10229 \item[和文B] リスト中のhboxの中身の先頭として出現した\textbf{JAchar}.和文Aとの違いは,これの前に
10230 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
10231 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
10232
10233 \item[欧文] リスト中に直接/hboxの中身として出現している「\textbf{JAchar}以外の文字」.次の3つの場合が該当:
10234 \begin{itemize}
10235 \item \textit{id}が\textit{id\_glyph}である.
10236 \item \textit{id}が\textit{id\_math}である(つまりこのクラスタは1つの文中数式をなす).
10237 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
10238 \end{itemize}
10239 \item[箱] box,またはそれに類似するもの.次の2つが該当:
10240 \begin{itemize}
10241 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
10242 \item \textit{id}が\textit{id\_box\_like}である.
10243 \end{itemize}
10244
10245 \end{description}
10246
10247 \subsection{段落/hboxの先頭や末尾}
10248 \paragraph{先頭部の処理}
10249 まず,段落/hboxの一番最初にあるクラスタ\textit{Np}を探索する.
10250 hboxの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
10251 \begin{itemize}
10252 \item \cs{parindent} 由来のhbox($\mathit{subtype}=3$)
10253 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
10254 \end{itemize}
10255 これは,\cs{parindent}由来のhboxがクラスタを構成しないようにするためである.
10256
10257 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
10258 \begin{enumerate}
10259 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
10260 \item 問題のリストが字下げありの段落(\cs{parindent} 由来のhboxあり)の場合は,
10261 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
10262 \item そうでないとき(\verb+noindent+ で開始された段落やhbox)は,
10263 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
10264 \end{enumerate}
10265 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
10266 そこで,以下の場合には,$g$の直前に \cs{penalty10000} を挿入する:
10267 \begin{itemize}
10268 \item 問題にしているリストが段落であり,かつ
10269 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
10270 \end{itemize}
10271
10272 \paragraph{末尾の処理}
10273 末尾の処理は,問題のリストが段落のものかhboxのものかによって異なる.
10274 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\
10275 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
10276 \textit{Nq}の直後に挿入するのみである.
10277
10278 一方.前者(段落)の場合は,リストの末尾は常に \cs{penalty10000} と,
10279 \cs{parfillskip} 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
10280 %この \cs{parfillskip} 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
10281 段落の最後の「通常の\textbf{JAchar}${}+{}$句点」が独立した行となるのを防ぐために,
10282 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
10283
10284 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
10285 かつその文字の\Param{kcatcode}が偶数であるような
10286 最後のクラスタの直前にあるものたちである%
10287 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
10288 を約物として考えていることになる.
10289 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
10290
10291 \subsection{概観と典型例:2つの「和文A」の場合}
10292 \label{ssec:cluster-wa}
10293 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
10294 ペナルティ,\cs{vadjust},whatsitなど,行組版には関係しないものがある.模式的に表すと,
10295 \[
10296  \Node{cluster}{\textit{Nq}}\longrightarrow
10297 \overbrace{
10298 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
10299 \longrightarrow \Node{cluster}{\textit{Np}}
10300 \]
10301 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
10302 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
10303 \[
10304  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
10305 \overbrace{
10306 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow
10307 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow
10308 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
10309 \Node{cluster}{\textit{Np}}
10310 \]
10311
10312 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
10313 この場合が全ての場合の基本となる.
10314
10315 \paragraph{「右空白」の算出}
10316 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの\textbf{JAchar}間に入る空白量となる.
10317 \begin{description}
10318 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
10319       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
10320 \begin{enumerate}
10321 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
10322       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
10323 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
10324       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
10325 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
10326 この場合,まず
10327 \[
10328 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
10329 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
10330 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
10331 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
10332 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
10333 }}
10334 \]
10335 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
10336
10337 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する\meta{ratio}の値を$d_b$,~$d_a$とする.
10338 \begin{itemize}
10339 \item
10340 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
10341 \Param{kanjiskip}を採用することとなる.
10342 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,\meta{ratio}の値は0であるかのように扱われる.
10343 \item
10344 \Param{diffrentjfm}の値が \texttt{pleft}, \texttt{pright},
10345       \texttt{paverage} のとき,
10346 \meta{ratio}の指定に従って比例配分を行う.
10347 JFM由来のグルー/カーンは以下の値となる:
10348 \[
10349  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
10350 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
10351 \]
10352 ここで.$f(x,y)$は
10353 \[
10354  f(x,y)=\begin{dcases*}
10355 x&($\Param{diffrentjfm}=\texttt{pleft}$),\\
10356 y&($\Param{diffrentjfm}=\texttt{pright}$),\\
10357 \frac{x+y}2&($\Param{diffrentjfm}=\texttt{paverage}$).
10358 \end{dcases*}
10359 \]
10360 \item
10361 \Param{differentjfm}がそれ以外の値の時は,\meta{ratio}の値は無視され,JFM由来のグルー/カーンは以下の値となる:
10362 \[
10363  f(\textit{gb},\textit{ga})
10364 \]
10365 ここで.$f(x,y)$は
10366 \[
10367  f(x,y)=\begin{dcases*}
10368 \min(x,y)&($\Param{diffrentjfm}=\texttt{small}$),\\
10369 \max(x,y)&($\Param{diffrentjfm}=\texttt{large}$),\\
10370 \frac{x+y}2&($\Param{diffrentjfm}=\texttt{average}$),\\
10371 x+y&($\Param{diffrentjfm}=\texttt{both}$).
10372 \end{dcases*}
10373 \]
10374 \end{itemize}
10375 \end{enumerate}
10376
10377 例えば,
10378 \begin{lstlisting}
10379 \jfont\foo=psft:Ryumin-Light:jfm=ujis;-kern
10380 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis;-kern
10381 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo;-kern
10382 \end{lstlisting}
10383 という3フォントを考え,
10384 \[
10385  \overbrace{\Node{glyph}{\cs{ foo}, `あ'}}^{p}
10386 \longrightarrow \overbrace{\Node{glyph}{\cs{bar}, `い'}}^{q}
10387 \longrightarrow \overbrace{\Node{glyph}{\cs{baz}, `う'}}^{r}
10388 \]
10389 という3ノードを考える(それぞれ単独でクラスタをなす).
10390 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
10391 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
10392
10393   なお,JFMで\texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
10394 \texttt{kanjiskip\_shrink}キーが指定されていた場合は,……
10395   
10396 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
10397 以下で定めた量「右空白」として採用する.
10398 この段階においては,\cs{inhibitglue} は効力を持たないため,
10399 結果として,2つの\textbf{JAchar}間には常に何らかのグルー/カーンが挿入されることとなる.
10400 \begin{enumerate}
10401 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
10402 \Param{autospacing}パラメータが両方ともfalseだった場合は,長さ0のglueとする.
10403 \item ユーザ側から見た\Param{kanjiskip}パラメータの自然長が$\cs{maxdimen}=(2^{30}-1)\,\mbox{sp}$で
10404 なければ,\Param{kanjiskip}パラメータの値を持つglueを採用する.
10405 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
10406 どちらか片方のクラスタだけが\textbf{JAchar}(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
10407 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
10408 \end{enumerate}
10409 \end{description}
10410 %\paragraph{「左空白」の算出とそれに伴う補正}
10411 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
10412 %挿入は一切行われない(機能自体削除している).
10413 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
10414 \paragraph{禁則用ペナルティの挿入}
10415 まず,
10416 \[
10417  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
10418 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
10419 \]
10420 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
10421 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
10422 算出では単純な整数の加減算を行う.
10423
10424 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
10425 \begin{description}
10426 \item[P-normal~{[PN]}]
10427 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
10428 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
10429 また,$10000 + (-10000) = 0$としている.
10430
10431 少々困るのは,(a)部分にペナルティが存在していない場合である.
10432 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
10433 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
10434 ということになるが,実際には僅かにこれより複雑である.
10435 \begin{itemize}
10436 \item 「右空白」がカーンであるとき,
10437 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
10438 この場合は$a\neq 0$であってもペナルティの挿入はしない.
10439 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
10440 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
10441 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
10442 %\textit{penalty\_node}を作って挿入する.
10443 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
10444 \end{itemize}
10445 \end{description}
10446
10447 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
10448   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
10449 \begin{table}[t]
10450 %<en>\caption{Summary of JFM glues}
10451 %<ja>\caption{JFM グルーの概要}
10452 \label{tab-jfmglue}
10453 %<en>\medskip
10454 \begin{center}
10455 \small
10456 \begin{tabular}{c|cccccc}
10457 \toprule
10458 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
10459 \sf 和文A&
10460 \gkf{E}{M→K}{PN}&
10461 \gkf{---}{\OA →K}{PN}&
10462 \gkf{---}{\NA →X}{PN}&
10463 \gkf{---}{\OA}{PA}&
10464 \gkf{---}{\OA}{PN}&
10465 \gkf{---}{\OA}{PS}\\
10466 \sf 和文B&
10467 \gkf{E}{\OB→K}{PA}&
10468 \gkf{---}{K}{PS}&
10469 \gkf{---}{X}{PS}\\
10470 \sf 欧文&
10471 \gkf{E}{\NB →X}{PA}&
10472 \gkf{---}{X}{PS}\cr
10473 \sf 箱&\gkf{E}{\OB}{PA}\\
10474 \sf glue&\gkf{E}{\OB}{PN}\\
10475 \sf kern&\gkf{E}{\OB}{PS}\\
10476 \bottomrule
10477 \end{tabular}
10478 \end{center}
10479 \begin{quote}
10480 %<*en>
10481 In the table above, {\small\gkf{E}{M→K}{PN}} means that
10482 %</en>
10483 %<*ja>
10484 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
10485 %</ja>
10486 \begin{enumerate}
10487 %<*en>
10488 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
10489 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
10490 %</en>
10491 %<*ja>
10492 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
10493   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
10494 %</ja>
10495
10496 % %<*en>
10497 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is
10498 %   determined by the method ``\textsf{line-end~[E]}''.
10499 % %</en>
10500 % %<*ja>
10501 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
10502 %   方法で決定される.
10503 % %</ja>
10504
10505 %<*en>
10506 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty
10507   between two clusters for \emph{kinsoku shori}.
10508 %</en>
10509 %<*ja>
10510 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを設定するために「\textsf{P-normal~[PN]}」の方法を採用する.
10511 %</ja>
10512 \end{enumerate}
10513 \end{quote}
10514 \end{table}
10515
10516 \subsection{その他の場合}
10517 本節の内容は\autoref{tab-jfmglue}にまとめてある.
10518
10519 \paragraph{和文Aと欧文の間}
10520 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
10521 \begin{itemize}
10522 \item 「右空白」については,まず以下に述べる\textsf{欧文境界B~[\NB]}により空白を決定しようと試みる.
10523 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
10524 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
10525 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
10526 \end{itemize}
10527 \begin{description}
10528 \item[欧文境界B~{[\NB]}] 以下で求めた量を「右空白」として採用する.
10529 この処理は\textsf{JFM-origin~[M]}の変種と考えて良く,
10530 典型例は「和文の閉じ括弧と欧文文字の間に入る半角アキ」である.
10531 \begin{enumerate}
10532 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合%
10533 (証としてwhatsitノードが自動挿入される),未定義.
10534 \item そうでなければ,
10535 \textit{Nq}と「文字コードが$x$の文字」との間に入るグルー/カーンとする.
10536 この$x$は次の場合分けによる:
10537   \begin{itemize}
10538     \item $\mathit{Np}.\mathit{id}$が\textit{id\_math}のとき(つまりクラスタ\textit{Np}が文中数式を表す)
10539     ときは,$x=-1$.
10540     \item \textit{Np}の中身の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
10541 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが偶数)ときは,
10542     $x=\text{\texttt{'nox\_alchar'}}$.
10543     \item 以上のいずれでもないときは,$x=\text{\texttt{'alchar'}}$.
10544   \end{itemize}
10545 \end{enumerate}
10546 \item[\Param{xkanjiskip}~{[X]}]
10547 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
10548 以下で定めた量を「右空白」として採用する.
10549 \cs{inhibitglue} は効力を持たない.
10550 \begin{enumerate}
10551 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
10552 \begin{itemize}
10553 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメータが共にfalseである.
10554 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
10555 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが2以上).
10556 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
10557 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが偶数).
10558 \end{itemize}
10559 \item ユーザ側から見た\Param{xkanjiskip}パラメータの自然長が$\cs{maxdimen}=(2^{30}-1)\,\textrm{sp}$で
10560 なければ,\Param{xkanjiskip}パラメータの値を持つglueを採用する.
10561 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
10562 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
10563 \end{enumerate}
10564 \end{description}
10565
10566 \paragraph{欧文と和文Aの間}
10567 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
10568 \textsf{和文A}のクラスタが逆になるので,\textsf{欧文境界B~[\NB]}の部分が変わるだけである.
10569 \begin{itemize}
10570 \item 「右空白」については,まず以下に述べる\textsf{欧文境界A~[\OA]}により空白を決定しようと試みる.
10571 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
10572 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
10573 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
10574 \end{itemize}
10575 \begin{description}
10576 \item[欧文境界A~{[\NA]}] これは\textsf{欧文境界B~[\NB]}で\textit{Np}と\textit{Nq}の役割が
10577   交換されたものと思えば良い.
10578   この処理で定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
10579 \begin{enumerate}
10580 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
10581   未定義.
10582 \item そうでなければ,
10583 「文字コードが$x$の文字」と\textit{Np}との間に入るグルー/カーンと定める.
10584 $x$は\textit{Nq}から\textsf{欧文境界B~[\NB]}におけるそれと同じ方法で定めるが,
10585 \texttt{'nox\_alchar'}か\texttt{'alchar'}は
10586 \begin{quote}
10587   \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
10588 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが2以上).
10589 \end{quote}
10590   か否かで判断する.
10591 \end{enumerate}
10592 \end{description}
10593
10594 \paragraph{和文Aと箱・グルー・カーンの間}
10595 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
10596 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
10597 ペナルティの挿入処理は若干異なったものとなっている.
10598 \begin{itemize}
10599 \item 「右空白」については,以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
10600 それが失敗した場合は,「右空白」は挿入されない.
10601 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
10602 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
10603 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
10604 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
10605 \[
10606  a:=(\text{\textit{Nq}の文字に対する\Param{postbreakpenalty}の値}).
10607 \]
10608 \begin{description}
10609 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
10610 (明示的に両クラスタの間に \cs{penalty10000} があった場合を除き)いつも許容される.そのため,
10611 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
10612 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
10613 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
10614 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
10615 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
10616 \end{description}
10617 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
10618 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
10619 \end{itemize}
10620
10621 \begin{description}
10622 \item[Boundary-B~{[\OB]}] この処理は\textsf{欧文境界B~[\NB]}と同様であり,
10623   $x$が次によって決まることのみが異なる:
10624   \begin{itemize}
10625     \item \textit{Np}がグルーやカーンのときは,$x=\text{\texttt{'glue'}}$.
10626     \item そうでない(\textit{Np}が\textsf{箱})ときは,$x=\text{\texttt{'jcharbdd'}}$.
10627   \end{itemize}
10628 \item[P-allow~{[PA]}]
10629 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
10630 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
10631
10632 (a)部分にペナルティが存在していない場合,
10633 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
10634 そのために,以下のいずれかの場合に$a$をもつ\textit{penalty\_node}を作って
10635 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
10636 \begin{itemize}
10637 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
10638 \item $a\neq 0$のときは,「右空白」がグルーであっても\textit{penalty\_node}を作る.
10639 \end{itemize}
10640
10641 \item[P-suppress~{[PS]}]
10642 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
10643 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
10644
10645 (a)部分にペナルティが存在していない場合,
10646 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
10647 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
10648 そのため,「右空白」がglueであれば,その直前に \cs{penalty10000} を挿入する.
10649 \end{description}
10650
10651 \paragraph{箱・グルー・カーンと和文Aの間}
10652 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
10653 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
10654 %が,「左空白」がなくなることにのみ注意.
10655 \begin{itemize}
10656 \item 「右空白」については,以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
10657 それが失敗した場合は,「右空白」は挿入されない.
10658 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
10659 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
10660 $\mathit{Nq}.\mathit{tail}$は無意味なので,
10661 \[
10662  a:=(\text{\textit{Np}の文字に対する\Param{prebreakpenalty}の値}).
10663 \]
10664 \begin{description}
10665 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
10666 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
10667 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
10668 \end{description}
10669 \end{itemize}
10670
10671 \begin{description}
10672 \item[Boundary-A~{[\OA]}] この処理は\textsf{欧文境界A~[\NA]}と同様であり,
10673   $x$が次によって決まることのみが異なる:
10674   \begin{itemize}
10675     \item \textit{Nq}がグルーやカーンのときは,$x=\text{\texttt{'glue'}}$.
10676     \item そうでない(\textit{Nq}が\textsf{箱})ときは,$x=\text{\texttt{'jcharbdd'}}$.
10677   \end{itemize}
10678 \end{description}
10679
10680 \paragraph{和文Aと和文Bの違い}
10681 先に述べたように,\textsf{和文B}はhboxの中身の先頭(or 末尾)として出現している
10682 \textbf{JAchar}である.リスト内に直接ノードとして現れている\textbf{JAchar}(\textsf{和文A})との違いは,
10683 \begin{itemize}
10684 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
10685 (\textsf{JFM由来[M]},\textsf{Boundary-A~[\OA]}など)の挿入は行われない.
10686 %「左空白」の算出も行われない.
10687 例えば,
10688 \begin{itemize}
10689 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
10690 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
10691 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
10692 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
10693 \end{itemize}
10694 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
10695 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
10696 \textsf{P-suppress~[PS]}が用いられる.
10697 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
10698 \end{itemize}
10699
10700
10701 次が具体例である:
10702 \begin{LTXexample}
10703 あ.\inhibitglue A\\
10704 \hbox{あ.}A\\
10705 あ.A
10706 \end{LTXexample}
10707 \begin{itemize}
10708 \item 1行目の\cs{inhibitglue}は\textsf{欧文境界B~[\NB]}の処理のみを抑止するので,ピリオドと「A」の間には
10709 \Param{xkanjiskip}(四分アキ)が入ることに注意.
10710 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(hboxの中身の末尾として登場しているから)ので,
10711 そもそも\textsf{欧文境界B~[\NB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
10712 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
10713 ピリオドと「A」の間には\textsf{欧文境界B~[\NB]}由来の半角アキが入ることになる.
10714 \end{itemize}
10715 %</ja>
10716
10717 %<*ja>
10718 \section{ベースライン補正の方法}
10719 \subsection{\texttt{yoffset} フィールド}
10720 \Param{yalbaselineshift}等のベースライン補正は,基本的には対象となっている
10721 \textit{glyph\_node}の \texttt{yoffset} フィールドの値を増減することによって
10722 実装されている.なお,\texttt{yoffset} の値は上方向への移動量であるのに対し,
10723 \Param{yalbaselineshift}などは下方向への移動量である.
10724
10725 さて,\texttt{yoffset} の増減によって見かけのグリフ位置は上下に移動するが,
10726 仮想ボディの高さ$h$,深さ$d$については
10727 \begin{description}
10728  \item[$\texttt{yoffset}\geq 0$のとき]
10729 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$,
10730 $d = \max(\texttt{depth} - \texttt{yoffset}, 0)$,
10731  \item[$\texttt{yoffset}<0$のとき]
10732 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, $d=\texttt{depth}$.
10733 \end{description}
10734 という仕様になっている.つまり,\texttt{yoffset} が負(グリフを下ける)の場合に深さは増加しな
10735 い(\autoref{tab:yoffset_and_im}参照).
10736
10737 \begin{table}[t]
10738 \caption{\texttt{yoffset} and imaginary body}
10739 \label{tab:yoffset_and_im}
10740 \centering\small
10741 \fboxsep0pt
10742 \def\T#1#2{\fcolorbox{blue}{white}{%
10743   \setbox0=\hbox{\LARGE #1%
10744     \directlua{
10745       local p = tex.nest[tex.nest.ptr].tail
10746       p.yoffset = #2 * 65536
10747     }%
10748   }%
10749   \copy0\kern-\wd0\smash{\color{red}\vrule width \wd0 height 0.2pt depth 0.2pt}%
10750 }}
10751 \begin{tabular}{>{\bfseries}lccccc}
10752 \toprule
10753 \texttt{yoffset}&10\,pt&5\,pt&0&$-5$\,pt&$-10$\,pt\\
10754 \midrule
10755 仮想ボディ&\T{y}{10}, \T{H}{10}&\T{y}{5}, \T{H}{5}&\T{y}{0}, \T{H}{0}%
10756 &\T{y}{-5}, \T{H}{-5}&\T{y}{-10}, \T{H}{-10}\\[10pt]
10757 \bottomrule
10758 \end{tabular}
10759 \end{table}
10760
10761 \subsection{\textbf{ALchar}の補正}
10762 上記の問題について,\textbf{ALchar}のベースライン補正では
10763 「正しい深さ」を持った罫線(rule)を補うという対応策をとった.
10764 この罫線による補正は,\textit{id}が\textit{id\_glyph}であるクラスタ単位,
10765 大雑把に言えば音節単位で行われる.
10766 文字列``Typeset''を
10767 \begin{itemize}
10768  \item フォントはLatin Modern Roman (\texttt{lmroman10-regular.otf}) 10\,pt
10769  \item \Param{yalbaselineshift}は5\,pt
10770 \end{itemize}
10771 という状況で組んだ場合を例にとって説明しよう.
10772
10773 \LuaTeX・\Pkg{luaotfload}によるカーニング・ハイフネーションが終わった段階では,……
10774
10775
10776
10777 %</ja>
10778
10779 %<en>\section{Patch for the \Pkg{listings} Package}
10780 %<ja>\section{\Pkg{listings} パッケージへの対応}
10781
10782 %<*en>
10783 It is well-known that the \Pkg{listings} package outputs weird results
10784 for Japanese input.
10785 The \Pkg{listings} package makes most of letters active and assigns
10786 output command for each letter~(\cite{listings}).
10787 But Japanese characters are not included in these activated letters.
10788 For \pTeX{} series, there is no method to make Japanese characters active;
10789 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
10790 %</en>
10791 %<*ja>
10792 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
10793 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
10794 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
10795 力命令を割り当てている(\cite{listings}).
10796 しかし,そこでアクティブにする文字の中に,和文文
10797 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
10798 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
10799 %</ja>
10800
10801 %<*en>
10802 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
10803 The callback function inserts the output command (active character \cs{ltjlineendcomment})
10804 before each letter above \texttt{U+0080}.
10805 This method can omits the process to make all Japanese characters active
10806 (most of the activated characters are not used in many cases).
10807 %</en>
10808 %<*ja>
10809 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
10810 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
10811 という方法をとっている.出力命令としては,アクティブ文字化した\cs{ltjlineendcomment}を用いている.
10812 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
10813 見通しが良い実装になっている.
10814 %</ja>
10815
10816
10817 %<*en>
10818 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
10819 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
10820 %</en>
10821 %<*ja>
10822 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
10823 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
10824 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
10825 意識する必要はない.
10826 %</ja>
10827
10828 %<en>\subsection{Notes and additional keys}
10829 %<ja>\subsection{注意}
10830 % %<*en>
10831 % \paragraph{Escaping to \LaTeX}
10832 % We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
10833 % But it has a drawback; any commands whose name contains a \textbf{JAchar}
10834 % cannot be used in any ``escape to \LaTeX''.
10835
10836 % Consider the following input:
10837 % %</en>
10838 % %<*ja>
10839 % \paragraph{\LaTeX へのエスケープ}
10840 % 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
10841 % \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
10842 % \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
10843 % 例えば次のような入力を考えよう:
10844 % %</ja>
10845 % \begin{lstlisting}[showspaces][escapechar=\!]
10846 % !\cs{begin}!{lstlisting}[escapechar=\#]
10847 % #\ほげ xぴよ#
10848 % !\cs{end}!{lstlisting}
10849 % \end{lstlisting}
10850 % %<en>The line~2 is transformed by the callback to
10851 % %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
10852 % \begin{lstlisting}[showspaces, escapechar=\!]
10853 % #\!\IVSA FFFFF!ほ!\IVSA FFFFF!げ x!\IVSA FFFFF!ぴ!\IVSA FFFFF!よ#
10854 % \end{lstlisting}
10855 % %<*en>
10856 % before the line is actually processed.
10857 % In the escape (between the character ``\verb+#+''),
10858 % the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
10859 % Hence the control symbol ``\cs{}\IVSA FFFFF'' will be executed,
10860 % instead of ``\verb+\ほげ+''.
10861 % %</en>
10862 % %<*ja>
10863 % と変換されてから,実際の処理に回される.
10864 % 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
10865 % \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
10866 % 結局「\verb+\ほげ+」の代わりに
10867 % 「\cs{}\IVSA FFFFF」というcontrol symbolが実行されることになる.
10868 % %</ja>
10869
10870 %<*en>
10871 \paragraph{Variation selectors}
10872 \Pkg{lltjp-listings} add two keys, namely \texttt{vsraw}~and~\texttt{vscmd},
10873 which specify how variation selectors are treated in
10874 \texttt{lstlisting} or other enviroments.
10875 Note that these additional keys are not usable in the preamble,
10876 since \Pkg{lltjp-listings} is loaded at \verb+\begin{document}+.
10877
10878 \texttt{vsraw} is a key which takes a boolean value, and its default value is
10879 false.
10880 \begin{itemize}
10881  \item If the \texttt{vsraw} key is true, then
10882 variation selectors are ``combined'' with the previous character.
10883 %</en>
10884 %<*ja>
10885 \paragraph{異体字セレクタの扱い}
10886 \texttt{lstlisting} 環境などの内部にある異体字セレクタを扱うため,
10887 \Pkg{lltjp-listings} では \texttt{vsraw} と \texttt{vscmd} という2つのキーを追加した.
10888 しかし,\Pkg{lltjp-listings} が実際に読み込まれるのは \verb+\begin{document}+\
10889 のところであるので,プリアンブル内ではこれらの追加キーは使用できない.
10890
10891 \texttt{vsraw}は,ブール値の値をとるキーであり,標準ではfalseである.
10892 \begin{itemize}
10893  \item trueの場合は,異体字セレクタは「直前の文字に続けて」出力されるため,
10894 例えば以下の例(左側は入力,右側はその出力)のようになる.
10895 %</ja>
10896 %%%% [preset=...]: workaround for lstlisting inside LTXexample
10897 \begin{LTXexample}[preset=\expandafter\def\csname @captype\endcsname{lstlisting}]
10898 \begin{lstlisting}[vsraw=true]
10899 葛󠄀城市,葛󠄁飾区,葛西
10900 \end{lstlisting}
10901 \end{LTXexample}
10902 %<*en>
10903 \item If the \texttt{vsraw} key is false, then
10904 variation selectors are typeset by an appropriate command, which is specified by
10905       the \texttt{vscmd} key.
10906 The default setting of the \texttt{vscmd} key produces the following.
10907 %</en>
10908 %<*ja>
10909 \item falseの場合は,異体字セレクタは適当な命令によって「見える形で」出力される.
10910 どのような形で出力されるかを規定するのが \texttt{vscmd} キーであり,
10911 \Pkg{lltjp-listings} の標準設定では以下の例の右側のように出力される.
10912 %</ja>
10913 \begin{LTXexample}[preset=\expandafter\def\csname @captype\endcsname{lstlisting}]
10914 \begin{lstlisting}[vsraw=false,
10915    vscmd=\ltjlistingsvsstdcmd]
10916 葛󠄀城市,葛󠄁飾区,葛西
10917 \end{lstlisting}
10918 \end{LTXexample}
10919 %<ja> ちなみに,本ドキュメントでは次のようにしている:
10920 %<en> For example, the following code is the setting of the \texttt{vscmd} key in this document.
10921 \begin{lstlisting}[numbers=left]
10922 \def\IVSA#1#2#3#4#5{%
10923   \hbox to1em{\hss\textcolor{blue}{\raisebox{3.5pt}{\normalfont\ttfamily%
10924     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{0#1#2\crcr#3#4#5\crcr}\hss}}}}\hss}%
10925 }
10926 {\catcode`\%=11
10927   \gdef\IVSB#1{\expandafter\IVSA\directlua{
10928     local cat_str = luatexbase.catcodetables['string']
10929     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
10930 }}}
10931 \lstset{vscmd=\IVSB}
10932 \end{lstlisting}
10933 \end{itemize}
10934 %<*en>
10935 The default output command of variation selectors is stored in \verb+\ltjlistingsvsstdcmd+.
10936 %</en>
10937 %<*ja>
10938 既定の出力命令を復活させたい場合は\ \verb+vscmd=\ltjlistingsvsstdcmd+\
10939 とすれば良い.
10940 %</ja>
10941
10942 %<*en>
10943 \paragraph{The \texttt{doubleletterspace} key}
10944 Even the column format is \texttt{[c]fixed}, sometimes characters are not vertically aligned.
10945 The following example  is typeset with \texttt{basewidth=2em}, and
10946 you'll see the leftmost ``\texttt{H}'' are not vertically aligned.
10947 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
10948 :H:
10949 :HHHH:
10950 \end{lstlisting}
10951
10952 \Pkg{lltjp-listing} adds the \texttt{doubleletterspace} key (not activated by default, for
10953 compatibility) to
10954 improve the situation, namely doubles inter-character space in each output unit.
10955 With this key, the above input now produces better output.
10956 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
10957 :H:
10958 :HHHH:
10959 \end{lstlisting}
10960 %</en>
10961 %<*ja>
10962 \paragraph{\texttt{doubleletterspace}キー}
10963 \Pkg{listings}パッケージで列揃えが \texttt{[c]fixed} となっている場合でも,
10964 場合によっては文字が縦に揃わない場合もある.
10965 例を以下に示そう.これは強調するために \texttt{basewidth=2em} を設定している.
10966 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
10967 :H:
10968 :HHHH:
10969 \end{lstlisting}
10970 1行目と2行目の「\texttt{H}」の位置が揃っていないが,
10971 これは出力単位ごとに,先頭・末尾・各文字間に同じ量の空白を挿入することによる.
10972
10973 \Pkg{lltjp-listing}では,このような症状を改善させるために \texttt{doubleletterspace} キー
10974 を追加した(標準では互換性のために無効になっている).このキーを有効にすると,
10975 出力単位中の各文字間の空白を2倍にすることで文字を揃いやすくしている.
10976 上と同じものを \texttt{doubleletterspace} キーを有効にして組んだものが以下であり,
10977 きちんと「\texttt{H}」の位置が揃っていることが分かる.
10978 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
10979 :H:
10980 :HHHH:
10981 \end{lstlisting}
10982 %</ja>
10983
10984 %<en>\subsection{Class of characters}
10985 %<ja>\subsection{文字種}
10986
10987 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
10988 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
10989 \begin{enumerate}
10990 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
10991 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
10992 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
10993 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
10994 %<en>\item Collects \textit{others}.
10995 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
10996 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
10997 %<ja>\item letterが出現したら集めた文字列を出力する.
10998 %<en>\item Turns back to 1.
10999 %<ja>\item 1.に戻る.
11000 \end{enumerate}
11001 %<*en>
11002 By the above process, line breaks inside of an identifier are blocked.
11003 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
11004 for the name of identifiers or not.
11005 %</en>
11006 %<*ja>
11007 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
11008 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
11009 %</ja>
11010
11011 %<*en>
11012 For Japanese characters, line breaks are permitted on both sides
11013 except for brackets, dashes, etc.
11014 Hence the patch \Pkg{lltjp-listings} introduces
11015 a new flag \verb+\lst@ifkanji+, which indicates
11016 whether the previous character is a Japanese character or not.
11017 For illustration, we introduce following classes of characters:
11018 %</en>
11019 %<*ja>
11020 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
11021 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
11022 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
11023 以降,説明のために以下のように文字を分類する:
11024 %</ja>
11025 %<*ja>
11026 \begin{center}
11027 \small
11028 \begin{tabular}{llllll}
11029 \toprule
11030 &\emph{Letter}&\emph{Other}&\emph{Kanji}&\emph{Open}&\emph{Close}\\\midrule
11031 \verb+\lst@ifletter+&T&F&T&F&T\\
11032 \verb+\lst@ifkanji+&F&F&T&T&F\\
11033 \emph{意図}&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
11034 \bottomrule
11035 \end{tabular}
11036 \end{center}
11037 %</ja>
11038 %<*en>
11039 \begin{center}
11040 \small
11041 \begin{tabular}{llll}
11042 \toprule
11043 &\textbf{Letter}&\textbf{Other}&\\\midrule
11044 \verb+\lst@ifletter+&T&F&\\
11045 \verb+\lst@ifkanji+&F&F&\\
11046 \textbf{Meaning}&char in an identifier&other alphabet&\\
11047   \midrule
11048 &\textbf{Kanji}&\textbf{Open}&\textbf{Close}\\\midrule
11049 \verb+\lst@ifletter+&T&F&T\\
11050 \verb+\lst@ifkanji+&T&T&F\\
11051 \textbf{Meaning}&most of Japanese char&opening brackets&closing brackets\\
11052 \bottomrule
11053 \end{tabular}
11054 \end{center}
11055 %</en>
11056 %<*en>
11057 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
11058 Other according to circumstances.
11059 %</en>
11060 %<*ja>
11061 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
11062 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
11063 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
11064 これは間違いではない.
11065 %</ja>
11066
11067 %<*en>
11068 For example, let us consider the case an Open comes after a Letter.
11069 Since an Open represents Japanese open brackets,
11070 it is preferred to be permitted to insert line break after the Letter.
11071 Therefore, the collected character string is output in this case.
11072 %</en>
11073 %<*ja>
11074 例えば,Letterの直後にOpenが来た場合を考える.
11075 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
11076 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
11077 %</ja>
11078
11079 %<*en>
11080 The following table summarizes $5\times 5=25$ cases:
11081 %</en>
11082 %<*ja>
11083 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
11084 %</ja>
11085 \begin{center}
11086 \small
11087 \begin{tabular}{lllllll}
11088 \toprule
11089 %<*en>
11090 &&\multicolumn{4}{c}{\textbf{Next}}\\\cmidrule(lr){3-7}
11091 &&\hbox to 4em{Letter\hss}&\hbox to 4em{Other\hss}
11092 &\hbox to 4em{Kanji\hss}&\hbox to 4em{Open\hss}&Close\\\midrule
11093 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11094 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11095 \textbf{Prev}&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11096 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
11097 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11098 %</en>
11099 %<*ja>
11100 &&\multicolumn{4}{c}{\textbf{後側文字種}}\\\cmidrule(lr){3-7}
11101 &&\hbox to 4em{Letter\hss}&\hbox to 4em{Other\hss}
11102 &\hbox to 4em{Kanji\hss}&\hbox to 4em{Open\hss}&Close\\\midrule
11103 \emph{直}&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11104 \emph{前}&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11105 \emph{文}&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11106 \emph{字}&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
11107 \emph{種}&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11108 %</ja>
11109 \bottomrule
11110 \end{tabular}
11111 \end{center}
11112 %<en>In the above table,
11113 %<ja>上の表において,
11114 \begin{itemize}
11115 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
11116 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
11117
11118 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
11119 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
11120 \end{itemize}
11121
11122 %<*en>
11123 Characters above or equal to~\texttt{U+0080} \emph{except Variation Selectors}
11124 are classified into above 5~classes by the following rules:
11125 %</en>
11126 %<*ja>
11127 \texttt{U+0080}以降の\emph{異体字セレクタ以外の}各文字が
11128 Letter, Other, Kanji, Open, Closeのどれに属するかは次によって決まる:
11129 %</ja>
11130 \begin{itemize}
11131 %<en>\item \textbf{ALchar}s above or equal to~\texttt{U+0080} are classified as Letter.
11132 %<ja>\item \<(\texttt{U+0080}以降の)\textbf{ALchar}は,すべてLetter扱いである.
11133
11134 %<en>\item \textbf{JAchar}s are classified in the order as follows:
11135 %<ja>\item \textbf{JAchar}については,以下の順序に従って文字種を決める:
11136 \begin{enumerate}
11137 %<en>\item Characters whose \Param{prebreakpenalty} is greater than or equal to 0 are classified as Open.
11138 %<ja>\item \Param{prebreakpenalty}が0以上の文字はOpen扱いである.
11139
11140 %<en>\item Characters whose \Param{postbreakpenalty} is greater than or equal to 0 are classified as Close.
11141 %<ja>\item \Param{postbreakpenalty}が0以上の文字はClose扱いである.
11142
11143 %<en>\item Characters that don't satisfy the above two conditions are classified as Kanji.
11144 %<ja>\item 上の3条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
11145 \end{enumerate}
11146 \end{itemize}
11147
11148 %<*en>
11149 The width of halfwidth kana (\texttt{U+FF61}--\texttt{U+FF9F})
11150 is same as the width of \textbf{ALchar};
11151 the width of the other \textbf{JAchar}s is double the width of \textbf{ALchar}.
11152 %</en>
11153 %<*ja>
11154 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
11155 半角カナは欧文文字1文字分の幅となる.
11156 %</ja>
11157
11158 %<*en>
11159 This classification process is executed every time a character appears in
11160 the \texttt{lstlisting} environment or other environments/commands.
11161 %</en>
11162 %<*ja>
11163 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
11164 %</ja>
11165
11166 %<*ja>
11167 \section{和文の行長補正方法}
11168 \label{sec-adjspec}
11169 \Pkg{luatexja-adjust}で提供される優先順位付きの行長調整の詳細を大まかに述べると,次のようになる.
11170 \begin{itemize}
11171 \item (\texttt{lineend=extended}の場合)\textbf{JAglue}の挿入処理のところで,
11172   ……
11173 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
11174       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{xkanjiskip},
11175       \Param{kanjiskip},JFMグルー)と
11176       それ以外のグルーの全てで(優先順位なく)負担される.
11177 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
11178       落中の各行ごとに},行末文字の位置を調整(\texttt{lineend=true}の場合)したり,優先度付きの行長調整
11179       を実現するためにグルーの伸縮度を調整する.
11180       その処理においては,グルーの自然長と\textbf{JAglue}以外の
11181       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
11182       変更する設計とした.
11183 \end{itemize}
11184 この章の残りでは各処理について解説する.
11185
11186 \paragraph{準備:合計伸縮量の計算}
11187 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
11188 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
11189 いう4つの無限大レベル(後ろの方ほど大きい)がある.行の調整に
11190 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている行では,
11191 「行末文字の位置調整」のみ行い,「グルーの調整」は行わない.}
11192
11193 まず,段落中の行中のグルーを
11194 \begin{itemize}
11195 \item \textbf{JAglue}ではないグルー
11196 \item JFMグルー(優先度\footnote{%
11197   \ref{ssec:jfm-str}節にあるように,
11198   各JFMグルーには$-4$から3までの優先度がついている.場合によっては
11199   伸びと縮みで異なる優先度が付いているかもしれない.}%
11200 別にまとめられる)
11201 \item 和欧文間空白(\Param{xkanjiskip})
11202 \item 和文間空白(\Param{kanjiskip})
11203 \end{itemize}
11204 の$1+1+8+1=10$つに類別する.
11205 そして許容されている伸び量(\texttt{stretch}の値)の合計を
11206 無限のレベルごとに
11207 \begin{align*}
11208  T^{+}_{l}&:= \sum_{\text{$\texttt{stretch\_order}(p) = l$}} \texttt{stretch}(p),&
11209  l\in \{\text{(finite)}, \texttt{fi}, \texttt{fil}, \texttt{fill}, \texttt{filll}\}
11210 \end{align*}
11211 と計算する.さらに,
11212 \begin{align*}
11213 T^{+}&:=T^{+}_{L^+},&L^{+} = \max \{l\in
11214  \{\text{(finite)}, \texttt{fi}, \texttt{fil}, \texttt{fill}, \texttt{filll}\}:
11215  T^{+}_l\neq 0\}
11216 \end{align*}
11217 とおく.有限の伸び量については,上記の8種類の類別ごとにも合計を計算する.
11218 さらに縮み量(\texttt{shrink}の値)についても同様の処理を行い,$T^{-}$を計算する.
11219
11220 また,行長から自然長を引いた値を\textit{total}とおく.
11221
11222 \subsection{行末文字の位置調整(行分割後の場合)}
11223 行末が\textbf{JAchar}であり,この文字の属する文字クラスでは
11224 \begin{quote}
11225   \texttt{end\_adjust = \{$a_{1}$, $a_{2}$, ..., $a_{n}$\}}
11226 \end{quote}
11227 であったとする.
11228 このとき,以下の条件を満たした場合,
11229 この文字クラスに対する\texttt{end\_adjust}の値のいずれかだけこの文字の位置を移動させる.
11230 \begin{description}
11231   \item[最終行以外] 行長調整に無限大の伸縮度が用いられていない.
11232   すなわち,$\textit{total}>0$ならば$L^{+}=(\text{finite})$であり,
11233   $\textit{total}>0$ならば$L^{-}=(\text{finite})$である.
11234   \item[最終行] 行長調整に無限大に伸び縮みするグルーが用いられたなら,それは\cs{parfillskip}のみであり,
11235     かつ,次の不等式が成立する:
11236   \[
11237    \min\{0,a_{1}\}\text{\cs{zw}}\leq (\text{\cs{parfillskip}の実際の長さ}) \leq \max\{0,a_{n}\}\text{\cs{zw}}
11238   \]
11239 \end{description}
11240
11241 各$1\leq i\leq n$に対して,
11242 「行末に$a_{i}$全角だけのカーンを追加した時の,\textit{glue\_set}の値」を
11243 $b_{i}$とおく.式で書くと,
11244 \[
11245 b_{i} = \begin{dcases*}
11246   \frac{\lvert\textit{total}-a_{i}\text{\cs{zw}}\rvert}{T^{+}}
11247           &($\textit{total}-a_{i}\text{\cs{zw}}\geq 0$),\\
11248   \frac{\lvert\textit{total}-a_{i}\text{\cs{zw}}\rvert}{T^{-}}
11249           &($\textit{total}-a_{i}\text{\cs{zw}}<0$).
11250 \end{dcases*}
11251 \]
11252 $b_{i}$達の最小値を与えるような$i$を$j$としたとき\footnote{%
11253   そのような$i$が2つ以上あるときは,$|\textit{total}-a_{i}\cdot \text{\cs{zw}}|$,
11254   $|a_{i}|$, $a_i$の順で比較して一番小さくなるものが選ばれる.
11255 },
11256 行末に大きさ$a_{j}$のカーンを追加する.
11257 \textit{total}から$a_{j}$全角の大きさだけ引いておく.
11258
11259 \subsection{行末文字の位置調整(行分割での考慮)}
11260 \texttt{lineend=extended}が指定されている場合,\TeX による行分割が行われる前に
11261 各\textbf{JAchar}の直後に,その文字が行末に来たときの位置補正用のノードを挿入していく.
11262
11263 \ref{sec-jfmglue}章の用語を使って述べる.
11264 前側のクラスタ\textit{Nq}が「和文A」「和文B」であり,
11265 JFMによって\texttt{end\_adjust}の値が
11266 \begin{quote}
11267   \texttt{end\_adjust = \{$a_{1}$, $a_{2}$, ..., $a_{n}$\}}
11268 \end{quote}
11269 であったとする.このとき,次のクラスタ\textit{Np}の直前に以下のノード列を挿入する.
11270 \textbf{JAglue}の挿入過程で禁則処理のために「\textit{Nq}と\textit{Np}の間のペナルティ値を増やす」ことが
11271 行われることがあるが,以下で述べられている$(n+1)$個のペナルティはみなその処理対象になっている.
11272 \begin{align*}
11273   \Node{kern}{$a_{1}\text{\cs{zw}}$}
11274   &\longrightarrow \Node{penalty}{$0$} \longrightarrow\Node{kern}{$(a_{2}-a_{1})\text{\cs{zw}}$}
11275   \longrightarrow \Node{penalty}{$0$} \longrightarrow\Node{kern}{$(a_{3}-a_{2})\text{\cs{zw}}$}\\
11276   &\longrightarrow
11277   \cdots \longrightarrow\Node{penalty}{$0$} \longrightarrow
11278   \Node{kern}{$(a_{n}-a_{n-1})\text{\cs{zw}}$}
11279   \longrightarrow \Node{penalty}{$0$} \longrightarrow
11280   \Node{kern}{$-a_{n}\text{\cs{zw}}$} \longrightarrow \Node{penalty}{$10000$}
11281 \end{align*}
11282 $n$個あるペナルティの箇所が改行可能箇所である.いずれかで改行された場合は,
11283 その前にあるカーン($n$箇所のうちどこで改行しても,合計の長さは$a_{i}$の形)は行末に残るが,
11284 後ろのペナルティ・カーンは除去される.なお,$a_1=0$のときは最初の幅が$a_{1}\text{\cs{zw}}$のカーンは不要なので挿入されず,
11285 さらにかつ$n=1$であった場合は後ろのペナルティも挿入されない.
11286
11287 なお,段落の末尾には\cs{penalty10000}と\cs{parfillskip}由来のグルーが自動的に入るが,
11288 これらとの兼ね合いのため\emph{最後のクラスタについては上記のノード挿入処理は行われない}.
11289 段落最終行の行末文字の位置調整は,すでに述べた「行分割後の場合」における最終行の処理をそのまま用いている.
11290
11291 \subsection{グルーの調整}
11292 $|\textit{total}|$の分だけが,行中のグルーの伸び量,あるいは縮み量に応じて負担されることになる.
11293 以下,$\textit{total}\geq 0$であると仮定して話を進めるが,負のときも同様である.
11294 \Pkg{luatexja-adjust}の初期値では以下の順に伸び量を負担するようになっており,
11295 (優先度$-4$のJFMグルーは例外として)できるだけ\Param{kanjiskip}を自然長のままにすることを
11296 試みている.この順番は\Param{stretch\_priority}(縮み量については\Param{shrink\_priority})
11297 パラメータで変更可能である.
11298 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
11299  \item \textbf{JAglue}以外のグルー
11300  \item 優先度3のJFMグルー
11301  \item 優先度2のJFMグルー
11302  \item 優先度1のJFMグルー
11303  \item 優先度0のJFMグルー
11304  \item 優先度$-1$のJFMグルー
11305  \item 優先度$-2$のJFMグルー
11306  \item \Param{xkanjiskip}
11307  \item 優先度$-3$のJFMグルー
11308  \item \Param{kanjiskip}
11309  \item 優先度$-4$のJFMグルー
11310 \end{enumerate}
11311 \begin{enumerate}
11312  \item 行末の\textbf{JAchar}を移動したことで$\textit{total}=0$となれば,
11313 調整の必要はなく,行が格納されているhboxの
11314 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
11315 以降,$\textit{total}\neq 0$と仮定する.
11316  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
11317        合計,と称す)よりも小さければ,
11318 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
11319 よって,以下の処理を行う:
11320 \begin{enumerate}
11321 \item 各\textbf{JAglue}の伸び量を0とする.
11322 \item 行が格納されているhboxの
11323 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
11324 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
11325 \end{enumerate}
11326 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(K)のどこまで負担すれば
11327 \textit{total}以上になるかを計算する.
11328 例えば,
11329 \[
11330  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
11331  \qquad 0\le p<1
11332 \]
11333 であった場合,各グルーは次のように組まれる:
11334 \begin{itemize}
11335  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
11336  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
11337  \item (D)--(K)に属するグルーは自然長のまま.
11338 \end{itemize}
11339 実際には,前に述べた「設計」に従い,次のように処理している:
11340 \begin{enumerate}
11341 \item (C)に属するグルーの伸び量を$p$倍する.
11342 \item (D)--(K)に属するグルーの伸び量を0とする.
11343 \item 行が格納されているhboxの
11344 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
11345 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
11346 \end{enumerate}
11347 \item \textit{total}が(A)--(K)の伸び量の合計よりも大きい場合,どうしようもないので
11348       \verb+^^;+何もしない.
11349 \end{enumerate}
11350
11351 %</ja>
11352
11353 %<*ja>
11354 \section{複数フォントの「合成」(未完)}
11355 \section{\LuaTeX-jaにおけるキャッシュ}
11356 \Pkg{luaotfload}パッケージが,各TrueType・OpenTypeフォントの情報を
11357 キャッシュとして保存しているのと同様の方法で,
11358 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
11359 \begin{itemize}
11360  \item 通常,キャッシュは \texttt{\$TEXMFVAR/luatexja/} 以下に保存され,
11361 そこから読み込みが行われる.
11362  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua.gz},gzip圧縮されているため)以外にも,
11363 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
11364 \begin{itemize}
11365  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
11366 テキスト形式のものよりそちらを優先して読み込む.
11367  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
11368 同時に更新される.
11369 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
11370 \LuaTeX-jaはバイナリキャッシュを作成する.
11371 未圧縮のテキスト形式のキャッシュ(\texttt{hoge.lua})は20200802.0以降では利用しない.
11372 \end{itemize}
11373 \end{itemize}
11374 %</ja>
11375 %<*en>
11376 \section{Cache Management of \LuaTeX-ja}
11377 \LuaTeX-ja creates some cache files to reduce the loading time.
11378 in a similar way to the \Pkg{luaotfload} package:
11379 \begin{itemize}
11380  \item Cache files are usually stored in (and loaded from)
11381 \texttt{\$TEXMFVAR/luatexja/}.
11382  \item In addition to caches of the text form (the extension is ``\texttt{.lua.gz}'',
11383 because they are compressed by gzip),
11384 caches of the \emph{binary}~(bytecode) form are supported.
11385 \begin{itemize}
11386  \item In loading a cache, the binary cache precedes
11387 the text form.
11388  \item When \LuaTeX-ja updates a compressed text cache \texttt{hoge.lua.gz},
11389 its binary version is also updated.
11390 \end{itemize}
11391 \end{itemize}
11392 %</en>
11393
11394 %<*ja>
11395 \subsection{キャッシュの使用箇所}
11396
11397 \LuaTeX-ja では以下のキャッシュを使用している:
11398 \begin{cslist}
11399 \item[ltj-cid-auto-adobe-japan1.\{lua.gz,luc\}]
11400 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
11401 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
11402 生成には\texttt{UniJIS2004-UTF32-\{H,V\}}, \texttt{Adobe-Japan1-UCS2}という3つの
11403 CMapが必要である.
11404
11405 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
11406 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
11407 キャッシュの名称,必要となるCMapについては\autoref{tab:cid-cache}を参照して欲しい.
11408 %</ja>
11409 %<*en>
11410 \subsection{Use of cache}
11411
11412 \LuaTeX-ja uses the following cache:
11413 \begin{cslist}
11414 \item[ltj-cid-auto-adobe-japan1.\{lua.gz,luc\}]
11415 The font table of a CID-keyed non-embedded Japanese font.
11416 This is loaded in every run.
11417 It is created from three CMaps, \texttt{UniJIS2004-UTF32-\{H,V\}} and
11418              \texttt{Adobe-Japan1-UCS2},
11419 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
11420
11421 Similar caches are created as \autoref{tab:cid-cache},
11422 if you specified \texttt{cid} key in \cs{jfont}
11423 to use other CID-keyed non-embedded fonts for Chinese or Korean,
11424 as in Page~\pageref{para-cid}.
11425 %</en>
11426
11427 \begin{table}[!tb]
11428  \centering\small
11429 \caption{\texttt{cid} key and corresponding files}
11430 \label{tab:cid-cache}
11431 \vspace*{\medskipamount}
11432 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
11433 \toprule
11434 \bf \texttt{cid} key&\bf name of the cache &
11435 \multicolumn{2}{c}{\bf used CMaps}\\
11436 \midrule
11437 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.\{lua.gz,luc\}&UniJIS2004-UTF32-*&Adobe-Japan1-UCS2\\
11438 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.\{lua.gz,luc\}&UniKS-UTF32-*&Adobe-Korea1-UCS2\\
11439 Adobe-KR-*&ltj-cid-auto-adobe-kr.\{lua.gz,luc\}&UniAKR-UTF32-*&Adobe-KR-UCS2\\
11440 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.\{lua.gz,luc\}&UniGB-UTF32-*&Adobe-GB1-UCS2\\
11441 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.\{lua.gz,luc\}&UniCNS-UTF32-*&Adobe-CNS1-UCS2\\
11442 \bottomrule
11443 \end{tabular}
11444 \end{table}
11445
11446 %<*ja>
11447 \item[ltj-kinsoku\_default.\{lua.gz,luc\}]
11448 禁則処理,\Param{kansujichar}などの標準設定が格納されたファイルである.
11449 %</ja>
11450 %<*en>
11451 \item[ltj-kinsoku.luc]
11452 The bytecode cache which default \textit{kinsoku} parameters are stored.
11453 %</en>
11454
11455 %<*ja>
11456 \item[ltj-jisx0208.luc]
11457 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイトコード化したものである.
11458 これはJIS~X~0208とUnicodeとの変換テーブルであり,
11459 \pTeX との互換目的の文字コード変換命令で用いられる.
11460 %</ja>
11461 %<*en>
11462 \item[ltj-jisx0208.luc]
11463 The bytecode version of \texttt{ltj-jisx0208.lua}.
11464 This is the conversion table between JIS~X~0208 and Unicode
11465 which is used in Kanji-code conversion commands for compatibility with \pTeX.
11466 %</en>
11467
11468 %<*ja>
11469 \item[ltj-ivd\_aj1.luc]
11470 \LuaTeX-ja配布中の\texttt{ltj-ivd\_aj1.lua}をバイトコード化したものである.
11471 これはUnicodeの漢字異体字データベースのAdobe-Japan1コレクションの内容を
11472   格納したテーブルであり,\Pkg{luatexja-otf}パッケージの\cs{CID}命令で使われることがある.
11473 %</ja>
11474 %<*en>
11475 \item[ltj-ivd\_aj1.luc]
11476 The bytecode version of \texttt{ltj-ivd\_aj1.lua}.
11477 %</en>
11478
11479 %<*ja>
11480 \item[extra\_***.\{lua.gz,luc\}]
11481 フォント``\texttt{***}''における,グリフ番号からUnicode値への変換テーブル,縦組時のグリフ回転の有無を格納したテーブル,
11482 及び縦組時におけるグリフの原点位置・高さのテーブルを格納している.
11483 %</ja>
11484 %<*en>
11485 \item[extra\_***.\{lua.gz,luc\}]
11486 This file conains some information (especially for vertical typesetting) about the font `\texttt{***}''.
11487 %</en>
11488 \end{cslist}
11489
11490 %<*en>
11491 \subsection{Internal}
11492 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
11493 (\texttt{ltj-base.lua}).
11494 There are four public functions for cache management in \texttt{luatexja.base},
11495 where \meta{filename} stands for the file name \emph{without suffix}:
11496 \begin{cslist}
11497 \item[save\_cache(\meta{filename}, \meta{data})]
11498 Save a non-nil table \meta{data} into a cache \meta{filename}.
11499 Both the compressed text form \meta{filename}\texttt{.lua.gz} and its binary version
11500 are created or updated.
11501
11502 \item[save\_cache\_luc(\meta{filename}, \meta{data}{[, \meta{serialized\_data}]})]
11503
11504 Same as \texttt{save\_cache}, except that only the binary cache is updated.
11505 The third argument \meta{serialized\_data} is not usually given.
11506 But if this is given, it is treated as a string representation of \meta{data}.
11507
11508 \item[load\_cache(\meta{filename}, \meta{outdate})]
11509 Load the cache \meta{filename}.
11510 \meta{outdate} is a function which takes one argument (the contents of the cache),
11511 and its return value is whether the cache is outdated.
11512
11513 \texttt{load\_cache} first tries to
11514 read the binary cache \meta{filename}\texttt{.luc}.
11515 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
11516 If the binary cache is not found or
11517 its contents is outdated, \texttt{load\_cache} tries to
11518 read the compressed text form \meta{filename}\texttt{.lua.gz}.
11519 Hence, the return value of \texttt{load\_cache} is non-nil,
11520 if and only if the updated cache is found.
11521
11522 \item[remove\_cache(\meta{filename})]
11523 Remove the cahce \meta{filename}.
11524 \end{cslist}
11525 %</en>
11526 %<*ja>
11527 \subsection{内部命令}
11528 \LuaTeX-jaにおけるキャッシュ管理は,\texttt{luatexja.base}~(\texttt{ltj-base.lua})に
11529 実装しており,以下の関数が公開されている.
11530 ここで,\meta{filename}は保存するキャッシュのファイル名を\emph{拡張子なしで}指定する.
11531 \begin{cslist}
11532 \item[save\_cache(\meta{filename}, \meta{data})]
11533 nilでない\meta{data}をキャッシュ\meta{filename}に保存する.
11534 テキスト形式の\meta{filename}\texttt{.lua.gz}\footnote{拡張子からわかる通り,実際にはgzip圧縮される.}のみならず,
11535 そのバイナリ形式も作成・更新される.
11536
11537 \item[save\_cache\_luc(\meta{filename}, \meta{data}{[, \meta{serialized\_data}]})]
11538
11539 \texttt{save\_cache}と同様だが,バイナリキャッシュのみが更新される.
11540 第3引数\meta{serialized\_data}が与えられた場合,それを
11541 \meta{data}の文字列化表現として使用する.
11542 そのため,\meta{serialized\_data}は普通は指定しないことになるだろう.
11543
11544 \item[load\_cache(\meta{filename}, \meta{outdate})]
11545 キャッシュ\meta{filename}を読み込む.
11546 \meta{outdate}は1引数(キャッシュの中身)をとる関数であり,
11547 その戻り値は「キャッシュの更新が必要」かどうかを示すブール値でないといけない.
11548
11549 \texttt{load\_cache}は,まずバイナリキャッシュ\meta{filename}\texttt{.luc}を
11550 読みこむ.もしその内容が「新しい」,つまり\meta{outdate}の評価結果が \texttt{false} なら
11551 \texttt{load\_cache}はこのバイナリキャッシュの中身を返す.
11552 もしバイナリキャッシュが見つからなかったか,「古すぎる」ならば(gzip圧縮された)テキスト形式の
11553              \meta{filename}\texttt{.lua.gz}を読み込み,\meta{outdate}で再度評価する.
11554
11555 以上より,\texttt{load\_cache}自体がnilでない値を返すのは,ちょうど「新しい」キャッシュが
11556 見つかった場合である.
11557
11558 \item[remove\_cache(\meta{filename})]
11559 キャッシュ\meta{filename}を削除する.テキスト形式(gzip圧縮されているか否かを問わず)も
11560 バイナリ形式もまとめて削除する.
11561 \end{cslist}
11562 %</ja>
11563
11564
11565 %<*ja>
11566 \section{縦組の実装}
11567 \label{sec-dir-imp}
11568 \ref{sec-direction}章の最初でも述べたように,
11569 \LuaTeX-jaは横組(\texttt{TLT})で組んだボックスを回転させる方式で
11570 縦組を実装している.
11571
11572 \LuaTeX-jaにおける縦組の実装は
11573 \pTeX における実装(\cite{ptexdoc,ptextug})をベースにしている.
11574
11575 \subsection{direction~whatsit}
11576 \textit{direction}~whatsitとは,\textit{direction}という特定の \verb+user_id+ を持つ
11577 whatsitのことであり,以下のタイミングで作られる.
11578 \begin{itemize}
11579  \item 組方向を \cs{tate} 等で変更したとき.
11580  \item \cs{hbox}, \cs{vbox}, \cs{vtop} による明示的なボックスの開始時.\\
11581 \verb+\hbox{}+, \verb+\vbox{}+ といった,
11582 \begin{itemize}
11583  \item \cs{tate} 等によりボックス内部の組方向を変更していない
11584  \item ボックスの中身のリストが空である
11585 \end{itemize}
11586 場合は,\LuaTeX の \verb+hpack_filter+, \verb+vpack_filter+ といった
11587 callbackに処理が回らない.そこで,\LuaTeX-ja では,\cs{everyhbox}, \cs{everyvbox} を利用す
11588        ることで各ボックスの先頭に確実に追加するようにしている\footnote{%
11589   問題は \cs{hbox to 25pt\{\}} という状況である.実際のこのボックスの中身は空でない(少な
11590        くともdirection whatsitがある)ため,何も対策をしなければhpack時にUnderfill警告が発
11591        生してしまうことになる.\LuaTeX-jaではそうならないように「\cs{hbadness},
11592        \cs{vbadness} を一時的に10000に変更し,hpack, vpack後に元の値に戻す」処理を行ってい
11593        る.
11594 }.
11595  \item \cs{vsplit}によってvboxを分割した時の「残り」の先頭.
11596  \item \LuaTeX-ja読み込み前に作成したボックスの寸法を \cs{ltjsetwd} 等によって変更した時.
11597  \item \cs{insert} によるinsertionでは,中身の先頭に\textit{direction}~whatsitは作られず,
11598 その代わりに中身の各ボックス・罫線の直前に作られる\footnote{%
11599  これは,ページ分割の過程でinsertionが分割される時,「現在のページで出力される部分」が空と
11600        なることがあることによる.先頭にwhatsitを置くと,最悪でも「現在のページにwhatsitが
11601        残る」ことになってしまう.}.
11602 \end{itemize}
11603 なお,\verb+\vtop{...}+ の場合は,先頭にdirection whatsitを置くと
11604 ボックスの高さが常に0\,ptになるという問題が発生する.そのため,この場合に限っては
11605 vpack時にdirection whatsitをリストの2番目に移動させている.
11606
11607 direction whatsitはあくまでも組方向処理のための補助的なノードであるので,
11608 \cs{unhbox}, \cs{unhcopy} によってボックスの中身が展開される時には展開直前に削除される.
11609 これは
11610 \begin{lstlisting}
11611  % yoko direction
11612 \setbox0=\hbox{\tate B}
11613 \noindent % 水平モードに入る.この時点でのリストの中身は空
11614 \unhbox0 A
11615 \end{lstlisting}
11616 といった場合に,段落が縦組で組まれたり,あるいは
11617 \begin{lstlisting}
11618 \setbox0=\hbox{}
11619 \leavevmode \hbox{A}\unhbox0
11620 \setbox1=\lastbox % \box1 はどうなる?
11621 \end{lstlisting}
11622 で \cs{box1} が \cs{hbox\{A\}} でなく空になってしまうことを防ぐためである.
11623
11624
11625 \subsection{\textit{dir\_box}}
11626 縦中横など異方向のボックスを配置する場合に,周囲の組方向と大きさを整合させるため,
11627 \LuaTeX-jaでは \verb+\ltj@dir+ が128以降の\textit{hlist\_node}, \textit{vlist\_node}を
11628 用いる.これらは\pTeX における\textit{dir\_node}の役割と同じ果たしており,
11629 この文章中では\textit{dir\_box}と呼称する.
11630
11631 \subsubsection{異方向のボックスの整合}
11632 \textit{dir\_box}の第一の使用目的は,異方向のボックスの大きさを整合させることである.
11633 例えば,
11634 \begin{lstlisting}
11635  % yoko direction
11636 平成\hbox{\tate 26}年
11637 \end{lstlisting}
11638 は段落中で
11639 \[
11640  \xymatrix{
11641    {}\Node{glyph}{`平'}\ar[r]&{}\Node{glyph}{`成'}\ar[r]&
11642    {}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[r]\ar[d]^{\text{中身}}&{}\Node{glyph}{`年'}\\
11643    &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
11644  }
11645 \]
11646 というリストを作る.その後,この段落が終了したときに,
11647 \LuaTeX-jaの\textbf{JAglue}挿入処理が行われ
11648 \[
11649  \xymatrix{
11650    {}\Node{glyph}{`平'}\ar[r]
11651   &{}\textcolor{blue}{\Node{glue}{\Param{xkanjiskip}}}\ar[r]
11652   &{}\Node{glyph}{`成'}\ar[r]
11653   &{}\textcolor{blue}{\Node{penalty}{0}}
11654     \ar`r[d] `[l] `[ddll] `[dl] [dl]
11655   \\
11656   &&{}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{yoko})}{3.02779}{10.00003}{0.0}}\ar[r]\ar[d]^{\text{中身}}
11657   &{}\textcolor{blue}{\Node{penalty}{0}}\ar[r]
11658   &{}\Node{glyph}{`年'}\\
11659   &&{}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[d]^{\text{中身}}\\
11660   &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
11661  }
11662 \]
11663 のようになる(青字は\textbf{JAglue},赤字が整合処理のための\textit{dir\_box}である).
11664 \TeX の \cs{showbox} 形式で書けば
11665
11666 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
11667 \catcode`\@=0 @catcode`@\=12
11668 .\tenmin 平
11669 @textcolor{blue}{.\glue 0.0 plus 0.4 minus 0.4}
11670 .\tenmin 成
11671 @textcolor{blue}{.\penalty 0}
11672 @textcolor{red}{.\hbox(10.00003+0.0)x3.02779, direction TLT}
11673 ..\hbox(3.02779+0.0)x10.00003, direction TLT
11674 ...\whatsit4=[]
11675 ...\tenrm 2
11676 ...\tenrm 6
11677 @textcolor{blue}{.\penalty 0}
11678 .\tenmin 年
11679 }\medskip
11680
11681 \noindent である.
11682
11683 なお,\cs{raise},~\cs{lower}, \cs{moveleft},~\cs{moveright} といったボックス移動命令では.
11684 移動を正しく表現するために段落やボックスの途中でも異方向のボックスは\textit{dir\_box}にカ
11685 プセル化している.
11686 例えば
11687 \begin{lstlisting}
11688  % yoko direction
11689 平成\raise1pt\hbox{\tate 26}年\showlists
11690 \end{lstlisting}
11691 は以下のような結果を得る.
11692
11693 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
11694 \catcode`\@=0 @catcode`@\=12
11695 (前略)
11696 \tenrm 平
11697 \tenrm 成
11698 @textcolor{red}{\hbox(10.00003+0.0)x3.02779, shifted -1.0, direction TLT}
11699 .\hbox(3.02779+0.0)x10.00003, direction TLT
11700 ..\whatsit4=[]
11701 ..\tenrm 2
11702 ..\tenrm 6
11703 \tenrm 年
11704 }\medskip
11705
11706 また,メインの垂直リストに異方向のボックスが追加される場合にも同様に即座に
11707 \textit{dir\_box}にカプセル化している.ページ分割のタイミングを正
11708 しく\TeX が判断するためである.
11709 \cs{lastbox} によるボックスの取得では,\textit{dir\_box}は削除される.
11710
11711 \subsubsection{異方向のボックス寸法の格納}
11712 第二の使用目的は,現在の組方向がボックス本来の組方向とは異なる状況で,
11713 \cs{ltjsetwd} によってボックス寸法を設定されたことを記録することである.
11714
11715 例えば
11716 \begin{lstlisting}[numbers=left]
11717 \setbox0=\hbox{\vrule width 10pt height 5pt depth 2pt}
11718 \setbox1=\hbox{\tate\ltjsetwd0=20pt}
11719 \wd0=9pt
11720 \setbox1=\hbox{\dtou\ltjsetwd0=20pt}
11721 \setbox0=\hbox{\dtou a\box0}
11722 \end{lstlisting}
11723 というコードを考える.1行目で \cs{box0} には横組の
11724 幅10\,pt,高さ5\,pt,深さ2\,ptのボックスが代入される.
11725 よって,
11726 \begin{itemize}
11727  \item 縦組下では \cs{box0} は幅7\,pt,高さ・深さ5\,ptのボックスとして扱われる.
11728  \item \cs{dtou} 下では \cs{box0} は幅7\,pt,高さ10\,pt,深さ0\,ptのボックスとして扱われる.
11729 \end{itemize}
11730 このとき,\cs{box0} の\emph{中身}は
11731 \[
11732  \xymatrix{
11733    {}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
11734  }
11735 \]
11736 である.
11737
11738 さて,2行目で縦組時の \cs{box0} の幅が20\,ptに設定される.この情報が
11739 direction~whatsit内部のノードリストに,\textit{dir\_box}として格納される:
11740 \[
11741  \xymatrix{
11742    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
11743    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}}
11744  }
11745 \]
11746
11747 次に,3行目では横組時の,つまり \cs{box0} 本来の組方向での深さが9\,ptに変更される.
11748 このとき,\cs{box0} は
11749 \begin{itemize}
11750  \item 縦組下では寸法代入が既に行われているので,2行目で作成された\textit{dir\_box}の通り
11751        に幅20\,pt,高さ・深さ5\,ptのボックスとして扱われる.
11752  \item \cs{dtou} 下ではまだ寸法代入が行われていないので,
11753 \cs{box0} の寸法変更に追従し,幅7\,pt,高さ9\,pt,深さ0\,ptのボックスとして扱われる.
11754 \end{itemize}
11755
11756 4行目では \cs{dtou} 下での\cs{box0} の幅が20\,ptに設定されるので,2行目と同じように
11757 \[
11758  \xymatrix{
11759    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
11760    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[r]&
11761    {}\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}
11762  }
11763 \]
11764 と\textit{dir\_box}が作成される.
11765
11766 このように寸法代入によってつくられた\textit{dir\_box}は,前節の整合過程のときに再利用され
11767 る.上記の例でいえば,5行目を実行した後の \cs{box0} の内容は
11768 \[
11769  \xymatrix{
11770    {}\Node{whatsit}{\cs{dtou}}\ar[r]&
11771    {}\Node{glyph}{`a'}\ar[r]&
11772    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[d]_{\text{中身}}\\
11773    &&{}\HNode{hbox}{9.0}{5.0}{2.0}\ar[d]_{\text{中身}}\\
11774    &&{}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
11775  }
11776 \]
11777 のようになる.
11778
11779 \subsection{縦組用字形の取得}
11780 縦組時には,「\hbox to \zw{、}」(\texttt{U+3001})から「\ltjjachar"FE11」(\texttt{U+FE11})%"
11781 のように縦組用字形への置き換えに関係する処理は,以下のようになっている.
11782
11783
11784 \begin{table}[t]
11785   \def\D#1#2#3#4{%
11786         {\fboxsep0pt\fcolorbox{cyan}{white}%
11787     {\large\KOZM\ltjjachar"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})%"
11788   }
11789   \def\DH#1#2#3#4{%
11790         {\fboxsep0pt\fcolorbox{cyan}{white}%
11791     {\large\ltjjachar"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})%"
11792   }
11793   \caption{\LuaTeX-ja標準で行われる縦組形への置換}
11794   \label{tab:vert_replace}\small\centering
11795   \begin{tabular}{*{3}{l@{}>{${}\longmapsto{}$}c@{}l}}
11796         \toprule
11797         \D 3001&&\D FE11&\D 3002&&\D FE12&\D 3016&&\DH FE17\\
11798         \D 3017&&\DH FE18&\D 2026&&\D FE19&\D 2025&&\D FE30\\
11799         \D 2014&&\D FE31&\D 2013&&\D FE32&\D FF3F&&\D FE33\\
11800         \D FF08&&\D FE35&\D FF09&&\D FE36&\D FF5B&&\D FE37\\
11801         \D FF5D&&\D FE38&\D 3014&&\D FE39&\D 3015&&\D FE3A\\
11802         \D 3010&&\D FE3B&\D 3011&&\D FE3C&\D 300A&&\D FE3D\\
11803         \D 300B&&\D FE3E&\D 3008&&\D FE3F&\D 3009&&\D FE40\\
11804         \D 300C&&\D FE41&\D 300D&&\D FE42&\D 300E&&\D FE43\\
11805         \D 300F&&\D FE44&\D FF3B&&\D FE47&\D FF3D&&\D FE48\\
11806         \bottomrule
11807   \end{tabular}
11808 \end{table}
11809 \begin{itemize}
11810         \item 各縦組用和文フォントは読み込み時に以下の属性が設定される:
11811         \begin{description}
11812           \item[\textit{vert\_activated}] 真となるのは,
11813           明示的に \texttt{-vert} も \texttt{-vrt2} のいずれも指定されていないちょうどその時.
11814           \item[\textit{auto\_enable\_vrt2}] 真となるのは,
11815           \texttt{vert}, \texttt{vrt2}のいずれについても有効・無効が指定されていないちょうどその時.
11816         \end{description}
11817         \textit{vert\_activated}については\texttt{luatexja.define\_jfont}コールバックで渡される引数
11818         \texttt{jfont\_info}から取得可能である.
11819
11820         \item \textit{auto\_enable\_vrt2}が真の場合は,現在のscript tagとlanguage system identifierの値で
11821         \texttt{vrt2}機能が利用可能か調べる.利用可能ならば\texttt{vrt2}を,そうでなければ
11822         \texttt{vert}を有効化する.
11823         \item また,各和文フォント読み込み時には,
11824         「OpenType機能による置換以前に行う縦組形への置換」を格納したテーブル\textit{vform}も作成する.
11825         \begin{enumerate}
11826           \item \autoref{tab:vert_replace}に示した各置換$i\longmapsto v$に対し,
11827           置換先$v$がフォント内に存在する文字コードであるならば,$i\longmapsto v$を\textit{vform}に登録する.
11828           \item \ref{ssec:tfont}節にある\texttt{jpotf}が指定された場合,
11829           \LuaTeX-ja内部の別のテーブル\textit{vert\_jpotf\_table}に登録されている各置換$i\longmapsto v$に対して
11830           置換先$v$がフォント内に存在する文字コードであるならば,$i\longmapsto v$を\textit{vform}に登録する.
11831           \item もし\texttt{vert}も\texttt{vrt2}も現在のscript, languageでは有効にできない場合,
11832           どこかのscript, languageにおける\texttt{vert}で定義されている
11833           置換$i\longmapsto v$をすべて\textit{vform}に登録する.
11834         \end{enumerate}
11835
11836         あとで説明するように,\textit{vform}は\textit{vert\_activated}が真であるような縦組用和文フォントでしか
11837         利用されない.
11838         
11839         \item 「現在の水平リスト」内の\textbf{JAchar}を(欧文フォントから)和文フォントへ置き換える処理において,
11840     その時点での組方向が縦組であり,かつ処理対象の各ノードの縦組用フォントで
11841         \textit{vert\_activated}が真である場合,\textit{vform}に従いグリフが置き換えられる.
11842
11843         \Pkg{luaotfload}が行う,OpenType機能に沿ったグリフ置換はこの後の処理となる.
11844   \end{itemize}
11845 %</ja>
11846
11847 \newpage
11848 \begin{thebibliography}{99}
11849   \addcontentsline{toc}{section}{\refname}
11850 \bibitem{texbytopic}
11851 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
11852 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
11853 \bibitem{uptex} Takuji Tanaka. \newblock
11854 upTeX---Unicode version of pTeX with CJK extensions,
11855 TUG 2013, October 2013.\newblock
11856 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
11857 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert.\newblock
11858 \url{http://mytexpert.osdn.jp/index.php?Listings}
11859 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
11860 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
11861 \url{http://www.w3.org/TR/jlreq/}%
11862 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
11863 \bibitem{min10} 乙部厳己.「min10フォントについて」\newblock
11864 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
11865 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard). 「JIS~X~4051,
11866 日本語文書の組版方法(Formatting rules for Japanese documents)」, 1993, 1995, 2004.
11867 \bibitem{ptexdoc} 濱野尚人,田村明史,倉沢良一.「\TeX の出版への応用—縦組み機能の組み込み—」.
11868 \newblock\texttt{.../texmf-dist/doc/ptex/base/ptexdoc.pdf}
11869 \bibitem{ptextug} Hisato Hamano. \newblock
11870 \textit{Vertical Typesetting with \TeX}, TUGBoat~\textbf{11}(3), 346--352, 1990.
11871 \bibitem{pdfstd} International Organization for Standardization. \newblock
11872 ISO 32000-1:2008, \textit{Document management -- Portable document format -- Part 1: PDF
11873       1.7}, 2008. \newblock
11874 \url{http://www.iso.org/iso/iso\_catalogue/catalogue_tc/catalogue\_detail.htm?csnumber=51502}
11875 \bibitem{tc18ltja} 北川弘典.「\LuaTeX-jaの近況」,\TeX Conf~2018.
11876   \url{https://raw.githubusercontent.com/h-kitagawa/presentations/main/tc18ltja.pdf}
11877 \bibitem{bxghost} Takuto ASAKURA. \newblock The \textsf{BXghost} Package. \url{https://github.com/wtsnjp/BXghost}
11878 \end{thebibliography}
11879
11880 \makeatletter
11881 \let\ltj@@end=\@@end
11882 {\catcode`\%=12\relax\catcode`\~=12\relax
11883 \protected\gdef\@@end{%
11884 \typeout{attributes:}
11885 \directlua{
11886   for i=0,65535 do
11887     local a = tex.getattribute(i)
11888     if a~=-0x7FFFFFFF then
11889       texio.write_nl('term and log',
11890         string.format('attr %6d, %d', i, a))
11891     end
11892     tex.setbox('global', i, nil)
11893   end
11894   print('IC', luatexja.inherit_na_count )
11895 }\ltj@@end}}
11896 \end{document}
11897 %</!showexpl>
11898 %<*showexpl>
11899 %%
11900 %% config file for showexpl.sty
11901 %%
11902 %% Copyright The LuaTeX-ja project team, 2012
11903 %%
11904 \ProvidesFile{showexpl.cfg}
11905   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
11906 \lstset{}
11907 \def\SX@Info{}
11908 \endinput
11909 %</*showexpl>