From 5142daa13e19b32afa064863e039da3afaf06e83 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 27 Nov 2019 03:01:12 +0000 Subject: CTAN sync 201911270301 --- info/ptex-manual/README.md | 4 +- info/ptex-manual/eptexdoc.pdf | Bin 381070 -> 380603 bytes info/ptex-manual/eptexdoc.tex | 375 +++++++++++++++++++-------- info/ptex-manual/ptex-guide-en.pdf | Bin 69161 -> 99191 bytes info/ptex-manual/ptex-guide-en.tex | 506 ++++++++++++++++++++++++++++++++----- info/ptex-manual/ptex-manual.pdf | Bin 381437 -> 381432 bytes info/ptex-manual/ptex-manual.sty | 4 +- info/ptex-manual/ptex-manual.tex | 1 - 8 files changed, 713 insertions(+), 177 deletions(-) (limited to 'info') diff --git a/info/ptex-manual/README.md b/info/ptex-manual/README.md index 2fb6a003af..7a4f165607 100644 --- a/info/ptex-manual/README.md +++ b/info/ptex-manual/README.md @@ -7,7 +7,7 @@ This is a project of preparing a manual of Japanese pTeX and e-pTeX. The following documents are maintained by Japanese TeX Development Community: - * ptex-guide-en.pdf: Guide of pTeX and friends (in English) + * ptex-guide-en.pdf: Guide to pTeX and friends (in English) * ptex-manual.pdf: The manual of pTeX. * eptexdoc.pdf: The manual of e-pTeX. * jfm.pdf: Specification of JFM (Japanese Font Metric) format. @@ -36,6 +36,6 @@ the 3-clause BSD license (see [LICENSE](./LICENSE)). ## Release Date -2019-10-19 +2019-11-26 Japanese TeX Development Community diff --git a/info/ptex-manual/eptexdoc.pdf b/info/ptex-manual/eptexdoc.pdf index 30ef9193c9..4836488c05 100644 Binary files a/info/ptex-manual/eptexdoc.pdf and b/info/ptex-manual/eptexdoc.pdf differ diff --git a/info/ptex-manual/eptexdoc.tex b/info/ptex-manual/eptexdoc.tex index 62d11cc730..e4e7650324 100644 --- a/info/ptex-manual/eptexdoc.tex +++ b/info/ptex-manual/eptexdoc.tex @@ -28,7 +28,7 @@ %%%%%%%%%%%%%%%% % logos -\newcommand{\OMEGA}{$\Omega$} +\newcommand{\OMEGA}{\texorpdfstring{$\Omega$}{Ω}} \protected\def\epTeX{$\varepsilon$\nobreakdash-\pTeX} \protected\def\eupTeX{$\varepsilon$\nobreakdash-\upTeX} \protected\def\eTeX{$\varepsilon$\nobreakdash-\TeX} @@ -217,7 +217,7 @@ tracing機能や条件判断文の強化などあるが,そこら辺はパッ 以下,\eTeX 拡張を\pTeX 拡張とマージするにあたって調整した箇所を述べる. \begin{cslist} - \csitem[\.{lastnodetype}] + \csitem[\.{lastnodetype} (read-only integer)] \pTeX 拡張では,\TeX と比較して\node{dir\_node}と\node{disp\_node}という2種類のノードが 追加された.前者は,現在のリストの中に違う組方向のboxを挿入する際に寸法を補正するために作られ, \.{hbox}や\.{vbox}のコンテナとなっている. @@ -241,7 +241,7 @@ tracing機能や条件判断文の強化などあるが,そこら辺はパッ \item 14&unset node\cr\item 15&math mode nodes\cr \end{multilist}} - \csitem[\.{currentiftype}] + \csitem[\.{currentiftype} (read-only integer)] \ifnum\epTeXversion>190131 %%%%% TL2019-hack 条件判断文とそれを表す数字との対応は以下のようになっている (\epTeX~190709以降). @@ -305,7 +305,7 @@ tracing機能や条件判断文の強化などあるが,そこら辺はパッ のようにエラーが出る. \end{itemize} - \csitem[\.{iffontchar}] + \csitem[\.{iffontchar} ] \begin{itemize} \item 和文フォントの場合: \.{iffontchar} \\ を$f$,を$c$とおくと, @@ -355,13 +355,18 @@ fam256d.tex}(本文)と\texttt{fam256p.tex}(preamble部)に対応する extended modeの時に限り有効になる. \paragraph{数式フォント制限の緩和} -\OMEGA の大きな特徴としては,\TeX 内部のデータ構造を倍の領域を用いるよう -に改変し\footnote{詳しい話は\texttt{texk/web2c/texmfmem.h}中の共用体% -\texttt{memoryword}の定義を参照.大雑把に言うと,1つの「メモリ要素」に2つの32\,bit整 -数を同時に格納できるようになっている.},\TeX に従来から存在し -ていた「256個制限」を$2^{16}$個にまで緩和したことが挙げられる.同様に, -\OMEGA では(\cite{yamamoto}にもあるように)数式フォントを同時に256個まで -用いることができ,各フォントも65536文字まで許されるようになっている. +\OMEGA の大きな特徴としては,\TeX 内部のデータ構造を改変し +\footnote{詳しくは\texttt{texk/web2c/texmfmem.h}中の共用体% +\texttt{memoryword}の定義を参照.大雑把に言うと, +1つの「メモリ要素」に2つの32\,bit整数を同時に格納できるようになっている. +なお,少なくともtetex3以降では\texttt{memoryword}は8バイトであるが, +\TeX 82では1つの「メモリ要素」を2つの32\,bit整数として使うことはしていない. +% [TODO] 正確には "big TeX" からだが, +% ・big TeX はいつからあるのか? ・それが標準になったのはいつから? +}, +\TeX に従来から存在していたいくつかの「256個制限」を$2^{16}$個にまで緩和したことが挙げられる. +同様に,\OMEGA では(\cite{yamamoto}にもあるように)数式フォントを +同時に256個まで用いることができ,各フォントも65536文字まで許されるようになっている. \medskip @@ -389,26 +394,27 @@ extended modeの時に限り有効になる. すなわち,以下のプリミティブが追加されている\footnote{\OMEGA では\bits{8}のところが\bits{16}に なっている.}. \begin{cslist}[itemsep=\dimexpr-\baselineskip+\medskipamount] -\csitem[\.{omathcode} \bits{8}\texttt{=}\bits{27}]\ -\csitem[\.{omathcode} \bits{8}]\ -\csitem[\.{omathchar} \bits{27}]\ -\csitem[\.{omathaccent} \bits{27}]\ -\csitem[\.{omathchardef} \texttt{=}\bits{27}]\ -\csitem[\.{odelcode} \bits{8}\texttt{=}\bits{27}\ \bits{24}]\ -\csitem[\.{odelimiter} \bits{27}\ \bits{24}]\ -\csitem[\.{oradical} \bits{27}\ \bits{24}]\ + \csitem[\.{omathcode} \bits{8}\texttt{=}\bits{27}]\ + \csitem[\.{omathcode} \bits{8}]\ + \csitem[\.{omathchar} \bits{27}]\ + \csitem[\.{omathaccent} \bits{27}]\ + \csitem[\.{omathchardef} \texttt{=}\bits{27}]\ + \csitem[\.{odelcode} \bits{8}\texttt{=}\bits{27}\ \bits{24}]\ + \csitem[\.{odelimiter} \bits{27}\ \bits{24}]\ + \csitem[\.{oradical} \bits{27}\ \bits{24}]\ \end{cslist} \vspace{-\baselineskip} ここで,27\,bitとか24\,bitの自然数の意味については,上の表の \OMEGA の行を参照して欲しい.上に書いた内部のデータ構造から推測できる通り, -\.{omathchar}等のcharacter codeの指定に使われる16\,bitの数値のうち実際に使われるのは下位 -8\,bitであり,上位8\,bitは無視される. -例えば,|\omathchar"4012345|と|\omathchar"4010045|は内部表現としては全く同じである. +\.{omathchar}等のcharacter codeの指定に使われる16\,bitの数値のうち +実際に使われるのは下位8\,bitであり,上位8\,bitは無視される. +例えば,|\omathchar"4012345|と|\omathchar"4010045|は同義である. -なお,|\odelcode|~\bits 8として -delimiter codeを取得しようとしても,現時点のパッチでは,うまく動作しない -\footnote{51\,bit自然数を返さないといけないですからねえ.やる気があれば -検討してみます.}. +なお,|\mathcode|~\bits 8としてmath code値を取得できる文字はファミリ番号が16未満のもの +(すなわち,\TeX82における|\mathcode|格納値の形式に当てはまるもの)に限られる. +delimiter codeについても同様である. +さらに,|\odelcode|~\bits 8として51\,bitの形式のdelimiter codeを取得することはできない +($-1$が返る). \medskip \LaTeX において数式フォントを同時に16個以上使うには,|\omathchar|% @@ -454,7 +460,7 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う }. \item |\gluestretchorder|\indcs{gluestretchorder}, |\glueshrinkorder|\indcs{glueshrinkorder}の動作を\eTeX のそれと合わせた. - 具体的には,ある適当なglue~|\someglue|の伸び量をとおくとき, + 具体的には,あるglue~|\someglue|の伸び量をとおくとき, \[ \hbox{|\gluestretchorder\someglue|}= \begin{cases} @@ -469,21 +475,23 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う \end{itemize} \paragraph{レジスタについて} -\OMEGA では(前にも書いたが)データ構造の変更が行われ,それによってレジ -スタが各種類あたり65536個使えるようになっている. +\OMEGA では(前にも書いたが)データ構造の変更が行われ,それによってレジスタが +各種類あたり0番から65535番までの65536個を使えるようになっている. 一方,\eTeX では,256番以降のレジスタを専用のsparse treeに格納することにより, 32767番までのレジスタの使用を可能にしていた.このツリー構造を分析してみる -と,65536個までレジスタを拡張するのはさほど難しくないことのよう -に思われた.具体的には,ツリーの階層を1つ増やしてみた(だから,おそらく -各種類あたり$16\cdot 32768=524288$個まで使えるとは思うが,これはきりが悪 -い). -そこで,\epTeX では\eTeX 流の方法を用いながらも,レジスタをさ -らに65536個まで増やしている. +と,65536個までレジスタを拡張するのはさほど難しくないことが分かった. +そこで,\epTeX では\eTeX 流の方法を用いながらも, +ツリーの階層を1つ増やして,レジスタ(count, dimen, skip, muskip, box, token)を +\OMEGA と同じように0番から65535番までの65536個を使えるようにした. +同様に,マーク(mark)のクラス数も32768個から65536個まで増やしている. \section{\hologo{pdfTeX}由来の機能} 開発中の\LaTeX 3では,\eTeX 拡張の他に,\hologo{pdfTeX}で導入された -\.{pdfstrcmp}(又はその同等品)が必要となっており,もはや純粋な\eTeX ですら +プリミティブ\.{pdfstrcmp}(またはその同等品% +\footnote{\hologo{XeTeX}では\.{strcmp}という名称で, +\hologo{LuaTeX}ではLuaを用いて実装されている.})% +が必要となっており,もはや純粋な\eTeX ですら \LaTeX 3を利用することはできない状況である (\cite{expl31,expl32,expl33}). その他にも,\hologo{pdfTeX}由来のいくつかのプリミティブ(\cite{pdftexman})の実装が 日本の\TeX ユーザからあり, @@ -496,7 +504,7 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う \csitem [\.{pdfstrcmp} ] 2つの引数を文字列化したものを先頭バイトから比較し, 結果を$-1$(第1引数の方が先),0(等しい),1(第2引数の方が先)として文字列で返す. - + 比較する文字列中に和文文字がある場合には,(\epTeX の内部漢字コードにかかわらず) UTF-8で符号化して比較する. そのため,例えば @@ -512,17 +520,20 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う |\UseRawInputEncoding|の実行が必要になる. }. - \csitem[\.{pdfpagewidth}, \.{pdfpageheight}] + \csitem[\.{pdfpagewidth}, \.{pdfpageheight} (dimension)] ページの「幅」「高さ」を表す内部長さであるが, \emph{ここで言う「幅」は「字送り方向」のことではなく,物理的な意味である}. この2つの内部長さを設定するだけではdviに何の影響も与えない. - すぐ後で述べる\.{pdflastxpos}, \.{pdflastypos}による出力位置の取得 + 後で述べる\.{pdflastxpos}, \.{pdflastypos}による出力位置の取得 の際の原点位置を設定するためだけに使われ,初期値は0である. + \csitem[\.{readpapersizespecial} (integer)] + \pTeX 系列では, 用紙サイズの指定には伝統的にpapersize specialが利用されてきた.それを考慮して, + 本内部整数\.{readpapersizespecial}(既定値は1)が正の場合は papersize specialがdvi中に書き出される時,\epTeX にはその内容を解釈して - 自動的に\.{pdfpagewidth}, \.{pdfpageheight}の値を設定する機能がある + 自動的に\.{pdfpagewidth}, \.{pdfpageheight}の値を設定する \footnote{% papersize specialで指定した長さは常に\texttt{true}付きで解釈するのが慣習と なっているが,\epTeX~180901より前では\texttt{true}なしの寸法として解釈するという @@ -533,7 +544,7 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う \def\<#1>{\langle\mbox{#1}\rangle} \begin{align*} \ &\longrightarrow \texttt{papersize=}\\texttt{,}\\\ - \ &\longrightarrow \ + \ &\longrightarrow \ \\\\ \ &\longrightarrow \texttt{.} \mid \\ \mid \\ @@ -541,12 +552,13 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う 負の符号や小数点としての「\texttt{,}」,そして一切の空白を許容しないところに 注目してほしい.また,\texttt{zw},~\texttt{zh},~\texttt{em},~\texttt{ex}という 現在のフォントに依存する単位も使用不可能である. - }.\epTeX~180901より前ではこの機能は常に有効 - であったが,\epTeX~180901以降では内部整数 - \.{readpapersizespecial}\indcs{readpapersizespecial}(既定値は1)が正の場合のみ有効となる. - - \csitem[\.{pdflastxpos}, \.{pdflastypos}] - \.{pdfsavepos}\indcs{pdfsavepos}が置かれた場所の,dviにおける出力位置を返す内部整数(読み取り専用). + }. + + このプリミティブは\epTeX~180901で追加された.それより前のバージョンでは + 前段落で述べた機能は常に有効であった. + + \csitem[\.{pdflastxpos}, \.{pdflastypos} (read-only integer)] + \.{pdfsavepos}\indcs{pdfsavepos}が置かれた場所の,dviにおける出力位置を返す内部整数. 原点はページの(物理的な意味の)左下隅であり,$y$軸は(物理的な)上方向に向かって増加する. \begin{itemize} \item ページの物理的な幅と高さはすぐ上の\.{pdfpagewidth}, \.{pdfpageheight}で設定する. @@ -561,7 +573,7 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う 移動したところになる \footnote{これは\hologo{pdfTeX}のdviモードや\hologo{XeTeX}と同じ挙動である.}. \end{itemize} - + \csitem[\.{pdfcreationdate}] エンジン起動時の時刻を,\texttt{\pdfcreationdate}の形式で表した文字列に展開する. 末尾に|+09'00'|などと表示されるのはローカルのタイムゾーンであるが, @@ -580,24 +592,24 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う それぞれの更新時刻(\.{pdfcreationdate}と同じ形式)と ファイルサイズを表す文字列に展開する. これらも\Pkg{standalone}パッケージのために\epTeX に実装されたプリミティブである. - + \csitem[\.{pdffiledump} \textrm{[}\texttt{offset} \textrm{]}% \ \texttt{length} ] で与えられたファイル名のバイト目(先頭は0)からバイトを読み込み, 16進表記(大文字)したものに展開される. - + 本プリミティブはHeiko Oberdiek氏による\Pkg{bmpsize}パッケージを\epTeX でも使うために 角藤さんが実装したものである(2014/05/06). - - \csitem[\.{pdfshellescape}] - \.{write18}によるshell-escapeが利用可能になっているかを示す内部整数(読み取り専用). + + \csitem[\.{pdfshellescape} (read-only integer)] + \.{write18}によるshell-escapeが利用可能になっているかを示す内部整数. 0ならば不許可,1ならば許可,2ならばrestricted shell-escape% \footnote{あらかじめ「安全」と認められたプログラム(\texttt{texmf.cnf}中で指定する) のみ実行を許可する仕組み.}% である. - + 本プリミティブは\TeX ユーザの集い2014でリクエストを受けて実装された(\cite{pdfse}). - + \csitem[\.{pdfmdfivesum} {[\texttt{file}]} ] 引数のMD5ハッシュ値か,あるいは\texttt{file}が指定された場合は ファイル名がのファイルのMD5ハッシュ値を計算する. @@ -607,8 +619,8 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う このプリミティブは\cite{xe5}以降の議論を元に,角藤さんがリクエストしたもので, 2015/07/04に\epTeX に実装されている. - - \csitem[\.{pdfpritimive}, \.{ifpdfprimitive}] + + \csitem[\.{pdfpritimive} , \.{ifpdfprimitive} ] \.{pdfprimitive}は次に続く制御綴がプリミティブと同じ名称であった場合に, プリミティブ本来の意味で実行させるものである.例えば \begin{verbatim} @@ -620,20 +632,21 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う これらのプリミティブは2015/07/15版の\Pkg{expl3}パッケージで使われた (\cite{15715})ことを受けて実装されたものだが, - 現在ではこれらのプリミティブは使われていない. + 現在では\Pkg{expl3}パッケージではこれらのプリミティブは要求していない. \csitem[\.{pdfuniformdeviate} , \.{pdfnormaldeviate}] \.{pdfuniformdeviate}は,0以上未満の一様分布に従う乱数(整数値)を生成する. \.{pdfnormaldeviate}は,平均値0,標準偏差65536の正規分布に従う乱数(整数値)を生成する. - - 現在の乱数生成の種の値は,\.{pdfrandomseed}\indcs{pdfrandomseed}で取得できる(読み取り専用). - 種の初期化にはシステムのマイクロ秒単位での現在時刻情報が使われる.また,種の値は - \.{pdfsetrandomseed} \indcs{pdfsetrandomseed}によって特定の値に設定可能である. - - \LaTeX3のl3fpにおいて,2016/11/12あたりから実装された乱数生成機能(\cite{random})を + + \csitem[\.{pdfrandomseed} (read-only integer), \.{pdfsetrandomseed} ] + 乱数生成の種の値は,\.{pdfrandomseed}で取得できる. + 種の初期化にはシステムのマイクロ秒単位での現在時刻情報が使われる.また,種の値を + 設定するには\.{pdfsetrandomseed}に引数として渡せば良い. + + \LaTeX3の\Pkg{l3fp}において,2016/11/12あたりから実装された乱数生成機能(\cite{random})を サポートするために\epTeX~161114から実装された. - \csitem[\.{pdfelapsedtime}, \.{pdfresettimer}] + \csitem[\.{pdfelapsedtime} (read-only integer), \.{pdfresettimer}] \.{pdfelapsedtime}は,エンジン起動からの経過時間を``scaled seconds''すなわち $1/65536$秒単位で返す.この値は\.{pdfresettimer}によって再び0にリセットできる. すぐ上の乱数生成プリミティブと同時に実装された. @@ -648,19 +661,20 @@ delimiter codeを取得しようとしても,現時点のパッチでは,う \epTeX~180518以降で利用可能である. \ifnum\epTeXversion>190131 %%%%% TL2019-hack - \csitem[\.{ifincsname}] + \csitem[\.{ifincsname}] \texttt{\.{csname}~...~\.{endcsname}}内で評価されたちょうどその時に真となる. \LaTeX~2019-10-01で行われる変更(\cite{latex95,tjb83})で必要になったために \epTeX~190709で導入された. \fi %%%%% TL2019 \end{cslist} + \section{バージョン番号} \pTeX~p3.8.0に\.{ptexversion}が実装されたのと同時に,\epTeX でもバージョン番号を 取得する\.{epTeXversion}プリミティブが\epTeX~180121から追加された. \begin{cslist} - \csitem[\.{epTeXversion}] + \csitem[\.{epTeXversion} (read-only integer)] \epTeX のバージョン番号(例えば\the\epTeXversion)を内部整数で返す.\epTeX 起動時のバナーでは \eTeX, \pTeX のバージョン番号も表示されるので,それを再現しようとすると以下のようになる. \begin{verbatim} @@ -668,8 +682,6 @@ This is e-pTeX, Version 3.14159265-% p\number\ptexversion.\number\ptexminorversion\ptexrevision-% \number\epTeXversion-\number\eTeXversion\eTeXrevision ... \end{verbatim} - - \end{cslist} @@ -707,17 +719,20 @@ min10フォントメトリックで「ちょっと」を組むと「ょっ」の 改善する助けになることを目指して実装された. \begin{cslist} - \csitem[\.{lastnodechar}] - 現在構築中のリストの「最後のノード」が文字由来であれば,そのコード番号(内部コード)を内部整数として返す. - + \csitem[\.{lastnodechar} (read-only integer)] + 現在構築中のリストの「最後のノード」が文字由来であれば, + そのコード番号(内部コード)を内部整数として返す. + 上記「最後のノード」では,\pTeX によって自動挿入される \begin{itemize} \item JFMによって入るグルー \item 行末禁則処理のために挿入されるペナルティ \item 欧文文字のベースライン補正用のノード \end{itemize} - は無視される.また,「最後のノード」が欧文文字のリガチャであった場合は,リガチャそれ自身のコード番号ではなく, - 最後の構成要素の文字のコード番号を返す.「最後のノード」が文字を表すものでなかった場合は,$-1$が返る. + は無視される.また,「最後のノード」が欧文文字のリガチャであった場合は, + リガチャそれ自身のコード番号ではなく, + 最後の構成要素の文字のコード番号を返す. + 「最後のノード」が文字を表すものでなかった場合は,$-1$が返る. \end{cslist} 例えば,\.{lastnodechar}を使って @@ -735,7 +750,6 @@ min10フォントメトリックで「ちょっと」を組むと「ょっ」の }が得られる.これによって,\.{textmc}等の命令の直前の文字を知ることができるので, あとは\TeX マクロ側でなんとかできるだろう,という目論見である. - また,上記の説明にあるとおり, \begin{verbatim} abcfi\the\lastnodechar, abc\char"1C \the\lastnodechar @@ -770,11 +784,12 @@ abcfi\the\lastnodechar, abc\char"1C \the\lastnodechar \begin{verbatim} これは,\relax\sffamily{}\the\lastnodechar\textmc{『ほげ党宣言』}…… \end{verbatim} -などとノードに関係しないものが途中にあっても,それは単純に無視されて +のようにノードを作らない\.{relax}, |{}|, \.{sffamily}などが途中にあっても, +それらは単純に無視されて \begin{quote} これは,\relax\sffamily{}\the\lastnodechar\textmc{『ほげ党宣言』}…… \end{quote} -となる. +と「,」の内部コードが取得される. \section{\.{lastnodesubtype}プリミティブ} \cite{tjb28,plt63}などの議論で,「最後のグルーがJFMグルーだけ\.{unskip}する」処理の必要性が @@ -783,13 +798,13 @@ abcfi\the\lastnodechar, abc\char"1C \the\lastnodechar そのため,\epTeX~180226で\.{lastnodesubtype}プリミティブを追加した. \begin{cslist} - \csitem[\.{lastnodesubtype}] - 現在構築中のリストの「最後のノード」(\.{lastnodechar}プリミティブと同様)の - subtype値を内部整数として返す. -\begin{itemize} - \item 「最後のノード」が文字ノードのときは0が返る. - \item 現在構築中のリストが空のときは$-1$が返る. -\end{itemize} + \csitem[\.{lastnodesubtype} (read-only integer)] + 現在構築中のリストの「最後のノード」(\.{lastnodechar}プリミティブと同様)の + subtype値を内部整数として返す. + \begin{itemize} + \item 「最後のノード」が文字ノードのときは0が返る. + \item 現在構築中のリストが空のときは$-1$が返る. + \end{itemize} \end{cslist} 実際に有用なのは,以下の場合であろう: @@ -872,17 +887,148 @@ abcfi\the\lastnodechar, abc\char"1C \the\lastnodechar \cite{eptexinputenc}を参照してほしいが,おおまかに述べると以下のようになるだろう. \begin{cslist} - \csitem[\.{epTeXinputencoding} ] + \csitem[\.{epTeXinputencoding} ] 現在読み込んでいるファイルの文字コードをに変更する. 実際に変更されるのは「次の行」であり,また現在のファイルからさらに\.{input}等で 読まれたファイルには効力を及ぼさない. + + 引数の読み取りは, + (\LaTeX で定義が上書きされていない,プリミティブの)\.{input}の引数(ファイル名)を + 取得するのと同じルーチンが用いられる. + そのため, +\begin{verbatim} +\epTeXinputencoding sjis +\end{verbatim} + のように,は|{}|で囲まないこと. の末尾は,空白トークンや展開不能トークンによって区切られる. - % [TODO] これで合っていますか? -- aminophen + % scan_file_name で を取得しているので, + % \epTeXinputencoding "euc" \epTeXinputencoding ""e""u""c"" も OK. の値は,基本的には\pTeX の\texttt{-kanji}オプションで指定できる値 (\texttt{euc}, \texttt{sjis}, \texttt{jis}, \texttt{utf8})である. + 大文字小文字は考慮しない(\TeX の\.{uccode}, \.{lccode}は参照しない). + % BINARY, ISO-2022-JP, EUC-JP, Shift_JIS, UTF-8 (, uptex) も OK + % ptexenc 側で strcasecmp で比較しているので,大文字・小文字の区別はしない + % (\uccode, \lccode は参照しない) \end{cslist} +\ifnum\epTeXversion>190131 %%%%% TL2019-hack +\section{\.{current[x]spacingmode}プリミティブ} +もともと\pTeX 系列では,\.{kanjiskip},~\.{xkanjiskip}の挿入が有効になっているか +直接的に知る方法が\.{showmode}プリミティブしかなかった. +これでは使い勝手が悪いので, +\.{currentspacingmode}, \.{currentxspacingmode}プリミティブが2019/10/28に +山下さんによって実装された(\cite{tjb94}). + +\begin{cslist} + \csitem[\.{currentspacingmode} (read-only integer)] + \pTeX の「標準で\.{kanjiskip}を挿入する」機能が有効(\.{autospacing})ならば1, + 無効(\.{noautospacing})ならば0を返す. + \csitem[\.{currentxspacingmode} (read-only integer)] + \pTeX の「標準で\.{xkanjiskip}を挿入する」機能が有効(\.{autoxspacing})ならば1, + 無効(\.{noautoxspacing})ならば0を返す. +\end{cslist} + +同様に,\eupTeX でも\.{currentcjktoken}プリミティブが2019/10/28に実装された. +% e-pTeX の追加プリミティブではないが,ドキュメント化の都合上ここに書いた. + +\begin{cslist} + \csitem[\.{currentcjktoken}(read-only integer,\emph{\eupTeX のみ})] + \upTeX の「和文(CJK)文字と欧文文字を区別する」機能について, + \.{enablecjktoken}の状態ならば0, + \.{disablecjktoken}の状態ならば1, + \.{forcecjktoken}の状態ならば2を返す. +\end{cslist} +\fi %%%%% TL2019 + +\ifnum\epTeXversion>190131 %%%%% TL2019-hack +\section{\.{Uchar}, \.{Ucharcat}プリミティブ} +\hologo{XeTeX}, \hologo{LuaTeX}には,引数を文字コードとする +\emph{文字トークン}に展開される「\.{Uchar} 」というプリミティブが存在する +\footnote{\.{char}は展開不能プリミティブであることに注意.}. +また,\hologo{XeTeX}には「\.{Ucharcat}~~」という, +文字コード・カテゴリーコードがそれぞれ, である +文字トークンを作るプリミティブが存在する\footnote{\hologo{LuaTeX}ではLuaによる代替物がある.}. + +% pTeX の「抜け道」の具体的なコード? +\pTeX で「和文版\.{Uchar}」に相当することは\TeX~Live 2019以前の\pTeX ではマクロで実現することが可能だが, +将来の\pTeX の改修で不可能になる恐れ(\cite{tjb81,tjb95})があるので, +\epTeX~191112で前段落で述べた\.{Uchar}, \.{Ucharcat}プリミティブを追加することにした. + +\begin{cslist} + \csitem[\.{Uchar} ] + 文字コードがの文字トークンに展開される. + 指定した値と得られる文字トークンの対応表は次の通り. + + \begin{center} + \small\medskip + \begin{tabular}{lccc} + \toprule + &和文・欧文&\multicolumn{2}{c}{category code}\\\cmidrule(lr){3-4} + &&\epTeX&\eupTeX\\ + \midrule + 0--31, 33--255&欧文文字トークン&12&12\\ + 32 &欧文文字トークン&10&10\\ + 256以上の&和文文字トークン&---(都度取得)&その時の\.{kcatcode}\footnotemark\\ + \bottomrule + \end{tabular} + \end{center} + \footnotetext{もし\.{kcatcode}の値が15だったときは,得られる和文文字トークンの + \.{kcatcode}は18となる.} + + \csitem[\.{Ucharcat} ] + 文字コード・カテゴリーコードがそれぞれ, の文字トークンに展開される. + + \epTeX では和文文字トークンにはカテゴリーコードの情報は保存されないため, + \epTeX の\.{Ucharcat}は欧文文字トークンの生成しかサポートしない. + 具体的には, + 指定可能な値はが0--255,が1--4, 6--8, 10--13のみである. +\end{cslist} +\begin{dangerous} + \eupTeX では,\.{Ucharcat}で和文文字トークンの生成もサポートしている. + + \medskip + \begin{itemize} + \item が0--127のときは,欧文文字トークンのみ生成可能である.従って + の指定可能値は1--4, 6--8, 10--13. + \item が128--255のときは,欧文文字トークン・和文文字トークンの + どちらも生成可能である. + の指定可能値は1--4, 6--8, 10--13(以上欧文文字トークンを生成), + および16--19(和文文字トークンを生成). + \item が256以上のときは,和文文字トークンのみ生成可能である.従って + の指定可能値は16--19. + \end{itemize} +\end{dangerous} +\begin{dangerous} + \.{Uchar}で和文文字トークンを生成するには,その和文文字コードを + 与える必要があるが,その値は内部漢字コードに依るので, + |\jis|や|\euc|等の文字コード変換プリミティブを使うのが便利である + (例えば|\Uchar\jis"3441|で「\Uchar\jis"3441」を得る). + + ただし,\eupTeX の\.{Ucharcat}ではを + 空白トークンで区切る必要があり,注意を要する. + 例えば,カテゴリーコード17の「漢」を得ようとして, + 単に + \begin{quote} + \verb+\Ucharcat\jis"3441 17 % エラー+ + \end{quote} + と書くとエラー\footnote{% + \.{jis}の展開時に後ろの空白トークンが食われてしまい,\.{Uchar}には + 文字コード2845017($\text{漢}=\text{U+6F22}\rightarrow 28450$と17が + 繋がった結果)が渡ってしまう. + }が発生する.次のように書けばエラーが回避できるようである. + \begin{quote} + \verb+\Ucharcat\jis"3441\noexpand\space17 % エラー回避+ + \end{quote} + あるいは: + \begin{quote} + \verb+\Ucharcat\numexpr\jis"3441\relax 17 % エラー回避+ + \end{quote} +\end{dangerous} +\fi %%%%% TL2019 + + + \begin{comment} \section{互換性} \eTeX, \pTeX との互換性をはかるのに有効な手段としては,まず\texttt{TRIP} @@ -948,38 +1094,39 @@ $3$\,sp)だが,どこか気になるところである. \begin{thebibliography}{99} \bibitem{h7k} 北川 弘典,「計算数学II 作業記録」,2008.\\ \url{https://osdn.jp/projects/eptex/document/resume/ja/1/resume.pdf}ほか, - 本pdfと同じディレクトリにある\texttt{resume.pdf}がそれにあたる. - \bibitem{yamamoto} 山本 和義,「数式famの制限とluatex」,掲示板「\TeX\ - Q\ \&\ A」,2009/02/12.\\ + 本pdfと同じディレクトリにある\texttt{eptex\_resume.pdf}がそれにあたる. + \bibitem{yamamoto} 山本 和義,「数式famの制限とluatex」, + 掲示板「\TeX\ Q\ \&\ A」,2009/02/12.\\ \url{http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/52744.html} - \bibitem{yamamoto2} 山本 和義,「Re: 数式famの制限とluatex」,掲示板「\TeX\ - Q\ \&\ A」,2009/02/16. + \bibitem{yamamoto2} 山本 和義,「Re: 数式famの制限とluatex」, + 掲示板「\TeX\ Q\ \&\ A」,2009/02/16. \url{http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/52767.html} -\bibitem{yamamoto3} 山本 和義,「数式fam拡張マクロ for e-pTeX等」,掲示板「\TeX\ - Q\ \&\ A」,2009/02/21. + \bibitem{yamamoto3} 山本 和義,「数式fam拡張マクロ for e-pTeX等」, + 掲示板「\TeX\ Q\ \&\ A」,2009/02/21. \url{http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/52799.html} -\bibitem{expl31} 河原,「パッケージとディストリビューションについて」,掲示板「\TeX\ - Q\ \&\ A」,2010/12/16. + \bibitem{expl31} 河原,「パッケージとディストリビューションについて」, + 掲示板「\TeX\ Q\ \&\ A」,2010/12/16. \url{http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/55464.html} - \bibitem{expl32} 角藤 亮,「Re: パッケージとディストリビューションについて」,掲示板「\TeX\ - Q\ \&\ A」,2010/12/19. + \bibitem{expl32} 角藤 亮,「Re: パッケージとディストリビューションについて」, + 掲示板「\TeX\ Q\ \&\ A」,2010/12/19. \url{http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/55478.html} - \bibitem{expl33} zrbabbler,「LaTeX3 と expl3 パッケージ」,ブログ「マクロツイーター」内 - ,2010/12/22. + \bibitem{expl33} zrbabbler,「LaTeX3 と expl3 パッケージ」, + ブログ「マクロツイーター」内,2010/12/22. \url{http://d.hatena.ne.jp/zrbabbler/20101222/1293050561} - \bibitem{strcmp} 角藤 亮,「Re: e-pTeX 101231」,掲示板「\TeX\ - Q\ \&\ A」,2011/01/01.\\ + \bibitem{strcmp} 角藤 亮,「Re: e-pTeX 101231」, + 掲示板「\TeX\ Q\ \&\ A」,2011/01/01.\\ \url{http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/55528.html} \bibitem{pdfse} Dora TeX,「Re: |\pdfshellescape|, |\lastnodechar| の実装」,\TeX~Forum,2014/11/19. \url{http://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=1435#p8053} \bibitem{lnc} 北川 弘典,「|\lastnodechar| プリミティブについて」,2014/12/15.\\ - \url{https://ja.osdn.net/projects/eptex/wiki/lastnodechar} + \url{https://ja.osdn.net/projects/eptex/wiki/lastnodechar} \bibitem{xe5} Joseph Wright, ``[XeTeX] |\(pdf)mdfivesum|'', 2015/07/01,\\ \url{http://tug.org/pipermail/xetex/2015-July/026044.html} - \bibitem{15715} tat tsan,「[expl3 / e(u)ptex] 2015/07/15 版 expl3 パッケージが - 、(u)platex で通らない」,\TeX~Forum,2015/07/26.\\ + \bibitem{15715} tat tsan, + 「[expl3 / e(u)ptex] 2015/07/15 版 expl3 パッケージが、(u)platex で通らない」, + \TeX~Forum,2015/07/26.\\ \url{http://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=1632} \bibitem{random} Joseph Wright, ``[tex-live] Random number primitives'', 2016/11/12,\\ @@ -988,11 +1135,11 @@ $3$\,sp)だが,どこか気になるところである. \url{http://abenori.blogspot.jp/2016/02/e-ptexeptexinputencoding.html}. \bibitem{etexman} The \NTS\!\ Team. \textit{The \eTeX\ manual} (v2.0). \\ |$TEXMFDIST/doc/etex/base/etex_man.pdf| - \bibitem{omegaman} J.\ Plaice, Y.\ Haralambous. \textit{Draft - documentation for the $\it\Omega$ system}, 1999.\\ + \bibitem{omegaman} J.\ Plaice, Y.\ Haralambous. + \textit{Draft documentation for the $\it\Omega$ system}, 1999.\\ |$TEXMFDIST/doc/omega/base/doc-1.8.tex| - \bibitem{pdftexman} H\`an Th\'{\^e} Th\`anh et al. \textit{The - \hologo{pdfTeX}\ user manual}, 2015.\\ + \bibitem{pdftexman} H\`an Th\'{\^e} Th\`anh et al. + \textit{The \hologo{pdfTeX}\ user manual}, 2015.\\ |$TEXMFDIST/doc/pdftex/manual/pdftex-a.pdf| \bibitem{l2e26} The \LaTeX3 Project Team, \textit{\LaTeX\ News Issue 26}, 2017.\\ @@ -1004,7 +1151,7 @@ $3$\,sp)だが,どこか気になるところである. \bibitem{plt63} Dora TeX, 「p 指定の tabular でのセル冒頭の |\relax\par|」,2018/02/19.\\ \url{https://github.com/texjporg/platex/issues/63}. - \bibitem{expanded1} Joseph Wright, + \bibitem{expanded1} Joseph Wright, ``[tex-live] Primitive parity, |\expanded| and |\Ucharcat|'', 2018/05/04,\\ \url{http://tug.org/pipermail/tex-live/2018-May/041599.html} @@ -1012,12 +1159,20 @@ $3$\,sp)だが,どこか気になるところである. Joseph Wright, ``A `new' primitive: |\expanded|'', 2018/12/06.\\ \url{https://www.texdev.net/2018/12/06/a-new-primitive-expanded} \bibitem{latex95} - Volker-Weissmann, ``Feature Request: Better error messages for non-ASCII symbols in labels.'', + Volker-Weissmann, ``Feature Request: Better error messages for + non-ASCII symbols in labels.'', 2018/12/03.\\ \url{https://github.com/latex3/latex2e/issues/95} \ifnum\epTeXversion>190131 %%%%% TL2019-hack + \bibitem{tjb81} 北川 弘典,「バイト列と和文文字トークンの区別」,2019/06/08.\\ + \url{https://github.com/texjporg/tex-jp-build/issues/81}. \bibitem{tjb83} aminophen,「[e-pTeX] |\ifincsname|」,2019/07/09.\\ \url{https://github.com/texjporg/tex-jp-build/issues/83}. + \bibitem{tjb94} aminophen,「e(u)ptex: add |\current(x)spacingmode|, |\currentcjktoken|」,% + 2019/10/28.\\ + \url{https://github.com/texjporg/tex-jp-build/pull/94}. + \bibitem{tjb95} 北川 弘典,「[eptex] |\Uchar| and |\Ucharcat|」,2019/10/30.\\ + \url{https://github.com/texjporg/tex-jp-build/issues/95}. \fi %%%%% TL2019 \end{thebibliography} diff --git a/info/ptex-manual/ptex-guide-en.pdf b/info/ptex-manual/ptex-guide-en.pdf index f33abf4c40..6228a3f4b5 100644 Binary files a/info/ptex-manual/ptex-guide-en.pdf and b/info/ptex-manual/ptex-guide-en.pdf differ diff --git a/info/ptex-manual/ptex-guide-en.tex b/info/ptex-manual/ptex-guide-en.tex index bbf6918839..7e7eab90ba 100644 --- a/info/ptex-manual/ptex-guide-en.tex +++ b/info/ptex-manual/ptex-guide-en.tex @@ -16,11 +16,12 @@ \usepackage[dvipdfmx,hyperfootnotes=false]{hyperref} \usepackage{pxjahyper} \usepackage{hologo} +\usepackage{xspace} \usepackage{makeidx}\makeindex % common \usepackage{ptex-manual} - +\let\emph=\origemph \makeatletter \newlist{simplelist}{description}1 \setlist[simplelist]{% @@ -55,14 +56,14 @@ \def\pLaTeX{p\LaTeX}\def\upLaTeX{u\pLaTeX} \def\pdfTeX{pdf\TeX} \def\OMEGA{$\Omega$} -\def\TL{\TeX\ Live\ } +\def\TL{\TeX\ Live\xspace} \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}} +\title{\textsf{\textbf{Guide to \pTeX\ for developers unfamiliar with 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} @@ -71,7 +72,7 @@ \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}. +DVI drivers with Japanese support including \emph{dvips} and \emph{dvipdfmx}. Formats based on \LaTeX\ is called \pLaTeX\ when running on \pTeX/\epTeX, and called \upLaTeX\ when running on \upTeX/\eupTeX. @@ -93,7 +94,7 @@ 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 +Note: This English edition (\jobname.pdf) is \emph{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} @@ -129,8 +130,8 @@ so we focus mainly on \epTeX/\eupTeX. \section{Compatibility with Western \TeX} %%% pTeX/upTeX は Knuthian TeX に対してほぼ上位互換 -\pTeX/\upTeX\ are almost uppercompatible with Knuthian \TeX, -however, they do not pass TRIP test. +\pTeX/\upTeX\ are almost upward compatible with Knuthian \TeX, +however, they do not pass the 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, @@ -138,16 +139,16 @@ 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, +\epTeX/\eupTeX\ are almost upward compatible with \eTeX, however, input handling is similar to \pTeX/\upTeX. -It does not pass e-TRIP test. +It does not pass the 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, +\epTeX/\eupTeX\ are \emph{not} upward compatible with DVI mode of \pdfTeX, which will be discussed later in section \ref{dvi-pdftex}. %%% LaTeX ムニャムニャ @@ -171,7 +172,7 @@ related to the followings: \item Adjustment for mixing horizontal and vertical texts \end{itemize} %%% author レベルでは LaTeX とほぼ互換,ただし例外あり -For authors, \pLaTeX/\upLaTeX\ is almost uppercompatible with +For authors, \pLaTeX/\upLaTeX\ are almost upward compatible with original \LaTeX, except for the followings: \begin{itemize} \item Order of float objects; in \pLaTeX/\upLaTeX, @@ -182,7 +183,7 @@ original \LaTeX, except for the followings: % [TODO] 他にもあるか? \end{itemize} %%% developer レベルでは pdfTeX 拡張や pLaTeX カーネルでムニャムニャ -For developers, additional cares may be needed, +For developers, additional care may be needed, for changes in the kernel macros and/or absence of \pdfTeX\ features. %%% 際立った pTeX 系列の特徴 @@ -192,7 +193,7 @@ The most important characteristics of \pTeX/\upTeX\ can be summarized as follows: %%% 欧文と和文が別個に存在する・縦組がある \begin{itemize} - \item Japanese characters are interpret and handled completely apart from + \item Japanese characters are interpreted 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'' (横組), @@ -211,20 +212,83 @@ summarized as follows: \section{Output format --- DVI} %%% DVI だけ -The output of \pTeX/\upTeX\ is always a DVI file. +The output of \pTeX\ family is always a DVI file. +This is in contrast to the mainstream of \pdfTeX\ in the Western \TeX\ world. + +In case you are not familiar with DVI output processing, +first we give some general notice on how to get a ``correct'' output +using \LaTeX\ in DVI mode. + +\begin{itemize} + \item The DVI format is, as its name suggests, inherently driver-independent. + However, some \LaTeX\ packages (\Pkg{graphicx}, \Pkg{color}, \Pkg{hyperref} etc.) + embed some \.{special} commands into the DVI, which can be interpreted later + by some specific DVI driver. + Such a DVI is no longer driver-independent, thus those are called + driver-dependent packages. + \item In almost all major \TeX\ distributions (of course including \TL), + the default DVI driver is set to |dvips|. + When you choose to process the resulting DVI file with a driver + other than dvips (e.g. dvipdfmx) after running \LaTeX, + you need to pass a proper driver option (e.g. |[dvipdfmx]|) to + all driver-dependent packages. +\end{itemize} + +%%% 日本の DVI ドライバの状況 +Now, let's move on to the situation in Japan, +which is slightly complicated due to historical reasons +but may also apply to other countries: +\begin{itemize} + \item There are two major conventions to pass a proper driver option + to all driver-dependent packages: + \begin{enumerate} + \item To give a driver option to each driver-dependent package: +\begin{verbatim} +\documentclass{article} +\usepackage[dvipdfmx]{graphicx} +\usepackage[dvipdfmx]{color} +\end{verbatim} + \item To have a driver option as global: +\begin{verbatim} +\documentclass[dvipdfmx]{article} +\usepackage{graphicx} +\usepackage{color} +\end{verbatim} + \end{enumerate} + The former convention has been used for many years since 1990s + when the number of driver-dependent packages was limited. + But in recent years (around 2010--), there are much more + driver-dependent packages available. Thus + we (Japanese \TeX\ experts) advise a global driver option + rather than individual package options for simplicity, + but not yet fully widespread.\footnote{The fact that + there had been a mismatch in option names + (\code{[dvipdfm]} vs. \code{[dvipdfmx]}) + between packages may also have been part of it; + \Pkg{geometry} did not understand \code{[dvipdfmx]} option until 2018!} + \item Many people still see driver options as ``optional''; + they do without driver options unless really needed. + For example, the convention of having a global driver option + does no harm even when no driver-dependent package is used, but + some users choose to omit a driver option to avoid a warning: +\begin{verbatim} +LaTeX Warning: Unused global option(s): + [dvipdfmx]. +\end{verbatim} +\end{itemize} + +\subsection{Extensions of DVI format in \pTeX\ family} + %%% pTeX の DVI は欧文の横組みだけなら普通。和文が入ると特殊,縦組ならIDも変化 -Its DVI format is completely compatible with Knuthian \TeX, -as long as the following conditions are met: +The DVI format output by \pTeX\ family is fully 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. +However, some additional DVI commands, which are defined in the +standard \cite{dvistd0} but never used in \TeX82, can come out. \begin{itemize} \item |set2| (129), |put2| (134): Appears in both \pTeX\ and \upTeX\ DVI. @@ -254,37 +318,23 @@ 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 +There are some DVI drivers with Japanese support. +The most eminent drivers are \emph{dvips} and \emph{dvipdfmx}. +Nowadays most of casual Japanese users are using \emph{dvipdfmx} as a DVI driver. +On the other hand, users of \emph{dvips} are unignorable, especially those working in publishing industry. +In recent years, most of major driver-dependent packages support +both two drivers. -\subsubsection{Using {\em dvipdfmx}} +\subsubsection{Using \emph{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}} +\subsubsection{Using \emph{dvips}} A DVI file which is output by \pTeX\ can be converted to a PostScript file using dvips. @@ -302,17 +352,65 @@ developed by Japanese \TeX\ Development Community. We focus on programming aspects of \pTeX\ and its variants. %%% レジスタの数 -\subsection{Number of registers} +\subsection{Number of registers and marks} \pTeX\ and \upTeX\ have exactly the same number ($=256$) of registers -as Knuthian \TeX. +(count, dimen, skip, muskip, box, and token) as Knuthian \TeX. \epTeX\ and \eupTeX\ in extended mode have more registers; there are 65536, which is twice as many as 32768 of \eTeX. +Similarly \epTeX\ and \eupTeX\ have 65536 mark classes, +which is twice as many as 32768 of \eTeX. -% [TODO] まとめて 65536 個と書いて良い? レジスタの種類毎に書くべき? +The following code presents an example of detecting the number of +regsiters and mark classes available: +\begin{verbatim} + \ifx\eTeXversion\undefined + % Knuthian TeX, pTeX, upTeX: + % 256 registers, 1 mark + \else + \ifx\omathchar\undefined + % e-TeX, pdfTeX (in extended mode): + % 32768 registers, 32768 mark classes + \else + % e-pTeX, e-upTeX (in extended mode): + % 65536 registers, 65536 mark classes + \fi + \fi +\end{verbatim} +Here a primitive \.{omathchar}, which is derived from \OMEGA, is used +as a marker of a change file \code{fam256.ch}.\footnote{% +There is another \pTeX-derived engine named \pTeX-ng (or Asiatic \pTeX) +\url{https://github.com/clerkma/ptex-ng}; it is based on +\eTeX\ and \upTeX, but currently does not adopt \code{fam256.ch} +so it has the same number of registers and mark classes as \eTeX.} + +%%% 数式ファミリの数 +\subsection{Number of math families} + +In \pTeX\ and \upTeX, +the number of math fonts is restricted to 16, +each of which can contain 256 characters (same as Knuthian \TeX). +In \epTeX\ and \eupTeX, a change file \code{fam256.ch}, +which is derived from \OMEGA, extends the upper limit to 256. +As a consequence, \epTeX\ and \eupTeX\ allows 256 math fonts, +each of which can contain 256 characters.\footnote{\OMEGA\ allows +256 math fonts, each of which can contain 65536 characters.} + +For \pLaTeX/\upLaTeX\ users to use more than 16 math fonts, +it is necessary to use macros which exploit \OMEGA-derived primitives +such as \.{omathchar}. +Recent (u)\pLaTeX\ (since 2016/11/29) partially supports this, +and the maximum number of math alphabets that can be defined by +|\DeclareMathAlphabet| is extended to 256 (|\e@mathgroup@top|) +without needing any extension package. +However, symbol fonts are restricted to 16 as +|\DeclareMathSymbol| etc still use the standard \.{mathchar} etc. +A simple solution to use more symbol fonts as well as math alphabets +is to load a package \Pkg{mathfam256}\footnote{% +\url{https://www.ctan.org/pkg/mathfam256}} though it's still preliminary. %%% 拡張プリミティブ -\subsection{Additional primitives} +\subsection{Additional primitives and keywords} % tex -ini: 322 multiletter control sequences % ptex -ini: 366 multiletter control sequences % uptex -ini: 374 multiletter control sequences @@ -325,7 +423,7 @@ there are 65536, which is twice as many as 32768 of \eTeX. 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. +The features of each primitive can be found in Japanese edition. % [TODO] 抜けがないか? % [TODO] アルファベット順に正しく並んでいるか? @@ -410,6 +508,8 @@ Knuthian \TeX; however, it is enabled in \pTeX\ family. %%% その他の独自拡張 \subsubsection{\epTeX\ additions (available in \epTeX, \eupTeX)} \begin{simplelist} + \csitem[\.{currentspacingmode} \New{191112 (\TL2020)}] + \csitem[\.{currentxspacingmode} \New{191112 (\TL2020)}] \csitem[\.{epTeXinputencoding} \New{160201 (\TL2016)}] \csitem[\.{epTeXversion} \New{180121 (\TL2018)}] \csitem[\.{expanded} \New{180518 (\TL2019)}] @@ -446,10 +546,18 @@ Knuthian \TeX; however, it is enabled in \pTeX\ family. \csitem[\.{pdfstrcmp}] \csitem[\.{pdfuniformdeviate} \New{161114 (\TL2017)}] \csitem[\.{readpapersizespecial} \New{180901 (\TL2019)}] + \csitem[\.{Uchar} \New{191112 (\TL2020)}] + \csitem[\.{Ucharcat} \New{191112 (\TL2020)}] \csitem[\.{vfi}] \csitem[\texttt{fi}\index{fi=\texttt{fi}}] \end{simplelist} +%%% e-upTeX の独自拡張 +\subsubsection{\eupTeX\ additions (available in \eupTeX)} +\begin{simplelist} + \csitem[\.{currentcjktoken} \New{191112 (\TL2020)}] +\end{simplelist} + % [TODO] 引数は何で返り値は何か,expandable? %%% (e-)TeX にあるが (e-)upTeX にないもの @@ -462,7 +570,7 @@ 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 も参照 +% [TODO] Please also refer to ptex.man1.pdf \subsection{Behavior of Western \TeX\ primitives} @@ -478,7 +586,6 @@ other codes will give an error ``! Bad character code.'' |\sfcode|, |\mathcode|, |\delcode|, - |\mathchardef|, |\lccode|, |\uccode|. \end{quote} @@ -501,6 +608,7 @@ The following primitives are extended to support Japanese characters: \.{chardef} =] In addition to 0--255, internal codes of Japanese characters are allowed. For putting Japanese characters, a Japanese font is chosen. + More information can be found in \ref{chardef}. \csitem[\.{font}, \.{fontname}, \.{fontdimen}] % [TODO] @@ -525,14 +633,16 @@ If either token is a control sequence, 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, +However, this includes a lie; in the real implementation of \code{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 +Here we provide some code examples which may be useful for package developers. +% [TODO] 本当は Based on the above knowledge としたいところだが +% 説明が圧倒的に不足しているので天下り的なコード解説… %%% pTeX かどうかの判定 \subsubsection{Detecting \pTeX} @@ -542,23 +652,210 @@ 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 + % pTeX / upTeX / e-pTeX / e-upTeX + \fi +\end{verbatim} + +%%% upTeX かどうかの判定 +\subsubsection{Detecting \upTeX} + +\upTeX/\eupTeX\ are almost upward compatible +with \pTeX/\epTeX\ respectively, however, +there are two major differences: +\begin{enumerate} + \item Improvements in the \.{kcatcode} business, + mainly for better handling of Latin-1 characters and CJK tokens. + \item Unicode as the default internal kanji encoding, + for direct use of its huge character set. +\end{enumerate} + +The first difference can be detected by checking if +\.{...cjktoken} primitive is defined. +\begin{verbatim} + \ifx\enablecjktoken\undefined + \else + % upTeX/e-upTeX \fi \end{verbatim} -% [TODO] upTeX 系列は \enablecjktoken か \ucs か? -% [TODO] \forcecjktoken は比較的新しい? -% [TODO] 内部コードが uptex かどうかの判定 +The second difference can be detected by checking if +the character \code{0x2121} (fullwidth space in JIS encoding) +is stored as \hex{3000} internally. +\begin{verbatim} + \ifx\kanjiskip\undefined + \else + \ifnum\jis"2121="3000 + % upTeX/e-upTeX with internal Unicode + \else + % pTeX/e-pTeX + % or, upTeX/e-upTeX with internal EUC-JP or Shift-JIS + \fi + \fi +\end{verbatim} +Please note that +the format-build setting of \verb+-kanji-internal=(sjis|euc)+ with +\upTeX\ makes it effectively \pTeX\ regarding the character set, +which means that only JIS~X~0208 character set is supported. %%% pTeX のバージョン判定 +% [TODO] 何が有用? + +%%% 大きな定数を定義する話 +\subsubsection{Defining large integer constants} +\label{chardef} + +According to \cite{topic} (Section 3.3), +\begin{quote} +A control sequence that has been defined with a \.{chardef} command +can also be used as a . +This fact is used in allocation commands such as |\newbox|. +Tokens defined with \.{mathchardef} can also be used this way. +\end{quote} +Here is the list of primitives which can be used for this purpose +in \pTeX\ family: +\begin{simplelist} + \csitem[\.{chardef} =] + Defines a control sequence to be a synonym for + \.{char} . + + \csitem[\.{kchardef} = (for \upTeX/\eupTeX)] + Defines a control sequence to be a synonym for + \.{kchar} . + + \csitem[\.{mathchardef} =<15-bit number>] + Defines a control sequence to be a synonym for + \.{mathchar} <15-bit number>. + + \csitem[\.{omathchardef} =<27-bit number> (for \epTeX/\eupTeX)] + Defines a control sequence to be a synonym for + \.{omathchar} <27-bit number>. +\end{simplelist} + +The first two (\.{chardef} and \.{kchardef}) are usable only when +the integer being defined is in the range of valid character codes, +which is not necessarily continuous (see \ref{kanji-internal}). +The most efficient and convenient way of defining integer constants +is as follows: +\begin{itemize} + \item 0--255: \.{chardef} + % "FF = 255 + \item 256--32767: \.{mathchardef} + % "7FFF = 32767 + \item 32768--134217727: \.{omathchardef} (only for \epTeX/\eupTeX) + % "7FFFFFF = 134217727 + \item (optional) 256--2147483647: \.{chardef} (only for \upTeX/\eupTeX) + % "7FFFFFFF = 2147483647 (+1 => ! Number too big.) +\end{itemize} + +%%% 指定のコードの和文トークンを得る方法 +\subsubsection{Creating a Japanese character token with a specified code} + +Short version: +\begin{itemize} + \item With \epTeX~191112 or later (\TL2020), + you can use expandable primitives \.{Uchar} and \.{Ucharcat} + \item Otherwise, use the ``\.{kansuji} trick''. +\end{itemize} + +\paragraph{The ``\.{kansuji} trick''} +This is a modified version of the ``\.{lowercase} trick'' +available in \pTeX\ family. + +\begin{dangerous} +Short note on the ``\.{lowercase} trick'': +to create a character token with a specified code value between 0--255 +with Knuthian \TeX, the ``\.{lowercase} trick'' can be used; for example, +\begin{verbatim} + \begingroup + \lccode`\?=\mycount + \lowercase{\endgroup \def\X{?}} +\end{verbatim} +defines |\X| which expands to a character number |\mycount| +while the \.{catcode} of |?| (\the\catcode`\?) is preserved. +However, the trick cannot be applied to Japanese characters, +since \pTeX\ family does not support \.{lccode} outside 0--255. +\end{dangerous} + +\.{kansuji} is an expandable primitive like \.{number} or \.{romannumeral}, +and it converts an integer into its corresponding kanji notation +called ``kansuji'' (漢数字). The important point here is that +the number-kanji mapping can be altered by \.{kansujichar}. + +Example 1: equivalent to |\def\X{あ}| (JIS code \code{0x2422} is ``あ''): +\begin{verbatim} + \begingroup + \kansujichar1=\jis"2422 \xdef\X{\kansuji1} + \endgroup +\end{verbatim} + +Example 2: equivalent to |\def\日本{Japan}|. +\begin{verbatim} + \begingroup + \kansujichar5=\jis"467C\relax + \kansujichar6=\jis"4B5C\relax + \expandafter\gdef\csname\kansuji56\endcsname{Japan} + \endgroup +\end{verbatim} + +Since \.{kansujichar} accepts only Japanese character code, +the ``\.{kansuji} trick'' and the ``\.{lowercase} trick'' should be +used complementarily. + +\paragraph{\.{Uchar}, \.{Ucharcat}} +The ``\.{kansuji} trick'' above include an assignment of \.{kansujichar} +which is unexpandable. +\epTeX~191112 or later (\TL2020) provides expandable primitives +\.{Uchar} and \.{Ucharcat}, which are derived from \hologo{XeTeX}. + +\begin{simplelist} + \csitem[\.{Uchar} ] + Expands to a character token with specified slot . + \begin{itemize} + \item When an 8-bit number (0--255) is given, + it expands to a Latin character token with category code 12, + except for a space character (32) which has category code 10. + \item When a Japanese character code greater than 255 is given, + it expands to a Japanese character token with its current category code; + 16--18 for \epTeX, 16--19 for \eupTeX. + % [TODO] 本当は pTeX では和文文字トークン自体は \kcatcode を + % 持たないが,簡単のためまあいっか. + \end{itemize} + + \csitem[\.{Ucharcat} ] + Expands to a character token with slot and + specified. + \begin{itemize} + \item With \epTeX: + \begin{itemize} + \item Only 8-bit number (0--255) are allowed for ; + that is, only Latin characters can be generated. + \item The values allowed for are 1--4, 6--8, 10--13. + \end{itemize} + \item With \eupTeX: + \begin{itemize} + \item When is between 0--127, + only Latin characters can be generated. + Thus, the values allowed for are + 1--4, 6--8, 10--13. + \item When is between 128--255, + both Latin and Japanese characters can be generated + depending on the specified ; + 1--4, 6--8, 10--13: Latin character, + 16--19: Japanese character. + \item When is greater than 255, + only Japanese characters can be generated. + Thus, the values allowed for are + 16--19. + \end{itemize} + \end{itemize} +\end{simplelist} %%% 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. +\epTeX/\eupTeX\ are \emph{not} upward compatible with DVI mode of \pdfTeX. %%% pdfTeX の DVI モードにあって e-(u)pTeX にないプリミティブ %%% その他ムニャムニャ @@ -591,29 +888,112 @@ 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} +\subsection{Automatic insertion of glue and penalties} -Sometimes \pTeX\ family automatically inserts glues and penalties +Sometimes \pTeX\ family automatically inserts glue 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. - %%% 欧文とは別個 +\pTeX\ family can have 3 different ``current'' fonts at the same time; +a Latin font, a Japanese font for horizontal writing (``yoko-gumi''), +and a Japanese font for vertical writing (``tate-gumi''). +The first one is the same as in the Knuthian \TeX, +which is defined in a standard TFM format. +The latter two are specific to \pTeX\ family, which are defined +in a JFM (Japanese \TeX\ font metric) format.\footnote{% +A JFM is a modified version of the standard TFM. +It can be created by (u)pPLtoTF, and decoded by (u)pTFtoPL. +Please also refer to the man pages of these programs +(\code{ppltotf.man1.pdf} and \code{ptftopl.man1.pdf}).} + +While typesetting, \pTeX\ family automatically switches between +these 3 fonts, depending on the character code and the writing direction: +\begin{itemize} + \item For typesetting Latin characters, + the current Latin font shown by |\the\font| is selected. + \item For typesetting Japanese characters, + the current Japanese font suitable for the current writing direction + is selected. It is shown by |\the\jfont| for horizontal writing + and |\the\tfont| for vertical writing. +\end{itemize} + %%% \nullfont しても全部消えない +%%% 「和文 \nullfont」は和文フォントが一回もグローバルに +%%% 設定されていないとき = iniTeX 時しかない +In Knuthian \TeX, the primitive \.{nullfont} refers to an ``empty font'' +in which all characters are undefined. +However in \pTeX\ family, this is regarded as a Latin font +and there is no equivalent to ``Japanese \.{nullfont}'' by design. +To elaborate, it is possible \emph{only} when no Japanese font is +set globally, i.e. in ini\TeX\ mode. +Once a valid Japanese font is selected, there is no way of +selecting ``Japanese \.{nullfont}'' to discard all characters. + +Moreover, \pTeX\ and friends assume that each Japanese font +(except ``Japanese \.{nullfont}'' in ini\TeX\ mode) +contains all valid Japanese character code. +In other words, all Japanese fonts share the same character set +corresponding to the whole valid Japanese character code range.\label{jfont} + +\section{Other strange beasts} %%% 縦組は諦めよう +% [TODO] どこに書くか困ったので最後に:内部コードのアレな話 +\subsection{Internal kanji encodings}\label{kanji-internal} + +The is a union of the following two: +\begin{itemize} + \item Range of numbers between 0--255, and + \item Numbers allowed for internal code of Japanese characters. +\end{itemize} +The former is the same as Knuthian \TeX, but the latter is a problem. +In \upTeX/\eupTeX\ with \code{-kanji-internal=uptex} (default on), +the range is very simple: +\[ c \ge 0 \] +However in \pTeX/\epTeX, only legacy encodings (EUC-JP as |euc|, +or Shift-JIS as |sjis|) are available for \code{-kanji-internal}. +In this case, the range can be represented as follows: +\[ + c = 256c_1+c_2 \; (c_i\in C_i) +\] +where +\[ + \begin{cases} + C_1=C_2=\{\hex{a1},\dots,\hex{fe}\} & (\mathtt{euc}), \\ + C_1=\{\hex{81},\dots,\hex{9f}\}\cup\{\hex{e0},\dots,\hex{fc}\}, + C_2=\{\hex{40},\dots,\hex{7e}\}\cup\{\hex{80},\dots,\hex{fc}\} & (\mathtt{sjis}). + \end{cases} +\] +Therefore, the overall range of is \emph{not} continuous. + +To check whether an integer is a valid Japanese character code or not, +you can use \.{iffontchar} with \epTeX~190709 or later (\TL2020). +Suppose a count register |\mycount| stores an integer, you can do it as follows: +\begin{verbatim} + \iffontchar\jfont\mycount + % \mycount is a valid Japanese character code + \fi +\end{verbatim} +Here the primitive \.{jfont} is used merely as +a representative non-empty\footnote{This assumption is always safe after +one of the standard \pTeX\ formats (e.g. plain \pTeX, \pLaTeX) is loaded.} +Japanese font containing all valid Japanese character code (see \ref{jfont}). + + \newpage \begin{thebibliography}{99} \bibitem{dvistd0} TUG DVI Standards Working Group, \textit{The DVI Driver Standard, Level 0}.\\ \url{https://ctan.org/pkg/dvistd} + \bibitem{topic} Victor Eijkhout, \textit{\TeX\ by Topic, A \TeX nician's Reference}, + Addison-Wesley, 1992.\\ + \url{https://www.eijkhout.net/texbytopic/texbytopic.html} \end{thebibliography} \newpage diff --git a/info/ptex-manual/ptex-manual.pdf b/info/ptex-manual/ptex-manual.pdf index 219af34588..6c35fa4654 100644 Binary files a/info/ptex-manual/ptex-manual.pdf and b/info/ptex-manual/ptex-manual.pdf differ diff --git a/info/ptex-manual/ptex-manual.sty b/info/ptex-manual/ptex-manual.sty index 686d10998e..10b527e921 100644 --- a/info/ptex-manual/ptex-manual.sty +++ b/info/ptex-manual/ptex-manual.sty @@ -19,7 +19,8 @@ \leavevmode\par\nopagebreak} }{} -\def\emph#1{{\bfseries\sffamily\gtfamily\mathversion{bold}#1}} +\let\origemph=\emph +\def\emph#1{{\bfseries\sffamily\gtfamily\selectfont\mathversion{bold}#1}} \def\paragraph#1{\par\medskip\par\noindent\emph{■#1}\par\nobreak} \def\Pkg#1{\textsf{#1}} @@ -115,6 +116,7 @@ \bigskipamount=\baselineskip \medskipamount=.5\baselineskip \smallskipamount=.25\baselineskip + \clubpenalty=10000 \widowpenalty=9999 \divide\@tempdima by\dimexpr1zw\relax\@tempcnta=\@tempdima \leftskip=\dimexpr\textwidth-\@tempcnta zw\relax \@totalleftmargin\dimexpr\leftskip+0zw diff --git a/info/ptex-manual/ptex-manual.tex b/info/ptex-manual/ptex-manual.tex index 176624be85..f298c03870 100644 --- a/info/ptex-manual/ptex-manual.tex +++ b/info/ptex-manual/ptex-manual.tex @@ -1248,7 +1248,6 @@ p3.1.2で復活したという経緯がある.}. |\sfcode|, |\mathcode|, |\delcode|, - |\mathchardef|, |\lccode|, |\uccode| \end{quote} -- cgit v1.2.3