(少し予定変更。「練習問題」は明日の夜に掲載します。)
周知の通り、「ある程度新しい」pTeX は UTF-8 での入力が扱える。しかし、「ある程度古い」pTeX を使っている人の中には、今自分の使っている pTeX エンジン(ptex/platex コマンド)が UTF-8 入力に対応しているのかが解らなくて困っている人がいるかも知れない。以下では、簡単に、pTeX の「文字コードに関する性質」を調べる方法を説明する。
UTF-8 入力に対応しているか
今自分の使っている pTeX エンジン(ptex/platex コマンド)が UTF-8 での入力に対応しているかはヘルプ画面、すなわち ptex --help
を実行すれば解る。
Usage: ptex [OPTION]... [TEXNAME[.tex]] [COMMANDS] ……(省略)…… -fmt=NAME use NAME instead of program name or %&format. [-no]-guess-input-enc disable/enable to guess input file encoding -halt-on-error stop processing at the first error [-no]-file-line-error disable/enable file:line:error style messages -ini be iniptex. -interaction=STRING set interaction mode (STRING=batchmode|nonstopmode| scrollmode|errorstopmode) -ipc send DVI output to a socket as well as the usual output file -ipc-start as -ipc, and also start the server at the other end -jobname=STRING set the job name to STRING -kanji=STRING set Japanese encoding (STRING=euc|jis|sjis|utf8) -kanji-internal=STRING set Japanese internal encoding (STRING=euc|sjis) -kpathsea-debug=NUMBER set path searching debugging flags according to the bits of NUMBER [-no]-mktex=FMT disable/enable mktexFMT generation (FMT=tex/tfm) -mltex enable MLTeX extensions such as \charsubdef -output-comment=STRING use STRING for DVI file comment instead of date -output-directory=DIR use existing DIR as the directory to write files in [-no]-parse-first-line disable/enable parsing of first line of input file -progname=STRING set program (and fmt) name to STRING -recorder enable filename recorder [-no]-shell-escape disable/enable \write18{SHELL COMMAND} -shell-restricted enable restricted \write18 -sjis-terminal always output to stdout and stderr by CP932 -src-specials insert source specials into the DVI file -src-specials=WHERE insert source specials in certain places of the DVI file. WHERE is a comma-separated value list: cr display hbox math par parend vbox -synctex=NUMBER generate SyncTeX data for previewers if nonzero -translate-file=TCXNAME use the TCX file TCXNAME -help print this message and exit. -version print version information and exit. Email bug reports to ptex-staff@ml.asciimw.jp.
オプション一覧の中で、入力漢字コードを指定するものは
-kanji=STRING set Japanese encoding (STRING=euc|jis|sjis|utf8)
である。だから、この STRING
の選択肢の中に utf8
があれば、UTF-8 の入力が可能だということである。(で、その指定のためのオプションは当然 -kanji=utf8
である。)参考として、UTF-8 入力に非対応の pTeX の表示を挙げておく。
-kanji=STRING set Japanese encoding (STRING=euc|jis|sjis)
なお、もし platex-utf8
というコマンドがあるならば、それは platex -kanji=utf8
と同じ動作をする。(ptex
についても同様。)しかし、UTF-8 対応であっても platex-utf8
があるとは限らない。
入力漢字コード自動判定に対応しているか
自動判定を有効/無効にするオプションは -guess-input-enc
/-no-guess-input-enc
である。従って、オプション一覧に以下の行が存在すれば、対応していると判断できる。
[-no]-guess-input-enc disable/enable to guess input file encoding
既定の入力漢字コード
ptex -version
を実行する。
pTeX 3.1415926-p3.2 (sjis) (TeX Live 2012/dev/W32TeX) kpathsea version 6.1.0dev ……(省略)……
先頭行のバージョン番号の次に出ている「(sjis)
」が既定の入力文字コード。ただし、これが「(utf8.euc)
」のように2つ出ている場合は左側のものが入力文字コードである。((右側は内部文字コードで、これは -kanji-internal
で設定される。))
自動判定が既定で有効であるか
Kpathsearch の guess_input_kanji_encoding
変数の値を調べる。
> kpsewhich --var-value=guess_input_kanji_encoding
1
「1
」「t
」「y
」の何れかであれば有効、それ以外なら無効である。
upTeX がインストールされているか
インストールされていれば、uptex
や uplatex
のコマンドが存在するはずなので、uplatex -version
などを実行して確かめる。