summaryrefslogtreecommitdiff
path: root/info/ptex-manual/ptex-guide-en.tex
blob: bbf6918839fe91688e2ee45900ba88c6e3bc6867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
%#!make ptex-guide-en.pdf
\documentclass[a4paper,11pt]{article}
\usepackage[textwidth=42zw,lines=40,truedimen,centering]{geometry}

%%%%%%%%%%%%%%%%
% additional packages
\usepackage{amsmath}
\usepackage{array}\usepackage[all]{xy}
\SelectTips{cm}{}
%\usepackage[dvipdfmx]{graphicx}
\usepackage[T1]{fontenc}
\usepackage{booktabs,enumitem,multicol}
\usepackage[defaultsups]{newpxtext}
\usepackage[zerostyle=c,straightquotes]{newtxtt}
\usepackage{newpxmath}
\usepackage[dvipdfmx,hyperfootnotes=false]{hyperref}
\usepackage{pxjahyper}
\usepackage{hologo}
\usepackage{makeidx}\makeindex

% common
\usepackage{ptex-manual}

\makeatletter
\newlist{simplelist}{description}1
\setlist[simplelist]{%
  itemsep=0pt, listparindent=1zw, itemindent=10pt,
  font=\normalfont\mdseries, leftmargin=2zw,
  before=\advance\@listdepth\@ne,
  after=\advance\@listdepth\m@ne
}
\makeatother

\def\code#1{\texttt{#1}}

%%%%%%%%%%%%%%%%
\makeatletter
\setlist{leftmargin=2zw}
\setlist[description]{labelwidth=2zw,labelindent=1zw,topsep=\medskipamount}

\def\>{\ifhmode\hskip\xkanjiskip\fi}

\def\tsp{_{\mbox{\fontsize\sf@size\z@\ttfamily \char32}}}
\def\tpar{_{\mbox{\fontsize\sf@size\z@\ttfamily \string\par}}}
\def\tign{_{\mbox{\fontsize\sf@size\z@\selectfont --}}}

\usepackage{shortvrb}
\MakeShortVerb*{|}
%%%%%%%%%%%%%%%%

% logos
\def\epTeX{$\varepsilon$-\pTeX}\def\eTeX{$\varepsilon$-\TeX}
\def\eupTeX{$\varepsilon$-\upTeX}\def\upTeX{u\pTeX}
\def\pTeX{p\kern-.10em\TeX}
\def\pLaTeX{p\LaTeX}\def\upLaTeX{u\pLaTeX}
\def\pdfTeX{pdf\TeX}
\def\OMEGA{$\Omega$}
\def\TL{\TeX\ Live\ }

\def\_{\leavevmode\vrule width .45em height -.2ex depth .3ex\relax}

\frenchspacing
\begin{document}
\catcode`\<=13
\title{\emph{Guide of \pTeX\ for developers not interested in Japanese}}
\author{Japanese \TeX\ Development Community\null
\thanks{\url{https://texjp.org},\ e-mail: \texttt{issue(at)texjp.org}}}
\date{version p\the\ptexversion.\the\ptexminorversion\ptexrevision, \today}
\maketitle

\pTeX\ and its variants, \upTeX, \epTeX\ and \eupTeX, are all \TeX\ engines
with native Japanese support.
Its output is always a DVI file, which can be processed by several
DVI drivers with Japanese support including {\em dvips} and {\em dvipdfmx}.
Formats based on \LaTeX\ is called \pLaTeX\ when running on \pTeX/\epTeX,
and called \upLaTeX\ when running on \upTeX/\eupTeX.

%%% Target readers of this document: 日本語機能でないパッケージ作者に絞る
\section*{Purpose of this document}

This document is written for developers of \TeX/\LaTeX, who aim to
support \pTeX/\pLaTeX\ and its variants \upTeX/\upLaTeX.
Knowledge of the followings are assumed:
\begin{itemize}
  \item Basic knowledge of Western \TeX\ (Knuthian \TeX, \eTeX\ and \pdfTeX),
  \item ... and its programming conventions.
\end{itemize}

%%% 日本語(の組版・文字コード)の知識は要らない。その話はできる限り避ける
Any knowledge of Japanese (characters, encodings, typesetting conventions etc.)
is not assumed; some explanations are provided in this document when needed.
We hope that this document helps authors of packages or classes
to proceed with supporting \pTeX\ family smoothly.

\begin{quotation}
Note: This English edition (\jobname.pdf) is {\em not} meant
to be a complete translation of Japanese edition (ptex-manual.pdf).
For example, this document does not cover the following aspects of \pTeX:
\begin{itemize}
  \item Typesetting conventions of Japanese characters
  \item Details of vertical writing
\end{itemize}
For beginners of writing Japanese texts,
please refer to the Japanese edition.
\end{quotation}

\tableofcontents


\newpage


%%%%%
\part{Brief introduction}% 概論

%%% pTeX とその仲間
\section{\pTeX\ and its variants}

% [TODO] \pTeX, \upTeX, \epTeX, \eupTeX を簡単に紹介

%%% e-(u)pTeX の話がメイン
There is no advantage to choose \pTeX/\upTeX\ over \epTeX/\eupTeX,
so we focus mainly on \epTeX/\eupTeX.

% [TODO] pLaTeX/upLaTeX も e- で走っていて,これで十分であると付け加える
% [TODO] 既に pTeX/upTeX が暗に e-pTeX/e-upTeX を指す文献もあることに言及

%%% 欧文 TeX との互換性
\section{Compatibility with Western \TeX}

%%% pTeX/upTeX は Knuthian TeX に対してほぼ上位互換
\pTeX/\upTeX\ are almost uppercompatible with Knuthian \TeX,
however, they do not pass TRIP test.
%%% 入力の8bitの扱いが異なる。フォントの8bitはそのまま
In \pTeX/\upTeX, input handling is different from Knuthian \TeX;
if a pair of two or more 8-bit codes matches Japanese character code,
it is regarded as one Japanese character.
There is no difference in handling 8-bit TFM font.

%%% e-pTeX/e-upTeX は e-TeX に対してほぼ上位互換
\epTeX/\eupTeX\ are almost uppercompatible with \eTeX,
however, input handling is similar to \pTeX/\upTeX.
It does not pass e-TRIP test.
%%% だけど e-TeX はもうなく,pdfTeX の DVI モードがあるだけ
That said, please note that ``raw \eTeX'' is unavailable anymore
in \TeX\ Live and derived distributions;
they provide a command |etex| only as ``DVI mode of \pdfTeX.''
%%% e-pTeX/e-upTeX は pdfTeX の DVI モードに対して上位互換ではない
We should note that
\epTeX/\eupTeX\ are {\em not} uppercompatible with DVI mode of \pdfTeX,
which will be discussed later in section \ref{dvi-pdftex}.

%%% LaTeX ムニャムニャ
\section{\LaTeX\ on \pTeX/\upTeX\ --- \pLaTeX/\upLaTeX}

%%% pLaTeX と upLaTeX ムニャムニャ
Formats based on \LaTeX\ is called \pLaTeX\ when running on \pTeX/\epTeX,
and called \upLaTeX\ when running on \upTeX/\eupTeX.
In recent versions (around 2011) of \TeX\ Live and its derivatives,
the default engines of \pLaTeX\ and \upLaTeX\ are \epTeX\ and \eupTeX.
That is, the command |platex| starts \epTeX\ (not \pTeX) with
preloaded format |platex.fmt|.

%%% カーネルが拡張されている
In the kernel level (|platex.ltx| and |uplatex.ltx|),
\pLaTeX\ and \upLaTeX\ adds some additional commands
related to the followings:
\begin{itemize}
  \item Selection of Japanese fonts
  \item Crop marks (called ``tombow'') for printings
  \item Adjustment for mixing horizontal and vertical texts
\end{itemize}
%%% author レベルでは LaTeX とほぼ互換,ただし例外あり
For authors, \pLaTeX/\upLaTeX\ is almost uppercompatible with
original \LaTeX, except for the followings:
\begin{itemize}
  \item Order of float objects; in \pLaTeX/\upLaTeX,
    <bottom float> is placed above <footnote>.
    That is, the complete order is
    <top float> $\rightarrow$ <body text> $\rightarrow$
    <bottom float> $\rightarrow$ <footnote>.
  % [TODO] 他にもあるか?
\end{itemize}
%%% developer レベルでは pdfTeX 拡張や pLaTeX カーネルでムニャムニャ
For developers, additional cares may be needed,
for changes in the kernel macros and/or absence of \pdfTeX\ features.

%%% 際立った pTeX 系列の特徴
\section{Eminent characteristics of \pTeX/\upTeX}

The most important characteristics of \pTeX/\upTeX\ can be
summarized as follows:
%%% 欧文と和文が別個に存在する・縦組がある
\begin{itemize}
  \item Japanese characters are interpret and handled completely apart from
    Western characters.
  \item Texts can be aligned vertically, called ``tate-gumi'' (縦組).
    The horizontal alignment of texts is called ``yoko-gumi'' (横組),
    and both ``tate-gumi'' and ``yoko-gumi'' can be mixed
    even within a single document.
\end{itemize}


\newpage


%%%%%
\part{Details}% 各論

%%% 出力フォーマット
\section{Output format --- DVI}

%%% DVI だけ
The output of \pTeX/\upTeX\ is always a DVI file.
%%% pTeX の DVI は欧文の横組みだけなら普通。和文が入ると特殊,縦組ならIDも変化
Its DVI format is completely compatible with Knuthian \TeX,
as long as the following conditions are met:
\begin{itemize}
  \item No Japanese characters are typeset.
  \item There is no portion of vertical text alignment.
\end{itemize}

\subsection{Extensions of DVI format}

In \pTeX/\upTeX,
some additional DVI commands, which are defined in the
standard \cite{dvistd0} but never used in \TeX82, are used.
\begin{itemize}
  \item |set2| (129), |put2| (134):
    Appears in both \pTeX\ and \upTeX\ DVI.
    Used to typeset a Japanese character with 2-byte code.
  \item |set3| (130), |put3| (135):
    Appears in only \upTeX\ DVI.
    Used to typeset a Japanese character with 3-byte code.
\end{itemize}
When \pTeX\ is going to typeset a Japanese character into DVI,
it is encoded in JIS, which is always a 2-byte code.
For this purpose, |set2| or |put2| are used.
When \upTeX\ is going to output a Japanese character into DVI,
it is encoded in UTF-32.
If the code is equal to or less than |U+FFFF|,
the lower 16-bit is used with |set2| or |put2|.
If the code is equal to or greater than |U+10000|,
the lower 24-bit is used with |set3| or |put3|.

In addition, \pTeX/\upTeX\ defines one additional DVI command.
\begin{itemize}
  \item |dir| (255):
    Used to change directions of text alignment.
\end{itemize}
The DVI format in the preamble is always set to 2, as with \TeX82.
On the other hand, the DVI ID in the postamble can be special.
Normally it is set to 2, as with \TeX82; however,
when |dir| (255) appears at least once in a single \pTeX/\upTeX\ DVI,
the |post_post| table of postamble contains $\mathrm{ID} = 3$.

%%% 日本の DVI ドライバの状況
\subsection{DVI drivers with Japanese support}

There is some DVI drivers with Japanese support.
The most eminent drivers are {\em dvips} and {\em dvipdfmx}.
Nowadays most of casual Japanese users are using {\em dvipdfmx} as a DVI driver.
On the other hand, users of {\em dvips} are unignorable, especially those
working in publishing industry.

\subsubsection{Using {\em dvipdfmx}}

A DVI file which is output by \pTeX\ can be converted directly to a PDF file
using dvipdfmx.
% [TODO] Mention kanji-config-updmap for font setup

{\em Note for casual \LaTeX\ users} ---
when you choose to process the resulting DVI file with dvipdfmx
after running \LaTeX\ (command |platex| or |uplatex|),
you need to pass a proper driver option |[dvipdfmx]| for
all driver-dependent packages, such as |graphicx| and |color|.
This is because the default for such packages is set to |dvips| mode
as with the original \LaTeX\ in DVI mode (command |latex|).
For simplicity, we recommend a global driver option |[dvipdfmx]|
as in the following example:
\begin{verbatim}
  \documentclass[dvipdfmx,...]{article}
  \usepackage{graphicx}
  \usepackage{color}
\end{verbatim}

\subsubsection{Using {\em dvips}}

A DVI file which is output by \pTeX\ can be converted to a PostScript file
using dvips.
% [TODO] Mention kanji-config-updmap again

The resulting PostScript file can then be converted to
a PDF file using Ghostscript (ps2pdf) or Adobe Distiller.
When using Ghostscript, a proper setup of Japanese font must be done
before converting PostScript into PDF.
An easy solution for the setup is a script |cjk-gs-integrate|
developed by Japanese \TeX\ Development Community.

\section{Programming on \pTeX\ family}

We focus on programming aspects of \pTeX\ and its variants.

%%% レジスタの数
\subsection{Number of registers}

\pTeX\ and \upTeX\ have exactly the same number ($=256$) of registers
as Knuthian \TeX.
\epTeX\ and \eupTeX\ in extended mode have more registers;
there are 65536, which is twice as many as 32768 of \eTeX.

% [TODO] まとめて 65536 個と書いて良い? レジスタの種類毎に書くべき?

%%% 拡張プリミティブ
\subsection{Additional primitives}
% tex -ini: 322 multiletter control sequences
% ptex -ini: 366 multiletter control sequences
% uptex -ini: 374 multiletter control sequences
% eptex -ini: 379 multiletter control sequences
% eptex -ini -etex: 469 multiletter control sequences
% euptex -ini: 387 multiletter control sequences
% euptex -ini -etex: 477 multiletter control sequences
% etex (pdftex) -ini: 470 multiletter control sequences
% etex (pdftex) -ini -etex: 539 multiletter control sequences

Here we provide only complete lists of additional primitives
of \pTeX\ family in alphabetical order.
Feature of each primitive can be found in Japanese edition.

% [TODO] 抜けがないか?
% [TODO] アルファベット順に正しく並んでいるか?
% [TODO] 追加されたバージョン情報は正しいか?

\def\New#1{--- New primitive since #1}

\subsubsection{Sync\TeX\ additions (available in \pTeX, \upTeX, \epTeX, \eupTeX)}
In the standard build of \TL, Sync\TeX\ extension is unavailable in
Knuthian \TeX; however, it is enabled in \pTeX\ family.
\begin{simplelist}
 \csitem[\.{synctex}]
\end{simplelist}

%%% pTeX のやつ
\subsubsection{\pTeX\ additions (available in \pTeX, \upTeX, \epTeX, \eupTeX)}
\begin{simplelist}
 \csitem[\.{autospacing}]
 \csitem[\.{autoxspacing}]
 \csitem[\.{disinhibitglue} \New{p3.8.2 (\TL2019)}]
 \csitem[\.{dtou}]
 \csitem[\.{euc}]
 \csitem[\.{ifdbox} \New{p3.2 (\TL2011)}]
 \csitem[\.{ifddir} \New{p3.2 (\TL2011)}]
 \csitem[\.{ifmbox} \New{p3.7.1 (\TL2017)}]
 \csitem[\.{ifmdir}]
 \csitem[\.{iftbox}]
 \csitem[\.{iftdir}]
 \csitem[\.{ifybox}]
 \csitem[\.{ifydir}]
 \csitem[\.{inhibitglue}]
 \csitem[\.{inhibitxspcode}]
 \csitem[\.{jcharwidowpenalty}]
 \csitem[\.{jfam}]
 \csitem[\.{jfont}]
 \csitem[\.{jis}]
 \csitem[\.{kanjiskip}]
 \csitem[\.{kansuji}]
 \csitem[\.{kansujichar}]
 \csitem[\.{kcatcode}]
 \csitem[\.{kuten}]
 \csitem[\.{noautospacing}]
 \csitem[\.{noautoxspacing}]
 \csitem[\.{postbreakpenalty}]
 \csitem[\.{prebreakpenalty}]
 \csitem[\.{ptexminorversion} \New{p3.8.0 (\TL2018)}]
 \csitem[\.{ptexrevision} \New{p3.8.0 (\TL2018)}]
 \csitem[\.{ptexversion} \New{p3.8.0 (\TL2018)}]
 \csitem[\.{scriptbaselineshiftfactor} \New{p3.7 (\TL2016)}]
 \csitem[\.{scriptscriptbaselineshiftfactor} \New{p3.7 (\TL2016)}]
 \csitem[\.{showmode}]
 \csitem[\.{sjis}]
 \csitem[\.{tate}]
 \csitem[\.{tbaselineshift}]
 \csitem[\.{textbaselineshiftfactor} \New{p3.7 (\TL2016)}]
 \csitem[\.{tfont}]
 \csitem[\.{xkanjiskip}]
 \csitem[\.{xspcode}]
 \csitem[\.{ybaselineshift}]
 \csitem[\.{yoko}]
 \csitem[\texttt{H}\index{H=\texttt{H}}]
 \csitem[\texttt{Q}\index{Q=\texttt{Q}}]
 \csitem[\texttt{zh}\index{zh=\texttt{zh}}]
 \csitem[\texttt{zw}\index{zw=\texttt{zw}}]
\end{simplelist}

%%% upTeX のやつ
\subsubsection{\upTeX\ additions (available in \upTeX, \eupTeX)}
\begin{simplelist}
 \csitem[\.{disablecjktoken}]
 \csitem[\.{enablecjktoken}]
 \csitem[\.{forcecjktoken}]
 \csitem[\.{kchar}]
 \csitem[\.{kchardef}]
 \csitem[\.{ucs}]
 \csitem[\.{uptexrevision} \New{u1.23 (\TL2018)}]
 \csitem[\.{uptexversion} \New{u1.23 (\TL2018)}]
\end{simplelist}

%%% e-pTeX/e-upTeX の pdfTeX 由来
%%% e-pTeX/e-upTeX の Omega 由来
%%% その他の独自拡張
\subsubsection{\epTeX\ additions (available in \epTeX, \eupTeX)}
\begin{simplelist}
 \csitem[\.{epTeXinputencoding} \New{160201 (\TL2016)}]
 \csitem[\.{epTeXversion} \New{180121 (\TL2018)}]
 \csitem[\.{expanded} \New{180518 (\TL2019)}]
 \csitem[\.{hfi}]
 \csitem[\.{ifincsname} \New{190709 (\TL2020)}]
 \csitem[\.{ifpdfprimitive} \New{150805 (\TL2016)}]
 \csitem[\.{lastnodechar} \New{141108 (\TL2015)}]
 \csitem[\.{lastnodesubtype} \New{180226 (\TL2018)}]
 \csitem[\.{odelcode}]
 \csitem[\.{odelimiter}]
 \csitem[\.{omathaccent}]
 \csitem[\.{omathchar}]
 \csitem[\.{omathchardef}]
 \csitem[\.{omathcode}]
 \csitem[\.{oradical}]
 \csitem[\.{pagefistretch}]
 \csitem[\.{pdfcreationdate} \New{130605 (\TL2014)}]
 \csitem[\.{pdfelapsedtime} \New{161114 (\TL2017)}]
 \csitem[\.{pdffiledump} \New{140506 (\TL2015)}]
 \csitem[\.{pdffilemoddate} \New{130605 (\TL2014)}]
 \csitem[\.{pdffilesize} \New{130605 (\TL2014)}]
 \csitem[\.{pdflastxpos}]
 \csitem[\.{pdflastypos}]
 \csitem[\.{pdfmdfivesum} \New{150702 (\TL2016)}]
 \csitem[\.{pdfnormaldeviate} \New{161114 (\TL2017)}]
 \csitem[\.{pdfpageheight}]
 \csitem[\.{pdfpagewidth}]
 \csitem[\.{pdfprimitive} \New{150805 (\TL2016)}]
 \csitem[\.{pdfrandomseed} \New{161114 (\TL2017)}]
 \csitem[\.{pdfresettimer} \New{161114 (\TL2017)}]
 \csitem[\.{pdfsavepos}]
 \csitem[\.{pdfsetrandomseed} \New{161114 (\TL2017)}]
 \csitem[\.{pdfshellescape} \New{141108 (\TL2015)}]
 \csitem[\.{pdfstrcmp}]
 \csitem[\.{pdfuniformdeviate} \New{161114 (\TL2017)}]
 \csitem[\.{readpapersizespecial} \New{180901 (\TL2019)}]
 \csitem[\.{vfi}]
 \csitem[\texttt{fi}\index{fi=\texttt{fi}}]
\end{simplelist}

% [TODO] 引数は何で返り値は何か,expandable?

%%% (e-)TeX にあるが (e-)upTeX にないもの
\subsection{Omitted primitives and unsupported features}

Compared to Knuthian \TeX\ and \eTeX,
some primitives are omitted due to conflict with Japanese handling.
%%% encTeX 拡張など
One is enc\TeX\ extension, such as |\mubyte|.
The ML\TeX\ extension, such as |\charsubdef|, is included but not well-tested.
%%% コマンドラインオプションの話

% [TODO] ptex.man1.pdf も参照

\subsection{Behavior of Western \TeX\ primitives}

Here we provide some notes on behavior of Knuthian \TeX\ and \eTeX\ primitives
when used within \pTeX\ family.

\subsubsection{Primitives with limitations in handling Japanese}

Each of the following primitives allows only character codes 0--255;
other codes will give an error ``! Bad character code.''
\begin{quote}
 |\catcode|,
 |\sfcode|,
 |\mathcode|,
 |\delcode|,
 |\mathchardef|,
 |\lccode|,
 |\uccode|.
\end{quote}

Each of the following primivies has |\...char| in its name,
however, the effective values are restricted to 0--255.
\begin{quote}
 |\endlinechar|,
 |\newlinechar|,
 |\escapechar|,
 |\defaulthyphenchar|,
 |\defaultskewchar|.
\end{quote}

\subsubsection{Primitives capable of handling Japanese}

The following primitives are extended to support Japanese characters:
\begin{cslist}
 \csitem[\.{char} <character code>,
   \.{chardef} <control sequence>=<character code>]
  In addition to 0--255, internal codes of Japanese characters are allowed.
  For putting Japanese characters, a Japanese font is chosen.

 \csitem[\.{font}, \.{fontname}, \.{fontdimen}]
  % [TODO]

 \csitem[\.{accent} <character code>=<character>]
  % [TODO]

 \csitem[\.{if} <token$_1$> <token$_2$>, \.{ifcat} <token$_1$> <token$_2$>]
  Japanese character token is also allowed.
  In that case,
  \begin{itemize}
    \item |\if| tests the internal character code of the Japanese character.
    \item |\ifcat| tests the |\kcatcode| of the Japanese character.
  \end{itemize}
\end{cslist}

\begin{dangerous}
\TeX book describes the behavior of |\if| and |\ifcat| as follows;
\begin{quote}
If either token is a control sequence,
\TeX\ considers it to have character code 256 and category code 16,
unless the current equivalent of that control sequence
has been |\let| equal to a non-active character token.
\end{quote}
However, this includes a lie; in the real implementation of tex.web,
a control sequence is considered to have a category code 0.
\end{dangerous}

\subsection{Case study}

Based on the above knowledge, we provide some code examples
which may be useful for package developers.

%%% pTeX かどうかの判定
\subsubsection{Detecting \pTeX}

Since the primitive |\ptexversion| is rather new (added in 2018),
the safer solution for detecting \pTeX\ is
to test if a primitive |\kanjiskip| is defined.
\begin{verbatim}
  \ifx\kanjiskip\undefined
    % not pTeX, upTeX, e-pTeX and e-upTeX
  \else
    % pTeX, upTeX, e-pTeX and e-upTeX
  \fi
\end{verbatim}

% [TODO] upTeX 系列は \enablecjktoken か \ucs か?
% [TODO] \forcecjktoken は比較的新しい?
% [TODO] 内部コードが uptex かどうかの判定

%%% pTeX のバージョン判定

%%% pdfTeX と違うところ
\subsection{Difference from \pdfTeX\ in DVI mode}\label{dvi-pdftex}

As stated above,
\epTeX/\eupTeX\ are {\em not} uppercompatible with DVI mode of \pdfTeX.

%%% pdfTeX の DVI モードにあって e-(u)pTeX にないプリミティブ
%%% その他ムニャムニャ

%%% ファイルの文字コードはどうするか
\subsection{Recommendation for file encoding}

%%% 全部アスキーにしてしまえ
%%% UTF-8 にしたい場合はムニャムニャ
%%% \epTeXinputencoding を使う話

%%% e-upTeX の入力解析:euc/sjis を語りたくないので utf8.uptex 前提
\subsection{Input handling}

For simplicity, first we introduce of input handling of \eupTeX.

%%% 文字の和文扱い・欧文扱い
%%% 和文カテゴリーコード
%%% \...cjktoken
%%% ちなみに e-pTeX では:euc/sjis があることにだけ触れる

%%% e-upTeX の和文トークンの話:和文トークンが混ざっているので注意
\subsection{Japanese tokens}

%%% 和文組版の厳選トピック
\section{Basic introduction to Japanese typesetting}

%%% 和文をやり過ごすために注意すべきこと
This section does not aim to explain Japanese typesetting completely;
here we provide a minimum requirement for ``getting away'' with Japanese.

%%% 空白・ペナルティ挿入:勝手に入ってくる!
\subsection{Automatic insertion of glues and penalties}

Sometimes \pTeX\ family automatically inserts glues and penalties
between characters.
% [TODO] もう少しだけ詳しく

%%% 和文フォント
\subsection{Japanese fonts}

For typesetting Japanese characters, a JFM (Japanese \TeX\ font metric)
format is used. It is a modified version of \TeX\ TFM.

%%% 欧文とは別個
%%% \nullfont しても全部消えない

%%% 縦組は諦めよう

\newpage

\begin{thebibliography}{99}
 \bibitem{dvistd0} TUG DVI Standards Working Group,
  \textit{The DVI Driver Standard, Level 0}.\\
  \url{https://ctan.org/pkg/dvistd}
\end{thebibliography}

\newpage
\printindex


\end{document}