├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── create_archive.sh ├── eptex_resume.pdf ├── eptex_resume.tex ├── eptexdoc.pdf ├── eptexdoc.tex ├── fam256d.tex ├── fam256p.tex ├── haranoaji.map ├── jfm.pdf ├── jfm.tex ├── jtex_asciimw.pdf ├── jtex_asciimw.tex ├── jtexdoc_asciimw.pdf ├── jtexdoc_asciimw.tex ├── ptex-guide-en.pdf ├── ptex-guide-en.tex ├── ptex-manual.pdf ├── ptex-manual.sty ├── ptex-manual.tex ├── ptexdoc_asciimw.pdf ├── ptexdoc_asciimw.tex ├── ptexskip_asciimw.pdf └── ptexskip_asciimw.tex /.gitignore: -------------------------------------------------------------------------------- 1 | ## Core latex/pdflatex auxiliary files: 2 | *.aux 3 | *.lof 4 | *.log 5 | *.lot 6 | *.fls 7 | *.out 8 | *.toc 9 | *.fmt 10 | 11 | ## Intermediate documents: 12 | *.dvi 13 | *-converted-to.* 14 | # these rules might exclude image files for figures etc. 15 | # *.ps 16 | # *.eps 17 | # *.pdf 18 | 19 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 20 | *.bbl 21 | *.bcf 22 | *.blg 23 | *-blx.aux 24 | *-blx.bib 25 | *.brf 26 | *.run.xml 27 | 28 | ## Build tool auxiliary files: 29 | *.fdb_latexmk 30 | *.synctex 31 | *.synctex.gz 32 | *.synctex.gz(busy) 33 | *.pdfsync 34 | 35 | ## Auxiliary and intermediate files from other packages: 36 | # algorithms 37 | *.alg 38 | *.loa 39 | 40 | # achemso 41 | acs-*.bib 42 | 43 | # amsthm 44 | *.thm 45 | 46 | # beamer 47 | *.nav 48 | *.snm 49 | *.vrb 50 | 51 | # cprotect 52 | *.cpt 53 | 54 | #(e)ledmac/(e)ledpar 55 | *.end 56 | *.[1-9] 57 | *.[1-9][0-9] 58 | *.[1-9][0-9][0-9] 59 | *.[1-9]R 60 | *.[1-9][0-9]R 61 | *.[1-9][0-9][0-9]R 62 | *.eledsec[1-9] 63 | *.eledsec[1-9]R 64 | *.eledsec[1-9][0-9] 65 | *.eledsec[1-9][0-9]R 66 | *.eledsec[1-9][0-9][0-9] 67 | *.eledsec[1-9][0-9][0-9]R 68 | 69 | # glossaries 70 | *.acn 71 | *.acr 72 | *.glg 73 | *.glo 74 | *.gls 75 | 76 | # gnuplottex 77 | *-gnuplottex-* 78 | 79 | # hyperref 80 | *.brf 81 | 82 | # knitr 83 | *-concordance.tex 84 | *.tikz 85 | *-tikzDictionary 86 | 87 | # listings 88 | *.lol 89 | 90 | # makeidx 91 | *.idx 92 | *.ilg 93 | *.ind 94 | *.ist 95 | 96 | # minitoc 97 | *.maf 98 | *.mtc 99 | *.mtc[0-9] 100 | *.mtc[1-9][0-9] 101 | 102 | # minted 103 | _minted* 104 | *.pyg 105 | 106 | # morewrites 107 | *.mw 108 | 109 | # mylatexformat 110 | *.fmt 111 | 112 | # nomencl 113 | *.nlo 114 | 115 | # sagetex 116 | *.sagetex.sage 117 | *.sagetex.py 118 | *.sagetex.scmd 119 | 120 | # sympy 121 | *.sout 122 | *.sympy 123 | sympy-plots-for-*.tex/ 124 | 125 | # pdfcomment 126 | *.upa 127 | *.upb 128 | 129 | #pythontex 130 | *.pytxcode 131 | pythontex-files-*/ 132 | 133 | # Texpad 134 | .texpadtmp 135 | 136 | # TikZ & PGF 137 | *.dpth 138 | *.md5 139 | *.auxlock 140 | 141 | # todonotes 142 | *.tdo 143 | 144 | # xindy 145 | *.xdy 146 | 147 | # xypic precompiled matrices 148 | *.xyc 149 | 150 | # WinEdt, Emacs 151 | *~ 152 | *.bak 153 | *.sav 154 | 155 | # endfloat 156 | *.ttt 157 | *.fff 158 | 159 | # Latexian 160 | TSWLatexianTemp* 161 | 162 | # tests 163 | tests/*.pdf 164 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2017-2025 Japanese TeX Development Community 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DOCTARGET = ptex-manual eptexdoc jfm \ 2 | ptex-guide-en 3 | # following documents are not maintained anymore; 4 | # even some descriptions might be different from 5 | # current status of pTeX 6 | # jtex_asciimw jtexdoc_asciimw 7 | # ptexdoc_asciimw ptexskip_asciimw 8 | # eptex_resume 9 | PDFTARGET = $(addsuffix .pdf,$(DOCTARGET)) 10 | DVITARGET = $(addsuffix .dvi,$(DOCTARGET)) 11 | KANJI = -kanji=utf8 12 | #FONTMAP = -f ipaex.map -f ptex-ipaex.map 13 | FONTMAP = -f ptex-haranoaji.map -f otf-haranoaji.map 14 | TEXMF = $(shell kpsewhich -var-value=TEXMFHOME) 15 | ifdef PLATEX 16 | PLATEX=${foo} 17 | else 18 | PLATEX=platex 19 | endif 20 | 21 | default: $(DVITARGET) 22 | all: $(PDFTARGET) 23 | 24 | ptex-manual.dvi: ptex-manual.tex 25 | $(PLATEX) $(KANJI) ptex-manual.tex 26 | $(PLATEX) $(KANJI) ptex-manual.tex 27 | # makeindex -s gind.ist -o ptex-manual.ind ptex-manual.idx 28 | mendex -U -s gind.ist -o ptex-manual.ind ptex-manual.idx 29 | $(PLATEX) $(KANJI) ptex-manual.tex 30 | rm -f *.aux *.log *.toc *.idx *.ind *.ilg *.out 31 | 32 | ptex-guide-en.dvi: ptex-guide-en.tex 33 | $(PLATEX) $(KANJI) ptex-guide-en.tex 34 | $(PLATEX) $(KANJI) ptex-guide-en.tex 35 | # makeindex -s gind.ist -o ptex-guide-en.ind ptex-guide-en.idx 36 | mendex -U -s gind.ist -o ptex-guide-en.ind ptex-guide-en.idx 37 | $(PLATEX) $(KANJI) ptex-guide-en.tex 38 | rm -f *.aux *.log *.toc *.idx *.ind *.ilg *.out 39 | 40 | eptexdoc.dvi: eptexdoc.tex fam256p.tex fam256d.tex 41 | $(PLATEX) $(KANJI) eptexdoc.tex 42 | $(PLATEX) $(KANJI) eptexdoc.tex 43 | mendex -U -s gind.ist eptexdoc.idx 44 | $(PLATEX) $(KANJI) eptexdoc.tex 45 | rm -f *.aux *.log *.toc *.idx *.ind *.ilg *.out 46 | 47 | .SUFFIXES: .tex .dvi .pdf 48 | .tex.dvi: 49 | $(PLATEX) $(KANJI) $< 50 | $(PLATEX) $(KANJI) $< 51 | $(PLATEX) $(KANJI) $< 52 | rm -f *.aux *.log *.toc 53 | .dvi.pdf: 54 | dvipdfmx $(FONTMAP) $< 55 | 56 | .PHONY: install clean 57 | install: 58 | mkdir -p ${TEXMF}/doc/ptex/ptex-manual 59 | cp ./LICENSE ${TEXMF}/doc/ptex/ptex-manual/ 60 | cp ./README* ${TEXMF}/doc/ptex/ptex-manual/ 61 | cp ./*.tex ${TEXMF}/doc/ptex/ptex-manual/ 62 | cp ./*.pdf ${TEXMF}/doc/ptex/ptex-manual/ 63 | clean: 64 | rm -f $(DVITARGET) $(PDFTARGET) 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ptex-manual 2 | 3 | This is a project of preparing a manual of Japanese pTeX and e-pTeX. 4 | 5 | ## Contents 6 | 7 | The following documents are maintained by Japanese TeX Development 8 | Community: 9 | 10 | * ptex-guide-en.pdf: Guide to pTeX and friends (in English) 11 | * ptex-manual.pdf: The manual of pTeX. 12 | * eptexdoc.pdf: The manual of e-pTeX. 13 | * jfm.pdf: Specification of JFM (Japanese Font Metric) format. 14 | 15 | This bundle also provides some old documents, which are no longer 16 | maintained by us: 17 | 18 | * jtex_asciimw.pdf: Report on Japanization of TeX. 19 | * jtexdoc_asciimw.pdf: Documentation of ASCII Nihongo TeX. 20 | * ptexdoc_asciimw.pdf: Application of TeX for publishing -- pTeX. 21 | * ptexskip_asciimw.pdf: Spacing arround math equations on pTeX. 22 | * eptex_resume.pdf: Report on development of e-pTeX. 23 | 24 | They are included for historical reasons only. Some descriptions 25 | may be inconsistent with the current versions of (e-)pTeX. 26 | 27 | ## Repository 28 | 29 | The bundle is maintained on GitHub: 30 | https://github.com/texjporg/ptex-manual 31 | 32 | ## License 33 | 34 | The bundle may be distributed and/or modified under the terms of 35 | the 3-clause BSD license (see [LICENSE](./LICENSE)). 36 | 37 | ## Release Date 38 | 39 | $RELEASEDATE 40 | 41 | Japanese TeX Development Community 42 | -------------------------------------------------------------------------------- /create_archive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PROJECT=ptex-manual 4 | TMP=/tmp 5 | LATESTRELEASEDATE=`git tag | sort -r | head -n 1` 6 | RELEASEDATE=`git tag --points-at HEAD | sort -r | head -n 1` 7 | 8 | if [ -z "$RELEASEDATE" ]; then 9 | RELEASEDATE="**not tagged**; later than $LATESTRELEASEDATE?" 10 | fi 11 | 12 | git archive --format=tar --prefix=$PROJECT/ HEAD | (cd $TMP && tar xf -) 13 | 14 | # Remove auxiliary files 15 | rm $TMP/$PROJECT/.gitignore 16 | rm $TMP/$PROJECT/create_archive.sh 17 | rm $TMP/$PROJECT/Makefile 18 | rm $TMP/$PROJECT/haranoaji.map 19 | perl -pi.bak -e "s/\\\$RELEASEDATE/$RELEASEDATE/g" $TMP/$PROJECT/README.md 20 | rm -f $TMP/$PROJECT/README.md.bak 21 | 22 | echo " * Create $PROJECT.zip" 23 | 24 | PWDF=`pwd` 25 | cd $TMP && zip -r $PWDF/$PROJECT.zip $PROJECT 26 | rm -rf $TMP/$PROJECT 27 | echo 28 | echo " * Done: $PROJECT.zip ($RELEASEDATE)" 29 | -------------------------------------------------------------------------------- /eptex_resume.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/eptex_resume.pdf -------------------------------------------------------------------------------- /eptexdoc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/eptexdoc.pdf -------------------------------------------------------------------------------- /fam256d.tex: -------------------------------------------------------------------------------- 1 | \begin{center} 2 | \Large\bfseries 3 | Test source for \texttt{FAM256} patch 4 | \end{center} 5 | 6 | 7 | 本ソースは山本和義氏による「数式famの制限とluatex」(qa:52744)中のコー 8 | ドをベースにしたものである. 9 | 10 | \bigskip 11 | 12 | \paragraph{More than 16 math font families.} 13 | \font\fontA=cmr10 14 | $ 15 | \mbfa{A} 16 | \mbfb{B} 17 | \mbfc{C} 18 | \mbfd{D} 19 | \mbfe{E} 20 | \mbff{F} 21 | \mbfg{G} 22 | \mbfh{H} 23 | \mbfi{I} 24 | \mbfj{J} 25 | \mbfk{K} 26 | \mbfl{L\ fam=\the\fam\ }$ 27 | 28 | $ 29 | \mbfaa{Aa} 30 | \mbfab{Ab} 31 | \mbfac{Ac} 32 | \mbfad{Ad} 33 | \mbfae{Ae} 34 | \mbfaf{Af} 35 | \mbfag{Ag} 36 | \mbfah{Ah} 37 | \mbfai{Ai} 38 | \mbfaj{Aj} 39 | \mbfak{Ak} 40 | \mbfal{Al} 41 | \mbfam{Am} 42 | \mbfan{An} 43 | \mbfao{Ao} 44 | \mbfap{Ap\ fam\the\fam\ } 45 | $ 46 | 47 | $ 48 | \mbfba{Aa} 49 | \mbfbb{Ab} 50 | \mbfbc{Ac} 51 | \mbfbd{Ad} 52 | \mbfbe{Ae} 53 | \mbfbf{Af} 54 | \mbfbg{Ag} 55 | \mbfbh{Ah} 56 | \mbfbi{Ai} 57 | \mbfbj{Aj} 58 | \mbfbk{Ak} 59 | \mbfbl{Al} 60 | \mbfbm{Am} 61 | \mbfbn{An} 62 | \mbfbo{Ao} 63 | \mbfbp{Ap\ fam\the\fam\ } 64 | $ 65 | 66 | $ 67 | \mbfca{Aa} 68 | \mbfcb{Ab} 69 | \mbfcc{Ac} 70 | \mbfcd{Ad} 71 | \mbfce{Ae} 72 | \mbfcf{Af} 73 | \mbfcg{Ag} 74 | \mbfch{Ah} 75 | \mbfci{Ai} 76 | \mbfcj{Aj} 77 | \mbfck{Ak} 78 | \mbfcl{Al} 79 | \mbfcm{Am} 80 | \mbfcn{An} 81 | \mbfco{Ao} 82 | \mbfcp{Ap\ fam\the\fam\ } 83 | $ 84 | 85 | $ 86 | \mbfda{Aa\ fam\the\fam\ } 87 | \mbfdb{Ab\ fam\the\fam\ } 88 | \mbfdc{Ac\ fam\the\fam\ } 89 | \mbfdd{Ad\ fam\the\fam\ } 90 | % 91 | \ \textfont255=\fontA \fam255 roman 92 | $ 93 | 94 | \medskip 95 | 96 | \paragraph{\.{omathchar}\ etc.} 97 | \omathcode`<="3460065 98 | \mathcode`>="4065 99 | \xdef\lx{\odelimiter"4450068"030001} 100 | \odelcode`[="410074"03000B 101 | ${\tt \verb|\mathchar"7F25|:\ }\mathchar"7F25,\ 102 | {\tt \verb|\omathchar"7420125|:\ } 103 | \omathchar"7420125$ 104 | 105 | {\tt meaning of \verb|\langle|:\ \meaning\langle}, 106 | 107 | {\tt meaning of \verb|\lx|:\ \meaning\lx} 108 | 109 | 110 | ${\tt \verb|\lx|:\ }\lx,\ 111 | {\tt \verb|\bigl\lx|:\ } \bigl\lx,\ 112 | {\tt \verb|\Bigl\lx|:\ } \Bigl\lx$ 113 | 114 | 115 | {\tt \verb+\the\mathcode`\f+:\ \cnttohex{\the\mathcode`\f}}, 116 | {\tt \verb+\the\omathcode`\f+:\ \cnttohex{\the\omathcode`\f}}(どちらも16進に 117 | 変換した) 118 | 119 | $\left[\right.\bigl[\Bigl[\Bigr)\bigr)) <>$ 120 | 121 | $\radical"270370{}$,\ $\oradical"460070"030074{} $\ 122 | $\radical"270370{a}$,\ $\oradical"460070"030074{a} $\ 123 | $\radical"270370{\int_V f\,d\mu}$,\ $\oradical"460070"030074{\int_V f\,d\mu} $ 124 | 125 | \medskip 126 | 127 | \.{odelcode} primitiveによる\emph{delimiter codeの取得}はうまく動かない:\\ 128 | {\tt \verb+\the\delcode`\|+:} ${\the\delcode`\|}$, 129 | {\tt \verb+\the\odelcode`\|+:} ${\the\odelcode`\|}$(どちらも10進) 130 | 131 | \medskip 132 | 133 | \paragraph{Infinite level ``fi''} 134 | \def\na{\hskip 0pt plus 1fi({\tt fi})\hskip 0pt plus 1fi} 135 | \def\nb{\hskip 0pt plus 1fil({\tt fil})\hskip 0pt plus 1fil} 136 | \def\nc{\hskip 0pt plus 1fill({\tt fill})\hskip 0pt plus 1fill} 137 | \def\nd{\hskip 0pt plus 1filll({\tt filll})\hskip 0pt plus 1filll} 138 | \fbox{\hbox to 14cm{■\na ■\nb ■\nc ■\nd ■}} 139 | 140 | \fbox{\hbox to 14cm{■\na ■\nb ■\nc ■}} 141 | 142 | \fbox{\hbox to 14cm{■\na ■\nb ■}} 143 | 144 | \fbox{\hbox to 14cm{■\na ■\na\na ■}} 145 | 146 | 147 | 148 | \paragraph{65536 registers} 149 | \leavevmode 150 | {\tracingall 151 | \setbox40000=\hbox to 10mm{fuga!}\copy40000 152 | {\setbox40000=\hbox to 10mm{a}\copy40000 153 | {\setbox40000=\hbox to 10mm{漢字仮名}\copy40000} 154 | \global\setbox40000=\hbox to 10mm{asdf}}\copy40000 155 | {\setbox40000=\hbox to 10mm{\TeX}\copy40000 156 | {\setbox40000=\hbox to 10mm{ほげほげ}\copy40000}\copy40000}} 157 | 158 | \count34656=465\count45486=124 159 | \advance\count34656 by\count45486 160 | \the\count34656\nonstopmode 161 | -------------------------------------------------------------------------------- /fam256p.tex: -------------------------------------------------------------------------------- 1 | \makeatletter 2 | \mathchardef\e@mathgroup@top=256 3 | \def\cnttohex#1{% 4 | {\count@=#1\@tempcnta=#1\@tempcntb=\@tempcnta\relax 5 | \divide\@tempcntb by 16% 6 | \ifnum\count@=0\else 7 | \multiply\@tempcntb by16% 8 | \advance\@tempcnta-\@tempcntb 9 | \divide\@tempcntb by16% 10 | \cnttohex{\the\@tempcntb}% 11 | \ifcase\@tempcnta\relax 0\or1\or2\or3\or4\or5\or6\or 12 | 7\or8\or9\or A\or B\or C\or D\or E\or F\fi 13 | \fi}} 14 | \makeatother 15 | 16 | 17 | 18 | \DeclareMathAlphabet{\mbfa}{OT1}{lmr}{m}{n} 19 | \DeclareMathAlphabet{\mbfb}{OT1}{lmr}{bx}{n} 20 | \DeclareMathAlphabet{\mbfc}{OT1}{lmr}{bx}{n} 21 | \DeclareMathAlphabet{\mbfd}{OT1}{lmr}{bx}{n} 22 | \DeclareMathAlphabet{\mbfe}{OT1}{lmr}{bx}{n} 23 | \DeclareMathAlphabet{\mbff}{OT1}{lmr}{bx}{n} 24 | \DeclareMathAlphabet{\mbfg}{OT1}{lmr}{bx}{n} 25 | \DeclareMathAlphabet{\mbfh}{OT1}{lmr}{bx}{n} 26 | \DeclareMathAlphabet{\mbfi}{OT1}{lmr}{bx}{n} 27 | \DeclareMathAlphabet{\mbfj}{OT1}{lmr}{bx}{n} 28 | \DeclareMathAlphabet{\mbfk}{OT1}{lmr}{bx}{n} 29 | \DeclareMathAlphabet{\mbfl}{OT1}{lmr}{bx}{n}% ここで15番 30 | 31 | \DeclareMathAlphabet{\mbfaa}{OT1}{lmtt}{m}{n} % 16 32 | \DeclareMathAlphabet{\mbfab}{OT1}{lmtt}{m}{n} 33 | \DeclareMathAlphabet{\mbfac}{OT1}{lmtt}{m}{n} 34 | \DeclareMathAlphabet{\mbfad}{OT1}{lmtt}{m}{n} 35 | \DeclareMathAlphabet{\mbfae}{OT1}{lmtt}{m}{n} 36 | \DeclareMathAlphabet{\mbfaf}{OT1}{lmtt}{m}{n} 37 | \DeclareMathAlphabet{\mbfag}{OT1}{lmtt}{m}{n} 38 | \DeclareMathAlphabet{\mbfah}{OT1}{lmtt}{m}{n} 39 | \DeclareMathAlphabet{\mbfai}{OT1}{lmtt}{m}{n} 40 | \DeclareMathAlphabet{\mbfaj}{OT1}{lmtt}{m}{n} 41 | \DeclareMathAlphabet{\mbfak}{OT1}{lmtt}{m}{n} 42 | \DeclareMathAlphabet{\mbfal}{OT1}{lmtt}{m}{n} 43 | \DeclareMathAlphabet{\mbfam}{OT1}{lmtt}{m}{n} 44 | \DeclareMathAlphabet{\mbfan}{OT1}{lmtt}{m}{n} 45 | \DeclareMathAlphabet{\mbfao}{OT1}{lmtt}{m}{n} 46 | \DeclareMathAlphabet{\mbfap}{OT1}{lmtt}{m}{n} 47 | 48 | \DeclareMathAlphabet{\mbfba}{OT1}{lmss}{m}{it} % 32 49 | \DeclareMathAlphabet{\mbfbb}{OT1}{lmss}{m}{it} 50 | \DeclareMathAlphabet{\mbfbc}{OT1}{lmss}{m}{it} 51 | \DeclareMathAlphabet{\mbfbd}{OT1}{lmss}{m}{it} 52 | \DeclareMathAlphabet{\mbfbe}{OT1}{lmss}{m}{it} 53 | \DeclareMathAlphabet{\mbfbf}{OT1}{lmss}{m}{it} 54 | \DeclareMathAlphabet{\mbfbg}{OT1}{lmss}{m}{it} 55 | \DeclareMathAlphabet{\mbfbh}{OT1}{lmss}{m}{it} 56 | \DeclareMathAlphabet{\mbfbi}{OT1}{lmss}{m}{it} 57 | \DeclareMathAlphabet{\mbfbj}{OT1}{lmss}{m}{it} 58 | \DeclareMathAlphabet{\mbfbk}{OT1}{lmss}{m}{it} 59 | \DeclareMathAlphabet{\mbfbl}{OT1}{lmss}{m}{it} 60 | \DeclareMathAlphabet{\mbfbm}{OT1}{lmss}{m}{it} 61 | \DeclareMathAlphabet{\mbfbn}{OT1}{lmss}{m}{it} 62 | \DeclareMathAlphabet{\mbfbo}{OT1}{lmss}{m}{it} 63 | \DeclareMathAlphabet{\mbfbp}{OT1}{lmss}{m}{it} 64 | 65 | \DeclareMathAlphabet{\mbfca}{OT1}{ptm}{m}{n} % 48 66 | \DeclareMathAlphabet{\mbfcb}{OT1}{ptm}{m}{n} 67 | \DeclareMathAlphabet{\mbfcc}{OT1}{ptm}{m}{n} 68 | \DeclareMathAlphabet{\mbfcd}{OT1}{ptm}{m}{n} 69 | \DeclareMathAlphabet{\mbfce}{OT1}{ptm}{m}{n} 70 | \DeclareMathAlphabet{\mbfcf}{OT1}{ptm}{m}{n} 71 | \DeclareMathAlphabet{\mbfcg}{OT1}{ptm}{m}{n} 72 | \DeclareMathAlphabet{\mbfch}{OT1}{ptm}{m}{n} 73 | \DeclareMathAlphabet{\mbfci}{OT1}{ptm}{m}{n} 74 | \DeclareMathAlphabet{\mbfcj}{OT1}{ptm}{m}{n} 75 | \DeclareMathAlphabet{\mbfck}{OT1}{ptm}{m}{n} 76 | \DeclareMathAlphabet{\mbfcl}{OT1}{ptm}{m}{n} 77 | \DeclareMathAlphabet{\mbfcm}{OT1}{ptm}{m}{n} 78 | \DeclareMathAlphabet{\mbfcn}{OT1}{ptm}{m}{n} 79 | \DeclareMathAlphabet{\mbfco}{OT1}{ptm}{m}{n} 80 | \DeclareMathAlphabet{\mbfcp}{OT1}{lmr}{bx}{n} 81 | 82 | \DeclareMathAlphabet{\mbfda}{OT1}{phv}{m}{n} % 64 83 | \DeclareMathAlphabet{\mbfdb}{OT1}{pcr}{m}{n} 84 | \DeclareMathAlphabet{\mbfdc}{OT1}{pag}{m}{n} 85 | \DeclareMathAlphabet{\mbfdd}{OT1}{ppl}{m}{n} 86 | 87 | -------------------------------------------------------------------------------- /haranoaji.map: -------------------------------------------------------------------------------- 1 | %% ptex-haranoaji-04.map 2 | rml 2004-H HaranoAjiMincho-Regular.otf 3 | rmlv 2004-V HaranoAjiMincho-Regular.otf 4 | gbm 2004-H HaranoAjiGothic-Medium.otf 5 | gbmv 2004-V HaranoAjiGothic-Medium.otf 6 | 7 | %% uptex-haranoaji-04.map 8 | urml UniJIS2004-UTF16-H HaranoAjiMincho-Regular.otf 9 | urmlv UniJIS2004-UTF16-V HaranoAjiMincho-Regular.otf 10 | ugbm UniJIS2004-UTF16-H HaranoAjiGothic-Medium.otf 11 | ugbmv UniJIS2004-UTF16-V HaranoAjiGothic-Medium.otf 12 | uprml-h UniJIS2004-UTF16-H HaranoAjiMincho-Regular.otf 13 | uprml-v UniJIS2004-UTF16-V HaranoAjiMincho-Regular.otf 14 | upgbm-h UniJIS2004-UTF16-H HaranoAjiGothic-Medium.otf 15 | upgbm-v UniJIS2004-UTF16-V HaranoAjiGothic-Medium.otf 16 | uprml-hq UniJIS-UCS2-H HaranoAjiMincho-Regular.otf 17 | upgbm-hq UniJIS-UCS2-H HaranoAjiGothic-Medium.otf 18 | 19 | %% otf-haranoaji.map 20 | % TEXT, 90JIS 21 | hminl-h H HaranoAjiMincho-Light.otf 22 | hminl-v V HaranoAjiMincho-Light.otf 23 | hminr-h H HaranoAjiMincho-Regular.otf 24 | hminr-v V HaranoAjiMincho-Regular.otf 25 | hminb-h H HaranoAjiMincho-Bold.otf 26 | hminb-v V HaranoAjiMincho-Bold.otf 27 | hgothr-h H HaranoAjiGothic-Regular.otf 28 | hgothr-v V HaranoAjiGothic-Regular.otf 29 | hgothb-h H HaranoAjiGothic-Bold.otf 30 | hgothb-v V HaranoAjiGothic-Bold.otf 31 | hgotheb-h H HaranoAjiGothic-Heavy.otf 32 | hgotheb-v V HaranoAjiGothic-Heavy.otf 33 | hmgothr-h H HaranoAjiGothic-Medium.otf 34 | hmgothr-v V HaranoAjiGothic-Medium.otf 35 | 36 | % TEXT, JIS04 37 | hminln-h H HaranoAjiMincho-Light.otf 38 | hminln-v V HaranoAjiMincho-Light.otf 39 | hminrn-h H HaranoAjiMincho-Regular.otf 40 | hminrn-v V HaranoAjiMincho-Regular.otf 41 | hminbn-h H HaranoAjiMincho-Bold.otf 42 | hminbn-v V HaranoAjiMincho-Bold.otf 43 | hgothrn-h H HaranoAjiGothic-Regular.otf 44 | hgothrn-v V HaranoAjiGothic-Regular.otf 45 | hgothbn-h H HaranoAjiGothic-Bold.otf 46 | hgothbn-v V HaranoAjiGothic-Bold.otf 47 | hgothebn-h H HaranoAjiGothic-Heavy.otf 48 | hgothebn-v V HaranoAjiGothic-Heavy.otf 49 | hmgothrn-h H HaranoAjiGothic-Medium.otf 50 | hmgothrn-v V HaranoAjiGothic-Medium.otf 51 | 52 | % CID 53 | otf-cjml-h Identity-H HaranoAjiMincho-Light.otf 54 | otf-cjml-v Identity-V HaranoAjiMincho-Light.otf 55 | otf-cjmr-h Identity-H HaranoAjiMincho-Regular.otf 56 | otf-cjmr-v Identity-V HaranoAjiMincho-Regular.otf 57 | otf-cjmb-h Identity-H HaranoAjiMincho-Bold.otf 58 | otf-cjmb-v Identity-V HaranoAjiMincho-Bold.otf 59 | otf-cjgr-h Identity-H HaranoAjiGothic-Regular.otf 60 | otf-cjgr-v Identity-V HaranoAjiGothic-Regular.otf 61 | otf-cjgb-h Identity-H HaranoAjiGothic-Bold.otf 62 | otf-cjgb-v Identity-V HaranoAjiGothic-Bold.otf 63 | otf-cjge-h Identity-H HaranoAjiGothic-Heavy.otf 64 | otf-cjge-v Identity-V HaranoAjiGothic-Heavy.otf 65 | otf-cjmgr-h Identity-H HaranoAjiGothic-Medium.otf 66 | otf-cjmgr-v Identity-V HaranoAjiGothic-Medium.otf 67 | 68 | % Unicode 90JIS 69 | otf-ujml-h UniJIS-UTF16-H HaranoAjiMincho-Light.otf 70 | otf-ujml-v UniJIS-UTF16-V HaranoAjiMincho-Light.otf 71 | otf-ujmr-h UniJIS-UTF16-H HaranoAjiMincho-Regular.otf 72 | otf-ujmr-v UniJIS-UTF16-V HaranoAjiMincho-Regular.otf 73 | otf-ujmb-h UniJIS-UTF16-H HaranoAjiMincho-Bold.otf 74 | otf-ujmb-v UniJIS-UTF16-V HaranoAjiMincho-Bold.otf 75 | otf-ujgr-h UniJIS-UTF16-H HaranoAjiGothic-Regular.otf 76 | otf-ujgr-v UniJIS-UTF16-V HaranoAjiGothic-Regular.otf 77 | otf-ujgb-h UniJIS-UTF16-H HaranoAjiGothic-Bold.otf 78 | otf-ujgb-v UniJIS-UTF16-V HaranoAjiGothic-Bold.otf 79 | otf-ujge-h UniJIS-UTF16-H HaranoAjiGothic-Heavy.otf 80 | otf-ujge-v UniJIS-UTF16-V HaranoAjiGothic-Heavy.otf 81 | otf-ujmgr-h UniJIS-UTF16-H HaranoAjiGothic-Medium.otf 82 | otf-ujmgr-v UniJIS-UTF16-V HaranoAjiGothic-Medium.otf 83 | 84 | % Unicode JIS04 85 | otf-ujmln-h UniJIS2004-UTF16-H HaranoAjiMincho-Light.otf 86 | otf-ujmln-v UniJIS2004-UTF16-V HaranoAjiMincho-Light.otf 87 | otf-ujmrn-h UniJIS2004-UTF16-H HaranoAjiMincho-Regular.otf 88 | otf-ujmrn-v UniJIS2004-UTF16-V HaranoAjiMincho-Regular.otf 89 | otf-ujmbn-h UniJIS2004-UTF16-H HaranoAjiMincho-Bold.otf 90 | otf-ujmbn-v UniJIS2004-UTF16-V HaranoAjiMincho-Bold.otf 91 | otf-ujgrn-h UniJIS2004-UTF16-H HaranoAjiGothic-Regular.otf 92 | otf-ujgrn-v UniJIS2004-UTF16-V HaranoAjiGothic-Regular.otf 93 | otf-ujgbn-h UniJIS2004-UTF16-H HaranoAjiGothic-Bold.otf 94 | otf-ujgbn-v UniJIS2004-UTF16-V HaranoAjiGothic-Bold.otf 95 | otf-ujgen-h UniJIS2004-UTF16-H HaranoAjiGothic-Heavy.otf 96 | otf-ujgen-v UniJIS2004-UTF16-V HaranoAjiGothic-Heavy.otf 97 | otf-ujmgrn-h UniJIS2004-UTF16-H HaranoAjiGothic-Medium.otf 98 | otf-ujmgrn-v UniJIS2004-UTF16-V HaranoAjiGothic-Medium.otf 99 | 100 | %% otf-up-haranoaji.map 101 | % TEXT, 90JIS 102 | uphminl-h UniJIS-UTF16-H HaranoAjiMincho-Light.otf 103 | uphminl-v UniJIS-UTF16-V HaranoAjiMincho-Light.otf 104 | uphminr-h UniJIS-UTF16-H HaranoAjiMincho-Regular.otf 105 | uphminr-v UniJIS-UTF16-V HaranoAjiMincho-Regular.otf 106 | uphminb-h UniJIS-UTF16-H HaranoAjiMincho-Bold.otf 107 | uphminb-v UniJIS-UTF16-V HaranoAjiMincho-Bold.otf 108 | uphgothr-h UniJIS-UTF16-H HaranoAjiGothic-Regular.otf 109 | uphgothr-v UniJIS-UTF16-V HaranoAjiGothic-Regular.otf 110 | uphgothb-h UniJIS-UTF16-H HaranoAjiGothic-Bold.otf 111 | uphgothb-v UniJIS-UTF16-V HaranoAjiGothic-Bold.otf 112 | uphgotheb-h UniJIS-UTF16-H HaranoAjiGothic-Heavy.otf 113 | uphgotheb-v UniJIS-UTF16-V HaranoAjiGothic-Heavy.otf 114 | uphmgothr-h UniJIS-UTF16-H HaranoAjiGothic-Medium.otf 115 | uphmgothr-v UniJIS-UTF16-V HaranoAjiGothic-Medium.otf 116 | 117 | % TEXT, JIS04 118 | uphminln-h UniJIS2004-UTF16-H HaranoAjiMincho-Light.otf 119 | uphminln-v UniJIS2004-UTF16-V HaranoAjiMincho-Light.otf 120 | uphminrn-h UniJIS2004-UTF16-H HaranoAjiMincho-Regular.otf 121 | uphminrn-v UniJIS2004-UTF16-V HaranoAjiMincho-Regular.otf 122 | uphminbn-h UniJIS2004-UTF16-H HaranoAjiMincho-Bold.otf 123 | uphminbn-v UniJIS2004-UTF16-V HaranoAjiMincho-Bold.otf 124 | uphgothrn-h UniJIS2004-UTF16-H HaranoAjiGothic-Regular.otf 125 | uphgothrn-v UniJIS2004-UTF16-V HaranoAjiGothic-Regular.otf 126 | uphgothbn-h UniJIS2004-UTF16-H HaranoAjiGothic-Bold.otf 127 | uphgothbn-v UniJIS2004-UTF16-V HaranoAjiGothic-Bold.otf 128 | uphgothebn-h UniJIS2004-UTF16-H HaranoAjiGothic-Heavy.otf 129 | uphgothebn-v UniJIS2004-UTF16-V HaranoAjiGothic-Heavy.otf 130 | uphmgothrn-h UniJIS2004-UTF16-H HaranoAjiGothic-Medium.otf 131 | uphmgothrn-v UniJIS2004-UTF16-V HaranoAjiGothic-Medium.otf 132 | -------------------------------------------------------------------------------- /jfm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/jfm.pdf -------------------------------------------------------------------------------- /jfm.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper,11pt,nomag]{jsarticle} 2 | \usepackage[textwidth=42zw,lines=40,truedimen,centering]{geometry} 3 | \usepackage{amsmath} 4 | \usepackage[defaultsups]{newpxtext} 5 | \usepackage[zerostyle=c,straightquotes]{newtxtt} 6 | \usepackage{newpxmath} 7 | 8 | % common 9 | \usepackage{ptex-manual} 10 | 11 | \usepackage{shortvrb} 12 | \MakeShortVerb*{|} 13 | 14 | \def\size#1{\mathit{#1}} 15 | 16 | \title{\emph{JFMファイルフォーマット}} 17 | \author{ASCII Corporation \& Japanese \TeX\ Development Community} 18 | \begin{document} 19 | \maketitle 20 | 21 | \emph{JFM (Japanese Font Metric)}は, 22 | \pTeX で和文フォントを扱うためのフォントメトリックであり, 23 | オリジナルの\TeX のTFM (\TeX\ Font Metric)に相当する. 24 | \pTeX と同じく株式会社アスキーによって開発され, 25 | この文書も\pTeX に付属していたものであるが,ここでは2018年以降に 26 | 日本語\TeX 開発コミュニティによって拡張されたJFMフォーマットに 27 | 基づいて説明する. 28 | 29 | なお,\pTeX の内部コードをUnicode化した\upTeX でも, 30 | JFMフォーマットの仕様は全く同じであり,ただ 31 | \node{char\_type}テーブルに文字コードを格納するときに 32 | JISコードを用いる(\pTeX の場合)か, 33 | UCS-4の下位3バイトを用いる(\upTeX の場合)かだけが異なる. 34 | 35 | \tableofcontents 36 | \clearpage 37 | 38 | \section{JFMファイルの構成}\label{jfm-format} 39 | 40 | JFMファイルのフォーマットは, 41 | 基本的にはTFMファイルのフォーマットに準拠しており, 42 | TFMを拡張した形になっている. 43 | ここでは,主にその拡張部分について説明を行い, 44 | その他の部分に関しては, 45 | \TeX\ the program等のTFMの説明を参照してもらいたい. 46 | 47 | JFMファイル全体の構成は, 48 | 表\ref{構成}(\pageref{構成}ページ)に示すとおりである. 49 | ここでTFMと異なるのは次の点である. 50 | \begin{enumerate} 51 | \item \node{char\_type}のテーブルが付け加えられたこと. 52 | \item \node{exten}の換わりに\node{glue}のテーブルが設けられたこと. 53 | \item 2に関連して,\node{lig\_kern}から\node{glue\_kern}テーブルへ変更されたこと. 54 | \item これらに伴い,先頭のファイル内の各部分を規定するパラメータ表が変更されている. 55 | また,オリジナルのTFMとの区別のために$\size{id}$を付加しており, 56 | 先頭の半ワード(2バイト)が横組用は11,縦組用は9である 57 | \footnote{欧文TFMの半ワードは$\size{lf}$すなわちファイルサイズであり, 58 | 11や9になることはない.}. 59 | \end{enumerate} 60 | 最初の7ワードは半ワード(=2バイト)ずつに区切られ, 61 | JFMファイルを構成する14個の要素のサイズが収められている 62 | \footnote{欧文TFMでは12個だが,JFMでは$\size{id}$と$\size{nt}$が増え, 63 | $\size{ne}$が$\size{ng}$に置き換わったため14個である.}. 64 | これらの値は,すべて$2^{15}$よりも小さい非負の値で, 65 | 次の条件を満たしていなければならない: 66 | \begin{align*} 67 | \size{bc} &= 0 \\ 68 | 0 &\leq \size{ec} \leq 255 \\ 69 | \size{lf} &= 7+\size{nt}+\size{lh}+(\size{ec}-\size{bc}+1)+\size{nw}+\size{nh} 70 | +\size{nd}+\size{ni}+\size{nl}+\size{nk}+\size{ng}+\size{np} 71 | \end{align*} 72 | ここで,$\size{bc}$と$\size{ec}$は最小・最大の文字タイプ番号, 73 | $\size{nt}$は\node{char\_type}テーブルに登録された文字の数(文字タイプ0も含む), 74 | $\size{nl}$と$\size{ng}$はそれぞれは\node{glue\_kern}テーブルと 75 | \node{glue}テーブルのサイズであり,その他の値はTFMを踏襲する. 76 | 77 | JFMファイルでもTFMファイルと同じく,拡張子は\code{.tfm}が用いられる. 78 | 79 | \subsection{\node{char\_type}テーブル} 80 | \pTeX では欧文\TeX よりはるかに多くの文字を扱う必要があるが, 81 | そのほとんどは漢字であり,それらは全て同一の寸法(全角幅)を持つ. 82 | また,括弧や句読点などの約物も種類が増えるが,こちらも 83 | 幾つかのパターンに分類すれば済む(例えば ``「'' と ``('' は同様に扱える). 84 | 85 | そこで,JFMフォーマットでは, 86 | 同一の文字幅,高さ,前後に挿入されるグルー等,「その文字が持つ属性全てが 87 | 同じもの」を1つの\emph{文字タイプ} (\node{char\_type})として, 88 | 欧文フォントの1文字と同様にして扱うようにしている. 89 | そして,文字コードと文字タイプとの対応付けを, 90 | この\node{char\_type}テーブルを使って行う. 91 | 92 | このテーブルの各エントリーは1ワード(=4バイト)で構成され, 93 | 上位3バイトに文字コード(符号位置),下位1バイトに文字タイプを持つ 94 | \footnote{文字コードを3バイトで持つのは,日本語\TeX{}開発コミュニティによる 95 | 新仕様.詳細は第\ref{jfm-new}節を参照.}. 96 | 文字コードは,それが16進数24bit(3バイト)で\code{0xABcdef}と表されるとき, 97 | \node{char\_type}テーブルには\code{cd ef AB}として格納される. 98 | テーブル内にはコードの値の順番に収められていなければならない. 99 | またこのテーブルの先頭には,デフォルトのインデックスとして 100 | 文字コード及び文字タイプの項が0のものが, 101 | 必ず1つ存在しなければならず,このテーブルに登録されていない文字は, 102 | 文字タイプが0として扱う. 103 | つまり,このデフォルト以外の文字幅,カーン等の属性を持つキャラクタ 104 | のコードとタイプが2番目以降のエントリーとして存在しなければならない. 105 | 106 | \subsection{\node{char\_info}テーブル} 107 | \node{char\_type}をインデックスとしてこのテーブルを 108 | 参照することにより,各\node{char\_type}の属性を検索する. 109 | 各テーブルへのインデックス等の情報を次の順番でパッキング 110 | して1ワードに収めてある. 111 | \begin{description}\itemindent=2zw 112 | \item[\node{width\_index} (8bits)] 113 | \node{width\_table}へのインデックス 114 | \item[\node{height\_index} (4bits)] 115 | \node{height\_table}へのインデックス 116 | \item[\node{depth\_index} (4bits)] 117 | \node{depth\_table}へのインデックス 118 | \item[\node{italic\_index} (6bits)] 119 | \node{italic\_table}へのインデックス 120 | \item[\node{tag} (2bits)] 121 | \node{remainder}をどのような目的で使うかを示す. 122 | \begin{description}\itemindent=1zw 123 | \item[$\size{tag}=0$] 124 | \node{remainder}の項は無効であり使用しないことを示す. 125 | \item[$\size{tag}=1$] 126 | \node{remainder}の項が\node{glue\_kern}への有効なインデックスであることを示す. 127 | \item[$\size{tag}=2, 3$] 128 | JFMでは使用していない. 129 | \end{description} 130 | \item[\node{remainder} (8bits)] 131 | \end{description} 132 | 133 | JFMでは$\size{bc}$は必ずゼロ\footnote{前節にあるとおり,文字コード及び 134 | 文字タイプの項が0のものが必ず1つ存在するため.}なので, 135 | 1つのJFMに含まれる\node{char\_info}は全部で$\size{ec}+1$ワードになる. 136 | 137 | % [TODO] char_info のサイズが ec+1 ということは, 138 | % 文字タイプは 0 から ec まで連続しなければならないのか? 139 | % (char_type テーブル内の文字コードの順序については説明があるが, 140 | % 文字タイプの連続性についてはどこにも明記されていない気がする…) 141 | 142 | \subsection{\node{glue\_kern}テーブル} 143 | 特定の文字タイプの組み合わせ時に挿入すべき\node{glue}又は\node{kern}を 144 | 簡単なプログラム言語によって指定する. 145 | 各命令は,以下の4バイトで構成される. 146 | \begin{description}\itemindent=2zw 147 | \item[第1バイト] (\node{skip\_byte}) 148 | \begin{itemize} 149 | \item 128より大きいとき\\ 150 | 現在のワードが\node{char\_info}から示された最初のワード 151 | である場合は,実際の\node{glue\_kern}プログラムが 152 | \node{glue\_kern}[$256\times\size{op\_byte}+\size{remainder}$]から 153 | 収められている(すなわち,再配置されている)ことを示す 154 | \footnote{再配置は,日本語\TeX{}開発コミュニティによって 155 | 新たにサポート.詳細は第\ref{jfm-new}節を参照.}. 156 | 最初のワードでない場合(すなわち,既に再配置先あるいは 157 | プログラムのステップを開始した後のワードである場合)は, 158 | その場でプログラムを終了する. 159 | \item 128のとき\\ 160 | このワードを実行してプログラムを終了する. 161 | \item 128より小さいとき\\ 162 | このワードを実行した後,次のステップまでスキップする 163 | ワード数を示す 164 | \footnote{スキップは,日本語\TeX{}開発コミュニティによって 165 | 新たにサポート.詳細は第\ref{jfm-new}節を参照.}. 166 | \end{itemize} 167 | \item[第2バイト] (\node{char\_type}) 168 | \begin{itemize} 169 | \item 次の文字の文字タイプが, 170 | このバイトで示す文字タイプ 171 | \footnote{ここに文字タイプが格納されるため, 172 | 文字タイプの上限は255なのである.}と同じ場合, 173 | 第3バイトの処理を実行し,プログラム終了. 174 | \item そうでなければ次のステップへ. 175 | \end{itemize} 176 | \item[第3バイト] (\node{op\_byte})\\ 177 | この値によってグルーを扱うかカーンを扱うかを規定するとともに, 178 | インデックスの一部を兼ねる 179 | \footnote{インデックスの一部を兼ねることで 180 | 256種類以上を扱う仕様は,日本語\TeX{}開発コミュニティによって 181 | 新たにサポート.詳細は第\ref{jfm-new}節を参照.}. 182 | \begin{itemize} 183 | \item 127以下の場合\node{glue}[$(\size{op\_byte}\times256+\size{remainder})\times 3$]のグルーを挿入. 184 | \item 128以上の場合\node{kern}[$(\size{op\_byte}-128)\times256+\size{remainder}$]のカーンを挿入. 185 | \end{itemize} 186 | \item[第4バイト] (\node{remainder})\\ 187 | 第3バイトにより規定される 188 | \node{glue}または\node{kern}へのインデックスの一部をなす. 189 | \end{description} 190 | 191 | \subsection{\node{glue}テーブル} 192 | 自然長,伸び長,縮み長の3ワードで1つのグルーを構成する 193 | (したがって,$ng$は必ず3の倍数となる). 194 | 各値は,$\mathrm{design size}\times2^{-20}$を単位として表す. 195 | \begin{description}\itemindent=2zw 196 | \item[第1ワード] width 197 | \item[第2ワード] stretch 198 | \item[第3ワード] shrink 199 | \end{description} 200 | 201 | \subsection{\node{param}テーブル} 202 | 一応,以下のように定義されている. 203 | \begin{description}\itemindent=2zw 204 | \item[\mbox{param[1]}] 205 | 文字の傾き (italic slant). 206 | \item[\mbox{param[2][3][4]}] 207 | 和文文字間に挿入するグルー(|\kanjiskip|)のデフォルト値. 208 | \item[\mbox{param[5]}] 209 | \pTeX{}でzhで参照される寸法. 210 | \item[\mbox{param[6]}] 211 | \pTeX{}でzwで参照される寸法. 212 | \item[\mbox{param[7][8][9]}] 213 | 和文文字と欧文文字間に挿入するグルー(|\xkanjiskip|)のデフォルト値. 214 | \end{description} 215 | \begin{dangerous} 216 | このように書かれているが,実際には 217 | \pTeX のzwは「文字タイプ0の文字の幅」, 218 | \pTeX のzhは「文字タイプ0の文字の高さと深さの和」である. 219 | 明示的に|\fontdimen|で取得する場合を除くと,JFMの\node{param}テーブルの 220 | 値が用いられる状況は限られている. 221 | % [TODO] 例えばいつ? 222 | % ptex-manual によると,\accent で和文文字をアクセントにした場合の 223 | % 上下位置補正に \fontdimen5 の値が用いられるらしい.他には? 224 | \end{dangerous} 225 | 226 | \subsection{日本語\TeX{}開発コミュニティによる新仕様}\label{jfm-new} 227 | 長らくJFMフォーマットは株式会社アスキーが開発した当初仕様のままであったが, 228 | 2018年1月から2月にかけ,日本語\TeX{}開発コミュニティは下記の3点につき 229 | JFMフォーマットの仕様を拡張した. 230 | \begin{enumerate} 231 | \item \node{char\_type}テーブルへの3バイトの文字コード格納 232 | \item \node{glue\_kern}テーブルでのスキップ(SKIP)コマンド使用 233 | \item \node{glue\_kern}テーブルでの再配置(rearrangement) 234 | \end{enumerate} 235 | 和文JFMでこれらの拡張機能が使われている場合は\pTeX~p3.8.0以上が必要である. 236 | % https://github.com/texjporg/tex-jp-build/issues/8 237 | % https://github.com/texjporg/tex-jp-build/pull/47 238 | 239 | また,2023年9月に「\node{glue\_kern}テーブルへの256種類以上の 240 | グルー又はカーンの格納」をサポートした. 241 | % https://github.com/texjporg/tex-jp-build/pull/162 242 | 243 | \subsubsection{\node{char\_type}テーブルへの3バイトの文字コード格納} 244 | \node{char\_type}テーブルの各エントリーは1ワード(=4バイト)で 245 | 構成されるが,オリジナルの仕様では 246 | \begin{itemize} 247 | \item 上位半ワードに文字コード(符号位置),下位半ワードに文字タイプを持つ 248 | \end{itemize} 249 | であった. 250 | \pTeX{}では内部処理にJISが用いられ,JFMで扱う文字コードは2バイトが 251 | 上限だったため十分であったが,\upTeX{}でBMP超えの3バイトの文字を 252 | JFMで扱うことができなかった.また,オリジナルの仕様では文字タイプ用に 253 | 下位半ワードが確保されている一方で,文字タイプの上限は255なので 254 | 実はその上位バイトは常に\code{00}であり,勿体なかった. 255 | 256 | そこで,日本語\TeX{}開発コミュニティの新仕様(2018年1月)では 257 | \begin{itemize} 258 | \item 上位3バイトに文字コード(符号位置),下位1バイトに文字タイプを持つ 259 | \item 文字コードは,それが16進数24bit(3バイト)で\code{0xABcdef}と 260 | 表されるとき,テーブルには\code{cd ef AB}として格納される 261 | \end{itemize} 262 | とした.オリジナルの仕様で常に\code{00}だったバイトが 263 | 「実は文字コードの上位だった」と解釈することにして, 264 | 3バイト(U+10000以上)の文字コードで不足する1バイトを確保したのである. 265 | これにより,新仕様はオリジナルの仕様の上位互換であることが保証されている. 266 | 267 | \subsubsection{\node{glue\_kern}テーブルでのスキップ(SKIP)コマンド使用} 268 | 「スキップ」(\code{SKIP})は,元々アスキーの公式ページ 269 | \footnote{\texttt{https://asciidwango.github.io/ptex/tfm/jfm.html}} 270 | % 旧: http://ascii.asciimw.jp/pb/ptex/tfm/jfm.html 271 | に文書化されてはいたが,実際には(p)PLtoTFは\code{GLUEKERN}プロパティ内で 272 | \code{SKIP}命令を受け付けず,\pTeX{}もやはりJFMの\code{SKIP}命令を 273 | サポートしていなかった.2018年2月の日本語\TeX{}開発コミュニティの改修により, 274 | 新たにサポートが開始された. 275 | 276 | \subsubsection{\node{glue\_kern}テーブルでの再配置(rearrangement)} 277 | 「再配置」は,サイズが256を超える大きな\node{glue\_kern}テーブルを 278 | 格納するための方策であり,欧文TFMの\node{lig\_kern}テーブルにおける 279 | それと同様である.2018年2月に日本語\TeX{}開発コミュニティによって, 280 | \pTeX{}及びpPLtoTFで新たにサポートされた. 281 | 282 | \subsubsection{\node{glue\_kern}テーブルへの256種類以上のグルー又はカーンの格納} 283 | 上記の「再配置」サポートによってグルーやカーンを挿入する文字の組み合わせを 284 | 多種類定義できるようになったが,依然そのグルーやカーンの寸法は256種類に 285 | 限られていた.これは従来のJFMでインデックスを第4バイト(\node{remainder})のみで 286 | 「\node{glue}[$\size{remainder}\times 3$]のグルー」 287 | 「\node{kern}[$\size{remainder}$]のカーン」 288 | と規定していたためである. 289 | 欧文TFMの\node{lig\_kern}テーブルでは5,000種類のカーンを扱えたので, 290 | 2023年9月以降の日本語\TeX{}開発コミュニティの改修でこれを取り入れ, 291 | 第3バイト(\node{op\_byte})も活用してインデックスの範囲を増やした. 292 | 293 | \subsection{JFMフォーマットの制約事項} 294 | 295 | 冒頭に述べたとおり,文字タイプ(\node{char\_type})の上限は255であり, 296 | それに伴い可能な字幅も最大256種類しか許されない(さらに同じ字幅でも 297 | \node{glue}又は\node{kern}の挿入規則を変える場合はその分減る). 298 | しかし,実際のフォントでは字幅が256種類を超えることもあり, 299 | そのような時にJFMフォーマットは使用できない. 300 | 301 | 例として,OTFパッケージ(japanese-otf) \cite{jotf}が提供する 302 | 「ヒラギノフォントのプロポーショナル仮名を使う|\propshape|命令」では 303 | \begin{itemize} 304 | \item 組版時に使われる\code{(up)phiraminw3-h.tfm}などの 305 | 「(u)\pTeX 用JFM」は,約物類とプロポーショナル仮名のみに対応する 306 | ので,字幅が256種類以内 307 | \item VFを介して実際のフォントに割り当てられる 308 | \code{hiramin-w3-h.tfm}などの「DVIドライバ用JFM」は, 309 | Adobe-Japan1-5の20{,}317文字を全てCIDコード順に実際のフォントに 310 | 即して定義しようとして,字幅が256種類を超えてしまう 311 | \end{itemize} 312 | という状況になっており,後者はJFMフォーマットで定義できない. 313 | 314 | 一方で,\OMEGA で使われるOFMフォーマットは最大65{,}536種類の字幅を 315 | 定義でき,かつ主要なDVIドライバ(\code{dvipdfmx}, \code{dvips})は 316 | JFMとOFMの両方に対応している. 317 | そこで\emph{あくまで回避策であるが},(u)\pTeX 用JFMはそのままに, 318 | 機能しないDVIドライバ用JFMの代わりに「正しい字幅を定義したOFM」を 319 | 用意して\code{dvipdfmx}や\code{dvips}に優先的に使わせるという方法が 320 | 長らく用いられてきた.OTFパッケージが提供するOFMファイル群(|\CID|で 321 | 使われる\code{otf-cjmr-h.ofm}\footnote{実はこちらは字幅が256種類 322 | 以内であり,JFMフォーマットで十分対応できるが.}や|\propshape|で 323 | 使われる\code{hiramin-w3-h.ofm}など)はこの目的で用意されている\cite{cidofm}. 324 | % メモ:\def\xspace{} 325 | % * OTFパッケージの|\CID|, |\propshape|では 326 | % DVIドライバ用JFMに割り当てるCMapは恒等変換|Identity-{H,V}|を指定 327 | % * \TL~2021以前の\code{dvips}では, 328 | % 回避策として用意された縦組用OFMがかえって邪魔となり不正な出力になった 329 | % (\code{-noomega}でOFMを無視する必要があった)が, 330 | % \TL~2022以降は「OFMの|FONTDIR RT|をJFMの|DIRECTION TATE|と同等に扱う」 331 | % という改修を入れており, 332 | % \code{otf-cj**-v.ofm}や\code{hira***-w*-v.ofm}もそれを利用するようにした 333 | 334 | 335 | % -- tables begin 336 | \DeleteShortVerb{|} 337 | \begin{table}[tbp]\small 338 | \caption{JFMファイルの構成\label{構成}} 339 | \begin{minipage}[b]{2in} 340 | \begin{tabular}{|c|c|} \hline 341 | \hbox to.8in{\hfil$\size{id}$\hfil} & 342 | \hbox to.8in{\hfil$\size{nt}$\hfil} \\ \hline 343 | $\size{lf}$ & $\size{lh}$ \\ \hline 344 | $\size{bc}$ & $\size{ec}$ \\ \hline 345 | $\size{nw}$ & $\size{nh}$ \\ \hline 346 | $\size{nd}$ & $\size{ni}$ \\ \hline 347 | $\size{nl}$ & $\size{nk}$ \\ \hline 348 | $\size{ng}$ & $\size{np}$ \\ \hline 349 | \multicolumn{2}{|c|}{} \\ 350 | \multicolumn{2}{|c|}{\node{header}} \\ 351 | \multicolumn{2}{|c|}{}\\ \hline 352 | \multicolumn{2}{|c|}{} \\ 353 | \multicolumn{2}{|c|}{\node{char\_type}} \\ 354 | \multicolumn{2}{|c|}{}\\ \hline 355 | \multicolumn{2}{|c|}{}\\ 356 | \multicolumn{2}{|c|}{\node{char\_info}} \\ 357 | \multicolumn{2}{|c|}{}\\ \hline 358 | \multicolumn{2}{|c|}{}\\ 359 | \multicolumn{2}{|c|}{\node{width}} \\ 360 | \multicolumn{2}{|c|}{}\\ \hline 361 | \multicolumn{2}{|c|}{}\\ 362 | \multicolumn{2}{|c|}{\node{height}} \\ 363 | \multicolumn{2}{|c|}{}\\ \hline 364 | \multicolumn{2}{|c|}{}\\ 365 | \multicolumn{2}{|c|}{\node{depth}} \\ 366 | \multicolumn{2}{|c|}{}\\ \hline 367 | \multicolumn{2}{|c|}{}\\ 368 | \multicolumn{2}{|c|}{\node{italic}} \\ 369 | \multicolumn{2}{|c|}{}\\ \hline 370 | \multicolumn{2}{|c|}{}\\ 371 | \multicolumn{2}{|c|}{\node{glue\_kern}} \\ 372 | \multicolumn{2}{|c|}{}\\ \hline 373 | \multicolumn{2}{|c|}{}\\ 374 | \multicolumn{2}{|c|}{\node{kern}} \\ 375 | \multicolumn{2}{|c|}{}\\ \hline 376 | \multicolumn{2}{|c|}{}\\ 377 | \multicolumn{2}{|c|}{\node{glue}} \\ 378 | \multicolumn{2}{|c|}{}\\ \hline 379 | \multicolumn{2}{|c|}{}\\ 380 | \multicolumn{2}{|c|}{\node{param}} \\ 381 | \multicolumn{2}{|c|}{}\\ \hline 382 | \end{tabular} 383 | \end{minipage} 384 | \begin{minipage}[b]{3.3in} 385 | \noindent 386 | \begin{tabular}{l} 387 | $\size{id}=$ JFM\_ID number. ($=11$ for yoko, $9$ for tate) \\ 388 | $\size{nt}=$ number of words in the character type table. \\ 389 | $\size{lf}=$ length of the entire file, in words. \\ 390 | $\size{lh}=$ length of the header data, in words. \\ 391 | $\size{bc}=$ smallest character type in the font. ($=0$ for JFM) \\ 392 | $\size{ec}=$ largest character type in the font. \\ 393 | $\size{nw}=$ number of words in the width table. \\ 394 | $\size{nh}=$ number of words in the height table. \\ 395 | $\size{nd}=$ number of words in the depth table. \\ 396 | $\size{ni}=$ number of words in the italic correction table. \\ 397 | $\size{nl}=$ number of words in the glue/kern table. \\ 398 | $\size{nk}=$ number of words in the kern table. \\ 399 | $\size{ng}=$ number of words in the glue table. \\ 400 | $\size{np}=$ number of font parameter words. \\ 401 | \end{tabular} 402 | \end{minipage} 403 | \end{table} 404 | \MakeShortVerb*{|} 405 | % -- tables end 406 | \clearpage 407 | 408 | 409 | \section{JPLファイル}\label{jpl-format} 410 | 411 | TFMはバイナリ形式であるが,これをプロパティ(特性)という概念を使って 412 | テキスト形式で視覚化したものがPL (Property List)ファイルである. 413 | 同様に,JFMをテキスト形式で視覚化したものが 414 | \emph{JPL (Japanese Property List)}ファイルである. 415 | JPLファイルでもPLファイルと同じく,拡張子は\code{.pl}が用いられる. 416 | 417 | 和文用JPLに特有のプロパティとして,以下が存在する. 418 | 419 | \subsection{\code{CHARSINTYPE}} 420 | \code{CHARSINTYPE \codechar{1バイト長の整数} \codechar{任意個数の和文文字}}の 421 | 形式で,文字タイプ\node{char\_type}及びそれに属する文字コードを設定する. 422 | 以下に示すのは,開き括弧類を\node{char\_type}が1のグループに, 423 | 閉じ括弧類を\node{char\_type}が2のグループに指定する例である(最初の 424 | \code{O 1}と\code{O 2}はそれぞれ8進数の1,2). 425 | \begin{verbatim} 426 | (CHARSINTYPE O 1 427 | ( 〔 [ { 〈 《 「 『 【 428 | ) 429 | (CHARSINTYPE O 2 430 | ) 〕 ] } 〉 》 」 』 】 431 | ) 432 | \end{verbatim} 433 | 434 | なお,\codechar{任意個数の和文文字}は直接入力のほか16進数コード値で与える 435 | こともできる.JISコードの場合は\code{J}で始め,UCSコード(\upTeX 専用)の 436 | 場合は\code{U}で始める. 437 | 以下の指定は上の例と等価である(例えば\codechar{(}はJIS~0x214A). 438 | \begin{verbatim} 439 | (CHARSINTYPE O 1 440 | J 214A J 214C J 214E J 2150 J 2152 J 2154 J 2156 J 2158 J 215A 441 | ) 442 | (CHARSINTYPE O 2 443 | J 214B J 214D J 214F J 2151 J 2153 J 2155 J 2157 J 2159 J 215B 444 | ) 445 | \end{verbatim} 446 | 447 | \subsection{\code{TYPE}} 448 | \code{TYPE \codechar{1バイト長の整数} \codechar{プロパティリスト}}の 449 | 形式で,文字タイプ\node{char\_type}に含まれる文字の性質を定義する. 450 | 欧文用PLの\code{CHARACTER}プロパティに相当するが,利用可能な下位のプロパティは 451 | \begin{itemize} 452 | \item \code{CHARWD \codechar{実数値}}:文字の幅 453 | \item \code{CHARHT \codechar{実数値}}:文字の高さ 454 | \item \code{CHARDP \codechar{実数値}}:文字の深さ 455 | \item \code{CHARIC \codechar{実数値}}:文字のイタリック補正値 456 | \end{itemize} 457 | に限られる(\code{NEXTLARGER}と\code{VARCHAR}は使えない). 458 | 459 | 以下の例は,\pTeX の既定で使用している|min10.tfm|のソース|min10.pl|からの 460 | 抜粋である.|min10.tfm|のデザインサイズは10.0\,ptであるので,これは 461 | 文字タイプ0に含まれる文字の幅を9.62216\,pt,高さを7.77588\,pt, 462 | 深さを1.38855\,ptという定義である. 463 | \begin{verbatim} 464 | (TYPE O 0 465 | (CHARWD R 0.962216) 466 | (CHARHT R 0.777588) 467 | (CHARDP R 0.138855) 468 | ) 469 | \end{verbatim} 470 | 471 | \subsection{\code{GLUEKERN}} 472 | JFMの\node{glue\_kern}テーブルに収めるプログラムを記述する. 473 | 欧文用PLの\code{LIGTABLE}と似ているが,\code{LIG}の代わりに\code{GLUE}を 474 | 用いるところが異なる. 475 | % [TODO] 書きかけ 476 | 477 | \subsection{\code{DIRECTION}} 478 | \code{DIRECTION \codechar{文字列}}の形式で,日本語フォントの組方向を指定する. 479 | \codechar{文字列}の一文字目が|Y|であれば横組,|T|であれば縦組として扱う. 480 | 未指定の場合はデフォルトで横組として扱う. 481 | (u)\pTeX と一緒に標準で配布しているものは,横組用に 482 | \begin{verbatim} 483 | (DIRECTION YOKO) 484 | \end{verbatim} 485 | を,縦組用に 486 | \begin{verbatim} 487 | (DIRECTION TATE) 488 | \end{verbatim} 489 | を指定している. 490 | 491 | \clearpage 492 | 493 | 494 | \section{JFMを扱うプログラム}\label{jfm-program} 495 | 496 | \pTeX と\upTeX ,あるいはそれらが生成したDVIを扱うプログラムが 497 | JFMを扱うのは当然であるが,ここではJFMおよび関連するフォントフォーマットを 498 | 扱うことに特化したプログラムの主なものを挙げる. 499 | 500 | \subsection{pPLtoTF, upPLtoTF} 501 | 502 | テキスト形式のJPLファイルをバイナリ形式のJFMファイルに変換する.いずれも 503 | 欧文\TeX 用の\code{pltotf}の上位互換であり,入力ファイルが欧文用のPLファイルで 504 | あれば欧文用のTFMを生成し,和文用のJPLファイルであれば和文用のJFMを生成する. 505 | 506 | \code{ppltotf}と\code{uppltotf}の違いは,エンコーディングである. 507 | \begin{itemize} 508 | \item \code{ppltotf}: 常に\textbf{JIS}コードでエンコードされたJFMを生成するため, 509 | \pTeX 用のJFM生成には多くの場合\code{ppltotf}コマンドが用いられる. 510 | \item \code{uppltotf}: デフォルトでは\textbf{Unicode}(UCS-4の下位3バイト)で 511 | エンコードされたJFMを生成するため,主に\upTeX 用のJFM生成に用いられる. 512 | \end{itemize} 513 | 514 | \code{ppltotf}においては,\code{-kanji}オプションで 515 | 入力JPLファイルの文字コードを指定できる 516 | (有効な値は\code{euc}, \code{jis}, \code{sjis}, \code{utf8}). 517 | \code{uppltotf}でも\code{-kanji}オプションが同じく使えるが, 518 | 同時にJFMのエンコードもJISになる(従って\code{ppltotf}と同じ挙動を示す)ことに注意 519 | \footnote{\code{uppltotf}における規定値は\code{uptex}であり, 520 | この場合はJFMがUnicodeでエンコードされる.}. 521 | 522 | \subsection{pTFtoPL, upTFtoPL} 523 | 524 | バイナリ形式のJFMファイルをテキスト形式のJPLファイルに変換する.いずれも 525 | 欧文\TeX 用の\code{tftopl}の上位互換であり,入力ファイルが欧文用のTFMであれば 526 | 欧文用のPLファイルを生成し,和文用のJFMであれば和文用のJPLファイルを生成する. 527 | 528 | \code{ptftopl}と\code{uptftopl}の違いは,やはりエンコーディングである. 529 | \begin{itemize} 530 | \item \code{ptftopl}: 入力JFMファイルを常に\textbf{JIS}コードで解釈するため, 531 | \pTeX 用のJFMデコードには多くの場合\code{ptftopl}コマンドが用いられる. 532 | \item \code{uptftopl}: 入力JFMファイルをデフォルトでは\textbf{Unicode}で解釈するため, 533 | 主に\upTeX 用のJFMデコードに用いられる. 534 | \end{itemize} 535 | 536 | \code{ptftopl}においては,\code{-kanji}オプションで 537 | 出力JPLファイルの文字コードを指定できる 538 | (有効な値は\code{euc}, \code{jis}, \code{sjis}, \code{utf8}). 539 | \code{uptftopl}でも\code{-kanji}オプションが同じく使えるが, 540 | 同時にJFMもJISコードで解釈される(従って\code{ptftopl}と同じ挙動を示す)ことに注意 541 | \footnote{\code{uptftopl}における規定値は\code{uptex}であり, 542 | この場合はJFMがUnicodeで解釈される.}. 543 | 544 | \subsection{chkdvifont} 545 | 546 | \TeX~Live 2019で追加された比較的新しいコマンドであり, 547 | TFM/JFMファイルの簡単な情報を表示する機能を持つ(\OMEGA 用のOFMファイルにも対応). 548 | 549 | 実行例を示す(注意:ファイル名の拡張子は省略不可.また,ファイルが 550 | 現在のディレクトリにない場合は,フルパスの指定が必要). 551 | 552 | \paragraph{欧文TFMの場合} 553 | \begin{verbatim} 554 | $ chkdvifont cmr10.tfm 555 | "cmr10" is a tfm file : 0 -> 127 556 | checksum = 4BF16079 557 | design size = 10485760 2^{-20} points = 10 points 558 | \end{verbatim} 559 | 一行目の表示から, 560 | 欧文TFMであることと$\size{bc}=0$,$\size{ec}=127$であることが読み取れる. 561 | 562 | \paragraph{和文横組用JFMの場合} 563 | \begin{verbatim} 564 | $ chkdvifont jis.tfm 565 | "jis" is a jfm file : 0 -> 5 566 | checksum = 00000000 567 | design size = 10485760 2^{-20} points = 10 points 568 | \end{verbatim} 569 | 和文(横組用)JFMであることと$\size{bc}=0$,$\size{ec}=5$であることが読み取れる. 570 | 571 | \paragraph{和文縦組用JFMの場合} 572 | \begin{verbatim} 573 | $ chkdvifont upjisr-v.tfm 574 | "upjisr-v" is a jfm(tate) file : 0 -> 5 575 | checksum = 00000000 576 | design size = 10485760 2^{-20} points = 10 points 577 | \end{verbatim} 578 | 和文縦組用JFMであることと$\size{bc}=0$,$\size{ec}=5$であることが読み取れる 579 | \footnote{\code{upjisr-v.tfm}は\upTeX 用JFMであるが, 580 | 原理的に\pTeX 用と\upTeX 用のJFMは区別できない.}. 581 | 582 | \paragraph{和文JFMの拡張機能が使われている場合} 583 | 第\ref{jfm-new}節で述べたとおり,日本語\TeX 開発コミュニティによって 584 | 下記の4点につきJFMフォーマットの仕様が拡張されている. 585 | \begin{enumerate} 586 | \item \node{char\_type}テーブルへの3バイトの文字コード格納 587 | \item \node{glue\_kern}テーブルでのスキップ(SKIP)コマンド使用 588 | \item \node{glue\_kern}テーブルでの再配置(rearrangement) 589 | \item \node{glue\_kern}テーブルへの256種類以上のグルー又はカーンの格納 590 | \end{enumerate} 591 | もしこれらの拡張機能が使われていれば,情報として表示される 592 | (下の例は再配置あり): 593 | \begin{verbatim} 594 | $ chkdvifont upphiraminw3-h.tfm 595 | "upphiraminw3-h" is a jfm file : 0 -> 146 596 | New features in Community pTeX / JFM 2.0: 597 | + rearrangement in glue_kern 598 | checksum = 00000000 599 | design size = 10485760 2^{-20} points = 10 points 600 | \end{verbatim} 601 | 602 | \subsection{makejvf}\label{makejvf} 603 | 604 | JFMファイルを基にして,VF (virtual font)を生成するプログラムである. 605 | \code{makejvf}が生成する和文VFの目的は以下のとおりである: 606 | \begin{itemize} 607 | \item \pTeX や\upTeX で使われる多くのJFMでは,約物類(かっこ,句読点など)の文字幅を 608 | 半角幅として定義し,見た目の空白をグルーやカーンの挿入によって実現している. 609 | 例えば``(''のような左に空きがある括弧類は,左半分は文字の一部として扱わず, 610 | 「グルーによる半角分の右シフト」と「半角幅の\inhibitglue (」として扱っている. 611 | \item 一方,DVIからPostScriptやPDFへ変換時に使われる実際のフォントでは, 612 | 約物類も全角幅でデザインされている.そのため,DVIに配置された 613 | ``(''を実際のフォントの``(''に安直に置き換えると,想定よりも右にずれた 614 | 位置に出力されてしまう. 615 | \item この位置ずれを補正するため,欧文フォントの合成や置換に実用されている 616 | VF(仮想フォント)という仕組みを和文フォントにも応用する. 617 | 例えばVF中に「``(''は左に半角分ずらして置き換える」という記述を追加することで, 618 | DVIドライバがそれを解釈して位置補正できるようにする. 619 | \end{itemize} 620 | 詳細はマニュアル|makejvf.1|(英語版)を参照してほしい. 621 | 622 | \subsection{jfmutil} 623 | 624 | JFMおよび和文VFを操作する種々の機能を提供するPerlスクリプトである. 625 | 主な機能は以下のとおり: 626 | \begin{itemize} 627 | \item 和文の仮想フォント(VFとJFMの組)に対応する独自仕様の 628 | テキスト形式(ZVP形式)と,仮想フォントとの間の相互変換. 629 | 欧文の仮想フォント(VFとTFMの組)とテキスト形式(VPL形式)との間を 630 | 相互変換する|vftovp|/|vptovf|の和文版に相当する. 631 | \item 和文・欧文問わず,VFそれ単独に対応する独自仕様の 632 | テキスト形式(ZVP0形式;ZVP形式のサブセット)と,VFとの間の相互変換. 633 | \item 和文の仮想フォント(VFとJFMの組)を別の名前で複製する機能. 634 | VF中に記録された参照先のJFM名も適切に変更される.多書体化などに有用. 635 | \end{itemize} 636 | 詳細は公式ドキュメントを参照してほしい. 637 | 638 | 639 | \section{付録:利用可能なJFMについて}\label{jfm-dist} 640 | 641 | \pTeX/\upTeX と一緒に標準で配布しているJFMについて,簡単に説明する. 642 | 643 | \subsection{ptex-fonts} 644 | 645 | コミュニティによる配布場所は |https://github.com/texjporg/ptex-fonts| であり, 646 | 内容物は以下のとおり.なお,\pTeX および\pLaTeX のフォーマットでは,既定で 647 | 横組用に |min*.tfm| と |goth*.tfm| を, 648 | 縦組用に |tmin*.tfm| と |tgoth*.tfm| を使用している. 649 | \begin{itemize} 650 | \item 株式会社アスキーによるもの 651 | \begin{itemize} 652 | \item |min*.tfm|,|goth*.tfm|,|nmin*.tfm|,|ngoth*.tfm|(以上,横組用) 653 | \item |tmin*.tfm|,|tgoth*.tfm|(以上,縦組用) 654 | \end{itemize} 655 | \item 東京書籍印刷,現リーブルテックの小林肇氏によるもの 656 | \begin{itemize} 657 | \item |jis*.tfm|(JISフォントメトリック) 658 | \end{itemize} 659 | \end{itemize} 660 | 661 | \paragraph{株式会社アスキーによるJFM} 662 | 663 | しばしば「|min10|系」と呼ばれる. 664 | 歴史が非常に古く,開発当時のドキュメントは残念ながらほとんど残っていない. 665 | 以下は,株式会社アスキーによる「日本語\TeX\ version j1.7」\cite{jtex1.7}に 666 | 付属していたドキュメント|README.KANJI|からの抜粋である. 667 | 668 | \begin{quotation} 669 | \paragraph{漢字フォント} 670 | 671 | ディレクトリ |jfms| 内の漢字フォント用 JFM(TFM)ファイルは、以下に 672 | 示すサイズ(ドット数)のフォントを想定して作成されています(日本 673 | 語 version j0.3 の配布時のものと若干異なります。注意して下さい)。 674 | 尚、(株)アスキーより販売されている「日本語 Micro TeX」において 675 | も、これと全く同じものを使用しています。 676 | 677 | \begin{verbatim} 678 | TeX での呼び名 実寸(pt) 300dpi 480dpi 240dpi 118dpi 679 | 5pt 4.58222 19 30 15 7 680 | 6pt 5.49866 23 36 18 9 681 | 7pt 6.4151 27 42 21 10 682 | 8pt 7.33154 30 49 24 12 683 | 9pt 8.24799 34 55 27 13 684 | 10pt 9.16443 38 61 30 15 685 | 10pt * 1.2^1/2 10.0391 42 67 33 16 686 | 10pt * 1.2^1 10.9973 46 73 36 18 687 | 10pt * 1.2^2 13.1968 55 88 44 22 688 | 10pt * 1.2^3 15.8361 66 105 52 26 689 | 10pt * 1.2^4 19.0034 79 126 63 31 690 | 10pt * 1.3^5 22.804 95 151 75 37 691 | \end{verbatim} 692 | 693 | このサイズ以外のフォントを使用する場合は、プリンタドライバで疑似的に 694 | これらのサイズに合わせるか、そのフォントに合わせたJFM(TFM)ファイル 695 | を作成するかのどちらかになります。互換性を考慮する場合は、前者の方法 696 | を取るべきです。しかし、それではどうしても気にくわないというのであれ 697 | ば、|jtex/TeXware| に JFM 用の |tftopl| および |pltotf| がありますから、これ 698 | を使用して新しい JFMファイルを作成して下さい。これらのユーティリティ 699 | のドキュメントは、株式会社アスキー発行の「日本語 TeX テクニカルブック 700 | I」を参照して下さい。(中略) 701 | 702 | |jfms| 内には、|min*.tfm|、|goth*.tfm| の他に |nmin*.tfm| と |ngoth*.tfm| が含 703 | まれています。前者は、句読点、ピリオド、カンマといくつかの仮名文字と 704 | の間でカーニング処理を行うようになっていますが、後者ではこの処理を行っ 705 | ていません。両者間では、これ以外の違いはありません。ただしマクロ中で 706 | は、前者のみが定義されており、後者を使用する場合は自分で定義する必要 707 | があります。 708 | \end{quotation} 709 | 710 | \jfont\minten=min10 % used in this paragraph! 711 | 通常の和文フォントは正方形の仮想ボディに収まるようにデザインされるが, 712 | 例えば公称10ポイントの|min10|は「幅\the\fontcharwd\minten`漢, 713 | 高さ\the\fontcharht\minten`漢,深さ\the\fontchardp\minten`漢」の 714 | % 幅9.62216pt,高さ7.77588pt,深さ1.38855pt 715 | 扁平な矩形でデザインされている($\mathrm{zw}=9.62216\,\mathrm{pt}$と 716 | $\mathrm{zh}=9.16443\,\mathrm{pt}$が一致しない). 717 | また,例えば|ちょっと|が「ちょっと」ではなく「{\minten ちょっと}」と 718 | 詰まるなどの不自然な挙動も知られている\cite{min10otobe}. 719 | ただし,\emph{互換性維持のため,コミュニティが修正を行う予定はない}. 720 | 721 | \paragraph{JISフォントメトリック} 722 | 723 | |jis*.tfm|は,JIS~X~4051-1995「日本語文書の行組版方法」になるべく即した 724 | メトリックとして開発された\cite{jistfm}. 725 | |min10|系を「そのまま置き換えて使ってもらう」ことを 726 | 意図しており,そのため,|min10|系の字詰まりの不具合等は直しつつ, 727 | zw,zhの値を仮定した既存スタイルに影響を与えないように 728 | |min10|のzw・zhの寸法は温存した設計になっている. 729 | なお,|jsclasses|は横組用の|jis.tfm|と|jisg.tfm|を標準で使用している. 730 | 731 | % JIS メトリックの説明(英語版) 732 | % https://okumuralab.org/~okumura/texfaq/japanese/ptex.html 733 | % http://ajt.ktug.org/2008/0201okumura.pdf 734 | 735 | なお,|jis.tfm|(n無し)と|jisn.tfm|(n有り)の違いは 736 | \begin{quote} 737 | 中黒\codechar{・},コロン\codechar{:},セミコロン\codechar{;}の組み方を 738 | 「半角幅+前後グルー」とするか「全角幅」とするか 739 | \end{quote} 740 | だけである. 741 | 742 | \paragraph{対応するVFと実フォント} 743 | 744 | 第\ref{makejvf}節で述べたとおり,\pTeX で使用するJFMと実際のフォントでは 745 | 約物など一部の字幅が異なり,その位置ずれを補正するためにVFを用いている. 746 | 対応は以下のとおり(左が\pTeX 用JFM,右がDVIドライバ用JFMである 747 | \footnote{DVIドライバ用JFMは全ての文字を全角扱いとしており,グルー挿入などは 748 | 一切定義していない.当然,\pTeX の組版時には使用すべきでない.}). 749 | 実際のCID/OpenType/TrueTypeフォントの割り当ては,後述のmapファイルに依存する. 750 | \begin{itemize} 751 | \item |min*.tfm| → |min*.vf| → |rml.tfm|(→明朝体フォント,横組) 752 | \item |goth*.tfm| → |goth*.vf| → |gbm.tfm|(→ゴシック体フォント,横組) 753 | \item |tmin*.tfm| → |tmin*.vf| → |rmlv.tfm|(→明朝体フォント,縦組) 754 | \item |tgoth*.tfm| → |tgoth*.vf| → |gbmv.tfm|(→ゴシック体フォント,縦組) 755 | \item |jis*.tfm| → |jis*.vf| → |rml.tfm|(→明朝体フォント,横組) 756 | \item |jisg*.tfm| → |jisg*.vf| → |gbm.tfm|(→ゴシック体フォント,横組) 757 | \item |jis*-v.tfm| → |jis*-v.vf| → |rmlv.tfm|(→明朝体フォント,縦組) 758 | \item |jisg*-v.tfm| → |jisg*-v.vf| → |gbmv.tfm|(→ゴシック体フォント,縦組) 759 | \end{itemize} 760 | なお,|tmin*.vf|及び|tgoth*.vf|では「縦書き時には 761 | クオート\codechar{’}\codechar{”}を出力する代わりに, 762 | ミニュート\codechar{′}\codechar{″}を加工した文字に置き換える」と 763 | いう処置も加えてある(\code{makejvf}の |-m| オプションの機能). 764 | 一方,|jis*-v.vf|及び|jisg*-v.vf|ではそのような処置を行わない. 765 | 766 | 上記のDVI用ドライバ用JFMから実際のフォントにアクセスする際は, 767 | (JFMがJISでエンコードしてあるため)JIS→CIDへの変換が必要である. 768 | この変換にはAdobeが配布しているCMapの|H|(横組用)と|V|(縦組用)が 769 | 利用でき\footnote{ただし,Adobeの|H|と|V|は古く, 770 | JISコードから「JIS90字形のCID」へのマッピングである. 771 | 「JIS2004字形のCID」へのマッピングは日本語\TeX 開発コミュニティが 772 | 用意した|2004-H|と|2004-V|が必要.},これもmapファイルで指定する. 773 | 774 | \subsection{uptex-fonts} 775 | 776 | 配布場所は |https://github.com/texjporg/uptex-fonts| であり, 777 | 内容物は以下のとおり.なお,\upTeX および\upLaTeX のフォーマットでは,既定で 778 | 横組用に |upjisr-h.tfm| と |upjisg-h.tfm| を, 779 | 縦組用に |upjisr-v.tfm| と |upjisg-v.tfm| を使用している. 780 | 781 | \paragraph{日本語用(upjis系)} 782 | 783 | JISフォントメトリックを基に,JIS~X~0208→Unicodeで追加された記号類を 784 | 各文字タイプに追加した日本語用メトリックである. 785 | |upjis*|と|upjpn*|のJFMの中身は同じであり, 786 | 対応するVFも(2022年現在は)実質的に同等である. 787 | 788 | \begin{dangerous} 789 | 両者の違いは歴史的経緯にすぎない. 790 | かつてはDVIドライバが|set3|命令すなわち「3バイト以上の文字出力」に 791 | 非対応のケースが多かったため,以下の仕様を設けていた. 792 | \begin{itemize} 793 | \item 標準フォント|upjis*| … BMP内のみ出力可(VFは|set2|まで) 794 | \item オプションの|upjpn*| … BMP外も出力可(VFは|set3|も使用) 795 | \end{itemize} 796 | しかし,2018年以降はDVIドライバの|set3|対応が進んだことから, 797 | 標準フォント|upjis*|でも「Adobe-Japan1で定義されたBMP外の文字」を 798 | 出力できるように,VFに|set3|命令も使用することとした\cite{upf3}. 799 | さらに,\TeX~Live 2021以降は各種DVIドライバによるJFM由来のVFの解釈が 800 | 以下のように拡張された: 801 | \begin{quote} 802 | |MAPFONT|で指示されているfont IDの一番若いものがJFMであり,\par 803 | 要求されたコードポイントが明言されていない場合は,\par 804 | それが最小のfont IDに属すとみなし,そのコードポイントそのものを出力する. 805 | \end{quote} 806 | この解釈拡張により,VFに個々の文字を(|set3|命令を使うなどして)定義することなく, 807 | 省略されている場合でも文字出力が可能となった\cite{tjb99}. 808 | \end{dangerous} 809 | 810 | \paragraph{中国語簡体字用(upsch系)・中国語繁体字用(uptch系)・韓国語用(upkor系)} 811 | 812 | 日本語と中国語・韓国語では, 813 | 実際のフォントにおける記号類のデザイン(仮想ボディの中での配置)や 814 | 字詰めの方式が異なる点が多い. 815 | そこで,\emph{実験的ではあるが},日本語用(upjis系)の組み方では 816 | 明らかに不自然な点を調整したJFMをそれぞれ用意した. 817 | 詳細は\cite{upf2}を参照されたい. 818 | 819 | \paragraph{対応するVFと実フォント} 820 | 821 | 対応は以下のとおり(左が\upTeX 用JFM,右がDVIドライバ用JFMである). 822 | 実際のCID/OpenType/TrueTypeフォントの割り当ては,後述のmapファイルに依存する. 823 | \begin{itemize} 824 | \item |upjisr-*.tfm| → |upjisr-*.vf| → |uprml-*.tfm|(→日本語・明朝体) 825 | \item |upjisg-*.tfm| → |upjisg-*.vf| → |upgbm-*.tfm|(→日本語・ゴシック体) 826 | \item |upjpnrm-*.tfm| → |upjpnrm-*.vf| → |uprml-*.tfm|(→日本語・明朝体) 827 | \item |upjpngt-*.tfm| → |upjpngt-*.vf| → |upgbm-*.tfm|(→日本語・ゴシック体) 828 | \item |upschrm-*.tfm| → |upschrm-*.vf| → |upstsl-*.tfm|(→簡体中国語・宋体) 829 | \item |upschgt-*.tfm| → |upschgt-*.vf| → |upstht-*.tfm|(→簡体中国語・黒体) 830 | \item |uptchrm-*.tfm| → |uptchrm-*.vf| → |upmsl-*.tfm|(→繁体中国語・宋体) 831 | \item |uptchgt-*.tfm| → |uptchgt-*.vf| → |upmhm-*.tfm|(→繁体中国語・黒体) 832 | \item |upkorrm-*.tfm| → |upkorrm-*.vf| → |uphysmjm-*.tfm|(→韓国語・バタン体) 833 | \item |upkorgt-*.tfm| → |upkorgt-*.vf| → |uphygt-*.tfm|(→韓国語・ドトゥム体) 834 | \end{itemize} 835 | 836 | 上記のDVI用ドライバ用JFMから実際のフォントにアクセスする際は, 837 | (JFMがUnicodeでエンコードしてあるため)Unicode→CIDへの変換が必要である. 838 | この変換には各言語についてAdobeが配布しているCMapの|Uni*-UTF16-H|(横組用)と 839 | |Uni*-UTF16-V|(縦組用)が利用でき\footnote{日本語については特に, 840 | |UniJIS-...|がUnicodeから「JIS90字形のCID」へ, 841 | |UniJIS2004-...|が「JIS2004字形のCID」へのマッピングとして, 842 | Adobeによって両方用意されている.},これもmapファイルで指定する. 843 | 844 | \begin{dangerous} 845 | % クオート記号の割り当て 846 | % https://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=3153 847 | 日本語の横組用|upjis〜-h.vf|及び|upjpn〜-h.vf|では 848 | \begin{itemize} 849 | \item クオート記号\codechar{‘}\codechar{’}\codechar{“}\codechar{”}だけを 850 | 特別に|uprml-hq.tfm|または|upgbm-hq.tfm|へ 851 | \item その他の文字を標準の|uprml-h.tfm|または|upgbm-h.tfm|へ 852 | \end{itemize} 853 | というように,VFで4文字だけ割り当て先を分けている. 854 | これは,実際のフォントにアクセスする際のUnicode→CID変換時に 855 | 標準の|UniJIS*-UTF16-H|だけではクオート記号が 856 | 欧文グリフのCID~98,96,108,122にマッピングされてしまい, 857 | \pTeX 互換のCID~670..673(全角幅)にならないのを避けるためである. 858 | この4文字のUnicode→CID変換はちょうど|UniJIS-UCS2-H|が 859 | 都合よく事足りるので,|ptex-fontmaps|で利用している. 860 | \end{dangerous} 861 | \begin{table}[b] 862 | \centering 863 | \begin{tabular}{ccccc}\hline 864 | 文字 & Unicode & JIS~X~0208 865 | & CID (UniJIS-UTF16-H) & CID (UniJIS-UCS2-H) \\ \hline 866 | \codechar{‘} & U+2018 & 1-38 & 98 & 670 \\ 867 | \codechar{’} & U+2019 & 1-39 & 96 & 671 \\ 868 | \codechar{“} & U+201C & 1-40 & 108 & 672 \\ 869 | \codechar{”} & U+201D & 1-41 & 122 & 673 \\ \hline 870 | \end{tabular} 871 | \end{table} 872 | 873 | \subsection{実フォントへの割り当て (ptex-fontmaps)} 874 | 875 | 先述のとおり,「DVIドライバ用JFM」に実際のOpenType/TrueTypeフォントを 876 | 割り当てるのはmapファイルの仕事である. 877 | \TeX~Liveでは|ptex-fontmaps|として複数のプリセットを用意しており, 878 | それらを|kanji-config-updmap(-sys)|というコマンドで切り替えることができる. 879 | 詳細は公式ドキュメント及び |https://github.com/texjporg/ptex-fontmaps| を参照のこと. 880 | 881 | \begin{thebibliography}{99} 882 | \bibitem{jtex1.7} 883 | 株式会社アスキー,「アスキー日本語\TeX 配布テープ 1992.02.24 (release~1.12)」 884 | \bibitem{min10otobe} 885 | 乙部厳己,「min10フォントについて」,2000/12/12,\\ 886 | |http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf| 887 | \bibitem{jistfm} 888 | 奥村晴彦,「pLaTeX2e 新ドキュメントクラス」,2016/07/07,\\ 889 | |https://oku.edu.mie-u.ac.jp/~okumura/jsclasses/| 890 | \bibitem{jotf} 891 | Shuzaburo Saito,「Open Type Font用VF」,2019/04/01,\\ 892 | |https://psitau.kitunebi.com/otf.html| 893 | \bibitem{cidofm} 894 | Hironobu Yamashita,「otf-cjXX-X.ofm は何のため?」,2019/05/31,\\ 895 | |https://github.com/texjporg/japanese-otf-mirror/issues/15| 896 | \bibitem{upf3} 897 | Takuji Tanaka,「uptex-fontsで提供するフォントの文字範囲など」,2017/07/22,\\ 898 | |https://github.com/texjporg/uptex-fonts/issues/3| 899 | \bibitem{tjb99} 900 | Takuji Tanaka,「和文vfの fallback を dviware で」,2020/03/11,\\ 901 | |https://github.com/texjporg/tex-jp-build/issues/99| 902 | \bibitem{upf2} 903 | Hironobu Yamashita,「中韓フォントの JFM」,2017/07/01,\\ 904 | |https://github.com/texjporg/uptex-fonts/issues/2| 905 | \end{thebibliography} 906 | 907 | \end{document} 908 | -------------------------------------------------------------------------------- /jtex_asciimw.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/jtex_asciimw.pdf -------------------------------------------------------------------------------- /jtex_asciimw.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\cs}[1]{{$\backslash$#1}} 2 | \documentstyle[twoside]{jarticle} 3 | \addtolength{\textheight}{.5in} 4 | \addtolength{\textwidth}{.7in} 5 | \setlength{\oddsidemargin}{.4in} 6 | \setlength{\evensidemargin}{.4in} 7 | \title{\TeX システムの日本語化} 8 | \author{倉沢 良一\\ASCII Corporation} 9 | \date{昭和62年 3月} 10 | \pagestyle{headings} 11 | \begin{document} 12 | \maketitle 13 | \begin{abstract} 14 | 現在、\TeX システム の日本語化を進めているが、 15 | 現時点で一応の動作が可能となった。 16 | そこで、ここにその報告と共にその内容に付いて解説する。 17 | ただし、ここに報告する内容については、 18 | 決して最終的なものではなく、 19 | 現時点での暫定的なものであることを承知してもらいたい。 20 | 尚、本稿はこの日本語化された\TeX システムで\LaTeX を用いて作成した。 21 | \end{abstract} 22 | % 23 | \newpage 24 | \tableofcontents 25 | \newpage 26 | %\listoftables 27 | %\newpage 28 | % 29 | \section{\TeX システム日本語化の方針} 30 | \TeX システムを日本語化するにあたり、次の事項に留意し 31 | その方針を決定した。 32 | \begin{enumerate} 33 | \item 完全なアッパーコンパチブルであること。 34 | \begin{itemize} 35 | \item 日本語化により本来\TeX の持つ機能が損なわれるようなことが 36 | あってはならない。 37 | \item 欧文、和文の区別が無く、同一のシステム(プログラム)で 38 | 扱えること。 39 | 当然これまでにある、又はこれから作られる欧文の原稿が 40 | 扱えること。 41 | \item 和文に対しても、欧文同様の機能が扱えること. 42 | (フォント、マクロ等) 43 | \end{itemize} 44 | \item 和文特有の特殊処理が行えること。 45 | \begin{itemize} 46 | \item 行頭、行末禁則を自動的に行えること。 47 | \item 和文、欧文間のスペーシングの調整等が自動的に行えること。 48 | \end{itemize} 49 | \item 仕上がりが美しいこと。\\ 50 | \TeX 本来の目的である``\.美\.し\.い\.出\.力''が得られなければ、 51 | 日本語化を行う意味は全く無くなってしまう。 52 | 高性能の出力デバイスと高品位のフォントを用いることにより、 53 | 写植機に負けない出力が得られること。 54 | \end{enumerate} 55 | 1.に関しては、あくまでも``\TeX システム''をそっくりそのまま 56 | 日本語環境の下で使いたいという要望である。 57 | 和文に対しても、欧文のように自由にフォントを切り換えたり、 58 | マクロ定義が行いたいというのは当然であり、 59 | それが\TeX のような文書処理システムの魅力の1つであるからである。\\ 60 | 2.に付いては、和文を扱う場合には必然的に付いてまわる問題で、 61 | これらの処理が確実に行われなければ、その文書処理系の利用価値は 62 | 半減してしまうと考えられる。\\ 63 | 3.の内容は少し大げさなようにも思えるが、 64 | Don\nolinebreak\ Knuthの\TeX 開発の目的からすれば、至極当然のことでもある。 65 | 又、これは 1.や2.の内容が大きく関わっているのは言うまでもないことである。 66 | 67 | このような要求を、出来る限り満足するために 68 | 次のような日本語化の方策をとることにした。 69 | \begin{itemize} 70 | \item 日本語化は、\TeX そのもの(initex、virtex)に対して行い、 71 | plainやlplain等のマクロには出来れば一切手を付けない。 72 | (付けたくない。) 73 | \item ただし、追加された機能の為のイニシャライズや、パラメータの設定、 74 | 漢字フォントの定義等は、\TeX のフレキシビリティを保つためにもマクロで 75 | 行えるようにする。 76 | \item 欧文で行えることは、可能な限り和文でも行えるようにポーティングする。 77 | \end{itemize} 78 | % 79 | \newpage 80 | \section{\TeX 日本語化の実際} 81 | 上記の方針に基づき日本語化を行った結果、現時点で以下のように実現されている。 82 | % 83 | \subsection{コード体系} 84 | インプリメントの容易さ、現在使用しているホストマシンのコード、 85 | 将来のパーソナルコンピュータへの移植等を考え合わせた結果、 86 | 内部コード、外部コード共にASCII、シフトJISの組み合せを用いた。 87 | ただし、DVIファイル内の漢字コードだけは、JISコードを出力するようになっている。 88 | また半角カナのサポートは行っていない。 89 | % 90 | \subsection{プリミティブ} 91 | 日本語化に伴い、幾つかのプリミティブの追加および拡張を行った。 92 | これらは、禁則処理、オートスペーシングおよび漢字コードのためのものである。 93 | この時、新しく追加するプリミティブについては、日本語独特の新しい処理に 94 | 対するものだけに止め、出来るだけ既存のプリミティブを拡張するように努めた。 95 | % 96 | \subsubsection{プリミティブの追加} 97 | \label{tbpri} 98 | Table~\ref{tb:prim}に示すプリミティブが追加されている。 99 | (詳しくは、以降のセクションで解説する。) 100 | % 101 | \subsubsection{プリミティブの拡張} 102 | 既存のプリミティブに関しては、出来得る限り欧文、和文の区別をせずに 103 | 扱えるよう拡張を行った。 104 | また内部で扱うトークンに対する日本語化を行うことによって、 105 | プリンティングキャラクタのみでなく、マクロ名やトークンリスト 106 | にも全角文字を半角文字と混在して扱えるようになっている。 107 | 108 | \noindent 例. 109 | \begin{quote} 110 | \cs{char}''82A0\\ 111 | \cs{accent}''5F`あ\\ 112 | \cs{def}\cs{改ページ}\{\cs{eject}\} 113 | \end{quote} 114 | % 115 | \begin{table}[htb] 116 | \begin{tabular}{|l|p{4in}|} \hline 117 | \cs{\it prebreakpenalty} & 118 | 指定するキャラクタコードの前方に挿入するペナルティの値を設定する。 119 | 行頭禁則の指定として用いる。 \\ 120 | & 例. {\tt\cs{prebreakpenalty}`、$=$1000} \\ \hline 121 | \cs{\it postbreakpenalty} & 122 | 指定するキャラクタコードの後方に挿入するペナルティの値を設定する。 123 | 行末禁則の指定として用いる。\\ 124 | & 例. {\tt\cs{postbreakpenalty}`[$=$1000} \\ \hline 125 | \cs{\it jis} & 126 | 漢字コードの変換を行うためのプリミティブで、 127 | JISコードから内部コードであるシフトJISに変換する。\\ 128 | & 例. {\tt\cs{prebreakpenalty}\cs{jis}"2122$=$1000} \\ \hline 129 | \cs{\it kuten} & 130 | \cs{jis}と同様に区点コードからシフトJISへ変換する。\\ 131 | & 例. {\tt\cs{postbreakpenalty}\cs{kuten}"0146$=$1000} \\ \hline 132 | \cs{\it sjis} & 133 | 上記の2つと同様であるが、内部コードがシフトJISであるので、 134 | そのままの値をかえす。\\ \hline 135 | \cs{\it kanjiskip} & 136 | 全角コード間に自動的に挿入されるグルーを持つレジスタ。\\ 137 | & 例. {\tt\cs{kanjiskip}$=$0pt puls .3pt minus .3pt} \\ \hline 138 | \cs{\it xkanjiskip} & 139 | 全角--半角コード間に自動的に挿入されるグルーを持つレジスタ。\\ 140 | & 例. {\tt\cs{xkanjiskip}$=$2.5pt puls 1pt minus 1pt} \\ \hline 141 | \cs{\it autospacing} & 142 | 全角コード間へのグルーの自動挿入を行うための指定。 \\ \hline 143 | \cs{\it noautospacing} & 144 | 全角コード間へのグルーの自動挿入を行わないための指定。 \\ \hline 145 | \cs{\it autoxspacing} & 146 | 全角--半角コード間へのグルーの自動挿入を行うための指定。\\ \hline 147 | \cs{\it noautoxspacing} & 148 | 全角--半角コード間へのグルーの自動挿入を行わないための指定。\\ \hline 149 | \cs{\it xspcode} & 150 | 全角--半角コード間へのグルーの自動挿入の対象となる 151 | 半角コードを指定する。 152 | 現在デフォルトの値としてアルファベットおよび数字に対して 153 | スペースが挿入されるように設定されている。 \\ 154 | & 例. {\tt\cs{xspcode}`A$=$0} \\ \hline 155 | \end{tabular} 156 | \caption{日本語化に伴い追加されたプリミティブ。} 157 | \label{tb:prim} 158 | \end{table} 159 | % 160 | \subsection{ラインブレーク} 161 | 欧文と和文の処理で見かけ上最も大きな違いは、ラインブレーク処理であると思われる。 162 | ``見かけ上''と言うのは、\TeX 内部の処理には 163 | さほど大きな変更はいらないからである。 164 | 具体的には、次のように文中のどの位置を 165 | ブレークポイントの対象とするかの問題である。 166 | \begin{itemize} 167 | \item 欧文中でのラインブレークは、ハイフネーション処理等の特別な場合を除いて、 168 | 単語中つまり連続する文字列中は、ブレーキングポイントとして選択されない。 169 | \item 和文中では禁則の例外を除いて、 170 | 全ての文字間がブレークポイントの対象になり得る。 171 | \end{itemize} 172 | 実際に\TeX 内部ではパラグラフ単位でラインブレークの処理が行われ、 173 | それは{\it line\_break}というルーチン内で、 174 | ブレーク可能な箇所を捜し出し、それを{\it try\_break} 175 | という関数に渡すことにより行われている。 176 | (勿論こんな単純なものではないが、基本的な操作としてこうした形になっている。 177 | 詳しくは、\TeX: The Program PART38、39 Breaking paragraphs into lines. 178 | を是非読んでみることをお勧めする。) 179 | そこで、和文中の文字間もブレークポイントの候補として、 180 | {\it try\_break}に渡すよう変更した。 181 | 182 | 又、本来ならばラインブレークの処理は、次項の禁則処理と密接な関係があり 183 | とても分けて考えられるものではない。 184 | しかしながら、\TeX では事実上完全に分けて考えても差し支えがないような 185 | 構造になっている。 186 | それは、ペナルティと呼ばれるブレーキングのための 187 | 一般的な評価値が導入されているためであり、 188 | ブレーキングルーチンではこの値を如何に評価するか 189 | だけを考えれば良く、 190 | 禁則処理ルーチンでは、この値を如何に設定するかだけを考えれば良い。 191 | % 192 | \subsection{禁則処理} 193 | % 194 | \subsubsection{禁則処理でのペナルティの応用} 195 | 前のセクションでも簡単に触れたように、 196 | 禁則処理も\TeX にとって全く新しい概念ではなく、 197 | ペナルティと言う形で導入されている。 198 | これは、上記のラインブレークやページブレーク処理時に、 199 | その箇所がブレークポイントとして、 200 | どの程度適切(負値のペナルティ)であるかあるいは 201 | 不適切(正値のペナルティ)であるかを示すための評価値である。 202 | したがって、ただ単にその箇所でのブレーキングを禁止するだけでは無く、 203 | 強制的なブレーキングや、禁則文字が連続するような場合の 204 | 優先順位付けにも利用できる。 205 | 206 | 日本語の禁則処理にこのペナルティを応用するためには次のようにすればよい。 207 | \begin{list}{}{\setlength{\leftmargin}{2cm}} 208 | \item[行頭禁則] 禁則文字の前に正のペナルティを付ける。 209 | \item[行末禁則] 禁則文字の後ろに正のペナルティを付ける。 210 | \end{list} 211 | こうした形でペナルティを自動的に挿入さえできれば、 212 | 後は既存の\TeX のルーチンをそのまま利用できるはずである。 213 | % 214 | \subsubsection{禁則テーブル} 215 | このペナルティを自動的に挿入するために、 216 | \TeX 内部に禁則文字とその文字に対応するペナルティ値と 217 | ペナルティの挿入位置(その文字の前に挿入するか後に挿入するかの別) 218 | のテーブルを持つことにした。 219 | そしてこのテーブルにこれらの情報を登録する手段として、 220 | {\bf\cs{pre\-break\-penalty}}と{\bf\cs{post\-break\-penalty}} 221 | の2つのプリミティブを追加した。 222 | {\bf\cs{pre\-break\-penalty}}は 223 | 指定した文字の直前にペナルティを挿入することを、 224 | {\bf\cs{post\-break\-penalty}}は 225 | 指定した文字の直後にペナルティを挿入することを指定するもので、 226 | 全角文字、半角文字の区別無しに指定できる。 227 | これらは、同一の文字に対して同時に両方のペナルティを挿入するようには 228 | 指定できない。 もし同一の文字に対して双方の指定がされた場合、 229 | 後からのものに置き換えられる。 230 | 勿論これらは``\{\}''による、グルーピング規則が適用される。 231 | 又、双方で指定できる文字数は最大で256文字までである。 232 | この値は、全角文字、半角文字を合わせて禁則対象となると考えられる 233 | 文字数を、十分にカバーしていると思われる。 234 | 235 | この禁則テーブルからの登録の削除は、 236 | ペナルティ値`0'を設定することによって行われるが、 237 | グローバルレベルでの設定でなければ、 238 | このテーブルの領域は解放されないことに注意して欲しい。 239 | なぜなら、ローカルレベルで領域を解放してしまえば、 240 | その外側のレベルに戻ったときに、そのレベルでの値を 241 | 最設定するための領域が確保されている保証がないからである。 242 | 243 | このテーブルができれば、各文字を読み込む度に、 244 | その文字がこのテーブルに登録されているかどうかを調べ、 245 | 登録されていればそのペナルティを文字の前後適切な位置に挿入して行けば良い。 246 | この禁則テーブルの検索にはハッシュ法を用いており、 247 | ハッシュ関数として 248 | \label{`ハッシュ関数'} 249 | \[\left\{ \begin{array}{cl} 250 | (C2+(C2<<(C1-0x81)))\,mod 256 & 漢字コード\\ 251 | & C1=上位バイト、C2=下位バイト\\ 252 | \\ 253 | C*2+1 & ASCIIコード 254 | \end{array} 255 | \right. \] 256 | を用いている。 257 | これは、おそらく禁則の対象となるであろう、 258 | 全角の記号、ひらがなカタカナの小文字、ASCIIコードの記号等 259 | を適当に散らばらせるように考えてある。 260 | 又、このテーブルには最大256文字まで登録可能であるが、 261 | むやみに多くの文字を登録してテーブルを満たすことは、 262 | 禁則文字検索のオーバーヘッドを大きくし、 263 | パフォーマンスに大きな影響を与えるので注意する必要がある。 264 | 265 | こうしてペナルティを適切に挿入さえしてしまえば、 266 | 後は\TeX のラインブレークルーチンに\. お\. ま\. か\. せしてしまえる。 267 | 勿論、このテーブルにいかにペナルティを登録するかは、 268 | ユーザーの責任であると共に、ペナルティ値の変更により自由に 269 | 禁則処理に変化をつけることができる。 270 | % 271 | \subsection{スペーシング} 272 | {\noautospacing\noautoxspacing 273 | これまでの変更で一通りの和文を出力することは可能である。 274 | ところがこれだけではまだ不十分で、 275 | このままでは決して\. 美\. し\. い出力は得られない。 276 | なぜなら、欧文では単語毎にスペースが挿入され、 277 | そこでのスペーシング量を調整することにより、 278 | ジャスティファイケーションの処理が行われていた。 279 | ところが、これまでの変更だけでは、 280 | 和文に対してそのような調整を行う部分がほとんど無いのである。 281 | この状態がいったいどのようなものであるか 282 | 試しに、この段落を上記の{\it\cs{noautospacing\/}}と 283 | {\it\cs{noautoxspacing\/}}によって、スペーシングの自動挿入を 284 | しないで組んでみた。 285 | この操作にによって、この段落中にとられるスペースは 286 | ピリオド、カンマの後のスペースのみである。\par} 287 | 288 | %\autospacing\autoxspacing 289 | 一目して解るように、行末に1文字以上の不揃いが出来てしっまている。 290 | これは、パラグラフ全体をダイナミックにブレーキングするといった、 291 | \TeX の長所が悪い方に働いてしまい、 292 | 数行先の禁則処理の影響がそのまま反映されているのである。 293 | 禁則ペナルティのパラメータの値の悪さも手伝ってか、 294 | 悲惨な結果となってしまっている。 295 | % 296 | \subsubsection{和文組版におけるスペーシング} 297 | これに対して一般に行われている和文の組版では、 298 | 行単位のみでのブレーキングが行われており、 299 | 最悪の場合でもこのようなことは起こらないようである。 300 | また組み幅は、全角の正数倍にとられるため日本語のみの 301 | 行では必ず行末がきれいに揃う仕掛になっている。 302 | ただし、禁則が生じたり、途中に欧文が挿入されたりした場合は、 303 | やはりどこかで調整が必要になってくる。 304 | こうした調整は次のような箇所で行われているようである。 305 | \begin{itemize} 306 | \item まずこうした調整に迫られた場合、追込みを考える。 307 | 追込みのために、カンマ、ピリオド、括弧等の文字を 308 | 半角幅にまで縮めてみる。 309 | \item それでも調整しきれず、行中に欧文が存在する場合は、 310 | 欧文間、和文--欧文間のスペースを調整する。 311 | \item さらに調整が必要な場合は、かな文字間のスペースを 312 | 調整する。 313 | \item これでもまだ駄目な場合、追い出しを試みる。 314 | \end{itemize} 315 | 説明が遅れてしまったが、和文--欧文間には見栄えを良くするために、 316 | 4分開けと呼ばれる全角幅の$1/4$のスペースが挿入される。 317 | 実際問題としては、禁則文字が連続でもしない限り、 318 | 行中に2つ以上のカンマ、ピリオドの類の文字が存在すれば、 319 | 最初の段階で調整は付いてしまう。 320 | 321 | \subsubsection{\TeX でのスペーシング} 322 | これを\TeX に応用することを考えてみる。 323 | 324 | まず組み幅の問題であるが、\TeX の場合、何文字幅といった 325 | 指定も簡単に実現可能ではあるが、既存のマクロ等の利用を考えると 326 | 組み幅ばかりでなく、インデント等の組み幅に関係する全てのパラメータ 327 | も同時に変更する必要があり、出来れば自由な組み幅の指定が出来た方が良い。 328 | そうなると、ピリオド、カンマ等の文字が一文字も表れないような行に対しても 329 | 組み幅を調整する手段が新たに必要となる。 330 | しかも、行中にそう何文字も表れないような文字に、 331 | こうした帳尻合わせを集中するのは、あまり\. 美\. し\. いことではない。 332 | 333 | 次に、和文--欧文間のスペース等は原稿中でいちいち気にしながら 334 | 挿入するのでは非常に面倒である。 こうした類のものは 335 | 折角コンピュータを使用しているのであるから、 336 | 自動的に行ってほしい。 337 | 338 | このような要求を満たすために次のような変更を加えることにした。 339 | \begin{enumerate} 340 | \item 全角文字間にもグルーを自動的に挿入できるようにする。 341 | これによりピリオド、カンマ等の文字が表れない行でも 342 | ジャスティファイケーションが行える。 343 | またカンマ等の持つスペースだけでなく、行全体で 344 | その調整分を分割するため、より自然な組みが実現できる。 345 | 勿論、ここで行う調整は0.数ptといった極めて微量の調整である。 346 | さらにこのグルーの導入により、1歯詰めなどといった組み方も 347 | 可能になる。 348 | \item 和文--欧文間のスペーシングは当然\TeX が自動的に行って 349 | くれるものだと考え、そのまま導入した。 350 | ただし、全ての和文--欧文間(全角文字--半角文字間) 351 | に挿入して良いわけではない。 352 | 例えば、半角のピリオド、カンマ、括弧類記号と 353 | 全角文字間には余計なスペースは入れない方がよい。 354 | \item オリジナルの\TeX では、改行キャラクタを読み込むことにより 355 | 単語の切れ目と判断し、スペースが挿入される。 356 | しかし、和文ではこうしたスペースを挿入されるのは 357 | 不都合である。 そこで全角文字の後の改行は 358 | ただ単に読み飛ばすだけの処理に変更する必要がある。 359 | \end{enumerate} 360 | 361 | 1.の実現方法として、{\bf\cs{kanjiskip}}というグルーレジスタを 362 | 新たに設け、このグルーを全角文字間に挿入するようにした。 363 | ただし、実際に他のグルーと同じように処理したのでは、 364 | 全角文字1文字に付き1グルー分のメモリを消費することになり、 365 | 余りにもメモリ効率が悪くなる。 そこでこのグルーに関しては、 366 | ラインブレークや、ボックスへの組み込みルーチン({\it hpack}) 367 | 内での組み幅の計算だけで処理するようにしてある。 368 | 369 | 2.に関しては、\TeX が数式中で行っているように、必要な箇所に 370 | 実際にグルーを挿入する。 挿入するグルーは、 371 | 1.と同じように{\bf\cs{xkanjiskip}}というレジスタを 372 | 設け、その値を使う。 373 | さらに、全角文字の前後に現れる半角文字の内の何れに対して、 374 | スペースを挿入すべきかを指定するために、 375 | 内部に128文字分のテーブルを設け、そこに登録されている 376 | 内容によってスペース挿入の有無を決定している。 377 | 現在デフォルトでアルファベットおよび数字がスペース挿入の 378 | 対象となっている。 このテーブルへの登録は、{\bf\cs{xspcode}}という 379 | プリミティブによって行う。 380 | 各ASCIIキャラクタに対して0を設定することにより、 381 | 全角との間のスペースの挿入を禁止し、それ以外の値で許可するようになっている。 382 | 383 | 尚、1.2.に共通する処理として、これらのレジスタの値は、 384 | そのパラグラフ、あるいは{\it hbox}に入った時点での値を保持して 385 | 使用し、その中でどんなに変更を加えても処理には影響が及ばない 386 | ようになっている。 387 | 又、これらの処理は、{\bf\cs{auto\-spacing}}、{\bf\cs{no\-auto\-spacing}}、 388 | {\bf\cs{auto\-xspacing}}、{\bf\cs{no\-auto\-xspacing}}によって 389 | ON、OFFできるようになっている。 390 | 391 | 3.は\TeX のスキャンニングルーチンを変更することで、 392 | スペーシングキャラクタとして、先のルーチンに渡って行かないようにした。 393 | % 394 | \subsection{フォント} 395 | フォントに関しても、できるだけ欧文のものと同じ扱いが出来るように 396 | 配慮した。 397 | \subsubsection{\TeX での日本語フォントの取り扱い} 398 | ユーザインタフェースからみた日本語フォントの取り扱いは、 399 | {\it\cs{mathcode}}等の数式関係のフォントの定義中には 400 | 含めることができないことを除くとほとんど同じようにして扱える。 401 | 異なる点は、半角文字と全角文字とを使い分ける度に 402 | フォントの切り換えを行うのは非常に繁雑なので、 403 | カレントフォントとしてこれまでの半角文字用の他に 404 | 全角文字用も独立して持つようにしたことである。 405 | これによって特にフォントの変更を行う必要がなければ、 406 | 全角、半角の区別を意識することなしに原稿を入力することが出来る。 407 | 具体的には次のように指定すれば良い。 408 | \begin{quote} 409 | \tt \cs{font}\cs{jfont}=min10\\ 410 | \cs{jfont} 411 | \end{quote} 412 | これを見てわかるように、これまでと全く同じようにして指定できる。 413 | この時指定された\cs{jfont}が漢字フォントであれば、 414 | 漢字用のカレントフォントを変更する。 415 | 漢字フォントと英字フォントの判別は、TFMファイルにより行っている。 416 | 417 | 又、数式中でのフォントを指定する、ファミリーに付いても 418 | 同様に、全角用のカレントファミリーを拡張した。 419 | これにより、全角文字に対しても、上付き文字や下付き文字の取り扱いが 420 | 可能になる。 421 | 勿論、半角、全角を意識する必要はない。 422 | ただ全角用カレントファミリーが半角用と異なる点は、 423 | 半角用のカレントファミリーは、マスモードに 424 | 切り替わった時点で-1にセットされるのに対し、 425 | 全角用のカレントファミリーは、そのままの値を保つことである。 426 | (マスモード中でのフォント切り換えのメカニズムに付いては、 427 | \TeX book p.154等を参照のこと。) 428 | これは、数式関係のフォント定義を日本語フォントにまで 429 | 拡張していないための措置であるが、 430 | 数式用フォントに関しては、全角文字に拡張してもほとんど 431 | 意味がないので、こうした形をとった。 432 | % 433 | \subsection{TFMファイルとcharノード} 434 | \TeX 内部では印字データをcharノードと呼ばれるノード中に 435 | そのフォントの種類と共に格納する。 436 | 又、\TeX システムには、TFMファイルと呼ばれるファイルがフォントの種類毎に 437 | 用意されており、 438 | そこに各フォント内に含まれるキャラクタの、各種サイズ等の情報が置かれている。 439 | 440 | \TeX のラインブレーク等の処理は、このcharノード中のキャラクタデータから 441 | TFMファイルの字幅情報等を検索して処理する仕組みになっている。 442 | したがって、\TeX を日本語化する際には、これらをどのように 443 | 拡張し、どのように対応付けるかがキーポイントとなる。 444 | % 445 | \subsubsection{TFMファイルの拡張} 446 | まずTFMファイルであるが、この中には{\it char\_info}と呼ばれる 447 | そのフォント中に存在するキャラクタのコードと1対1に対応するテーブルが 448 | 置かれている。 449 | このテーブル中には{\it width\/、height\/、depth}等の他のテーブルへの 450 | インデックスが設定されており、このインデックスを用いて 451 | それぞれのパラメータを参照する仕組みになっている。 452 | 453 | ただし、このインデックスのサイズから、 454 | 1フォント内に含まれるキャラクタのサイズの種類が制限されてしまっている。 455 | しかし、漢字フォントは1フォント内の数は多いが、そのサイズは記号等を 456 | 除いてほとんど同じであり、この制約内に十分に収まると判断した。 457 | そこでこの{\it char\_info}とその他のテーブルの仕組みは、 458 | そのまま利用することにし、{\it char\_info}テーブルと漢字の2バイトコードを、 459 | 対応付けるための方策を考えることにした。 460 | 461 | その手段として漢字コードと{\it char\_info}へのインデックスを持つテーブルを 462 | 付け加えることにした。 463 | ところが、漢字フォントは1フォント中に約7000文字もの数があり、 464 | そのままテーブルに持つのは得策ではない。 465 | この解決策として、1フォント内のキャラクタの大部分が同じサイズを持つという 466 | 漢字の特徴から、デフォルトサイズを規定し、これと異なるものだけを、 467 | そのコードと{\it char\_info}へのインデックスの対という形で 468 | テーブルを持つようにした。 469 | さらに、検索のオーバヘッドを軽減するために、 470 | テーブルを漢字コード順にソーティングした形で持つように規定した。 471 | 472 | 又、従来のTFMファイルと区別するためにサフィックスを``{\bf JFM}'' 473 | と変更した。 474 | % 475 | \subsubsection{charノードとJFMファイルの対応付け} 476 | charノードは、上記したとおりそこにフォントとキャラクタコードを 477 | 持ち、さらに次のノードへのポインタを含んでいる。 478 | これを日本語のために拡張するためには、ノードサイズを変更するか、 479 | 複数のノードによって1つのキャラクタを表現するかの2通りが 480 | 考えられる。 481 | 処理の効率から考えると、前者の方がより良いのであるが、 482 | そのためには\TeX のメモリ管理ルーチンの大変更をしなければ 483 | ならず、今回は断念した。 484 | 485 | ここで採用した方法は、\TeX : The program にも簡単に書かれていたとおり、 486 | 連続する2つのcharノードを使って日本語1文字を表すものである。 487 | 具体的には、2つ目のノードにキャラクタコードを格納し、 488 | 1つ目のノードには、フォントとTFMの{\it char\_info}への 489 | インデックスを格納するようにしてある。 490 | つまり、charノードを生成する段階で、TFMファイルに拡張したテーブルから、 491 | {\it char\_info}へのインデックスを検索してしまうのである。 492 | こうすることにより、この1つ目のcharノードは、 493 | 既存の欧文キャラクタのcharノードと全く同一に扱える。 494 | 2つ目のノードは、最後にDVIファイルに出力する時や、 495 | エラーが生じた場合に必要になるだけで、 496 | 一般の内部処理では読み飛ばしてやりさえすれば良い。 497 | 498 | あるcharノードが日本語用のものであるかどうかは、 499 | charノード内のフォントを調べ、それが漢字フォントであるかどうかによって 500 | 判断する。 501 | この処理を簡単に能率良く行うために、 502 | フォントが漢字かどうかのテーブルを\TeX 内部に設けてある。 503 | % 504 | \subsection{数式中での日本語の使用} 505 | フォントの項でも簡単に触れたとおり、 506 | 数式中においても日本語が扱えるように変更を行ってある。 507 | これは、数式中に直接日本語が含まれるような 508 | 使い方は希であるが、 509 | \ref{`ハッシュ関数'}中の式のように、 510 | 簡単な説明等を付け加えたいことは良くあるからである。 511 | % 512 | \newpage 513 | \section{今後の予定} 514 | 現時点までの\TeX の日本語の状態を一通り表面的な部分のみで 515 | あるが解説してみた。 516 | 勿論、まだ不十分な点は多々あるが、 517 | 実際にこの原稿を作ってみて、十分使用に耐えることは確信できた。 518 | 特に\LaTeX がそのまま日本語で使用できることは、 519 | 感激に価する。 520 | 今のところ、\LaTeX のコマンドで使用できないものは無いようである。 521 | 522 | 今後の予定として次のようなことを考えている。 523 | \begin{itemize} 524 | \item 自動的に挿入される、全角間および全角--半角間のスペースは、 525 | {\bf\cs{kanji\-skip}}、{\bf\cs{xkanji\-skip}}の値が必ず 526 | 使われてしまうが、これはJFMファイル中に、デフォルト値を 527 | 設定出来るようにして、フォントの変更と共に最適値を 528 | 使用できるようにしたい。 529 | \item 全角の記号等は、全角幅固定ではなく、基本的にはその文字の持つ 530 | 実際の幅で取り扱えなければ、行頭や行末におかれる場合、 531 | 行ぞろえが正確に行えず\. 美\. し\. く\. な\. い。 532 | こうした記号類は漢字フォントであっても、 533 | 独自の字幅情報を持つようにしたい。 534 | \item 全角文字に対しても、文字の組み合せによるカーニングを 535 | 行うべきである。 特にひらがなカタカナの後に、ピリオド、 536 | カンマの類の文字が続いた場合の、 537 | スペースの空き方が不自然なことが場合があり、 538 | 調整できるようにする必要がある。 539 | \end{itemize} 540 | % 541 | %\appendix{TFMファイルの構造} 542 | %\begin{tabular}{|cp{2in}|} \hline 543 | %lf & lh \\ \hline 544 | %bc & ec \\ \hline 545 | %nw & nh \\ \hline 546 | %nd & ni \\ \hline 547 | %nl & nk \\ \hline 548 | %ne & np \\ \hline 549 | %\multicolumn{2}{|c|}{} \\ hline 550 | \newpage 551 | \appendix 552 | \section{禁則ペナルティの設定例} 553 | 禁則ペナルティの設定例として、 554 | このテキスト制作時に使用した設定を上げておく。 555 | 556 | \vspace{15pt} 557 | {\tt\noindent 558 | \begin{tabular}{lll} 559 | %半角文字 560 | \cs{prebreakpenalty}`.=1000 & 561 | \cs{prebreakpenalty}`,=1000 & 562 | \cs{prebreakpenalty}`\}=1000 \\ 563 | \cs{postbreakpenalt}y`\{=1000 & 564 | \cs{prebreakpenalty}`)=1000 & 565 | \cs{postbreakpenalty}`(=1000 \\ 566 | \cs{prebreakpenalty}`]=1000 & 567 | \cs{postbreakpenalty}`[=1000 & 568 | \cs{postbreakpenalty}`!=500 \\ 569 | \cs{postbreakpenalty}`\#=500 & 570 | \cs{postbreakpenalty}`\$=500 & 571 | \cs{postbreakpenalty}`\%=500 \\ 572 | \cs{postbreakpenalty}`\&=500 & 573 | \cs{postbreakpenalty}`\`=500 & 574 | \cs{prebreakpenalty}`|=500 \\ 575 | \cs{prebreakpenalty}`;=500 & 576 | \cs{prebreakpenalty}`?=500 & 577 | \cs{prebreakpenalty}`:=500 \\ 578 | %全角文字 579 | \cs{prebreakpenalty}`、=1000 & 580 | \cs{prebreakpenalty}`。=1000 & 581 | \cs{prebreakpenalty}`,=1000 \\ 582 | \cs{prebreakpenalty}`.=1000 & 583 | \cs{prebreakpenalty}`・=1000 & 584 | \cs{prebreakpenalty}`:=500 \\ 585 | \cs{prebreakpenalty}`;=500 & 586 | \cs{prebreakpenalty}`?=500 & 587 | \cs{prebreakpenalty}`!=500 \\ 588 | \cs{prebreakpenalty}`)=800 & 589 | \cs{postbreakpenalty}`(=800 & 590 | \cs{prebreakpenalty}`}=800 \\ 591 | \cs{postbreakpenalty}`{=800 & 592 | \cs{prebreakpenalty}`[=800 & 593 | \cs{postbreakpenalty}`]=800 \\ 594 | \cs{postbreakpenalty}`‘=1000 & 595 | \cs{prebreakpenalty}`’=1000 & 596 | \cs{prebreakpenalty}`ー=200 \\ 597 | \cs{prebreakpenalty}`+=200 & 598 | \cs{prebreakpenalty}`−=200 & 599 | \cs{prebreakpenalty}`==200 \\ 600 | \cs{postbreakpenalty}`#=200 & 601 | \cs{postbreakpenalty}`$=200 & 602 | \cs{postbreakpenalty}`%=200 \\ 603 | \cs{postbreakpenalty}`&=200 & 604 | \cs{prebreakpenalty}`ぁ=150 & 605 | \cs{prebreakpenalty}`ぃ=150 \\ 606 | \cs{prebreakpenalty}`ぅ=150 & 607 | \cs{prebreakpenalty}`ぇ=150 & 608 | \cs{prebreakpenalty}`ぉ=150 \\ 609 | \cs{prebreakpenalty}`っ=150 & 610 | \cs{prebreakpenalty}`ゃ=150 & 611 | \cs{prebreakpenalty}`ゅ=150 \\ 612 | \cs{prebreakpenalty}`ょ=150 & 613 | \cs{prebreakpenalty}`ァ=150 & 614 | \cs{prebreakpenalty}`ィ=150 \\ 615 | \cs{prebreakpenalty}`ゥ=150 & 616 | \cs{prebreakpenalty}`ェ=150 & 617 | \cs{prebreakpenalty}`ォ=150 \\ 618 | \cs{prebreakpenalty}`ッ=150 & 619 | \cs{prebreakpenalty}`ャ=150 & 620 | \cs{prebreakpenalty}`ュ=150 \\ 621 | \cs{prebreakpenalty}`ョ=150 \\ 622 | \end{tabular} 623 | \begin{tabular}{ll} 624 | \cs{prebreakpenalty}\cs{jis}"212B=1000 & 625 | \cs{prebreakpenalty}\cs{jis}"212C=1000 \\ 626 | \cs{prebreakpenalty}\cs{jis}"212D=1000 & 627 | \cs{postbreakpenalty}\cs{jis}"212E=1000 \\ 628 | \cs{prebreakpenalty}\cs{jis}"2139=250 & 629 | \cs{prebreakpenalty}\cs{jis}"2144=250 \\ 630 | \cs{prebreakpenalty}\cs{jis}"2145=250 & 631 | \cs{postbreakpenalty}\cs{jis}"2146=1000 \\ 632 | \cs{prebreakpenalty}\cs{jis}"2147=1000 & 633 | \cs{postbreakpenalty}\cs{jis}"2148=1000 \\ 634 | \cs{prebreakpenalty}\cs{jis}"2149=1000 & 635 | \cs{postbreakpenalty}\cs{jis}"214C=800 \\ 636 | \cs{prebreakpenalty}\cs{jis}"214D=800 & 637 | \cs{postbreakpenalty}\cs{jis}"2152=800 \\ 638 | \cs{prebreakpenalty}\cs{jis}"2153=800 & 639 | \cs{postbreakpenalty}\cs{jis}"2154=800 \\ 640 | \cs{prebreakpenalty}\cs{jis}"2155=800 & 641 | \cs{postbreakpenalty}\cs{jis}"2156=800 \\ 642 | \cs{prebreakpenalty}\cs{jis}"2157=800 & 643 | \cs{postbreakpenalty}\cs{jis}"2158=800 \\ 644 | \cs{prebreakpenalty}\cs{jis}"2159=800 & 645 | \cs{postbreakpenalty}\cs{jis}"215A=800 \\ 646 | \cs{prebreakpenalty}\cs{jis}"215B=800 & 647 | \cs{prebreakpenalty}\cs{jis}"246E=150 \\ 648 | \cs{prebreakpenalty}\cs{jis}"256E=150 & 649 | \cs{prebreakpenalty}\cs{jis}"2575=150 \\ 650 | \cs{prebreakpenalty}\cs{jis}"2576=150 \\ 651 | \end{tabular}} 652 | 653 | %% texjporg: タイポだけ修正 (2017/04/12, 2017/07/16) 654 | \end{document} 655 | -------------------------------------------------------------------------------- /jtexdoc_asciimw.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/jtexdoc_asciimw.pdf -------------------------------------------------------------------------------- /jtexdoc_asciimw.tex: -------------------------------------------------------------------------------- 1 | \def\cs#1{$\backslash$\kern0pt#1} 2 | \def\angle#1{$\langle$\kern0pt#1\kern0pt$\rangle$} 3 | \documentstyle{jarticle} 4 | \begin{document} 5 | \title{日本語\TeX} 6 | \author{倉沢 良一\\ASCII Corporation} 7 | \date{昭和62年8月 \\ 昭和62年12月 \\ 平成元年10月} 8 | \maketitle 9 | \begin{abstract} 10 | これは、日本語\TeX の使い方の注意点と、 11 | \TeX の日本語化にともない変更あるいは追加された機能について 12 | 解説したドキュメントです。 13 | 基本的な\TeX の使い方については、\TeX bookや 14 | \LaTeX: A document Preparation System. をご覧ください。 15 | \end{abstract} 16 | 17 | \section{日本語\TeX の概要} 18 | 日本語\TeX は、オリジナルの\TeX と完全なアッパーコンパチブルを保っています。 19 | ですから、これまで欧文で作られたファイルはそのまま日本語\TeX に 20 | かけられるはずです。 21 | 現在のバージョンで扱える漢字コードは、シフトJISおよびEUCです。 22 | ただし、これらはソースファイルにパッチをあてて、makeし直さなければなりません。 23 | 24 | 日本語(2バイトコードキャラクタ)のハンドリングに関しては、 25 | でき得る限り英字(1バイトコードキャラクタ)と同じように取り扱える 26 | ようにしてあります。 27 | したがって、特殊な使い方をしない限り英字と同じようにして、 28 | 原稿ファイルを作成していくことができます。 29 | 30 | しかも、カレントフォントとして英字と漢字とを別々に持っているため、 31 | 英字と漢字の切り換えは特に気にする必要はなく、 32 | そのまま混在して使うことができます。 33 | 34 | 和文と欧文の処理の違いとしてラインブレークのタイミングと 35 | それに関係する禁則処理、さらに和文欧文が混在した場合のスペーシング 36 | の処理などがあります。 37 | 日本語\TeX では、これらの処理を自動的に行っていますが、 38 | 柔軟性を高めるために、こうした処理に関係するパラメータを自由に再設定 39 | できるようになっています。 40 | 41 | フォントに関しては、1フォントでJISコードの第1水準、第2水準全てを 42 | 扱えるように拡張してありますから、英字フォントと同じように漢字フォントを扱え、 43 | JFM(TFM)ファイルをつくることにより、自由に使用可能なフォントを増やして 44 | いくことができます。 45 | 46 | DVIファイルは、SET2 および PUT2 を使って2バイトコードを出力しているため、 47 | これまでのものとの互換性は保たれています。 48 | またDVIファイルには、JISコードを用いて出力しています。 49 | 50 | \section{原稿を書く上での注意点} 51 | 基本的には、欧文と和文は全く同じようにして扱えます。 52 | ただし、日本語特有の処理機能を持たせているため、 53 | 原稿を書くうえでは次のことに注意してください。 54 | \begin{itemize} 55 | \item コントロールシーケンスにも2バイトコードキャラクタ 56 | が使えるようになっています。 57 | したがって、コントロールシーケンスに続けて2バイトコードの 58 | 文字を書き並べる場合は、必ず半角スペースやタブ等で間を区切ってください。 59 | \item 欧文の場合、改行は単語間のスペースとして取り扱われますが、 60 | 日本語の場合、原稿内では自由な箇所で改行が行えたほうが便利です。\\ 61 | そこで日本語\TeX では、1行の終わりが1バイトコードの場合はスペーサー 62 | の挿入を行い、2バイトコードの場合は何も行わないようになっています。 63 | \item 2バイトコードキャラクタと1バイトコードキャラクタが 64 | 連続する場合、自動的に\cs{xkanjiskip}に設定されてているグルーを 65 | 挿入します。ただしこの処理は、どの1バイトコードキャラクタとの 66 | 間で行うか\cs{xspcode}によって指定でき、デフォルトではa--z, 67 | A--Z, 0--9との間で行われるように設定されています。 68 | この処理を特定の箇所で禁止したい場合は、 69 | そこに\cs{kern0pt}、\cs{hskip0pt}などを挿入してください。 70 | \item 禁則処理は、禁則の対象となるキャラクタの前方あるいは 71 | 後方にペナルティーを自動的に挿入することで実現しています。 72 | このペナルティーの設定は\cs{prebreakpenalty}、\cs{postbreakpenalty} 73 | によって行います。デフォルト値は、kinsoku.texに記述されています。 74 | \item 現在、jtex、jlatexで扱えるフォントは明朝体とゴシック体です。 75 | これらのフォントの指定は、 76 | jtex, jlatexともに、\cs{mc}、\cs{gt}で行えます。 77 | これら以外のフォントは、英字フォントと同じように、 78 | 対象のフォントにあわせてJFM(TFM)を作れば使用できます。 79 | \item フォントの切り換えは、英字と漢字は独立して行われます。 80 | jlatexでは、\cs{large},\cs{small}などサイズ変更の 81 | コントロールシーケンスによって、 82 | 連動してフォントをチェンジするようにしていますが、 83 | jtexではそのような操作は一切行っていませんので注意してください。 84 | ただし、指定したフォントが印字されるためには、それらの字体、サイズの 85 | フォントがそろっていなければ行えません。 86 | jlatexでは、次のフォントが存在するものと仮定しています。 87 | \begin{quote} 88 | min5, min6, min7, min8, min9, min10, 89 | min10 magstephalf, min10 magstep1, 90 | min10 magstep2, min10 magstep3, 91 | min10 magstep4, min10 magstep5, \\ 92 | goth5, goth6, goth7, goth8, goth9, goth10, 93 | goth10 magstephalf, goth10 magstep1, 94 | goth10 magstep2, goth10 magstep3, 95 | goth10 magstep4, goth10 magstep5 96 | \end{quote} 97 | これらが、きちんと印字されるかどうかはプリンタドライバの責任です。 98 | また、これらのフォントにはカーニング・パラメータが設定されています。 99 | カーニングを行いたくない場合は、上記のフォントの代りに以下のものを 100 | 使用してください。こちらのフォントは、カーニングのパラメータが設定 101 | されていないことを除いて上記のものと全く同じものです。 102 | \begin{quote} 103 | nmin5, nmin6, nmin7, nmin8, nmin9, nmin10, 104 | nmin10 magstephalf, nmin10 magstep1, 105 | nmin10 magstep2, nmin10 magstep3, 106 | nmin10 magstep4, nmin10 magstep5, \\ 107 | ngoth5, ngoth6, ngoth7, ngoth8, ngoth9, ngoth10, 108 | ngoth10 magstephalf, ngoth10 magstep1, 109 | ngoth10 magstep2, ngoth10 magstep3, 110 | ngoth10 magstep4, ngoth10 magstep5 111 | \end{quote} 112 | \item 現在のバージョンでは、全角スペースはほかの漢字キャラクタと同じように 113 | 扱われます。 114 | 半角スペースのような特別の処理は行っていませんので注意してください。 115 | \item コントロールシーケンス名にも全角文字を使用することができますが 116 | 次の点に注意してください。 117 | \begin{enumerate} 118 | \item 全角の1区、2区、7区に含まれる文字は、カテゴリーコードの 119 | 12つまり `Other\_character' と同様の扱いになります。 120 | したがって、これらの文字は ``エスケープ文字$+$1文字'' の 121 | コントロールシーケンスとしてのみ扱えます。 122 | \item そのほかの文字に付いては、カテゴリーコードの11(letter)と 123 | 同様に扱われます。 124 | また、これらの文字は半角文字と混在して使用することが 125 | できます。 126 | \end{enumerate} 127 | \item 半角カナは使えません。原稿内に半角カナのコードが入らないようにし 128 | てください。 129 | \end{itemize} 130 | 131 | \section{追加されたプリミティブ} 132 | 133 | 日本語\TeX にはつぎのプリミティブが追加されています。 134 | \begin{itemize} 135 | \item \cs{{\bf kanjiskip}} 136 | \begin{quote} 137 | \cs{kanjiskip}$=$\angle{dimen} 138 | \end{quote} 139 | 連続する2バイトコード間に自動的に挿入するグルーの値を 140 | 格納するレジスタです。 141 | ただし、この処理は\cs{autospacing}、\cs{noautospacing}によって 142 | 行うか行わないかの指定ができます。\\ 143 | このレジスタの値は、パラグラフの終わりまたは\cs{hbox}の最後の 144 | 時点で取り込まれ、処理されます。 145 | したがって、同一パラグラフ内、あるいは\cs{hbox}内で何度か値を 146 | 変化させたとしても、最後に設定された値によって全て処理されます。 147 | 148 | \noindent 149 | 使用例\\ 150 | {\tt\cs{kanjiskip}$=$10pt plus 1pt minus 1pt}\\ 151 | {\kanjiskip=10pt plus 1pt minus 1pt 152 | とするとこうなります。\par} 153 | \item \cs{{\bf xkanjiskip}} 154 | \begin{quote} 155 | \cs{xkanjiskip}$=$\angle{dimen} 156 | \end{quote} 157 | 連続する2バイトコードと\cs{xspcode}で指定された1バイトコードの間に 158 | 自動的に挿入するグルーの値を格納するレジスタです。 159 | ただし、この処理は\cs{autoxspacing}、\cs{noautoxspacing}によって 160 | 行うか行わないかの指定ができます。\\ 161 | \cs{kanjiskip}と同様のタイミングで取り込まれ処理されます。 162 | 163 | \noindent 164 | 使用例\\ 165 | {\tt\cs{xkanjiskip}$=$10pt plus 1pt minus 1pt}\\ 166 | {\xkanjiskip=10pt plus 1pt minus 1pt 167 | とするとalphabetやnumberとの間に挿入されるグルーが 168 | 10pt plus 1pt minus 1ptになります。\par} 169 | \item \cs{{\bf sjis}} 170 | \begin{quote} 171 | \cs{sjis}\angle{16--bit number} 172 | \end{quote} 173 | シフトJISコードから内部コードへの変換を行います。 174 | 175 | \noindent 176 | 使用例\\ 177 | {\tt\cs{char}\cs{sjis}"889F}\\ 178 | とすれば、`\char\sjis"889F' となります。 179 | \item \cs{{\bf jis}} 180 | \begin{quote} 181 | \cs{jis}\angle{16--bit number} 182 | \end{quote} 183 | JISコードから内部コードへの変換を行います。 184 | 185 | \noindent 186 | 使用例\\ 187 | {\tt\cs{char}\cs{jis}"3022}\\ 188 | とすれば、`\char\jis"3022' となります。 189 | \item \cs{{\bf kuten}} 190 | \begin{quote} 191 | \cs{kuten}\angle{16--bit number} 192 | \end{quote} 193 | 区点コードから内部コードへの変換を行います。 194 | 16進4桁の上2桁が区を下2桁が点であると解釈します。 195 | 196 | \noindent 197 | 使用例\\ 198 | {\tt\cs{char}\cs{kuten}"1003}\\ 199 | とすれば、`\char\kuten"1003' となります。 200 | \item \cs{{\bf xspcode}} 201 | \begin{quote} 202 | \cs{xspcode}\angle{8--bit number}$=$\angle{$0|1|2|3$} 203 | \end{quote} 204 | 2バイトコードと1バイトコードの間に自動的にスペースが挿入されますが、 205 | このプリミティブによってどの1バイトコードとの間でこの処理を行うか 206 | どうかを指定できます。この指定は0--3のいずれかを選択することにより 207 | 次のような動作を選択できます。 208 | \begin{itemize} 209 | \item 0を設定することによりこの1バイトコード文字と2バイトコード文字 210 | の間での処理を禁止します。 211 | \item 1を設定することでこの文字と直前の2バイトコード文字との間にのみ 212 | スペースを挿入することを許可します。 213 | \item 2を設定することにより直後の2バイトコード文字との間にのみ 214 | スペースを挿入することを許可します。 215 | \item 3を設定することで前後の2バイトコード文字との間でのスペースの 216 | 挿入を許可します。 217 | \end{itemize} 218 | 219 | \noindent 220 | 使用例\\ 221 | {\tt\cs{xspcode}`1=0\\ 222 | \cs{xspcode}`2=3\\ 223 | \cs{xspcode}`;=2}\\ 224 | とすることにより、`1' に対する処理を禁止し、 225 | `2' に対して前後の処理を許可します。 226 | また、`;' に対しては直後へのスペースの挿入を許可します。 227 | \item \cs{{\bf inhibitxspcode}} 228 | 指定した2バイトコードとそれに前後する1バイトコードの間に 229 | 自動的に挿入されるスペースを抑制します。 230 | この指定は0--3のいずれかを選択することにより 231 | 次のような動作を選択できます。 232 | \begin{itemize} 233 | \item 0を設定することによりこの2バイトコード文字と1バイトコード文字 234 | の間での処理を禁止します。 235 | \item 1を設定することでこの文字と直前の1バイトコード文字との間に 236 | スペースを挿入することを禁止します。 237 | \item 2を設定することにより直後の1バイトコード文字との間に 238 | スペースを挿入することを禁止します。 239 | \item 3を設定することで前後の1バイトコード文字との間でのスペースの 240 | 挿入を許可します。 241 | \end{itemize} 242 | このプリミティブは、日本語\TeX のバージョン1.4で追加しました。 243 | 244 | \noindent 245 | 使用例\\ 246 | {\tt\cs{inhibitxspcode}`?=0\\ 247 | \cs{inhibitxspcode}`(=2\\ 248 | \cs{inhibitxspcode}`)=1} 249 | \item \cs{{\bf jcharwidowpenalty}} 250 | \begin{quote} 251 | \cs{jcharwidowpenalty}$=$\angle{number} 252 | \end{quote} 253 | パラグラフの最後の全角文字が、孤立して改行されるのを防ぐための 254 | ペナルティです。またパラグラフの最後が1文字以上の1区、2区、7区 255 | に含まれる文字の場合は、その直前にある全角文字に対してこの 256 | ペナルティが使われます。 257 | \item \cs{{\bf autospacing}} 258 | \begin{quote} 259 | \cs{autospacing} 260 | \end{quote} 261 | このプリミティブによって2バイトコード間へのグルーの自動挿入を許可 262 | します。 263 | \item \cs{{\bf noautospacing}} 264 | \begin{quote} 265 | \cs{noautospacing} 266 | \end{quote} 267 | このプリミティブによって2バイトコード間へのグルーの自動挿入を禁止 268 | します。 269 | \item \cs{{\bf autoxspacing}} 270 | \begin{quote} 271 | \cs{autoxspacing} 272 | \end{quote} 273 | このプリミティブによって2バイトコードと1バイトコード間へのグルーの 274 | 自動挿入を許可します。 275 | \item \cs{{\bf noautoxspacing}} 276 | \begin{quote} 277 | \cs{noautoxspacing} 278 | \end{quote} 279 | このプリミティブによって2バイトコードと1バイトコード間へのグルーの 280 | 自動挿入を禁止します。 281 | \item \cs{{\bf prebreakpenalty}} 282 | \begin{quote} 283 | \cs{prebreakpenalty}\angle{16--bit number}$=$\angle{number} 284 | \end{quote} 285 | 指定する文字の前方に挿入するペナルティ値を設定します。 286 | この指定は、行頭禁則の指定にあたります。 287 | 288 | \noindent 289 | 使用例\\ 290 | {\tt\cs{prebreakpenalty}`あ$=$1000}\\ 291 | とすることにより、`あ' の前方に1000のペナルティ値が付けられます。 292 | \item \cs{{\bf postbreakpenalty}} 293 | \begin{quote} 294 | \cs{postbreakpenalty}\angle{16--bit number}$=$\angle{number} 295 | \end{quote} 296 | 指定する文字の後方に挿入するペナルティ値を設定します。 297 | この指定は、行末禁則の指定にあたります。\\ 298 | ただし、\cs{prebreakpenalty}と\cs{postbreakpenalty}を同一の 299 | 文字に対して同時に設定することはできません。 300 | 同一の文字に対して両方の指定を行った場合、後からの設定が有効になります。 301 | \item \cs{{\bf jfont}} \\ 302 | 基本的な動作は、``\cs{font}'' と同じです。 303 | ただし、`\cs{showthe}' などのプリミティブと組み合せた場合に 304 | カレントの漢字フォントを返します。 305 | フォントの定義は、\cs{font}, \cs{jfont}のどちらを使っても 306 | 英字フォント、漢字フォントの定義が行えます。 307 | \item \cs{{\bf jfam}} \\ 308 | `\cs{jfont}' と同様に ``\cs{fam}'' とほとんど同じ動作をします。 309 | `\cs{showthe}' などとの組み合せることで、カレントの漢字フォント 310 | ファミリーを返します。 311 | ただしこのプリミティブでは、英字フォントのファミリーを 312 | 漢字ファミリーとして定義できてしまいますので注意してください。 313 | \item {{\bf zw, zh}} \\ 314 | プリミティブとは異なりますが、{\bf em, ex}と同じように 315 | zw、zhは、それぞれカレントの2バイトコードフォントの幅(全角幅) 316 | および高さの単位記号です。 317 | 318 | \noindent 319 | 使用例\\ 320 | {\tt\cs{baselineskip}$=$1.5zh\\ 321 | \cs{hsize}=20zw}\\ 322 | でカレントフォントの高さの1.5倍の値が\cs{baselineskip}に代入され、 323 | \cs{hsize}が全角20文字分に設定されます。 324 | \end{itemize} 325 | 326 | \subsection{自動挿入されるスペースについて} 327 | \cs{kanjiskip}や\cs{xkanjiskip}の自動挿入は、単純に連続する文字列ばかりでなく 328 | shift\_amountが0である\cs{hbox}内の文字との前後関係においても行われます。 329 | これは、\cs{hbox}が入子状になっている場合でも同じです。 330 | つまり、その\cs{hbox}内に現れる最初の文字と最後の文字とが、 331 | boxの前後の文字に連続する文字列として解釈され、 332 | そこに指定されたスペースが挿入されることになります。 333 | \cs{vbox}はその対象とはなりません。具体的には以下の例を参考にしてください。 334 | 335 | \begin{tabular}{l@{ $\longrightarrow$ }c} 336 | \verb|あ\hbox{A}い| & あ\hbox{A}い \\ 337 | \verb|あ\hbox{\hbox{A}}い| & あ\hbox{\hbox{A}}い \\ 338 | \verb|あ\hbox{\hbox{\hbox{A}}}い| & あ\hbox{\hbox{\hbox{A}}}い \\ 339 | \verb|あ\hbox{\hbox{\hbox{\hbox{A}}}}い| & あ\hbox{\hbox{\hbox{\hbox{A}}}}い \\ 340 | \verb|あ\hbox{A\hbox{\vbox{\hbox{A}}}B}い| & 341 | あ\hbox{A\hbox{\vbox{\hbox{A}}}B}い \\ 342 | \verb|あ\hbox{\hbox{\vbox{\hbox{A}}}B}い| & 343 | あ\hbox{\hbox{\vbox{\hbox{A}}}B}い \\ 344 | \verb|あ\hbox{A\hbox{\vbox{\hbox{A}}}}い| & 345 | あ\hbox{A\hbox{\vbox{\hbox{A}}}}い \\ 346 | \verb|あfiい| & あfiい \\ 347 | \verb|あ\hbox{\hbox{\vbox{\hbox{A}}}}い| & 348 | あ\hbox{\hbox{\vbox{\hbox{A}}}}い \\ 349 | \verb|あ\hbox{\vbox{\hbox{\hbox{A}}}}い| & 350 | あ\hbox{\vbox{\hbox{\hbox{A}}}}い \\ 351 | \verb|あ\vbox{\hbox{\hbox{\hbox{A}}}}い| & 352 | あ\vbox{\hbox{\hbox{\hbox{A}}}}い \\ 353 | \verb|A\hbox{あ}A| & A\hbox{あ}A \\ 354 | \verb|A\hbox{\hbox{あ}}A| & A\hbox{\hbox{あ}}A \\ 355 | \verb|A\hbox{\hbox{\hbox{あ}}}A| & A\hbox{\hbox{\hbox{あ}}}A \\ 356 | \verb|A\hbox{\hbox{\hbox{\hbox{あ}}}}A| & A\hbox{\hbox{\hbox{\hbox{あ}}}}A \\ 357 | \verb|A\hbox{あ\hbox{\vbox{\hbox{あ}}}あ}A| & 358 | A\hbox{あ\hbox{\vbox{\hbox{あ}}}あ}A \\ 359 | \verb|A\hbox{\hbox{\vbox{\hbox{あ}}}あ}A| & 360 | A\hbox{\hbox{\vbox{\hbox{あ}}}あ}A \\ 361 | \verb|A\hbox{あ\hbox{\vbox{\hbox{あ}}}}A| & 362 | A\hbox{あ\hbox{\vbox{\hbox{あ}}}}A \\ 363 | \verb|A\hbox{\hbox{\vbox{\hbox{あ}}}}A| & 364 | A\hbox{\hbox{\vbox{\hbox{あ}}}}A \\ 365 | \verb|A\hbox{\vbox{\hbox{\hbox{あ}}}}A| & 366 | A\hbox{\vbox{\hbox{\hbox{あ}}}}A \\ 367 | \verb|A\vbox{\hbox{\hbox{\hbox{あ}}}}A| & 368 | A\vbox{\hbox{\hbox{\hbox{あ}}}}A \\ 369 | \end{tabular} 370 | 371 | \section{日本語化されていないプリミティブ} 372 | 次のプリミティブについては、日本語化(2バイトコードに対応)されていません。 373 | 374 | \begin{itemize} 375 | \item \cs{catcode}, \cs{sfcode}, \cs{mathcode}, \cs{delcode}, 376 | \cs{mathchardef}は、 377 | 2バイトコードに対してそれぞれの定義を行うことはできません。 378 | \item \cs{lccode}, \cs{uccode}は、2バイトコードをそのままとおし、 379 | ローワケース、アッパーケースの変更は行いません。 380 | \end{itemize} 381 | 382 | 383 | \section{問題点} 384 | 現在のバージョンの日本語\TeX には、次のような問題点があります。 385 | 使用の際には注意してください。 386 | 387 | \begin{itemize} 388 | \item 禁則処理および1バイトコードと2バイトコード間に挿入するグルーは、 389 | その処理の対象となる文字を単に文字コードでのみ判断しています。 390 | これは、2バイトコードの文字に対しては全く問題ないのですが、 391 | 1バイトコードの文字で問題が生じます。 392 | それは、\TeX の文字がコードと一対一に対応していないためで、 393 | フォントにより、特定のコードに割り付けられている文字が 394 | 変ってしまいます。 395 | たとえば、`\{' はフォントcmsyの66$_{16}$に対応付けられています。 396 | 66$_{16}$は、アスキーコードで `f' を示すわけですから禁則の対象文字 397 | とはなっていないはずです。 398 | 399 | したがって、今のままでは `\{' のような文字に対して自動的に禁則処理や 400 | グルーの自動挿入を行うことは不可能です。 401 | \end{itemize} 402 | %% cmsy の \{ は 0x6E でなく 0x66 (2001/08/24) 403 | %% texjporg: タイポだけ修正 (2017/03/13, 2017/04/12, 2017/04/16) 404 | \end{document} 405 | -------------------------------------------------------------------------------- /ptex-guide-en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/ptex-guide-en.pdf -------------------------------------------------------------------------------- /ptex-guide-en.tex: -------------------------------------------------------------------------------- 1 | %#!make ptex-guide-en.pdf 2 | \documentclass[a4paper,11pt,dvipdfmx]{article} 3 | \usepackage[textwidth=42zw,lines=40,truedimen,centering]{geometry} 4 | 5 | %%%%%%%%%%%%%%%% 6 | % additional packages 7 | \usepackage{amsmath} 8 | \usepackage{array} 9 | \usepackage[all]{xy} 10 | \SelectTips{cm}{} 11 | \usepackage[T1]{fontenc} 12 | \usepackage{booktabs,enumitem,multicol} 13 | \usepackage[defaultsups]{newpxtext} 14 | \usepackage[zerostyle=c,straightquotes]{newtxtt} 15 | \usepackage{newpxmath} 16 | \usepackage{color} 17 | \usepackage[hyperfootnotes=false]{hyperref} 18 | \usepackage{pxjahyper} 19 | \usepackage{hologo} 20 | \usepackage{xspace} 21 | \usepackage{makeidx}\makeindex 22 | 23 | % common 24 | \usepackage{ptex-manual} 25 | \let\emph=\origemph 26 | \makeatletter 27 | \newlist{simplelist}{description}1 28 | \setlist[simplelist]{% 29 | itemsep=0pt, listparindent=1zw, itemindent=10pt, 30 | font=\normalfont\mdseries, leftmargin=2zw, 31 | before=\advance\@listdepth\@ne, 32 | after=\advance\@listdepth\m@ne 33 | } 34 | \makeatother 35 | 36 | %%%%%%%%%%%%%%%% 37 | \makeatletter 38 | \setlist{leftmargin=2zw} 39 | \setlist[description]{labelwidth=2zw,labelindent=1zw,topsep=\medskipamount} 40 | 41 | \usepackage{shortvrb} 42 | \MakeShortVerb*{|} 43 | %%%%%%%%%%%%%%%% 44 | 45 | % foreign text -> italic 46 | \def\Foreign#1{\textit{#1}} 47 | 48 | \def\_{\leavevmode\vrule width .45em height -.2ex depth .3ex\relax} 49 | 50 | \frenchspacing 51 | \begin{document} 52 | \catcode`\<=13 53 | \title{\textsf{\textbf{Guide to \pTeX\ for developers unfamiliar with Japanese}}} 54 | \author{Japanese \TeX\ Development Community\null 55 | \thanks{\url{https://texjp.org},\ e-mail: \texttt{issue(at)texjp.org}}} 56 | \date{version p\the\ptexversion.\the\ptexminorversion\ptexrevision, \today} 57 | \maketitle 58 | 59 | \pTeX\ and its variants, \upTeX, \epTeX\ and \eupTeX, are all \TeX\ engines 60 | with native Japanese support. 61 | Its output is always a DVI file, which can be processed by several 62 | DVI drivers with Japanese support including \emph{dvips} and \emph{dvipdfmx}. 63 | Formats based on \LaTeX\ is called \pLaTeX\ when running on \pTeX/\epTeX, 64 | and called \upLaTeX\ when running on \upTeX/\eupTeX. 65 | 66 | %%% Target readers of this document: 日本語機能でないパッケージ作者に絞る 67 | \section*{Purpose of this document} 68 | 69 | This document is written for developers of \TeX/\LaTeX, who aim to 70 | support \pTeX/\pLaTeX\ and its variants \upTeX/\upLaTeX. 71 | Knowledge of the followings are assumed: 72 | \begin{itemize} 73 | \item Basic knowledge of Western \TeX\ (Knuthian \TeX, \eTeX\ and \pdfTeX), 74 | \item ... and its programming conventions. 75 | \end{itemize} 76 | 77 | %%% 日本語(の組版・文字コード)の知識は要らない。その話はできる限り避ける 78 | Any knowledge of Japanese (characters, encodings, typesetting conventions etc.) 79 | is not assumed; some explanations are provided in this document when needed. 80 | We hope that this document helps authors of packages or classes 81 | to proceed with supporting \pTeX\ family smoothly. 82 | 83 | \begin{quotation} 84 | Note: This English guide (\file{\jobname.pdf}) is \emph{not} meant 85 | to be a complete translation of Japanese manual (\file{ptex-manual.pdf}). 86 | For example, this document does not cover issues regarding Japanese typesettings. 87 | If you are interested in typesetting conventions of Japanese text, please also 88 | refer to \file{japanese.pdf} distributed with \Pkg{babel-japanese}. 89 | \end{quotation} 90 | 91 | This document is maintained at: 92 | \url{https://github.com/texjporg/ptex-manual/} 93 | 94 | \tableofcontents 95 | 96 | 97 | \newpage 98 | 99 | 100 | %%%%% 101 | \part{Brief introduction}% 概論 102 | 103 | %%% pTeX とその仲間 104 | \section{\pTeX\ and its variants} 105 | 106 | The figure below shows the relationship between engines. 107 | \[ 108 | \xymatrix@ur{ 109 | \text{\TeX} \ar[r]\ar[d] & \text{\eTeX} \ar[r]\ar[d] 110 | & \text{\fbox{\pdfTeX}} \\ 111 | \text{\pTeX} \ar[r]\ar[d] & \text{\fbox{\epTeX}} \ar[d] &\\ 112 | \text{\upTeX} \ar[r] & \text{\fbox{\eupTeX}} & 113 | } 114 | \] 115 | 116 | \pTeX\ is an old Japanese-specific extension of \TeX82, 117 | which aims to support proper typesetting of Japanese text 118 | but only supports a limited character set, JIS~X~0208 (6879 characters). 119 | 120 | \upTeX\ is developed as an extension of \pTeX\ to support full Unicode 121 | characters. It also includes modifications and extensions to overcome 122 | the difficulties of \pTeX\ in processing 8-bit Latin characters 123 | due to conflicts with legacy multibyte Japanese encodings. 124 | 125 | \epTeX\ and \eupTeX\ are \eTeX\ extensions of \pTeX\ and \upTeX\ respectively. 126 | In the current release, some extensions derived from \pdfTeX\ and \OMEGA\ are 127 | also available. 128 | 129 | %%% 際立った pTeX 系列の特徴 130 | \section{Eminent characteristics of \pTeX\ family} 131 | 132 | The most important characteristics of \pTeX\ family can be 133 | summarized as follows: 134 | %%% 欧文と和文が別個に存在する・縦組がある 135 | \begin{itemize} 136 | \item Japanese characters are interpreted and handled completely apart from 137 | Western characters. If a pair of two or more 8-bit codes in the input 138 | matches the pattern of Japanese character codes, it is regarded as one 139 | Japanese character and given a different \.{catcode} (\.{kcatcode}) value. 140 | \item There are two text directions; horizontal (\Foreign{yoko-gumi}; 横組) 141 | and vertical (\Foreign{tate-gumi}; 縦組). 142 | Two directions can be mixed even within a single document. 143 | \end{itemize} 144 | 145 | %%% 欧文 TeX との互換性 146 | \section{Compatibility with Western \TeX}\label{compat} 147 | 148 | %%% pTeX/upTeX は Knuthian TeX に対してほぼ上位互換 149 | \pTeX/\upTeX\ are almost upward compatible with Knuthian \TeX, 150 | however, they do not pass the TRIP test. 151 | %%% 入力の8bitの扱いが異なる。フォントの8bitはそのまま 152 | The most important difference lies in the handling of 8-bit code inputs; 153 | some 8-bit Latin characters may be subject to the encoding conversion. 154 | There is no difference in handling 8-bit TFM font. 155 | 156 | %%% e-pTeX/e-upTeX は e-TeX に対してほぼ上位互換 157 | \epTeX/\eupTeX\ are almost upward compatible with \eTeX, 158 | however, input handling is similar to \pTeX/\upTeX. 159 | It does not pass the e-TRIP test. 160 | %%% だけど e-TeX はもうなく,pdfTeX の DVI モードがあるだけ 161 | That said, please note that ``raw \eTeX'' is unavailable anymore 162 | in \TL and derived distributions; 163 | they provide a command |etex| only as ``DVI mode of \pdfTeX.'' 164 | %%% e-pTeX/e-upTeX は pdfTeX の DVI モードに対して上位互換ではない 165 | You should note that 166 | \epTeX/\eupTeX\ are \emph{not} upward compatible with DVI mode of \pdfTeX, 167 | which will be discussed later in Section \ref{dvi-pdftex}. 168 | 169 | %%% e-(u)pTeX の話がメイン 170 | There is no advantage to choose \pTeX/\upTeX\ over \epTeX/\eupTeX, 171 | so we focus mainly on \epTeX/\eupTeX. 172 | % [TODO] 既に pTeX/upTeX が暗に e-pTeX/e-upTeX を指す場合もある 173 | 174 | %%% LaTeX ムニャムニャ 175 | \section{\LaTeX\ on \pTeX/\upTeX\ --- \pLaTeX/\upLaTeX} 176 | 177 | %%% pLaTeX と upLaTeX ムニャムニャ 178 | Format based on \LaTeX\ is called \pLaTeX\ when running on \pTeX, 179 | and called \upLaTeX\ when running on \upTeX. 180 | %%% カーネルが拡張されている 181 | When building the format, |platex.ltx| (\pLaTeX) or 182 | |uplatex.ltx| (\upLaTeX) loads |latex.ltx| first 183 | and adds some additional commands related to the followings: 184 | \begin{itemize} 185 | \item Selection of Japanese fonts, 186 | \item Crop marks (called \Foreign{tombow}; トンボ) for printings, 187 | \item Adjustment for mixing horizontal and vertical texts. 188 | \end{itemize} 189 | %%% author レベルでは LaTeX とほぼ互換,ただし例外あり 190 | For authors, \pLaTeX/\upLaTeX\ are almost upward compatible with 191 | original \LaTeX, except for the followings: 192 | \begin{itemize} 193 | \item Order of float objects; in \pLaTeX/\upLaTeX, 194 | is placed above . 195 | That is, the complete order is 196 | $\rightarrow$ $\rightarrow$ 197 | $\rightarrow$ . 198 | % [TODO] 他にもあるか? 199 | \end{itemize} 200 | %%% developer レベルでは pdfTeX 拡張や pLaTeX カーネルでムニャムニャ 201 | For developers, additional care may be needed, 202 | for changes in the kernel macros and/or the engine difference 203 | (Japanese handling, absence of \pdfTeX\ features, etc). 204 | In recent versions of \TL and its derivatives, 205 | the default engines of \pLaTeX\ and \upLaTeX\ are as follows: 206 | \begin{center} 207 | \begin{tabular}{lll} 208 | Date & \pLaTeX & \upLaTeX \\ \hline 209 | \TL2010 & \pTeX & --- \\ 210 | \TL2011 & \epTeX & --- \\ 211 | \TL2012--2022, 2023 initial & \epTeX & \eupTeX \\ 212 | Since 2023-06-01 & \eupTeX\ in legacy (see below) & \eupTeX \\ 213 | \end{tabular} 214 | \end{center} 215 | The command |platex| started \epTeX\ (not \pTeX) with preloaded format 216 | |platex.fmt| in \TL2022. 217 | Since 2023-06-01, \pLaTeX\ has switched its engine from \epTeX\ to 218 | \eupTeX\ in ``legacy-encoding-compatibility mode.'' It means that 219 | additional primitives of (\eTeXpre)\upTeX\ is available also on \pLaTeX, 220 | but the internal code of Japanese characters is still non-Unicode 221 | to keep the backward compatibility. 222 | Further information can be found in Section \ref{detecting-uptex}. 223 | 224 | 225 | \newpage 226 | 227 | 228 | %%%%% 229 | \part{Details}% 各論 230 | 231 | %%% 出力フォーマット 232 | \section{Output format --- DVI} 233 | 234 | %%% DVI だけ 235 | The output of \pTeX\ family is always a DVI file. 236 | This is in contrast to the mainstream of \pdfTeX\ in the Western \TeX\ world. 237 | 238 | In case you are not familiar with DVI output processing, 239 | first we give some general notice on how to get a ``correct'' output 240 | using \LaTeX\ in DVI mode. 241 | 242 | \begin{itemize} 243 | \item The DVI format is, as its name suggests, inherently driver-independent. 244 | However, some \LaTeX\ packages (\Pkg{graphicx}, \Pkg{color}, \Pkg{hyperref} etc.) 245 | embed some \.{special} commands into the DVI, which can be interpreted later 246 | by some specific DVI driver. 247 | Such a DVI is no longer driver-independent, thus those are called 248 | driver-dependent packages. 249 | \item In almost all major \TeX\ distributions (of course including \TL), 250 | the default DVI driver is set to |dvips|. 251 | When you choose to process the resulting DVI file with a driver 252 | other than dvips (e.g. dvipdfmx) after running \LaTeX, 253 | you need to pass a proper driver option (e.g. |[dvipdfmx]|) to 254 | all driver-dependent packages. 255 | \end{itemize} 256 | 257 | %%% 日本の DVI ドライバの状況 258 | Now, let's move on to the situation in Japan, 259 | which is slightly complicated due to historical reasons 260 | but may also apply to other countries: 261 | \begin{itemize} 262 | \item There are two major conventions to pass a proper driver option 263 | to all driver-dependent packages: 264 | \begin{enumerate} 265 | \item To give a driver option to each driver-dependent package: 266 | \begin{verbatim} 267 | \documentclass{article} 268 | \usepackage[dvipdfmx]{graphicx} 269 | \usepackage[dvipdfmx]{color} 270 | \end{verbatim} 271 | \item To have a driver option as global: 272 | \begin{verbatim} 273 | \documentclass[dvipdfmx]{article} 274 | \usepackage{graphicx} 275 | \usepackage{color} 276 | \end{verbatim} 277 | \end{enumerate} 278 | The former convention has been used for many years since 1990s 279 | when the number of driver-dependent packages was limited. 280 | But in recent years (around 2010--), there are much more 281 | driver-dependent packages available. Thus 282 | we (Japanese \TeX\ experts) advise a global driver option 283 | rather than individual package options for simplicity, 284 | but not yet fully widespread.\footnote{The fact that 285 | there had been a mismatch in option names 286 | (\code{[dvipdfm]} vs. \code{[dvipdfmx]}) 287 | between packages may also have been part of it; 288 | \Pkg{geometry} did not understand \code{[dvipdfmx]} option until 2018!} 289 | \item Many people still see driver options as ``optional''; 290 | they do without driver options unless really needed. 291 | For example, the convention of having a global driver option 292 | does no harm even when no driver-dependent package is used, but 293 | some users choose to omit a driver option to avoid a warning\footnote{% 294 | Since \LaTeXe~2020-02-02, this warning is effectively gone. This is due 295 | to preloading of \Pkg{expl3} into the format, and the driver-dependent 296 | code of \Pkg{expl3} interprets the global driver option.}: 297 | \begin{verbatim} 298 | LaTeX Warning: Unused global option(s): 299 | [dvipdfmx]. 300 | \end{verbatim} 301 | \end{itemize} 302 | 303 | \subsection{Extensions of DVI format in \pTeX\ family} 304 | 305 | %%% pTeX の DVI は欧文の横組みだけなら普通。和文が入ると特殊,縦組ならIDも変化 306 | The DVI format output by \pTeX\ family is fully compatible with 307 | Knuthian \TeX, as long as the following conditions are met: 308 | \begin{itemize} 309 | \item No Japanese characters are typeset. 310 | \item There is no portion of vertical text alignment. 311 | \end{itemize} 312 | 313 | However, some additional DVI commands, which are defined in the 314 | standard \cite{dvistd0} but never used in \TeX82, can come out. 315 | \begin{itemize} 316 | \item |set2| (129): % |put2| (134) seems to be unused 317 | Used to typeset a Japanese character with 2-byte code 318 | (both \pTeX\ and \upTeX). 319 | \item |set3| (130): % |put3| (135) seems to be unused 320 | Used to typeset a Japanese character with 3-byte code 321 | (\upTeX\ only). 322 | \end{itemize} 323 | When \pTeX\ is going to typeset a Japanese character into DVI, 324 | it is encoded in JIS, which is always a 2-byte code. 325 | For this purpose, |set2| or |put2| are used. 326 | When \upTeX\ is going to output a Japanese character into DVI, 327 | it is encoded in UTF-32. 328 | If the code is equal to or less than |U+FFFF|, 329 | the lower 16-bit is used with |set2| or |put2|. 330 | If the code is equal to or greater than |U+10000|, 331 | the lower 24-bit is used with |set3| or |put3|. 332 | 333 | In addition, \pTeX/\upTeX\ defines one additional DVI command. 334 | \begin{itemize} 335 | \item |dir| (255): 336 | Used to change directions of text alignment. 337 | \end{itemize} 338 | The DVI format in the preamble is always set to 2, as with \TeX82. 339 | On the other hand, the DVI ID in the postamble can be special. 340 | Normally it is set to 2, as with \TeX82; however, 341 | when |dir| (255) appears at least once in a single \pTeX/\upTeX\ DVI, 342 | the |post_post| table of postamble contains $\mathrm{ID} = 3$. 343 | 344 | \subsection{DVI drivers with Japanese support} 345 | 346 | There are some DVI drivers with Japanese support. 347 | The most eminent drivers are \emph{dvips} and \emph{dvipdfmx}. 348 | Nowadays most of casual Japanese users are using \emph{dvipdfmx} as a DVI driver. 349 | On the other hand, users of \emph{dvips} are unignorable, especially those 350 | working in publishing industry. 351 | In recent years, most of major driver-dependent packages support 352 | both two drivers. 353 | 354 | \subsubsection{Using \emph{dvipdfmx}} 355 | 356 | A DVI file which is output by \pTeX\ can be converted directly to a PDF file 357 | using dvipdfmx. 358 | For Japanese fonts to be used in the output PDF, dvipdfmx refers to 359 | |kanjix.map| generated by the command |updmap|. 360 | You can use the script |kanji-config-updmap| to change font settings; 361 | please refer to its help message or documentation. 362 | 363 | \subsubsection{Using \emph{dvips}} 364 | 365 | A DVI file which is output by \pTeX\ can be converted to a PostScript file 366 | using dvips. 367 | For Japanese fonts to be used in the output PostScript, dvips refers to 368 | \code{psfonts.map} generated by the command \code{updmap}. 369 | You can use the script |kanji-config-updmap| to change font settings; 370 | please refer to its help message or documentation. 371 | 372 | The resulting PostScript file can then be converted to 373 | a PDF file using Ghostscript (ps2pdf) or Adobe Distiller. 374 | When using Ghostscript, a proper setup of Japanese font must be done 375 | before converting PostScript into PDF. 376 | An easy solution for the setup is to run a script |cjk-gs-integrate| 377 | developed by Japanese \TeX\ Development Community. 378 | 379 | \section{Programming on \pTeX\ family} 380 | 381 | We focus on programming aspects of \pTeX\ and its variants. 382 | 383 | %%% レジスタの数 384 | \subsection{Number of registers and marks} 385 | 386 | \pTeX\ and \upTeX\ have exactly the same number ($=256$) of registers 387 | (count, dimen, skip, muskip, box, and token) as Knuthian \TeX. 388 | \epTeX\ and \eupTeX\ in extended mode have more registers; 389 | there are 65536, which is twice as many as 32768 of \eTeX. 390 | Similarly \epTeX\ and \eupTeX\ have 65536 mark classes, 391 | which is twice as many as 32768 of \eTeX. 392 | 393 | The following code presents an example of detecting the number of 394 | regsiters and mark classes available: 395 | \begin{verbatim} 396 | \ifx\eTeXversion\undefined 397 | % Knuthian TeX, pTeX, upTeX: 398 | % 256 registers, 1 mark 399 | \else 400 | \ifx\omathchar\undefined 401 | % e-TeX, pdfTeX (in extended mode): 402 | % 32768 registers, 32768 mark classes 403 | \else 404 | % e-pTeX, e-upTeX (in extended mode): 405 | % 65536 registers, 65536 mark classes 406 | \fi 407 | \fi 408 | \end{verbatim} 409 | Here a primitive \.{omathchar}, which is derived from \OMEGA, is used 410 | as a marker of a change file \code{fam256.ch}.\footnote{% 411 | There is another \pTeX-derived engine named \pTeX-ng (or Asiatic \pTeX) 412 | \url{https://github.com/clerkma/ptex-ng}; it is based on 413 | \eTeX\ and \upTeX, but currently does not adopt \code{fam256.ch} 414 | so it has the same number of registers and mark classes as \eTeX.} 415 | 416 | %%% 数式ファミリの数 417 | \subsection{Number of math families} 418 | 419 | In \pTeX\ and \upTeX, 420 | the number of math fonts is restricted to 16, 421 | each of which can contain 256 characters (same as Knuthian \TeX). 422 | In \epTeX\ and \eupTeX, a change file \code{fam256.ch}, 423 | which is derived from \OMEGA, extends the upper limit to 256. 424 | As a consequence, \epTeX\ and \eupTeX\ allows 256 math fonts, 425 | each of which can contain 256 characters.\footnote{\OMEGA\ allows 426 | 256 math fonts, each of which can contain 65536 characters.} 427 | 428 | For \pLaTeX/\upLaTeX\ users to use more than 16 math fonts, 429 | it is necessary to use macros which exploit \OMEGA-derived primitives 430 | such as \.{omathchar}. 431 | Recent (u)\pLaTeX\ (since 2016/11/29) partially supports this, 432 | and the maximum number of math alphabets that can be defined by 433 | |\DeclareMathAlphabet| is extended to 256 (|\e@mathgroup@top|) 434 | without needing any extension package. 435 | However, symbol fonts are restricted to 16 as 436 | |\DeclareMathSymbol| etc still use the standard \.{mathchar} etc. 437 | A simple solution to use more symbol fonts as well as math alphabets 438 | is to load a package \Pkg{mathfam256}\footnote{% 439 | \url{https://www.ctan.org/pkg/mathfam256}} though it's still preliminary. 440 | 441 | %%% 拡張プリミティブ 442 | \subsection{Additional primitives and keywords} 443 | % -- as of r62095 444 | % tex -ini: 322 multiletter control sequences 445 | % ptex -ini: 374 multiletter control sequences (= 322 + p:48 + TL:3 + SyncTeX: 1) 446 | % uptex -ini: 381 multiletter control sequences (= 374 + up:7) 447 | % eptex -ini: 388 multiletter control sequences 448 | % eptex -ini -etex: 486 multiletter control sequences (= 374 + e:66 + ep:45 + TL:1) 449 | % euptex -ini: 395 multiletter control sequences 450 | % euptex -ini -etex: 494 multiletter control sequences (= 381 + e:66 + ep:46 + eup:1 + TL:1) 451 | % etex (pdftex) -ini: 477 multiletter control sequences 452 | % etex (pdftex) -ini -etex: 546 multiletter control sequences 453 | 454 | Here we provide only complete lists of additional primitives 455 | of \pTeX\ family in alphabetical order. 456 | The features of each primitive can be found in Japanese edition. 457 | 458 | % [TODO] 抜けがないか? 459 | % [TODO] アルファベット順に正しく並んでいるか? 460 | % [TODO] 追加されたバージョン情報は正しいか? 461 | 462 | \def\New#1{--- New primitive since #1} 463 | \def\NewKey#1{--- New keyword since #1} 464 | \def\NewMoved#1#2{--- Imported from #1, since #2} 465 | 466 | %%% pTeX のやつ 467 | \subsubsection{\pTeX\ additions (available in \pTeX, \upTeX, \epTeX, \eupTeX)} 468 | \begin{simplelist} 469 | \csitem[\.{autospacing}] 470 | \csitem[\.{autoxspacing}] 471 | \csitem[\.{disinhibitglue} \New{p3.8.2 (\TL2019)}] 472 | \csitem[\.{dtou}] 473 | \csitem[\.{euc}] 474 | \csitem[\.{ifdbox} \New{p3.2 (\TL2011)}] 475 | \csitem[\.{ifddir} \New{p3.2 (\TL2011)}] 476 | \csitem[\.{ifjfont} \New{p3.8.3 (\TL2020)}] 477 | \csitem[\.{ifmbox} \New{p3.7.1 (\TL2017)}] 478 | \csitem[\.{ifmdir}] 479 | \csitem[\.{iftbox}] 480 | \csitem[\.{iftdir}] 481 | \csitem[\.{iftfont} \New{p3.8.3 (\TL2020)}] 482 | \csitem[\.{ifybox}] 483 | \csitem[\.{ifydir}] 484 | \csitem[\.{inhibitglue}] 485 | \csitem[\.{inhibitxspcode}] 486 | \csitem[\.{jcharwidowpenalty}] 487 | \csitem[\.{jfam}] 488 | \csitem[\.{jfont}] 489 | \csitem[\.{jis}] 490 | \csitem[\.{kanjiskip}] 491 | \csitem[\.{kansuji}] 492 | \csitem[\.{kansujichar}] 493 | \csitem[\.{kcatcode}] 494 | \csitem[\.{kuten}] 495 | \csitem[\.{noautospacing}] 496 | \csitem[\.{noautoxspacing}] 497 | \csitem[\.{postbreakpenalty}] 498 | \csitem[\.{prebreakpenalty}] 499 | \csitem[\.{ptexfontname} \New{p4.1.0 (\TL2023)}] 500 | \csitem[\.{ptexlineendmode} \New{p4.0.0 (\TL2022)}] 501 | \csitem[\.{ptexminorversion} \New{p3.8.0 (\TL2018)}] 502 | \csitem[\.{ptexrevision} \New{p3.8.0 (\TL2018)}] 503 | \csitem[\.{ptextracingfonts} \New{p4.1.0 (\TL2023)}] 504 | \csitem[\.{ptexversion} \New{p3.8.0 (\TL2018)}] 505 | \csitem[\.{scriptbaselineshiftfactor} \New{p3.7 (\TL2016)}] 506 | \csitem[\.{scriptscriptbaselineshiftfactor} \New{p3.7 (\TL2016)}] 507 | \csitem[\.{showmode}] 508 | \csitem[\.{sjis}] 509 | \csitem[\.{tate}] 510 | \csitem[\.{tbaselineshift}] 511 | \csitem[\.{textbaselineshiftfactor} \New{p3.7 (\TL2016)}] 512 | \csitem[\.{tfont}] 513 | \csitem[\.{tojis} \New{p4.1.0 (\TL2023)}] 514 | \csitem[\.{toucs} \New{p3.10.0 (\TL2022)}] 515 | \csitem[\.{ucs} \NewMoved{\upTeX}{p3.10.0 (\TL2022)}\footnotemark] 516 | \csitem[\.{xkanjiskip}] 517 | \csitem[\.{xspcode}] 518 | \csitem[\.{ybaselineshift}] 519 | \csitem[\.{yoko}] 520 | \csitem[\texttt{H}\index{H=\texttt{H}}] 521 | \csitem[\texttt{Q}\index{Q=\texttt{Q}}] 522 | \csitem[\texttt{zh}\index{zh=\texttt{zh}}] 523 | \csitem[\texttt{zw}\index{zw=\texttt{zw}}] 524 | \end{simplelist} 525 | \footnotetext{The primitive \.{ucs} was part of ``\upTeX\ additions'' until \TL2021.} 526 | 527 | %%% upTeX のやつ 528 | \subsubsection{\upTeX\ additions (available in \upTeX, \eupTeX)} 529 | \begin{simplelist} 530 | \csitem[\.{disablecjktoken}] 531 | \csitem[\.{enablecjktoken}] 532 | \csitem[\.{forcecjktoken}] 533 | \csitem[\.{kchar}] 534 | \csitem[\.{kchardef}] 535 | %\csitem[\.{ucs}] % moved to pTeX 3.10.0 536 | \csitem[\.{uptexrevision} \New{u1.23 (\TL2018)}] 537 | \csitem[\.{uptexversion} \New{u1.23 (\TL2018)}] 538 | \end{simplelist} 539 | 540 | %%% e-pTeX/e-upTeX の pdfTeX 由来 541 | %%% e-pTeX/e-upTeX の Omega 由来 542 | %%% e-pTeX/e-upTeX の XeTeX/LuaTeX 由来 543 | %%% その他の独自拡張 544 | \subsubsection{\epTeX\ additions (available in \epTeX, \eupTeX)} 545 | \begin{simplelist} 546 | \csitem[\.{currentspacingmode} \New{191112 (\TL2020)}] 547 | \csitem[\.{currentxspacingmode} \New{191112 (\TL2020)}] 548 | \csitem[\.{epTeXinputencoding} \New{160201 (\TL2016)}] 549 | \csitem[\.{epTeXversion} \New{180121 (\TL2018)}] 550 | \csitem[\.{expanded} \New{180518 (\TL2019)}] 551 | \csitem[\.{hfi}] 552 | \csitem[\.{ifincsname} \New{190709 (\TL2020)}] 553 | \csitem[\.{ifpdfprimitive} \New{150805 (\TL2016)}] 554 | \csitem[\.{lastnodechar} \New{141108 (\TL2015)}] 555 | \csitem[\.{lastnodefont} \New{220214 (\TL2022)}] 556 | \csitem[\.{lastnodesubtype} \New{180226 (\TL2018)}] 557 | \csitem[\.{odelcode}] 558 | \csitem[\.{odelimiter}] 559 | \csitem[\.{omathaccent}] 560 | \csitem[\.{omathchar}] 561 | \csitem[\.{omathchardef}] 562 | \csitem[\.{omathcode}] 563 | \csitem[\.{oradical}] 564 | \csitem[\.{pagefistretch}] 565 | \csitem[\.{pdfcreationdate} \New{130605 (\TL2014)}] 566 | \csitem[\.{pdfelapsedtime} \New{161114 (\TL2017)}] 567 | \csitem[\.{pdffiledump} \New{140506 (\TL2015)}] 568 | \csitem[\.{pdffilemoddate} \New{130605 (\TL2014)}] 569 | \csitem[\.{pdffilesize} \New{130605 (\TL2014)}] 570 | \csitem[\.{pdflastxpos}] 571 | \csitem[\.{pdflastypos}] 572 | \csitem[\.{pdfmdfivesum} \New{150702 (\TL2016)}] 573 | \csitem[\.{pdfnormaldeviate} \New{161114 (\TL2017)}] 574 | \csitem[\.{pdfpageheight}] 575 | \csitem[\.{pdfpagewidth}] 576 | \csitem[\.{pdfprimitive} \New{150805 (\TL2016)}] 577 | \csitem[\.{pdfrandomseed} \New{161114 (\TL2017)}] 578 | \csitem[\.{pdfresettimer} \New{161114 (\TL2017)}] 579 | \csitem[\.{pdfsavepos}] 580 | \csitem[\.{pdfsetrandomseed} \New{161114 (\TL2017)}] 581 | \csitem[\.{pdfshellescape} \New{141108 (\TL2015)}] 582 | \csitem[\.{pdfstrcmp}] 583 | \csitem[\.{pdfuniformdeviate} \New{161114 (\TL2017)}] 584 | \csitem[\.{readpapersizespecial} \New{180901 (\TL2019)}] 585 | \csitem[\.{suppresslongerror} \New{211207 (\TL2022)}] 586 | \csitem[\.{suppressmathparerror} \New{211207 (\TL2022)}] 587 | \csitem[\.{suppressoutererror} \New{211207 (\TL2022)}] 588 | \csitem[\.{Uchar} \New{191112 (\TL2020)}] 589 | \csitem[\.{Ucharcat} \New{191112 (\TL2020)}] 590 | \csitem[\.{vadjust} \texttt{pre} \NewKey{210701 (\TL2022)}] 591 | \csitem[\.{vfi}] 592 | \csitem[\texttt{fi}\index{fi=\texttt{fi}}] 593 | \end{simplelist} 594 | 595 | %%% e-upTeX の独自拡張 596 | \subsubsection{\eupTeX\ additions (available in \eupTeX)} 597 | \begin{simplelist} 598 | \csitem[\.{currentcjktoken} \New{191112 (\TL2020)}] 599 | \end{simplelist} 600 | 601 | %%% ほか 602 | \subsubsection{Other cross-engine additions} 603 | % In the standard build of \TL, Sync\TeX\ extension is unavailable in 604 | % Knuthian \TeX; however, it is enabled in \pTeX\ family. 605 | Sync\TeX\ extension (available in \pTeX, \upTeX, \epTeX, \eupTeX): 606 | \begin{simplelist} 607 | \csitem[\.{synctex}] 608 | \end{simplelist} 609 | 610 | \noindent 611 | \TL additions (available in \pTeX, \upTeX, \epTeX, \eupTeX): 612 | \begin{simplelist} 613 | \csitem[\.{ignoreprimitiveerror} \New{250202 (\TL2025)}] % only e-(u)pTeX, not (u)pTeX 614 | \csitem[\.{partokencontext} \New{\TL2022}] 615 | \csitem[\.{partokenname} \New{\TL2022}] 616 | \csitem[\.{showstream} \New{\TL2022}] % only e-(u)pTeX, not (u)pTeX 617 | \csitem[\.{special} \texttt{shipout} \NewKey{230214 (\TL2023)}] % only e-(u)pTeX, not (u)pTeX 618 | \csitem[\.{tracingstacklevels} \New{\TL2021}] 619 | \end{simplelist} 620 | 621 | % [TODO] 引数は何で返り値は何か,expandable? 622 | 623 | %%% (e-)TeX にあるが (e-)upTeX にないもの 624 | %%% encTeX 拡張など 625 | \subsection{Omitted primitives and unsupported features} 626 | 627 | Compared to Knuthian \TeX\ and \eTeX, some primitives and extensions are 628 | omitted due to conflict with Japanese handling. 629 | \begin{itemize} 630 | \item The enc\TeX\ extension, including the primitives |\mubyte| etc., 631 | is unavailable. 632 | \item The ML\TeX\ extension, such as |\charsubdef|, is not enabled 633 | by default. It becomes available with the command-line option |-mltex|, 634 | but not well-tested. 635 | \end{itemize} 636 | 637 | %%% コマンドラインオプションの話 638 | 639 | % [TODO] Please also refer to ptex.man1.pdf 640 | 641 | \subsection{Behavior of Western \TeX\ primitives} 642 | 643 | Here we provide some notes on behavior of Knuthian \TeX\ and \eTeX\ primitives 644 | when used within \pTeX\ family. 645 | 646 | \subsubsection{Primitives with limitations in handling Japanese} 647 | 648 | Each of the following primitives allows only character codes 0--255; 649 | other codes will give an error ``! Bad character code.'' 650 | \begin{quote} 651 | |\catcode|, 652 | |\sfcode|, 653 | |\mathcode|, 654 | |\delcode|, 655 | |\lccode|, 656 | |\uccode|. 657 | \end{quote} 658 | 659 | Each of the following primivies has |\...char| in its name, 660 | however, the effective values are restricted to 0--255. 661 | \begin{quote} 662 | |\endlinechar|, 663 | |\newlinechar|, 664 | |\escapechar|, 665 | |\defaulthyphenchar|, 666 | |\defaultskewchar|. 667 | \end{quote} 668 | 669 | \subsubsection{Primitives capable of handling Japanese} 670 | 671 | The following primitives are extended to support Japanese characters: 672 | \begin{cslist} 673 | \csitem[\.{char} , 674 | \.{chardef} =] 675 | In addition to 0--255, internal codes of Japanese characters 676 | (see \ref{kanji-internal}) are allowed. 677 | For putting Japanese characters, a Japanese font 678 | (see \ref{japanese-fonts}) is chosen. 679 | Further information can be found in \ref{chardef}. 680 | 681 | \csitem[\.{font}, \.{fontname}, \.{fontdimen}] 682 | % [TODO] 683 | 684 | \csitem[\.{accent} =] 685 | % [TODO] 686 | 687 | \csitem[\.{if} , \.{ifcat} ] 688 | Japanese character token is also allowed. 689 | In that case, 690 | \begin{itemize} 691 | \item |\if| tests the internal character code of the Japanese character. 692 | \item |\ifcat| tests the |\kcatcode| of the Japanese character. 693 | \end{itemize} 694 | \end{cslist} 695 | 696 | \begin{dangerous} 697 | \TeX book describes the behavior of |\if| and |\ifcat| as follows; 698 | \begin{quote} 699 | If either token is a control sequence, 700 | \TeX\ considers it to have character code 256 and category code 16, 701 | unless the current equivalent of that control sequence 702 | has been |\let| equal to a non-active character token. 703 | \end{quote} 704 | However, this includes a lie; in the real implementation of \code{tex.web}, 705 | a control sequence is considered to have a category code 0. 706 | \end{dangerous} 707 | 708 | \subsection{Case study} 709 | 710 | Here we provide some code examples 711 | which may be useful for package developers. 712 | % [TODO] 本当は Based on the above knowledge としたいところだが 713 | % 説明が圧倒的に不足しているので天下り的なコード解説… 714 | 715 | %%% pTeX かどうかの判定 716 | \subsubsection{Detecting \pTeX} 717 | 718 | Since the primitive |\ptexversion| is rather new (added in 2018), 719 | the safer solution for detecting \pTeX\ is 720 | to test if a primitive |\kanjiskip| is defined. 721 | \begin{verbatim} 722 | \ifx\kanjiskip\undefined 723 | \else 724 | % pTeX / upTeX / e-pTeX / e-upTeX 725 | \fi 726 | \end{verbatim} 727 | 728 | %%% upTeX かどうかの判定 729 | \subsubsection{Detecting \upTeX}\label{detecting-uptex} 730 | 731 | \upTeX\ is almost upward compatible with \pTeX, however, 732 | there are two major differences: 733 | \begin{enumerate} 734 | \item Improvements in the \.{kcatcode} business, 735 | mainly for better handling of Latin-1 characters and CJK tokens. 736 | \item Unicode as the default internal Japanese encoding 737 | (see \ref{kanji-internal}), 738 | for direct use of its huge character set. 739 | \end{enumerate} 740 | 741 | The first difference can be detected by checking if 742 | \.{...cjktoken} primitive is defined. 743 | \begin{verbatim} 744 | \ifx\enablecjktoken\undefined 745 | \else 746 | % upTeX/e-upTeX 747 | \fi 748 | \end{verbatim} 749 | This can be called ``engine detection'' of \upTeX. 750 | 751 | The second difference can be detected by checking if 752 | the character \code{0x2121} (fullwidth space in JIS encoding) 753 | is stored as \hex{3000} internally. 754 | \begin{verbatim} 755 | \ifx\kanjiskip\undefined 756 | \else 757 | \ifnum\jis"2121="3000 758 | % upTeX/e-upTeX with internal Unicode 759 | \else 760 | % pTeX/e-pTeX 761 | % or, upTeX/e-upTeX with internal EUC-JP or Shift-JIS 762 | \fi 763 | \fi 764 | \end{verbatim} 765 | This can be called ``encoding detection'' of \upTeX. 766 | 767 | Please note that 768 | the format-build setting of \verb+-kanji-internal=(sjis|euc)+ with 769 | \upTeX\ makes it effectively \pTeX\ regarding the character set, 770 | which means that only JIS~X~0208 character set is supported. 771 | This can be called ``legacy-encoding-compatibility mode'' 772 | of \upTeX, where the \.{kcatcode} difference remains 773 | but the internal encoding difference disappears. 774 | This method is used in building |platex.fmt| on \eupTeX, 775 | since 2023-06-01. Therefore, to distinguish \upLaTeX\ from \pLaTeX, 776 | ``engine detection'' is not enough; you should use ``encoding detection.'' 777 | 778 | %%% pTeX のバージョン判定 779 | % [TODO] 何が有用? 780 | 781 | %%% 大きな定数を定義する話 782 | \subsubsection{Defining large integer constants} 783 | \label{chardef} 784 | 785 | According to \cite{topic} (Section 3.3), 786 | \begin{quote} 787 | A control sequence that has been defined with a \.{chardef} command 788 | can also be used as a . 789 | This fact is used in allocation commands such as |\newbox|. 790 | Tokens defined with \.{mathchardef} can also be used this way. 791 | \end{quote} 792 | Here is the list of primitives which can be used for this purpose 793 | in \pTeX\ family: 794 | \begin{simplelist} 795 | \csitem[\.{chardef} =] 796 | Defines a control sequence to be a synonym for 797 | \.{char} . 798 | 799 | \csitem[\.{kchardef} = (for \upTeX/\eupTeX)] 800 | Defines a control sequence to be a synonym for 801 | \.{kchar} . 802 | 803 | \csitem[\.{mathchardef} =<15-bit number>] 804 | Defines a control sequence to be a synonym for 805 | \.{mathchar} <15-bit number>. 806 | 807 | \csitem[\.{omathchardef} =<27-bit number> (for \epTeX/\eupTeX)] 808 | Defines a control sequence to be a synonym for 809 | \.{omathchar} <27-bit number>. 810 | \end{simplelist} 811 | 812 | The first two (\.{chardef} and \.{kchardef}) are usable only when 813 | the integer being defined is in the range of valid character codes, 814 | which is not necessarily continuous (see \ref{kanji-internal}). 815 | The most efficient and convenient way of defining integer constants 816 | is as follows: 817 | \begin{itemize} 818 | \item 0--255: \.{chardef} 819 | % "FF = 255 820 | \item 256--32767: \.{mathchardef} 821 | % "7FFF = 32767 822 | \item 32768--134217727: \.{omathchardef} (only for \epTeX/\eupTeX) 823 | % "7FFFFFF = 134217727 824 | \end{itemize} 825 | 826 | %%% 指定のコードの和文トークンを得る方法 827 | \subsubsection{Creating a Japanese character token with a specified code}\label{jtoken-tricks} 828 | 829 | Short version: 830 | \begin{itemize} 831 | \item With \epTeX~191112 or later (\TL2020), 832 | you can use expandable primitives \.{Uchar} and \.{Ucharcat}. 833 | \item Otherwise, use the ``\.{kansuji} trick''. 834 | \end{itemize} 835 | 836 | \paragraph{The ``\.{kansuji} trick''} 837 | This is a modified version of the ``\.{lowercase} trick'' 838 | available in \pTeX\ family. 839 | 840 | \begin{dangerous} 841 | Short note on the ``\.{lowercase} trick'': 842 | to create a character token with a specified code value between 0--255 843 | with Knuthian \TeX, the ``\.{lowercase} trick'' can be used; for example, 844 | \begin{verbatim} 845 | \begingroup 846 | \lccode`\?=\mycount 847 | \lowercase{\endgroup \def\X{?}} 848 | \end{verbatim} 849 | defines |\X| which expands to a character number |\mycount| 850 | while the \.{catcode} of |?| (\the\catcode`\?) is preserved. 851 | However, the trick cannot be applied to Japanese characters, 852 | since \pTeX\ family does not support \.{lccode} outside 0--255. 853 | \end{dangerous} 854 | 855 | \.{kansuji} is an expandable primitive like \.{number} or \.{romannumeral}, 856 | and it converts an integer into its corresponding \Foreign{kanji} notation 857 | called \Foreign{kansuji} (漢数字). The important point here is that 858 | the number-\Foreign{kanji} mapping can be altered by \.{kansujichar}. 859 | 860 | Example 1: equivalent to |\def\X{あ}| (JIS code \code{0x2422} is ``あ''): 861 | \begin{verbatim} 862 | \begingroup 863 | \kansujichar1=\jis"2422 \xdef\X{\kansuji1} 864 | \endgroup 865 | \end{verbatim} 866 | 867 | Example 2: equivalent to |\def\日本{Japan}|. 868 | \begin{verbatim} 869 | \begingroup 870 | \kansujichar5=\jis"467C\relax 871 | \kansujichar6=\jis"4B5C\relax 872 | \expandafter\gdef\csname\kansuji56\endcsname{Japan} 873 | \endgroup 874 | \end{verbatim} 875 | 876 | Since \.{kansujichar} accepts only Japanese character code, 877 | the ``\.{kansuji} trick'' and the ``\.{lowercase} trick'' should be 878 | used complementarily. 879 | 880 | \paragraph{\.{Uchar}, \.{Ucharcat}} 881 | The ``\.{kansuji} trick'' above includes an assignment of \.{kansujichar} 882 | which is unexpandable. 883 | \epTeX~191112 or later (\TL2020) provides expandable primitives 884 | \.{Uchar} and \.{Ucharcat}, which are derived from \hologo{XeTeX}. 885 | Regardless of their names, and unlike \hologo{XeTeX} or \hologo{LuaTeX}, 886 | these primitives do \emph{not} necessarily take 887 | a Unicode value as an argument. 888 | These primitives in \epTeX\ and \eupTeX\ take a valid character code 889 | (see \ref{kanji-internal}) based on the internal Japanese encoding. 890 | 891 | \begin{simplelist} 892 | \csitem[\.{Uchar} ] 893 | Expands to a character token with specified slot . 894 | \begin{itemize} 895 | \item When an 8-bit number (0--255) is given, 896 | it expands to a Latin character token with category code 12, 897 | except for a space character (32) which has category code 10. 898 | \item When a Japanese character code greater than 255 is given, 899 | it expands to a Japanese character token with its current category code; 900 | 16--18 for \epTeX, 16--19 for \eupTeX. 901 | % [TODO] 本当は pTeX では和文文字トークン自体は \kcatcode を 902 | % 持たないが,簡単のためまあいっか. 903 | \end{itemize} 904 | 905 | \csitem[\.{Ucharcat} ] 906 | Expands to a character token with slot and 907 | specified. 908 | \begin{itemize} 909 | \item With \epTeX: 910 | \begin{itemize} 911 | \item Only 8-bit number (0--255) are allowed for ; 912 | that is, only Latin characters can be generated. 913 | \item The values allowed for are 1--4, 6--8, 10--13. 914 | \end{itemize} 915 | \item With \eupTeX: 916 | \begin{itemize} 917 | \item When is between 0--127, 918 | only Latin characters can be generated. 919 | Thus, the values allowed for are 920 | 1--4, 6--8, 10--13. 921 | \item When is between 128--255, 922 | both Latin and Japanese characters can be generated 923 | depending on the specified ; 924 | 1--4, 6--8, 10--13: Latin character, 925 | 16--19: Japanese character. 926 | \item When is greater than 255, 927 | only Japanese characters can be generated. 928 | Thus, the values allowed for are 929 | 16--19. 930 | \end{itemize} 931 | \end{itemize} 932 | \end{simplelist} 933 | 934 | %%% pdfTeX と違うところ 935 | \subsection{Difference from \pdfTeX\ in DVI mode}\label{dvi-pdftex} 936 | 937 | As stated in Section \ref{compat}, \epTeX/\eupTeX\ are 938 | \emph{not} upward compatible with DVI mode of \pdfTeX, 939 | which is available as the |etex| command in \TL. 940 | Here we list some important differences: 941 | 942 | %%% pdfTeX の DVI モードにあって e-(u)pTeX にないプリミティブ 943 | First, some \pdfTeX-specific primitives are absent. Examples: 944 | \begin{itemize} 945 | \item All primitives specific to PDF output: 946 | \.{pdfoutput}, \.{pdfinfo}, \.{pdfobj} etc.\footnote{% 947 | \epTeX/\eupTeX\ has primitives \.{pdfpagewidth} and \.{pdfpageheight}; 948 | this is just because they were convenient for implementing \.{pdfsavepos}, 949 | and their behavior is somewhat different from that of \pdfTeX. 950 | Also note that \epTeX/\eupTeX\ does not have \.{pdfhorigin} 951 | and \.{pdfvorigin}.} 952 | \item All primitives related to micro-typography: 953 | \.{pdffontexpand}, \.{pdfprotrudechars}, etc. 954 | \item Some primitives related to handling of strings: 955 | \.{pdfescapestring}, \.{pdfescapehex} etc. 956 | \end{itemize} 957 | 958 | 959 | %%% その他ムニャムニャ 960 | 961 | %%% ファイルの文字コードはどうするか 962 | \subsection{Recommendation for file encoding}\label{file-enc} 963 | 964 | Due to historical reasons, 965 | multiple encodings are commonly used for Japanese text. 966 | Sometimes user documents and distribution files (classes, packages) 967 | may have different encodings. 968 | Among those, the universal UTF-8 and 969 | three major legacy encodings (ISO-2022-JP, EUC-JP, Shift-JIS) 970 | are accepted as input to \pTeX\ family, 971 | depending on the configuration and runtime options. 972 | To make this possible, 973 | \pTeX\ family does code conversion in input and output. 974 | 975 | The details are too complicated, so here we propose 976 | the optimum solution for Japanese file encoding 977 | for package/class developers who aim to support \pTeX\ family: 978 | 979 | %%% 全部アスキーにしてしまえ 980 | %%% UTF-8 にしたい場合はムニャムニャ 981 | %%% \epTeXinputencoding を使う話 982 | \begin{itemize} 983 | \item \underline{If you want to distribute files on CTAN/\TL, please use UTF-8.} 984 | \par 985 | UTF-8 files are \emph{almost always} safe enough 986 | for recent \pTeX/\upTeX\ (2018--), 987 | and the same files will have no problem when read by Western \TeX. 988 | To secure this ``\emph{almost always}'' to ``\emph{always}'', please add 989 | below at the beginning of your individual UTF-8 files:\par\quad 990 | \verb+\ifx\epTeXinputencoding\undefined \else \epTeXinputencoding utf8 \fi+\par 991 | it will help \pTeX\ family to read forcibly in UTF-8, 992 | so it becomes \emph{always} safe for 2016--. 993 | \item \underline{If you aim to support broader legacy environment of \pTeX\ specifically, ...} 994 | \par 995 | Extra care is required for missing features and 996 | different configurations which can lead to failure of reading UTF-8. 997 | There is no such thing as a perfect solution; instead, 998 | you should choose between encoding in ISO-2022-JP 999 | or writing in ASCII characters. 1000 | \begin{itemize} 1001 | \item Encoding in ISO-2022-JP:\par 1002 | All historical versions of \pTeX\ family can always read 1003 | ISO-2022-JP properly because it's a 7-bit encoding 1004 | safely distinguished from others. 1005 | This is why many old packages/classes widely used in Japan 1006 | are particularly encoded in ISO-2022-JP.\par 1007 | On the other hand, ISO-2022-JP is unsupported in Western \TeX; 1008 | also, CTAN/\TL requires some special handling of uploaded files. 1009 | \item Writing in ASCII characters:\par 1010 | Safe for Western \TeX\ and CTAN/\TL, but often requires lots of 1011 | {\TeX}niques and hard-to-read programmings (e.g. generating 1012 | Japanese tokens as in Section \ref{jtoken-tricks}, or encoding into 1013 | hex dump as in \Pkg{bxjalipsum.sty}, ...) 1014 | \end{itemize} 1015 | ... Annoying? Please forget that legacy environment ;-) 1016 | \end{itemize} 1017 | 1018 | \begin{dangerous} 1019 | For your information, here is the behavior of the common default 1020 | configuration available in the latest \TL distribution (since 2023). 1021 | \begin{itemize} 1022 | \def\Opt#1{\textcolor{red}{#1}} 1023 | \item \upTeX\ default: always properly reads \Opt{UTF-8} and ISO-2022-JP. 1024 | \item \pTeX\ default: always properly reads ISO-2022-JP. 1025 | It also properly reads \Opt{UTF-8} almost always\footnote{The 1026 | exception of ``almost always'' comes from a failure of guessing; 1027 | at the expense of properly reading a certain amount of 1028 | Shift-JIS and EUC-JP, there are occasional misreading of UTF-8.}, 1029 | and successful results of ``guess-input-enc'' conversion of 1030 | Shift-JIS and EUC-JP. 1031 | \item When the command-line option \verb+-kanji=(sjis|euc)+ is 1032 | specified: \Opt{UTF-8} above is replaced with the given encoding. 1033 | \end{itemize} 1034 | \end{dangerous} 1035 | 1036 | \begin{dangerous} 1037 | Note on older versions: 1038 | \begin{itemize} 1039 | \item The ``guess-input-enc'' conversion status above is relatively new: 1040 | \begin{itemize} 1041 | \item In \TL2023, it is available for all platform of \TL. 1042 | Default on for (\eTeXpre)\pTeX, off for (\eTeXpre)\upTeX, 1043 | but also controlled by runtime option \code{-(no-)guess-input-enc}. 1044 | \item In \TL2022 and older, it was limited for Windows only; 1045 | also, default on for all of (\eTeXpre)(u)\pTeX. 1046 | For Unix it was not implemented yet. 1047 | \end{itemize} 1048 | \item In \TL2017 and older, 1049 | the default input encoding of (\eTeXpre)\pTeX\ was 1050 | Shift-JIS for Windows, UTF-8 for Unix. 1051 | \item The primitive \.{epTeXinputencoding} was added to 1052 | \epTeX/\eupTeX\ in \TL2016. Older versions does not have it. 1053 | \item Very old distributions by ASCII Corporation (--2009) 1054 | supported only legacy encodings; UTF-8 was not allowed. 1055 | \end{itemize} 1056 | \end{dangerous} 1057 | 1058 | %%% e-upTeX の入力解析:euc/sjis を語りたくないので utf8.uptex 前提 1059 | \subsection{Input handling} 1060 | 1061 | For simplicity, first we introduce how \upTeX\ handles the input 1062 | when all files are UTF-8. 1063 | %%% 文字の和文扱い・欧文扱い 1064 | %%% 和文カテゴリーコード 1065 | %%% \...cjktoken 1066 | \begin{enumerate} 1067 | \item An input line is stored into the internal buffer. 1068 | (No effective code conversion here for \upTeX\footnote{To be precise, 1069 | it passes through a code conversion; however, this is an identity conversion 1070 | which has no effect because \upTeX\ defaults to internal Unicode.}.) 1071 | \item The input processor reads the buffer. 1072 | Here Japanese character tokens are distinguished from 1073 | ordinary 8-bit character tokens. 1074 | \item ... [TODO] 1075 | \end{enumerate} 1076 | 1077 | %%% ちなみに e-pTeX では:euc/sjis があることにだけ触れる 1078 | The situation is more complicated in \pTeX. 1079 | As described in Section \ref{file-enc}, it accepts UTF-8 input; 1080 | however, \pTeX\ uses a legacy encoding as the internal Japanese encoding 1081 | (default: Shift-JIS on Windows, and EUC-JP otherwise). 1082 | This means that \pTeX\ does code conversion in input and output. 1083 | ... [TODO] 1084 | 1085 | %%% e-upTeX の和文トークンの話:和文トークンが混ざっているので注意 1086 | \subsection{Japanese tokens} 1087 | 1088 | %%% 文字トークンが和文であるかを判定する方法 1089 | %%% (1) \meaning が kanji で始まるかどうか 1090 | %%% (2) pTeX: 文字コードが 256 以上かどうか 1091 | %%% (3) upTeX: 予め作っておいた \kcatcode 16--19 のトークン各々と \ifcat で比較 1092 | 1093 | %%% 和文組版の厳選トピック 1094 | \section{Basic introduction to Japanese typesetting} 1095 | 1096 | %%% 和文をやり過ごすために注意すべきこと 1097 | This section does not aim to explain Japanese typesetting completely; 1098 | here we provide a minimum requirement for ``getting away'' with Japanese. 1099 | 1100 | %%% 空白・ペナルティ挿入:勝手に入ってくる! 1101 | \subsection{Automatic insertion of glue and penalties} 1102 | 1103 | Sometimes \pTeX\ family automatically inserts glue and penalties 1104 | between characters. 1105 | % [TODO] もう少しだけ詳しく 1106 | 1107 | %%% 和文フォント 1108 | \subsection{Japanese fonts}\label{japanese-fonts} 1109 | 1110 | %%% 欧文とは別個 1111 | \pTeX\ family can have 3 different ``current'' fonts at the same time; 1112 | a Latin font, a Japanese font for horizontal writing (\Foreign{yoko-gumi}), 1113 | and a Japanese font for vertical writing (\Foreign{tate-gumi}). 1114 | The first one is the same as in the Knuthian \TeX, 1115 | which is defined in a standard TFM format. 1116 | The latter two are specific to \pTeX\ family, which are defined 1117 | in a JFM (Japanese \TeX\ font metric) format.\footnote{% 1118 | A JFM is a modified version of the standard TFM. 1119 | It can be created by (u)pPLtoTF, and decoded by (u)pTFtoPL. 1120 | Please also refer to the man pages of these programs 1121 | (\code{ppltotf.man1.pdf} and \code{ptftopl.man1.pdf}).} 1122 | 1123 | While typesetting, \pTeX\ family automatically switches between 1124 | these 3 fonts, depending on the character code and the writing direction: 1125 | \begin{itemize} 1126 | \item For typesetting Latin characters, 1127 | the current Latin font shown by |\the\font| is selected. 1128 | \item For typesetting Japanese characters, 1129 | the current Japanese font suitable for the current writing direction 1130 | is selected. It is shown by |\the\jfont| for horizontal writing 1131 | and |\the\tfont| for vertical writing. 1132 | \end{itemize} 1133 | 1134 | %%% \nullfont しても全部消えない 1135 | %%% 「和文 \nullfont」は和文フォントが一回もグローバルに 1136 | %%% 設定されていないとき = iniTeX 時しかない 1137 | In Knuthian \TeX, the primitive \.{nullfont} refers to an ``empty font'' 1138 | in which all characters are undefined. 1139 | However in \pTeX\ family, this is regarded as a Latin font 1140 | and there is no equivalent to ``Japanese \.{nullfont}'' by design. 1141 | To elaborate, it is possible \emph{only} when no Japanese font is 1142 | set globally, i.e. in ini\TeX\ mode. 1143 | Once a valid Japanese font is selected, there is no way of 1144 | selecting ``Japanese \.{nullfont}'' to discard all characters. 1145 | 1146 | Moreover, \pTeX\ and friends assume that each Japanese font 1147 | (except ``Japanese \.{nullfont}'' in ini\TeX\ mode) 1148 | contains all valid Japanese character code. 1149 | In other words, all Japanese fonts share the same character set 1150 | corresponding to the whole valid Japanese character code range.\label{jfont} 1151 | 1152 | \section{Other strange beasts} 1153 | 1154 | %%% 縦組は諦めよう 1155 | 1156 | % [TODO] どこに書くか困ったので最後に:内部コードのアレな話 1157 | %%% 和文文字コードは連続でない 1158 | \subsection{Internal Japanese encodings}\label{kanji-internal} 1159 | 1160 | The is a union of the following two: 1161 | \begin{itemize} 1162 | \item Range of numbers between 0--255, and 1163 | \item Numbers allowed for internal code of Japanese characters. 1164 | \end{itemize} 1165 | The former is the same as Knuthian \TeX, but the latter is a problem. 1166 | 1167 | In \upTeX\ (default internal Unicode mode), the range is very simple: 1168 | \[ c \ge 0 \] 1169 | 1170 | However in \pTeX, only limited encodings are available; 1171 | Shift-JIS as |sjis| (default for \TL Windows), or 1172 | EUC-JP as |euc| (otherwise). 1173 | The range can be represented as follows: 1174 | \[ 1175 | c = 256c_1+c_2 \; (c_i\in C_i) 1176 | \] 1177 | where 1178 | \[ 1179 | \begin{cases} 1180 | C_1=C_2=\{\hex{a1},\dots,\hex{fe}\} & (\mathtt{euc}), \\ 1181 | C_1=\{\hex{81},\dots,\hex{9f}\}\cup\{\hex{e0},\dots,\hex{fc}\}, 1182 | C_2=\{\hex{40},\dots,\hex{7e}\}\cup\{\hex{80},\dots,\hex{fc}\} & (\mathtt{sjis}). 1183 | \end{cases} 1184 | \] 1185 | Therefore, the overall range of is \emph{not} continuous. 1186 | This is similar for ``legacy-encoding-compatibility mode'' of \upTeX. 1187 | 1188 | %%% 和文文字の内部コードとして有効(is_char_kanji が真)かどうかの判定 1189 | %%% → ! Bad character code. エラーを出さないために使える 1190 | To check whether an integer is a valid Japanese character code or not, 1191 | you can use \.{iffontchar} with \epTeX~190709 or later (\TL2020). 1192 | Suppose a count register |\mycount| stores an integer, you can do it as follows: 1193 | \begin{verbatim} 1194 | \iffontchar\jfont\mycount 1195 | % \mycount is a valid Japanese character code 1196 | \fi 1197 | \end{verbatim} 1198 | Here the primitive \.{jfont} is used merely as 1199 | a representative non-empty\footnote{This assumption is always safe after 1200 | one of the standard \pTeX\ formats (e.g. plain \pTeX, \pLaTeX) is loaded.} 1201 | Japanese font containing all valid Japanese character code (see \ref{jfont}). 1202 | 1203 | %%% pTeX がサポートする文字集合は JIS X 0208 のみで,内部コードとして有効な範囲より狭い 1204 | %%% → JIS X 0208 に含まれる文字を表す整数値の判定もできる 1205 | Note that \pTeX\ (not including \upTeX\ with internal Unicode) does not 1206 | support typesetting characters outside JIS~X~0208, 1207 | which is a subset of accepted range of described above. 1208 | To check if an integer is in the range of JIS~X~0208, 1209 | you can use \.{toucs} with \pTeX~p3.10.0 or later (\TL2022): 1210 | \begin{verbatim} 1211 | \ifnum\toucs\mycount>0 1212 | % \mycount is in the range of JIS X 0208 1213 | \fi 1214 | \end{verbatim} 1215 | The primitive \.{toucs} converts an integer value 1216 | from an internal Japanese code to a Unicode. 1217 | This conversion is based on JIS-Unicode mapping table,\footnote{Defined in 1218 | \code{jisx0208.h} of \code{ptexenc} library.} and returns $-1$ 1219 | if no mapping is available for the input integer. 1220 | 1221 | 1222 | \newpage 1223 | 1224 | \begin{thebibliography}{99} 1225 | \bibitem{dvistd0} TUG DVI Standards Working Group, 1226 | \textit{The DVI Driver Standard, Level 0}.\\ 1227 | \url{https://ctan.org/pkg/dvistd} 1228 | \bibitem{topic} Victor Eijkhout, \textit{\TeX\ by Topic, A \TeX nician's Reference}, 1229 | Addison-Wesley, 1992.\\ 1230 | \url{https://www.eijkhout.net/texbytopic/texbytopic.html} 1231 | \end{thebibliography} 1232 | 1233 | \newpage 1234 | \printindex 1235 | 1236 | 1237 | \end{document} 1238 | -------------------------------------------------------------------------------- /ptex-manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/ptex-manual.pdf -------------------------------------------------------------------------------- /ptex-manual.sty: -------------------------------------------------------------------------------- 1 | %%% common macros for ptex-manual documents 2 | \def\headfont{\normalfont\mathversion{bold}\sffamily} 3 | \def\.#1{\texorpdfstring{% 4 | \leavevmode\hbox{\texttt{\textbackslash#1}}\ifmmode\else\textcompwordmark\fi}{\textbackslash #1}} 5 | 6 | \@ifpackageloaded{enumitem}{% 7 | \let\orig@cs=\. 8 | \def\ind@cs#1{\orig@cs{#1}\indcs{#1}} 9 | \def\indcs#1{\index{{\texttt{\textbackslash #1}}}} 10 | \newlist{cslist}{description}1 11 | \setlist[cslist]{% 12 | itemsep=\medskipamount,listparindent=1zw, 13 | font=\normalfont\mdseries, leftmargin=2zw, 14 | before=\advance\@listdepth\@ne, 15 | after=\advance\@listdepth\m@ne 16 | } 17 | \def\csitem[#1]{\item[\llap{$\blacktriangleright$~}\let\.=\ind@cs#1] 18 | \leavevmode\par\nopagebreak} 19 | }{} 20 | 21 | \let\origemph=\emph 22 | \def\emph#1{{\bfseries\sffamily\gtfamily\selectfont\mathversion{bold}#1}} 23 | \def\paragraph#1{\par\medskip\par\noindent\emph{■#1}\par\nobreak} 24 | 25 | \def\Pkg#1{\textsf{#1}} 26 | \def\adj@underbar{\catcode`\_=12 } 27 | \def\code{\begingroup\adj@underbar\code@} 28 | \def\code@#1{\endgroup\texttt{#1}} 29 | \def\file{\begingroup\adj@underbar\file@} 30 | \def\file@#1{\endgroup\textsf{#1}} 31 | \def\node{\begingroup\adj@underbar\node@} 32 | \def\node@#1{\endgroup\textit{#1}} 33 | \def\hex#1{\ifmmode\mbox\fi{\texttt{"#1}}}%" 34 | \def\codechar#1{\ensuremath{\langle\mbox{\kern0pt\code{#1}\kern0pt}\rangle}} 35 | \def\>{\ifhmode\hskip\xkanjiskip\fi} 36 | 37 | % print character code in hexadecimal 38 | \def\codeHEX#1{\code{\omathchardef\omc@=#1\relax\strip@omch@r{\meaning\omc@}}} 39 | {\escapechar-1 \xdef\omch@r{\string\omathchar}} 40 | \def\strip@omch@r#1{\expandafter\strip@omch@r@#1} 41 | \expandafter\def\expandafter\strip@omch@r@\expandafter#\expandafter1\omch@r#2{#2} 42 | 43 | \let\@lessthan < 44 | \begingroup 45 | \catcode`\<=13 46 | \gdef<{\ifmmode\@lessthan\else\expandafter\@@meta\fi} 47 | \gdef\@@meta#1>{\ensuremath{\langle\hbox{\normalfont\textit{#1}}\rangle}} 48 | \endgroup 49 | \AtBeginDocument{\catcode`\<=13\relax} 50 | \let\OR | 51 | 52 | \xspcode`\\=3 53 | \xspcode`\*=3 54 | \xspcode`\-=3 55 | \xspcode`\"=3 56 | \xspcode23=3 % \textcompwordmark 57 | 58 | \normalsize 59 | \bigskipamount=\baselineskip 60 | \medskipamount=.5\baselineskip 61 | \smallskipamount=.25\baselineskip 62 | 63 | \usepackage{etoolbox} 64 | \patchcmd\@verbatim\@totalleftmargin{\dimexpr\@totalleftmargin+2zw\relax}{}{} 65 | \patchcmd\quote{\list{}}{\par\addvspace\medskipamount\list{}}{}{} 66 | \patchcmd\endquote{\endlist}{\endlist\addvspace\medskipamount}{}{} 67 | \patchcmd\@verbatim{\trivlist}{\trivlist\addvspace\medskipamount\noautoxspacing}{}{} 68 | \patchcmd\endverbatim{\endtrivlist}{\endtrivlist\addvspace\medskipamount}{}{} 69 | \expandafter\let\csname endverbatim*\endcsname =\endverbatim 70 | \patchcmd\verb{\ifmmode\hbox\else\leavevmode\vadjust{}\fi\bgroup} 71 | {\ifmmode\else\leavevmode\vadjust{}\fi\hbox 72 | \bgroup\textcompwordmark\noautoxspacing\noautospacing}{}{} 73 | \patchcmd\verb@egroup{\egroup}{\egroup\textcompwordmark}{}{} 74 | 75 | \ifx\jsc@clsname\@undefined\else % jsclasses-specific 76 | \renewenvironment{theindex}{% 77 | \def\presectionname{}\def\postsectionname{}% 78 | \section*{\indexname} 79 | \@mkboth{\indexname}{\indexname}% 80 | \plainifnotempty % \thispagestyle{plain} 81 | \parindent\z@ 82 | \parskip\z@ \@plus .3\p@\relax 83 | \let\item\@idxitem 84 | \raggedright 85 | \begin{multicols}{2} 86 | }{ 87 | \end{multicols} 88 | \clearpage 89 | } 90 | \fi 91 | 92 | % multilist env. 93 | \newenvironment{multilist}[2]% 94 | {$$\setbox\z@=\hbox\bgroup % catch some funny things -> \mathord 95 | \let\a=\empty 96 | \let\b=\empty 97 | \count@=\z@ 98 | \toks@={#2}% 99 | \def\item##1\cr 100 | {\ifnum \count@=\z@ 101 | \count@=#1% 102 | \expandafter\def\expandafter\b\expandafter{\b\y{}}% 103 | \fi 104 | \advance\count@ by\m@ne 105 | \expandafter\def\expandafter\a\expandafter{\a\x{##1}}}% 106 | \ignorespaces}% 107 | {\loop 108 | \ifnum \count@>\z@ 109 | \expandafter\def\expandafter\a\expandafter{\a\expandafter\z\b\relax}% 110 | \advance\count@ by\m@ne 111 | \repeat 112 | \def\x##1{\expandafter\y\b\relax{##1}}% 113 | \def\y\y##1##2\relax##3% 114 | {\ifx @##1@% 115 | \def\b{##2\y{##3}}% 116 | \else 117 | \def\b{##2\y{##1&##3}}% 118 | \fi}% 119 | \def\z\y##1##2\relax{\def\b{##2\y{##1}}}% 120 | \a 121 | \def\x 122 | {\expandafter\egroup\expandafter\halign\expandafter\bgroup 123 | \expandafter&\the\toks@\cr}% 124 | \def\y##1{\expandafter\def\expandafter\x\expandafter{\x##1\cr}}% 125 | \b 126 | \x\egroup $$} 127 | 128 | % dangerous env. 129 | \font\man=manfnt at 10pt 130 | \def\dbend{\raise0pt\hbox{\man\char'177}} 131 | \newenvironment{dangerous}{% 132 | \ifnum\@listdepth>\z@ 133 | \GenericError{}{Do not use `dangerous' environment inside any list}{}{} 134 | \fi 135 | \par\addvspace\medskipamount 136 | \@tempdima=\dimexpr\textwidth-2zw\relax\small 137 | \bigskipamount=\baselineskip 138 | \medskipamount=.5\baselineskip 139 | \smallskipamount=.25\baselineskip 140 | \clubpenalty=10000 \widowpenalty=9999 141 | \divide\@tempdima by\dimexpr1zw\relax\@tempcnta=\@tempdima 142 | \leftskip=\dimexpr\textwidth-\@tempcnta zw\relax 143 | \@totalleftmargin\dimexpr\leftskip+0zw 144 | \linewidth=\dimexpr\@tempcnta zw-0zw 145 | \parindent1zw\noindent\kern-\leftskip\hbox to\leftskip{\dbend\hss}% 146 | \everypar{\everypar{}}\ignorespaces 147 | }{\par\addvspace\medskipamount} 148 | 149 | % macros for index (simplified from doc.sty) 150 | \newif\ifscan@allowed 151 | \def\dotfill{\leaders\hbox to.6em{\hss .\hss}\hskip\z@ plus1fill}% 152 | \def\pfill{\unskip~\dotfill\nobreak} 153 | 154 | % logos 155 | \RequirePackage{hologo} 156 | \def\eTeXpre{\texorpdfstring{$\varepsilon$\protect\nobreakdash-}{ε-}} 157 | \def\eTeX{\eTeXpre\TeX} 158 | \def\epTeX{\eTeXpre\pTeX}\def\eupTeX{\eTeXpre\upTeX} 159 | \def\pTeX{\texorpdfstring{p\kern-.10em\TeX}{pTeX}} 160 | \def\upTeX{u\pTeX}\def\pLaTeX{p\LaTeX}\def\upLaTeX{u\pLaTeX} 161 | \def\NTS{\leavevmode\hbox{$\cal N\kern-0.35em\lower0.5ex\hbox{$\cal T$}% 162 | \kern-0.2emS$}\,} 163 | \def\TeXXeT{\TeX-\reflectbox{\bfseries\TeX-}} 164 | \def\OMEGA{\texorpdfstring{$\Omega$}{Ω}} 165 | \def\pdfTeX{\hologo{pdfTeX}} 166 | \def\XeTeX{\hologo{XeTeX}} 167 | \def\LuaTeX{\hologo{LuaTeX}} 168 | \def\TL{\TeX\ Live\xspace} 169 | \AtBeginDocument{\providecommand{\texorpdfstring}[2]{#1}} 170 | 171 | % ptex-manual check 172 | \def\ptErr#1{\errhelp{}\errmessage{ptex-manual: #1}} 173 | 174 | %%% EOF 175 | -------------------------------------------------------------------------------- /ptexdoc_asciimw.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/ptexdoc_asciimw.pdf -------------------------------------------------------------------------------- /ptexdoc_asciimw.tex: -------------------------------------------------------------------------------- 1 | \documentstyle{jarticle} 2 | 3 | \西暦 4 | 5 | \title{\TeX の出版への応用\\ 6 | \large--- 縦組み機能の組み込み ---} 7 | \author{濱野 尚人\thanks{(株)\kern-2pt アスキー % 8 | 出版局 電子編集研究統轄部 出版技術部} 9 | \and 田村 明史${}^*$ 10 | \and 倉沢 良一\thanks{(株)\kern-2pt アスキー % 11 | システムソフトウェア事業部 技術統轄部 オフィスシステム技術部}} 12 | \date{\ } 13 | 14 | \setlength{\unitlength}{0.1in} 15 | 16 | \def\angle#1{$\langle{}$#1${}\rangle$} 17 | \def\pTeX{p\kern-.2em\TeX} 18 | 19 | \begin{document} 20 | 21 | \maketitle \thispagestyle{empty} 22 | 23 | \begin{abstract} 24 | 日本語\TeX を出版分野で本格的に応用するため, 縦組み機能を追加した. 25 | 拡張された\TeX は以下のような特長を持つ. 26 | \begin{itemize} 27 | \item 同一文書, 同一ページに縦/横組みの混在ができ, 28 | 縦組み中でも和/欧文/数式の混在が可能である. 29 | \item 英語版のオリジナル\TeX や(横組み)日本語\TeX と互換性があり, 30 | 従来の\TeX の文書やマクロをそのまま処理することができる. 31 | \item 縦組みを使用すると, 拡張フォーマットの{\tt DVI}ファイルを出力する. 32 | ただし, 横組みのみ使用している場合は, 33 | 従来のフォーマットの{\tt DVI}ファイルを出力する. 34 | \end{itemize} 35 | 本論文ではその設計と実現方法について説明する. 36 | \end{abstract} 37 | 38 | % \tableofcontents 39 | 40 | 41 | \section{はじめに} 42 | 43 | \TeX はスタンフォード大学のクヌース教授によって開発された組版システムであり, 44 | 組版の美しさと強力なマクロ機能を特徴としている. 45 | 日本語化され\cite{jtex}, 高品位の写植出力を得ることができるようになり, 46 | わが国でも\TeX によって組版された書籍が出版されるようになってきた. 47 | 48 | ところが, 従来の日本語\TeX は英語向けのシステムをベースとしているため, 49 | 縦組み, ルビなどの日本語特有の機能がない. 50 | \TeX を一般書籍の出版に使用するためするには, これらの機能を持った 51 | 「本格的出版に耐え得る日本語\TeX\kern0pt 」が必要であろうと判断し, 52 | 日本語\TeX の改造に取り組むことにした. 53 | この機能拡張された\TeX を\pTeX (\kern0pt publishing \TeX\kern0pt )と 54 | 呼ぶことにする. 55 | まず, 機能拡張第一弾として(株)\kern-3pt アスキーで開発された 56 | 日本語\TeX に縦組み機能を追加した. 57 | 58 | 本論文ではその設計と実現方法について報告する. 59 | 次章から\ref{output}章までで\pTeX の縦組み機能についての基本的な概念を説明し, 60 | \ref{imple}章で具体的な実現方法を説明する. 61 | 62 | 63 | \section{ディレクション} \label{direction} 64 | 65 | 文書を組版すると, いくつかの`ページ'の集合となる. 66 | `ページ'は`行'を``行送り方向''に並べたものであり, 67 | `行'は`文字'を``字送り方向''に並べたものである. 68 | 69 | 従来の\TeX では, ページはverticalボックス, 行はhorizontalボックスであり, 70 | ``行送り方向'', ``字送り方向''は横組み用に固定されていた. 71 | \pTeX では, \TeX の状態として``組み方向''(ディレクション)を考え, 72 | ディレクションによって`行送り方向', `字送り方向'を変えることにした. 73 | 縦組みは, 横組みの``行送り方向'', ``字送り方向''を, 74 | 右に$90^\circ$回転させたものと同じになる. 75 | \begin{quote} \begin{description} 76 | \item[横組み] 字送り方向: 水平右向き, 行送り方向: 垂直下向き 77 | \item[縦組み] 字送り方向: 垂直下向き, 行送り方向: 水平左向き 78 | \end{description} \end{quote} 79 | 80 | また, 縦組み中で使われた場合と横組み中で使われた場合で 81 | 動作が変わるようなマクロが書けるように, 82 | \verb|\iftdir|, \verb|\ifydir|というマクロも用意した. 83 | 84 | % \TeX の用語やプリミティブには上下左右を連想させる単語が多く使われているが, 85 | % これらの上下左右は座標系に依存するものである. 86 | % \TeX のプリミティブには\begin{quote} 87 | % \verb|\belowdisplayshortskip|, \verb|\belowdisplayskip|, 88 | % \verb|\lower|,\\ 89 | % \verb|\abovedisplayshortskip|, \verb|\abovedisplayskip|, 90 | % \verb|\raise|,\\ 91 | % \verb|\rightskip|, \verb|\moveright|,\\ 92 | % \verb|\leftskip|, \verb|\moveleft| 93 | % \end{quote}のようなものもある. 94 | % これらの, below, lowerは行送り方向, above, raiseは行送りの逆方向, 95 | % rightは字送り方向, leftは字送りの逆方向を意味しているものとして, 96 | % 縦組みでもそのまま使用する. 97 | 98 | 99 | \section{ボックス} 100 | 101 | オリジナルの\TeX では, 文字を並べて``行''のボックスを作るモードをhモードと言い, 102 | できたボックスをhボックスと呼ぶ. 103 | これは\TeX がアメリカで開発されたシステムであり, 104 | 英語では文字が水平(\kern0pt horizontal\kern0pt )に並ぶからである. 105 | ディレクションが横の場合はそのままで問題ない. 106 | ディレクションが縦の場合, 行の中で文字は垂直に並ぶのだが, 107 | やはり, 文字を並べて行のボックスを作るモードをhモードと言い, 108 | できたボックスをhボックスと呼ぶことにした. 109 | 横組みと縦組みの両方で使えるマクロを作りやすいように, 110 | `横組みの行のボックス'と`縦組みの行のボックス'は同じ名前の方が良く, 111 | `横組みの行のボックス'は従来のhボックスと同じものだから, 112 | 互換性を考慮してそのようにした. 113 | 114 | 同様に, ボックスを行送り方向に並べるモードをvモード, 115 | それらを集めて作られたボックスをvボックスと呼ぶことにした. 116 | 横ディレクションのvモードではボックスは縦(\kern0pt vertical\kern0pt )に並ぶが, 117 | 縦ディレクションのvモードではボックスが水平に右から左へ並ぶことになる. 118 | 119 | \TeX を起動した直後は横ディレクションのvモードであり, 120 | ディレクションを変えなければ従来の\TeX と互換性がある. 121 | つまり, ここで文字を入力すると横ディレクションのhモードに移行し, 122 | 文字を左から右に並べていく. 123 | ラインブレークによって作られたhボックスは, 124 | 横ディレクションのvモードで上から下に並べていく. 125 | 126 | \TeX のディレクションを変更するプリミティブとして, 127 | \verb|\yoko|, \verb|\tate|を用意した. 128 | ディレクションの変更は, 129 | 作成中のリストやボックスに何も入力されていない状態でのみ許すことにした. 130 | \TeX を起動して何も入力されていない状態で\verb|\tate|プリミティブを実行すると, 131 | 縦ディレクションのvモードになる. 132 | ここで文字を入力すると縦ディレクションのhモードに移行し 133 | 文字を上から下に並べていく. 134 | ラインブレークによって作られたhボックスは, 135 | 縦ディレクションのvモードで右から左に並べていく. 136 | 137 | ボックスの大きさ(ベースラインの位置)を表す用語として, 138 | \TeX ではWidth, Depth, Heightという言葉を使っている. 139 | \pTeX では, 140 | これらの言葉を, ボックスの字送り方向の大きさ(\kern0pt Width\kern0pt ), 141 | 行送り方向側の大きさ(\kern0pt Depth\kern0pt ), 142 | 行送り方向の反対側の大きさ(\kern0pt Height\kern0pt )であると定義した. 143 | よって, 縦ディレクション中のボックスでは, ボックスの高さを$W$といい, 144 | 左側の幅を$D$といい, 右側の幅を$H$という. 145 | \begin{quote} \begin{picture}(50,24)(0,4) 146 | \put(4,26){\makebox(24,0)[b]{横ディレクション中のボックス}} 147 | \put(4,24){\begin{picture}(0,0)(0,0) 148 | \thicklines 149 | \put(0,0){\vector(1,0){6}} 150 | \put(0,0.5){\makebox(6,0)[b]{\small 字送り方向}} 151 | \put(0,0){\vector(0,-11){6}} 152 | \put(0,-6){\makebox(0,0)[t]{\small 行送り方向}} 153 | \end{picture}} 154 | \put(6,6){\begin{picture}(0,0)(0,0) 155 | \thicklines 156 | \put(6,0){\framebox(12,10){}} \put(6,4){\line(1,0){12}} 157 | 158 | \thinlines 159 | \put(0,4){\line(1,0){5}} \put(19,4){\line(1,0){5}} 160 | \put(3,0){\line(1,0){2}} \put(3,10){\line(1,0){2}} 161 | \put(6,11){\line(0,1){2}} \put(18,11){\line(0,1){2}} 162 | 163 | \put(4,0){\vector(0,1){4}} \put(4,0){\vector(0,-1){0}} 164 | \put(3.5,0){\makebox(0,4)[r]{$D$}} 165 | \put(4,10){\vector(0,-1){6}} \put(4,10){\vector(0,1){0}} 166 | \put(3.5,4){\makebox(0,6)[r]{$H$}} 167 | \put(6,12){\vector(1,0){12}} \put(6,12){\vector(-1,0){0}} 168 | \put(6,12.5){\makebox(12,0)[b]{$W$}} 169 | \end{picture}} 170 | \put(35,26){\makebox(18,0)[b]{縦ディレクション中のボックス}} 171 | \put(53,24){\begin{picture}(0,0)(0,0) 172 | \thicklines 173 | \put(0,0){\vector(-1,0){6}} 174 | \put(-6,0.5){\makebox(6,0)[b]{\small 行送り方向}} 175 | \put(0,0){\vector(0,-11){6}} 176 | \put(0,-6){\makebox(0,0)[t]{\small 字送り方向}} 177 | \end{picture}} 178 | \put(35,0){\begin{picture}(0,0)(0,0) 179 | \thicklines 180 | \put(0,6){\framebox(10,12){}} \put(4,6){\line(0,1){12}} 181 | 182 | \thinlines 183 | \put(4,19){\line(0,1){5}} \put(4,0){\line(0,1){5}} 184 | \put(0,19){\line(0,1){2}} \put(10,19){\line(0,1){2}} 185 | \put(11,6){\line(1,0){2}} \put(11,18){\line(1,0){2}} 186 | 187 | \put(12,6){\vector(0,1){12}} \put(12,6){\vector(0,-1){0}} 188 | \put(12.5,6){\makebox(0,12)[l]{$W$}} 189 | 190 | \put(4,20){\vector(-1,0){4}} \put(4,20){\vector(1,0){0}} 191 | \put(0,20.5){\makebox(4,0)[b]{$D$}} 192 | \put(4,20){\vector(1,0){6}} \put(4,20){\vector(-1,0){0}} 193 | \put(4,20.5){\makebox(6,0)[b]{$H$}} 194 | \end{picture}} 195 | \end{picture} \end{quote} 196 | 197 | \subsection{異ディレクションのボックス} 198 | 199 | 一つの文書, 一枚のページであっても部分によって組み方向を変えられるように, 200 | 組み方向の混在を許すことにした. 201 | たとえば, 表の中で項目によって縦組み/横組みを使い分けることが可能になれば 202 | 表現力が増すことになる. 203 | また, 縦組み中で数桁の数を表現するとき, 204 | アラビア数字を横組みにして縦組み中に挿入することがある. 205 | これを出版業界では連数字と言うが, これも組み方向の混在機能で実現できる. 206 | 207 | 組み方向の混在を許すということは, 一つの文書に, 208 | 内部の文字が横に並ぶ横組みのhボックスと, 209 | 縦に並ぶ縦組みのhボックスの, 2種類のhボックスが存在することになる. 210 | 縦/横どちらのディレクションで作られたボックスであるか, ボックスごとに記録して, 211 | これらの組み方向の異なるボックスを区別することにした. 212 | 213 | \verb|\hbox|, \verb|\vbox|などで作られるボックスは, 通常, 214 | \verb|\hbox|, \verb|\vbox|が実行されたときの\TeX のディレクションと 215 | 同じディレクションを持つ. 216 | しかし以下のように\verb|\yoko|プリミティブを使うと, 217 | 縦ディレクションの中に, 218 | `123'という内容の横ディレクションを持つhボックスを置くこともできる. 219 | \begin{quote} 220 | (縦ディレクション)\\ 221 | \verb|\hbox{\yoko 123}| 222 | \end{quote} 223 | 224 | \verb|\hbox|, \verb|\vbox|でディレクションの異なるボックスを作ると, 225 | 横ディレクションを持つボックスは, 縦組み中では 226 | $W_t=H_y+D_y$, $H_t=W_y/2$, $D_t=W_y/2$ 227 | ($H_y$は, ボックスの横ディレクション中における$H$)となる. 228 | 縦ディレクションを持つボックスは, 横組み中では 229 | $W_y=H_t+D_t$, $H_y=W_t$, $D_y=0$となる. 230 | 231 | \begin{quote} \begin{picture}(50,24)(0,0) 232 | \put(0,22){\makebox(16,0)[b]{縦組み中の横組みのボックス}} 233 | \put(0,0){\begin{picture}(0,0)(0,0) 234 | \thicklines 235 | \put(0,6){\framebox(12,10){}} \put(0,10){\line(1,0){12}} 236 | 237 | \thinlines 238 | \put(2,10){\vector(0,-1){4}} \put(2,10){\vector(0,1){0}} 239 | \put(2.5,6){\makebox(0,4)[l]{$D_y$}} 240 | \put(2,10){\vector(0,1){6}} \put(2,10){\vector(0,-1){0}} 241 | \put(2.5,10){\makebox(0,4)[l]{$H_y$}} 242 | \put(0,14){\vector(1,0){12}} \put(0,14){\vector(-1,0){0}} 243 | \put(0,13.5){\makebox(12,0)[t]{$W_y$}} 244 | 245 | \put(6,0){\line(0,1){5}} \put(6,17){\line(0,1){5}} 246 | \put(0,17){\line(0,1){2}} \put(12,17){\line(0,1){2}} 247 | \put(13,6){\line(1,0){2}} \put(13,16){\line(1,0){2}} 248 | 249 | \put(14,6){\vector(0,1){10}} \put(14,6){\vector(0,-1){0}} 250 | \put(14.5,6){\makebox(0,10)[l]{$W_t$}} 251 | \put(6,18){\vector(-1,0){6}} \put(6,18){\vector(1,0){0}} 252 | \put(0,18.5){\makebox(6,0)[b]{$D_t$}} 253 | \put(6,18){\vector(1,0){6}} \put(6,18){\vector(-1,0){0}} 254 | \put(6,18.5){\makebox(6,0)[b]{$H_t$}} 255 | \end{picture}} 256 | \put(30,22){\makebox(22,0)[b]{横組み中の縦組みのボックス}} 257 | \put(30,4){\begin{picture}(0,0) 258 | \thicklines 259 | \put(6,0){\framebox(10,12){}} \put(10,0){\line(0,1){12}} 260 | 261 | \thinlines 262 | \put(14,0){\vector(0,1){12}} \put(14,0){\vector(0,-1){0}} 263 | \put(13.5,0){\makebox(0,12)[r]{$W_t$}} 264 | \put(10,10){\vector(-1,0){4}} \put(10,10){\vector(1,0){0}} 265 | \put(6,9.5){\makebox(4,0)[t]{$D_t$}} 266 | \put(10,10){\vector(1,0){6}} \put(10,10){\vector(-1,0){0}} 267 | \put(10,9.5){\makebox(4,0)[t]{$H_t$}} 268 | 269 | \put(0,0){\line(1,0){5}} \put(17,0){\line(1,0){5}} 270 | \put(3,12){\line(1,0){2}} 271 | \put(6,13){\line(0,1){2}} \put(16,13){\line(0,1){2}} 272 | 273 | \put(4,0){\line(0,-1){2}} \put(4,0){\vector(0,1){0}} 274 | \put(3.5,-2){\makebox(0,2)[r]{$D_y$}} 275 | \put(4,0){\vector(0,1){12}} \put(4,0){\vector(0,-1){0}} 276 | \put(3.5,0){\makebox(0,12)[r]{$H_y$}} 277 | \put(6,14){\vector(1,0){10}} \put(6,14){\vector(-1,0){0}} 278 | \put(6,14.5){\makebox(10,0)[b]{$W_y$}} 279 | \end{picture}} 280 | \end{picture} \end{quote} 281 | 282 | 二つの場合で$W$, $D$, $H$の算出方法が異なるのは, 283 | 縦組み, 横組みでの文字の扱いの違い(\ref{jfont}参照)を反映している. 284 | 285 | \TeX には256個のボックスレジスタが用意されていて 286 | \begin{quote} 287 | \verb|\setbox123\hbox{\yoko |\angle{文}\verb|}| 288 | \end{quote} 289 | と書けば, ボックスレジスタの123番に\angle{文}を内容とする 290 | 横ディレクションのhボックスが登録される. 291 | 登録されたボックスは 292 | \begin{quote} \begin{verbatim} 293 | \advance\ht123 by \dp123 294 | \dp123=0 295 | \end{verbatim} \end{quote} 296 | のように, \verb|\wd|, \verb|\dp|, \verb|\ht|を使って 297 | ボックスの大きさやベースラインの位置を自由に変えることができる. 298 | \pTeX では, レジスタの内容は 299 | \begin{quote} \begin{verbatim} 300 | \hbox{\tate\copy123} 301 | \hbox{\yoko\box123} 302 | \end{verbatim} \end{quote} 303 | のようにどのディレクションで使用されるかわからず, 304 | ボックスが使用されるディレクションによって, $W$, $D$, $H$は異なる値を持つ. 305 | そこで\verb|\wd|なども, 306 | そのときのディレクション用の$W$などをアクセスすることにした. 307 | \begin{quote} 308 | \verb|\hbox{\yoko \global\wd123=|\angle{縦高さ}\verb|}|\\ 309 | \verb|\hbox{\tate \global\wd123=|\angle{横幅}\verb|}|\\ 310 | \verb|\hbox{\tate\copy123}|\\ 311 | \verb|\hbox{\yoko\box123}| 312 | \end{quote} 313 | のように書けば, 3行目の\verb|\copy123|の$W$は\angle{縦高さ}であり, 314 | 4行目の\verb|\box123|の$W$は\angle{横幅}である. 315 | 316 | この場合注意しなければならないのは, 317 | \verb|\hbox|, \verb|\vbox|で作られたボックスは 318 | $W_t=H_y+D_y$, $W_y=H_t+D_t$であるが, 319 | \verb|\wd|, \verb|\dp|, \verb|\ht|を使って$W$, $D$, $H$を変更すると 320 | この関係は必ずしも成立しないということである. 321 | ディレクションによってボックスの大きさが変化することになる. 322 | 323 | \subsection{異ディレクションのアジャスト, インサート} 324 | 325 | vモードや内部vモードの中のhボックスの中に\verb|\vadjust|を使うと, 326 | vリストのそのボックスの次に, \verb|\vadjust|の内容が挿入される. 327 | 以下のようにディレクションの異なるhボックスの中でも 328 | 支障なく\verb|vadjust|が使えるようにした. 329 | \begin{quote} 330 | (縦ディレクション, vモード)\\ 331 | \verb|\hbox{\yoko |\ldots\verb|\vadjust{|\ldots\verb|}|\ldots\verb|}| 332 | \end{quote} 333 | \verb|\vadjust|の中括弧の内側は, 自動的に, 334 | それがアジャストされるリストのディレクションである縦ディレクションになる. 335 | 336 | \verb|\insert|の場合, クラスによってディレクションを変えたい場合もある. 337 | たとえば文書全体は縦組みで, 脚注は横組みするとしよう. 338 | 図をクラス12のインサートで, 脚注をクラス34のインサートで処理することにする. 339 | \begin{quote} 340 | (縦ディレクション, vモード)\\ 341 | \ldots\verb|\insert12{\tate |\ldots\verb|}|\ldots\\ 342 | \ldots\verb|\insert34{\yoko |\ldots\verb|}|\ldots\\ 343 | \ldots\verb|\insert12{\tate |\ldots\verb|}|\ldots\\ 344 | \ldots\verb|\insert34{\yoko |\ldots\verb|}|\ldots 345 | \end{quote} 346 | このように書けば, 347 | ボックスレジスタ12には縦ディレクションで図が集められ, 348 | ボックスレジスタ34には横ディレクションで脚注が集められるようにした. 349 | なお, 同じクラスに違うディレクションを混ぜて使うことはできない. 350 | 351 | 352 | \section{縦組みに使用する文字} \label{font} 353 | 354 | \subsection{縦組み用日本語フォント} 355 | 356 | \TeX は各フォントに一つずつ用意されている 357 | {\tt TFM}(\kern0pt{\it\TeX\/} {\it F\/}ont {\it M\/}etric\kern0pt )ファイルを 358 | 参照して組版を行う. 359 | {\tt TFM}ファイルにはそのフォントに含まれる各文字の大きさなど 360 | 組版に必要な情報が定義してある. 361 | 362 | \pTeX でも同様であるが, 日本語のフォントの場合, 同じ書体でも 363 | 縦組みで使うか横組みで使うかによって, 組版に必要な情報は変わってくる. 364 | たとえば, ``り''という文字は比較的縦に長い文字であるが, 365 | このような文字は横組みではとなりの文字との間隔をつめて組むことはできても, 366 | 縦組みではある程度間隔を空けないと読みにくくなってしまう. 367 | そこで, 横組み時と縦組み時では, 368 | 別の\verb|TFM|ファイルを参照して組版することにした. 369 | \TeX から見ると, 縦組みと横組みでは別のフォントを使っているように 370 | 見えることになる. 371 | ただし, 組み方向によるフォントの切り替えは, 372 | ユーザーが気にする必要がないように自動的に行うようにした. 373 | 和文用のカレントフォントを2つ用意し, 374 | ディレクションによって自動的に切り替えるようにしてある. 375 | また{\tt TFM}ファイルに縦組み用か横組み用かの情報を埋め込み, 376 | フォントを指定したとき, 自動的に適切なカレントフォントを切り替えるようにした. 377 | 378 | \label{jfont} 379 | 横組みでは, ベースラインは文字の下の方を通っている. 380 | 縦組みの和文フォントは, ベースラインが文字の中央を通ることにした. 381 | 行の途中で文字の大きさを変えたとき, そのほうが自然だと判断したからである. 382 | 383 | \subsection{縦組み中の欧文} 384 | 385 | 縦組みの部分に欧文や数式が出てくると, 386 | 従来の\TeX の欧文用フォントを$90^\circ$回転して上から下に向かって組んでいく. 387 | これは普通に横に組んだ欧文を, 90度回転させたような結果になる. 388 | ところが, \ref{jfont}で説明したように, 389 | 縦組みの和文のベースラインは文字の中心を通るようにしたので, 390 | そこに欧文のベースラインを一致させると行がずれて見えてしまう. 391 | そこで, \verb|\tbaselineshift|というdimen変数を用意し, 392 | その寸法だけ縦組み中の欧文のベースラインをシフトさせることにした. 393 | 394 | 横組みでも, 和文と欧文のベースラインの位置を細かく調節しないと, 395 | フォントのデザインによってはバランスが悪くなる場合があり, 396 | \verb|\ybaselineshift|を用意して調節可能にした. 397 | 398 | \begin{quote} \begin{picture}(0,46) 399 | \put(4,41){\line(0,1){5}} 400 | \put(4,40){\begin{picture}(0,0) 401 | \thicklines 402 | \put(-7,-14){\framebox(14,14){縦組みの漢字}} 403 | \put(0,0){\line(0,-1){14}} 404 | 405 | \thinlines 406 | \put(8,0){\line(1,0){2}} \put(8,-14){\line(1,0){2}} 407 | \put(-7,1){\line(0,1){2}} \put(7,1){\line(0,1){2}} 408 | 409 | \put(9,0){\vector(0,-1){14}} \put(9,0){\vector(0,1){0}} 410 | \put(9.5,-14){\makebox(0,14)[l]{$W$}} 411 | \put(0,2){\vector(1,0){7}} \put(0,2){\vector(-1,0){0.0}} 412 | \put(0,2.5){\makebox(7,0)[b]{$H$}} 413 | \put(0,2){\vector(-1,0){7}} \put(0,2){\vector(1,0){0.0}} 414 | \put(-7,2.5){\makebox(7,0)[b]{$D$}} 415 | \end{picture}} 416 | \put(4,19){\line(0,1){6}} \put(0,19){\line(0,1){5}} 417 | \put(0,23){\vector(1,0){4}} \put(0,23){\vector(-1,0){0}} 418 | \put(4.5,23){\makebox(0,0)[l]{\tt \char92 tbaselineshift}} 419 | \put(0,18){\begin{picture}(0,0) 420 | \thicklines 421 | \put(-4,-12){\framebox(12,12){英字($90^\circ$ 回転)}} 422 | \put(0,0){\line(0,-1){12}} 423 | 424 | \thinlines 425 | \put(-4,1){\line(0,1){2}} \put(8,1){\line(0,1){2}} 426 | \put(9,0){\line(1,0){2}} \put(9,-12){\line(1,0){2}} 427 | 428 | \put(-4,2){\vector(1,0){4}} \put(-4,2){\vector(-1,0){0}} 429 | \put(-4,2.5){\makebox(4,0)[b]{$D$}} 430 | \put(0,2){\vector(1,0){8}} \put(0,2){\vector(-1,0){0}} 431 | \put(4,2.5){\makebox(4,0)[b]{$H$}} 432 | \put(10,0){\vector(0,-1){12}} \put(10,0){\vector(0,1){0}} 433 | \put(10.5,0){\makebox(0,-12)[l]{$W$}} 434 | \end{picture}} 435 | \put(4,0){\line(0,1){5}} 436 | 437 | \put(16,8){\line(1,0){5}} 438 | \put(22,8){\begin{picture}(0,0) 439 | \thicklines 440 | \put(0,-2){\framebox(14,14){横組みの漢字}} 441 | \put(0,0){\line(1,0){14}} 442 | 443 | \thinlines 444 | \put(-3,-2){\line(1,0){2}} \put(-3,12){\line(1,0){2}} 445 | \put(0,13){\line(0,1){2}} \put(14,13){\line(0,1){2}} 446 | \put(-2,0){\vector(0,-1){2}} \put(-2,0){\vector(0,1){0}} 447 | \put(-2.5,-2){\makebox(0,2)[r]{$D$}} 448 | \put(-2,0){\vector(0,1){12}} \put(-2,0){\vector(0,-1){0}} 449 | \put(-2.5,0.0){\makebox(0.0,12.0)[r]{$H$}} 450 | \put(0,14){\vector(1,0){14}} \put(0,14){\vector(-1,0){0}} 451 | \put(0,14.5){\makebox(14,0.0)[b]{$W$}} 452 | \end{picture}} 453 | \put(37,8){\line(1,0){6}} \put(38,9){\line(1,0){5}} 454 | \put(39,9){\vector(0,-1){0}} \put(39,8){\vector(0,1){0}} 455 | \put(39,4){\line(0,1){7}} 456 | \put(39,3.5){\makebox(0,0)[t]{\tt \char92 ybaselineshift}} 457 | \put(44,9){\begin{picture}(0,0) 458 | \thicklines 459 | \put(0,-4){\framebox(12,12){英字(正立)}} 460 | \put(0,0){\line(1,0){12}} 461 | 462 | \thinlines 463 | \put(-3,-4){\line(1,0){2}} \put(-3,8){\line(1,0){2}} 464 | \put(0,9){\line(0,1){2}} \put(12,9){\line(0,1){2}} 465 | 466 | \put(-2,0){\vector(0,-1){4}} \put(-2,0){\vector(0,1){0}} 467 | \put(-2.5,-4){\makebox(0,4)[r]{$D$}} 468 | \put(-2,0){\vector(0,1){8}} \put(-2,0){\vector(0,-1){0}} 469 | \put(-2.5,0){\makebox(0,8)[r]{$H$}} 470 | \put(0,10){\vector(1,0){12}} \put(0,10){\vector(-1,0){0}} 471 | \put(0,10.5){\makebox(12,0)[b]{$W$}} 472 | \end{picture}} 473 | \put(57,8){\line(1,0){5}} 474 | \end{picture} \end{quote} 475 | 476 | 477 | \section{縦組み中の数式} 478 | 479 | 縦組み中の数式も, 欧文と同様にシフトさせなければならない. 480 | \TeX の数式には, 分数の線の高さなどを決定するための 481 | axis(軸)という概念があるので, これでシフト量を決定することにした. 482 | 483 | 問題は次のような場合である. 484 | \begin{quote} 485 | (縦ディレクション, hモード)\\ 486 | \ldots\verb|$ \hbox{$ |\angle{数式}\verb| $} $|\ldots 487 | \end{quote} 488 | この場合, 数式モードがネスティングされることになるので, 489 | 内側の\angle{数式}は2回シフトされることになってしまう. 490 | これを避けるため, \verb|$| の内側は, 491 | 普通の縦ディレクションではない縦数式ディレクションに移行することにした. 492 | 縦数式ディレクションでは 493 | 文字やボックスの並ぶ方向は縦ディレクションと同じであるが, 494 | その他の動作は横組みと同様である. 495 | 数式ディレクション中で数式モードに移行してもシフトは行わず, 496 | また, 日本語のフォントは横組みカレントフォントを使用する. 497 | つまり, 数式は横組みで組んだものを時計回りに90度回転して, 498 | 縦組み中に挿入する形になる. 499 | 500 | 便宜的に, 横組みでも数式モードに入ると横数式ディレクションに入ることにした. 501 | 現在のディレクションが通常のディレクションであるか, 502 | 数式ディレクションであるかは, \verb|\ifmdir|でテストできる. 503 | 504 | 505 | \section{組版結果の出力} \label{output} 506 | 507 | \TeX は\verb|\shipout|プリミテイブで, ボックスの左上隅が紙の左上隅から, 508 | 右に $\verb|\hoffset|+1インチ$, 509 | 下に $\verb|\voffset|+1インチ$ の位置になるように, 510 | {\tt DVI}(\kern0pt{\it D\/}e{\it v\/}ice {\it I\/}ndependent\kern0pt ) 511 | ファイルに出力する. 512 | \pTeX も同様である. 513 | \verb|\hoffset|, \verb|\voffset|は, ほかのプリミティブ名と違って, 514 | ディレクションに関係なく, h, vが本当にholizontal, vertcalを意味している. 515 | 516 | 従来の\verb|DVI|命令は, \.横\.組\.み\.の\.と\.きファイルが小さくなるように 517 | 工夫されている. 518 | たとえば, ``文字の印字''と``文字幅だけ右へ移動''が, 519 | 1つの命令でできるようになっている. 520 | \pTeX では, 縦組みの場合でも横組みと同様にファイルが小さくなるように, 521 | \verb|DVI|フォーマットを拡張した. 522 | 523 | ただし, たとえば従来の文書をこの\TeX で処理した場合など, 524 | その文書内で縦組みを使用していない場合, 525 | 従来のものと同じフォーマットの{\tt DVI}を出力する. 526 | また, プリアンブル, ポストアンブルをテストすれば, 527 | 文書内した縦組みを使用した箇所が存在するかどうかを知ることができるようにした. 528 | 529 | 530 | \section{インプリメント} \label{imple} 531 | 532 | 現在構築中のリストのネスティング状態を示す 533 | レコード(\kern0pt {\it list\_state\_record\/})に, 534 | ディレクションを表すフィールドを追加し, 535 | トップのディレクションをマクロ{\it direction\/}でアクセスできるようにした. 536 | {\it direction\/}の値は{\it dir\_yoko\/}か, {\it dir\_tate\/}か, 537 | $-{\it dir\_yoko\/}$か, $-{\it dir\_tate\/}$である. 538 | $-{\it dir\_yoko\/}$, $-{\it dir\_tate\/}$は数式ディレクションを意味する. 539 | 540 | 各種ノードにディレクションを保持するフィールドを加えなければならない. 541 | ボックスを表す{\it hlist\_node\/}, {\it vlist\_node\/}では 542 | 第1ワードの{\it sub\_type}フィールドが未使用だったので, 543 | これを{\it box\_dir\/}として使うことにした. 544 | \verb|\insert|によって生成される 545 | {\it ins\_node\/}には空いているフィールドがなかったので, 546 | サイズを1ワード大きくして全部で6ワードにし, 547 | 最後の1ワードを{\it ins\_dir\/}として使うことにした. 548 | 549 | \subsection{\it dir\_node} 550 | 551 | 縦ディレクションのリストに横ディレクションのボックスを追加するような場合, 552 | 間に{\it dir\_node\/}を挿入して, ボックスの大きさなどを整合させる. 553 | {\it dir\_node\/}は, {\it hlist\_node\/}, {\it vlist\_node\/}と 554 | 全く同じ構造を持っている. 555 | リストにはこの{\it dir\_node\/}が挿入され, 556 | {\it dir\_node\/}の{\it box\_dir\/}にはリストのディレクションが, 557 | {\it width\/},{\it depth\/},{\it height\/}には, 558 | リストのディレクションで見た, ボックスの$W$, $D$, $H$の値が入っている. 559 | {\it dir\_node\/}の{\it list\_ptr\/}は実体のボックスを指すポインタである. 560 | 実体のボックス({\it hlist\_node\/}, {\it vlist\_node\/})の 561 | {\it box\_dir\/}にはボックスのディレクションが, 562 | {\it width\/},{\it depth\/},{\it height\/}には, 563 | ボックスのディレクションで見た, $W$, $D$, $H$の値が入っている. 564 | 565 | たとえば 566 | \begin{quote} 567 | (縦ディレクション)\\ 568 | {\gt \verb|昭和\hbox{\yoko 38}年|} 569 | \end{quote} 570 | は図のようなリストを作る. 571 | \begin{quote} \begin{picture}(40,25)(-4,-22) 572 | \thinlines 573 | \put(0,0){\begin{picture}(0,0) 574 | \put(-4,-3){\framebox(8,4){}} 575 | \put(0,0){\vector(1,0){6}} 576 | \put(0,0){\circle*{0.3}} 577 | \put(-4,-1){\line(1,0){8}} 578 | \put(-4,-3){\makebox(8,2)[c]{`昭'}} 579 | \end{picture}} 580 | \put(10,0){\begin{picture}(0,0) 581 | \put(-4,-3){\framebox(8,4){}} 582 | \put(0,0){\vector(1,0){6}} 583 | \put(0,0){\circle*{0.3}} 584 | \put(-4,-1){\line(1,0){8}} 585 | \put(-4,-3){\makebox(8,2)[c]{`和'}} 586 | \end{picture}} 587 | \put(20,0){\begin{picture}(0,0) 588 | \put(-4,-7){\framebox(8,8){}} 589 | \put(-4,-1){\makebox(4,2)[c]{\bf 縦}} 590 | \put( 0,-1){\line(0,1){2}} 591 | \put( 2, 0){\vector(1,0){4}} 592 | \put(2,0){\circle*{0.3}} 593 | \put(-4,-1){\line(1,0){8}} 594 | \put(-4,-5){\makebox(8,4)[c]{\it dir\_node\/}} 595 | \put(-4,-5){\line(1,0){8}} 596 | \put( 0,-6){\circle*{0.3}} 597 | \put( 0,-6){\vector(0,-1){3}} 598 | \end{picture}} 599 | \put(30,0){\begin{picture}(0,0) 600 | \put(-4,-3){\framebox(8,4){}} 601 | \put(-4,-1){\line(4,1){8}} 602 | \put(-4,-1){\line(1,0){8}} 603 | \put(-4,-3){\makebox(8,2)[c]{`年'}} 604 | \end{picture}} 605 | 606 | \put(20,-10){\begin{picture}(0,0) 607 | \put(-4,-7){\framebox(8,8){}} 608 | \put(-4,-1){\makebox(4,2)[c]{\bf 横}} 609 | \put( 0,-1){\line(0,1){2}} 610 | \put( 0,-1){\line(2,1){4}} 611 | \put(-4,-1){\line(1,0){8}} 612 | \put(-4,-5){\makebox(8,4)[c]{\it hlist\_node\/}} 613 | \put(-4,-5){\line(1,0){8}} 614 | \put( 0,-6){\circle*{0.3}} 615 | \put( 0,-6){\vector(0,-1){3}} 616 | \end{picture}} 617 | 618 | \put(20,-20){\begin{picture}(0,0) 619 | \put(-4,-3){\framebox(8,4){}} 620 | \put(0,0){\vector(1,0){6}} 621 | \put(0,0){\circle*{0.3}} 622 | \put(-4,-1){\line(1,0){8}} 623 | \put(-4,-3){\makebox(8,2)[c]{`3'}} 624 | \end{picture}} 625 | \put(30,-20){\begin{picture}(0,0) 626 | \put(-4,-3){\framebox(8,4){}} 627 | \put(-4,-1){\line(4,1){8}} 628 | \put(-4,-1){\line(1,0){8}} 629 | \put(-4,-3){\makebox(8,2)[c]{`8'}} 630 | \end{picture}} 631 | \end{picture}\end{quote} 632 | \begin{quote}\gt\begin{verbatim} 633 | \tmin 昭 634 | \tmin 和 635 | \dirboxT(5.00002+5.00002)x6.44444 636 | .\hboxY(6.44444+0.0)x10.00003 637 | ..\tenrm 3 638 | ..\tenrm 8 639 | \penalty 500(for \jcharwidowpenalty) 640 | \glue(\kanjiskip) 0.0 plus 0.4 minus 0.4 641 | \tmin 年 642 | \end{verbatim} \end{quote} 643 | 644 | `\verb|\hbox{|'と入力されると, 645 | それまでのリストやモードやディレクションがセーブされ, 646 | 新たなリストやモードやディレクションが用意される. 647 | \verb|\tate|や\verb|\yoko|は, 648 | その時点でのリストが空であればディレクションを変更する. 649 | `\verb|\hbox{|'に対応する`\verb|}|'が入力されると, 650 | まず, \verb|\hbox{}|の内部のディレクションと同じディレクションのボックスが 651 | 作られる. 652 | そのディレクションと\verb|\hbox{}|の外側のディレクションが一致していなければ, 653 | {\it dir\_node}を使って, ディレクションが整合させられる. 654 | 655 | \subsection{\it disp\_node} 656 | 657 | 和文中の欧文や数式のベースラインをシフトさせるために, 658 | 新種のノード{\it disp\_node\/}(\kern0pt displacement node\kern0pt )を 659 | 導入することにした. 660 | このノードは, リンク情報ワードのほかに 661 | {\it disp\_dimen\/}フィールド(1ワード)を持っている. 662 | {\it disp\_node\/}はhリスト中にのみ存在し, 663 | このノード以降のすべてのノードのベースラインを, 664 | {\it disp\_dimen}だけ行送り方向にシフトさせる. 665 | 666 | たとえば, 縦ディレクションで\verb|\tbaselineshift|の値が2ポイントのとき, 667 | \begin{quote}\gt 668 | \ldots\verb|このdispノード|\ldots 669 | \end{quote} 670 | のように入力すると`\verb|disp|'の前に2ポイントの{\it disp\_node\/}, 671 | 後に0ポイントの{\it disp\_node\/}が挿入される. 672 | \begin{quote}\gt\begin{verbatim} 673 | \tmin こ 674 | \tmin の 675 | \displace 2.0 676 | \glue(\xkanjiskip) 2.5 plus 1.0 minus 1.0 677 | \tenrm d 678 | \tenrm i 679 | \tenrm s 680 | \tenrm p 681 | \displace 0.0 682 | \glue(\xkanjiskip) 2.5 plus 1.0 minus 1.0 683 | \tmin ノ 684 | \penalty 200(for kinsoku) 685 | \glue(\kanjiskip) 0.0 plus 0.4 minus 0.4 686 | \tmin ー 687 | \penalty 500(for \jcharwidowpenalty) 688 | \glue(\kanjiskip) 0.0 plus 0.4 minus 0.4 689 | \tmin ド 690 | \end{verbatim} \end{quote} 691 | 文字(\kern0pt {\it char\_node\/}), 692 | ボックス(\kern0pt {\it hlist\_node\/}, {\it vlist\_node\/}, {\it dir\_node\/}), 693 | 罫線(\kern0pt {\it rule\_node\/})以外のノードには, 694 | $H$や$D$がないので{\it disp\_node\/}の影響を受けない. 695 | だから 696 | \begin{quote}\gt 697 | \ldots\verb|このdvi fileフォーマット|\ldots 698 | \end{quote} 699 | のように入力されたとき, \verb|device|と\verb|independent|の間の空白の前後に 700 | {\it disp\_node\/}を入れるのは無駄である. 701 | \begin{quote}\gt\begin{verbatim} 702 | \tmin こ 703 | \tmin の 704 | \displace 2.0 705 | \glue(\xkanjiskip) 2.5 plus 1.0 minus 1.0 706 | \tenrm d 707 | \tenrm v 708 | \tenrm i 709 | \displace 0.0 710 | \glue 3.33333 plus 1.66666 minus 1.11111 711 | \displace 2.0 712 | \tenrm ^^L (ligature fi) 713 | \tenrm l 714 | \tenrm e 715 | \displace 0.0 716 | \glue(\xkanjiskip) 2.5 plus 1.0 minus 1.0 717 | \tmin フ 718 | \penalty 150(for kinsoku) 719 | \glue 1.07391 minus 1.07391 720 | \tmin ォ 721 | \end{verbatim} \end{quote} 722 | そこで, リストに{\it disp\_node\/}を加えるとき, 723 | 無駄な{\it disp\_node\/}を消すようにした. 724 | \begin{quote}\gt\begin{verbatim} 725 | .\tmin こ 726 | .\tmin の 727 | .\displace 2.0 728 | .\glue(\xkanjiskip) 2.5 plus 1.0 minus 1.0 729 | .\tenrm d 730 | .\tenrm v 731 | .\tenrm i 732 | .\glue 3.33333 plus 1.66666 minus 1.11111 733 | .\tenrm ^^L (ligature fi) 734 | .\tenrm l 735 | .\tenrm e 736 | .\displace 0.0 737 | .\glue(\xkanjiskip) 2.5 plus 1.0 minus 1.0 738 | .\tmin フ 739 | .\penalty 150(for kinsoku) 740 | .\glue 1.07391 minus 1.07391 741 | .\tmin ォ 742 | \end{verbatim} \end{quote} 743 | 744 | \subsection{縦組み用{\tt TFM}ファイル} 745 | 746 | 縦組みフォント用拡張{\tt TFM}ファイルのフォーマットは, 基本的には, 747 | 従来の{\tt JFM}フォーマット\cite{jfm}と変わらない. 748 | ただ各フィールドの意味が多少変化している. 749 | 最初のハーフワード(\kern0pt {\it id}\kern0pt )で 750 | {\tt JFM}フォーマットであることを示す. 751 | $\hbox{\it id} = 11$ の場合は横組み用{\tt JFM}, 752 | $\hbox{\it id} = 9$ の場合は縦組み用{\tt JFM}である. 753 | 754 | {\it width}, {\it italic}, {\it kern}, {\it glue}など 755 | 従来の横組み{\tt JFM}フォーマットで横方向の意味を持っていたフィールドは, 756 | 縦組み{\tt JFM}では縦(字送り)方向の意味を持つ. 757 | たとえば{\it width}はその文字の縦方向の大きさである. 758 | 759 | {\it height}, {\it depth}など 760 | 従来の横組み{\tt JFM}で縦方向の意味を持っていたフィールドは, 761 | 縦組み{\tt JFM}では横(行送り)方向の意味を持つ. 762 | {\it height}はその文字のベースラインの右側の大きさ, 763 | {\it depth}はその文字のベースラインの左側の大きさである. 764 | 765 | \subsection{拡張{\tt DVI}フォーマット} 766 | 767 | 従来の\verb|DVI|には水平方向へ移動する命令として\verb|right|, 768 | 垂直方向へ移動する命令として\verb|down|という名前が使用されている. 769 | hボックスを``水平ボックス''ではなく``字送り方向のボックス''と定義したように 770 | \verb|right|命令を字送り方向へ移動する命令, 771 | \verb|down|命令を行送り方向へ移動する命令と定義した. 772 | 字送り, 行送りの方向は, 組み方向によって変わるので, 773 | \verb|DVI|リーダにもディレクションを設けて, 774 | 新しい命令\verb|dir|によってディレクションを切り換えることにした. 775 | \verb|push|, \verb|pop|で, $(h,v,w,x,y,z)$の他に, 776 | ディレクション$d$もpush, popする. 777 | 778 | \verb|DVI|の命令は最初の1バイトで識別できるようになっている. 779 | すでに0--249が使用されている\footnote{ 780 | \TeX を, 英語などの左から右へ書く言語と, 781 | アラビア語やヘブライ語のように右から左へ書く言語を 782 | 混植できるように改造した事例\cite{arabic}では, 783 | そのインプリメントの方法として\verb|DVI|命令を拡張しており, 784 | 250, 251を使用している. 785 | }ので新しい命令は255を使うことにした. 786 | \verb|dir|(\kern0pt 255\kern0pt )命令は1バイトの引数$d$を1つ取る. 787 | \begin{itemize} 788 | \item $d=0$ $\cdots$ 横組み 789 | \item $d=1$ $\cdots$ 縦組み 790 | \end{itemize} 791 | 792 | 横ディレクションの場合は従来の\verb|DVI|とコンパチブルであるが, 793 | 縦ディレクションの場合は従来の\verb|DVI|で横方向に移動する命令 794 | \begin{quote} \begin{verbatim} 795 | set_char_* set? set_rule right? w? x? 796 | \end{verbatim} \end{quote} 797 | は縦方向(字送り方向)に移動する命令となり, 798 | 従来の\verb|DVI|で縦方向に移動する命令 799 | \begin{quote} \begin{verbatim} 800 | down? y? z? 801 | \end{verbatim} \end{quote} 802 | は横方向(行送り方向)に移動する命令となる. 803 | 804 | 文字は, ベースラインの方向が字送りの方向と一致するように, 805 | 必要なら回転して, 印字されなければならない. 806 | 罫線の命令もディレクションによって方向が変わる. 807 | 従来の\verb|set_rule|, \verb|put_rule|では, 808 | 最初の引数が高さ, 次の引数が幅を表していた. 809 | 拡張\verb|DVI|では, 最初の引数が罫線の行送り方向の反対側の大きさ, 810 | 次の引数が字送り方向の大きさを表している. 811 | \verb|set_rule|では2番目の引数で指定してある長さだけ 812 | 字送り方向に参照点を移動させる. 813 | 814 | 各ページの先頭では, {\tt DVI}リーダは横ディレクションであり, 815 | 拡張\verb|DVI|対応のプリンタドライバで, 従来の\verb|DVI|もプリントアウトでき, 816 | 拡張命令(\kern0pt \verb|dir|\kern0pt )を使っていない\verb|DVI|ファイルは, 817 | 従来のプリンタドライバでプリントアウトできる. 818 | 819 | \verb|DVI|ファイルには, ファイルの先頭(\kern0pt preamble\kern0pt )と 820 | 末尾(\kern0pt postamble\kern0pt )に\verb|DVI|のバージョンを表す 821 | {\it id\_byte}が書き込まれている. 822 | 従来の\verb|DVI|ではどちらの{\it id\_byte}も2である. 823 | 拡張命令を使っている\verb|DVI|ファイルでは, postambleの{\it id\_byte}を3にして, 824 | 拡張プリンタドライバでプリントアウトしなければならないことを表す. 825 | 826 | 827 | \section{日本語\TeX との互換性} 828 | 829 | \pTeX は, 機能面では従来の日本語\TeX との完全な互換性を保っている. 830 | 831 | 性能面での違いを比較するために 832 | SONY NEWS 1460上の日本語\TeX と\pTeX で本論文を組版し, 833 | cshのtimeコマンドでCPU時間を比較してみた. 834 | なおこのテストでは, あらかじめauxファイルを作成しておき, 835 | {\tt virtex}に\LaTeX のフォーマットファイルを読み込ませる形で起動して計測した. 836 | \begin{itemize} 837 | \item 日本語\TeX の場合:\\ 838 | \verb|24.7u 0.3s 0:25 99% 44+123k 0+16io 0pf+0w| 839 | 840 | \item \pTeX の場合:\\ 841 | \verb|25.0u 0.3s 0:25 99% 46+121k 0+16io 0pf+0w| 842 | \end{itemize} 843 | 844 | やはり多少負荷は重くなっているようだが, 845 | 約1 \%なのでほとんど変っていないと言っていいと思う. 846 | これは, \pTeX を日本語\TeX の置き換えとして使用しても 847 | 支障はないということを意味している. 848 | 849 | 850 | \section{おわりに} 851 | 852 | 今回行った\TeX の改造は, 相当大規摸なものである. 853 | アスキー版日本語\TeX の段階で既に{\tt trip test}をパスしなくなっており, 854 | これにさらに改造を加えたので, 855 | `もはやこれは\TeX ではない'という意見もあるかも知れない. 856 | 私は, \TeX の根本は以下の3項目であろうと考えている. 857 | \begin{itemize} 858 | \item ボックスとグルー 859 | \item ラインブレーク, ページブレーク 860 | \item マクロ 861 | \end{itemize} 862 | この機構は単純であるにもかかわらず非常に強力で, 863 | 組版の諸問題をほぼ解決することができる. 864 | この基本を踏み外さなければ, \TeX と呼んでいいのではないだろうか. 865 | 866 | もともと, \TeX システムはクヌース教授が伝統的な組版について調査し, 867 | 同等以上のクオリティを得ることを目標に作られたシステムである. 868 | \pTeX も, 従来の日本語の組版について十分調査し, 869 | 先人の行ってきた美しい組版のための工夫を, 870 | できる限り取り込んでいきたいと考えている. 871 | それをある程度効率よく行うためには, 872 | やはり, \TeX の内部に変更を加える必要がある. 873 | 874 | 今後の\pTeX の環境の整備, 機能拡張として以下のものを考えている. 875 | \begin{description} 876 | \item[マクロの充実]\ \\ 877 | 縦組みに必要なマクロを洗い出し, 充実させる必要がある. 878 | 879 | \item[約物のチューニング]\ \\ 880 | 現在の{\tt TFM}では, 約物(記号類)の扱いについて 881 | チューニングの足りない部分がある. 882 | 883 | {\tt TFM}のチューニングで対応しきれない場合は, 884 | \TeX 本体のスペーシングアルゴリズムに変更を 885 | 加えなければならないかもしれない. 886 | 887 | \item[漢字・カナ別フォント]\ \\ 888 | 写植にはカナ書体と言って, 漢字が含まれていない書体がある. 889 | これと漢字の書体(明朝, ゴシックなど)とを組み合わせて文章を組む. 890 | カナの書体を変えただけでもかなり雰囲気が変わるものである. 891 | 892 | これを\TeX で実現するには, カナのカレントフォントを設けて, 893 | コードによって漢字フォントとカナフォントを使い分けることになるだろう. 894 | 895 | \item[ルビ]\ \\ 896 | やはり日本語の書籍を組版するためには, ルビを避けるわけにはいかない. 897 | 898 | ルビの振ってあることばの途中でラインブレークが起こる場合があるので, 899 | ラインブレーク処理に手を加えなければならない. 900 | 縦組み拡張に匹敵する大改造になると思われる. 901 | \end{description} 902 | 903 | \subsection*{謝辞} 904 | 905 | 本研究の機会を与えてくださった 906 | (株)\kern-3pt アスキー 電子編集研究統轄部 井芹昌信 統轄部長, 907 | 同 技術統轄部 三浦雅孝 統轄部長, 908 | ならびに, \TeX システムについて貴重なご意見をいただいた 同 技術部 大野俊治 次長 909 | に感謝します. 910 | 911 | \begin{thebibliography}{9} 912 | \bibitem{texbook} Knuth, D. E. : {\em The \TeX book}, Addison-Wesley (1986)\\ 913 | [斎藤信男 監修, 鷺谷好輝 翻訳 : \TeX ブック, アスキー(1989)] 914 | \bibitem{texweb} Knuth, D. E. : {\em \TeX : the program}, Addison-Wesley (1986) 915 | \bibitem{jtex} 倉沢良一 : \TeX システムの日本語化, 916 | 日本語\TeX 配布テープ, {\tt ./doc/jtex.tex} (1987) 917 | \bibitem{jfm} 倉沢良一 : JFM file format, 918 | 日本語\TeX 配布テープ, {\tt ./doc/jfm.tex} (1987) 919 | \bibitem{arabic} Knuth, D. E. and MacKay, P. : 920 | Mixing right-to-left texts with left-to-right texts, 921 | {\em TUGboat Volume~8 No.~1}, pp.~14--25 (1987) 922 | \end{thebibliography} 923 | 924 | %% texjporg: タイポだけ修正 (2017/03/13) 925 | \end{document} 926 | -------------------------------------------------------------------------------- /ptexskip_asciimw.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/texjporg/ptex-manual/cdb9dcf825062041f02104c7e6e8ea7e1d66ef09/ptexskip_asciimw.pdf -------------------------------------------------------------------------------- /ptexskip_asciimw.tex: -------------------------------------------------------------------------------- 1 | \documentclass{jarticle} 2 | \ProvidesFile{ptexskip.tex}[1997/08/08 v0.4 about pTeX skips] 3 | \usepackage{plext} 4 | 5 | \title{p\TeX~2.1.5における数式の前後} 6 | \author{中野 賢\footnote{Ken Nakano (\texttt{}): 7 | 株式会社 アスキー 出版技術部}} 8 | \date{1997年8月8日} 9 | 10 | \newcommand{\hex}[1]{\hskip\xkanjiskip\texttt{"#1}} 11 | \newcommand{\cs}[1]{\hskip\xkanjiskip\texttt{\char"5C #1}} 12 | %\xspcode"5C=1 13 | \xspcode"22=2 % 2 14 | \xspcode"27=2 % 2 15 | \xspcode"5C=1 % 1 16 | \xspcode"60=1 % 1 17 | \prebreakpenalty"22=10001 % '' 18 | \prebreakpenalty"27=10002 % ' 19 | \postbreakpenalty"5C=10003 % ``, \ 20 | \postbreakpenalty"60=10004 % ` 21 | 22 | % サンプル用 23 | \newdimen\dimenA 24 | 25 | %\tracingcommands=2 26 | %\tracingmacros=2 27 | %\tracingparagraphs=2 28 | %\tracingoutput=2 29 | \showboxbreadth=\maxdimen 30 | \showboxdepth=\maxdimen 31 | \nonstopmode 32 | 33 | \begin{document} 34 | \maketitle 35 | 36 | \section*{はじめに} 37 | p\TeX{}では、和文と欧文の間に\emph{四分アキ}と呼ばれるスペースを 38 | 自動的に挿入するようになっている。挿入される箇所は、和文と欧文の間という 39 | だけでなく、他にも次の条件が揃っていなくてはならない。 40 | 41 | \begin{itemize} 42 | \item \cs{autoxspcode}の状態 43 | \item \cs{xspcode}および\cs{inhibitxspcode}による抑制を受けない 44 | \item shift\_amount(移動量)がゼロである\cs{hbox}の直前、直後 45 | \item 合字、ペナルティ、ベースライン調整量、暗黙の\cs{kern}の直前、直後 46 | \end{itemize} 47 | 48 | 本文では多くの場合、単純に文字が並んでいるだけなので、このような条件を 49 | 知らなくても、期待している結果を得ることができる。 50 | しかし、数式を組み立てた場合、自分ではとくに指定をしていなくても、 51 | \TeX{}が内部処理で、文字の位置を調整したり、\cs{vbox}に入れたりするために、 52 | 四分アキが入らず、その原因もわからないということがある。 53 | 54 | そこで、p\TeX~2.1.5では、テキスト数式の前後への四分アキの挿入方法を変更した。 55 | この文書では、その拡張に際しての仕様の変更について簡単に説明をしている。 56 | 57 | \section{p\TeX~2.1.4までの数式の前後} 58 | p\TeX~2.1.4で\footnote{より正確に言えば、p\TeX~2.1.5 $\beta$~6まで}、 59 | テキスト数式の前や後に四分アキが入らない主な原因は以下の3つである。 60 | 61 | \begin{itemize} 62 | \item \cs{xspcode}による影響の場合 63 | \item シフトされた\cs{hbox}となる場合 64 | \item \cs{vbox}となる場合 65 | \end{itemize} 66 | 67 | \subsection{\cs{xspcode}による影響の場合} 68 | \cs{xspcode}および\cs{inhibitxspcode}による抑制は、たとえば、 69 | $\alpha$や$\beta$の前後にスペースが入らないという結果をもたらす。 70 | なぜならば、$\alpha$はcmmi10の\hex{0B}の位置、$\beta$は\hex{0C}の位置に 71 | あるからである。これら文字の\cs{xspcode}の値はゼロ、すなわち前後への 72 | 四分アキを抑制するという動作をする。 73 | その結果、前後に四分アキが入らないのである。 74 | 75 | \subsection{シフトされた\cs{hbox}となる場合} 76 | shift\_amountがゼロでない\cs{hbox}の例としては、 77 | $\sum$や$\int$や$x^2$や$x_2$や$\sqrt{\hbox{Var(X)}}$などを挙げられる。 78 | 79 | $\sum$はcmex10の\hex{50}の位置にあり、これはcmr10の``P''と同じ位置 80 | なので\cs{xspcode}による抑制は受けない。しかし、位置の調整のために、 81 | \cs{hbox}に入れられ、左にシフトされる。この結果、\hex{50}の文字が 82 | 一つだけにも関わらず、処理対象外の\cs{hbox}となってしまい、 83 | 前後への四分アキが入らなくなる。$\int$も同様である。 84 | 85 | $x^2$や$x_2$などの場合は、上付き/下付き文字がシフトされた\cs{hbox}として 86 | 組み立てられているので、``$x$''の前には四分アキが入るが、 87 | ``2''の後ろには入らないことになる。 88 | 89 | 根号記号の場合は、全体がシフトされた\cs{hbox}として組み立てられるので、 90 | 前後に四分アキが入らない。 91 | 92 | \subsection{\cs{vbox}となる場合} 93 | その他に四分アキが入る箇所は、 94 | 合字、ペナルティ、ベースライン調整量、暗黙の\cs{kern}の直前か直後 95 | だけである。これ以外の箇所には入らない。 96 | 数式の前後に限れば、このうちの、\cs{vbox}の前後には入らないという 97 | 制限が大きく影響をしている。たとえば、$\frac{1}{k}$といった分数や、 98 | $x_k^2$のように上付きと下付き文字の両方を指定したときが、これに当たる。 99 | 100 | 分数の場合は、最終的に\cs{vbox}として組み立てられる。 101 | そのため、分数の前後に四分アキが入らなくなる。 102 | 上付きと下付きの両方がある場合は、それらが\cs{vbox}に入れられるため、 103 | 入らなくなるのである。上付きと下付きの一方の場合と状況は異なるが、 104 | 結果は一緒である。 105 | 106 | \section{p\TeX~2.1.5 $\beta7$での数式の前後} 107 | 今までの実装コードでは、数式の開始や終了のノードを見つけても、 108 | 開始/終了ノードを単純にスキップするだけで、その後、数式の内部の文字を見て、 109 | スペースを挿入するかどうかを判断をしていた。そのために数式を囲んでいる 110 | \cs{hbox}がシフトしていたり、\cs{vbox}であったりすると前後にスペースが 111 | 入らないという結果になっていた。 112 | 113 | そこで、$\beta7$では、数式の開始ノードを見つけたとき、次の要素が何で 114 | あるかを調べることにした。 115 | 116 | 数式の次の要素が``文字''そのものである場合、テキストの最後の文字との関係で 117 | 適切なスペースを入れる。ここで、従来の動作と異なるのは、数式内部の文字の 118 | \cs{xspcode}あるいは\cs{inhibitxspcode}の設定を無視するようにした点である。 119 | つまり、数式内の文字とその直前との文字が和文か欧文かだけを調べて、 120 | 四分アキか漢字間スペースを挿入するようにした。 121 | この変更で$\alpha$や$\beta$などの文字の前にスペースが入るようになる。 122 | 123 | 数式の開始ノードの次の要素が文字以外の場合は、それが何であっても 124 | 四分アキを入れる。この修正によって、数式がシフトされた\cs{hbox}や 125 | \cs{vbox}の場合であっても四分アキが入る。 126 | このようなボックスになるときは、上付き/下付き文字、分数、数学記号を 127 | 使った場合などである。 128 | 129 | 終了ノードの時点では、この後に挿入するスペースが決まっていればそれを用いる。 130 | すなわち、数式の最後とその後るの文字がともに和文であれば漢字間スペースを 131 | 挿入し、いずれかが欧文であれば四分アキを挿入する。 132 | このときも、数式内部の最後の文字の\cs{xspcode}も無視するようにし、 133 | $\alpha$や$\beta$などの後ろにも入るようにしている。 134 | 135 | シフトされた\cs{hbox}や\cs{vbox}などで終了したときは、 136 | 前側に四分アキを入れたので、合わせる意味で後側にも四分アキを挿入する。 137 | これで$x^2$や$\frac{dx}{dy}$や$\sqrt{3}$などの後ろにもスペースが入る。 138 | 139 | なお、数式の直前の文字と数式内部の先頭文字がともに欧文の場合、 140 | あるいは数式内部の最後と数式直後がともに欧文の場合は、 141 | \TeX{}と同じであり特別なスペースを入れないのは従来と同じである。 142 | 143 | \section{p\TeX~2.1.5 $\beta8$での数式の前後} 144 | p\TeX~2.1.5 $\beta8$では、単純にテキスト数式の前後に四分アキを入れる方法 145 | で実装している。ただし、「(」や「)」などによる抑制を効かせるべき箇所には 146 | 四分アキは入らない。つまり 147 | ``\verb|($y=a+b$)|''は 148 | ``($y=a+b$)''となり 149 | ``(\kern\xkanjiskip$y=a+b$\kern\xkanjiskip)''とは 150 | ならないことに注意する。 151 | `\verb|($y=a+b$)|'は 152 | `($y=a+b$)'となり 153 | `(\kern\xkanjiskip$y=a+b$\kern\xkanjiskip)'とは 154 | ならないことに注意する。 155 | \showlists 156 | 157 | $\beta7$版と$\beta8$版との仕様の違いは、 158 | 次のように数式内の文字が漢字で始まる(あるいは終わる)ときに現れる。 159 | \begin{verbatim} 160 | \kanjiskip=4pt \xkanjiskip=8pt 161 | □□$表面積=4\pi r^2$□□ 162 | \end{verbatim} 163 | この例をそれぞれで処理した場合、 164 | \begin{quote} 165 | \kanjiskip=4pt \xkanjiskip=8pt 166 | □□\kern\kanjiskip$表面積=4\pi r^2$\kern\xkanjiskip □□ 167 | \quad($\beta7$\kern.25zw 版)\\ 168 | □□\kern\xkanjiskip$表面積=4\pi r^2$\kern\xkanjiskip □□ 169 | \quad($\beta8$\kern.25zw 版)\\ 170 | □□$表面積=4\pi r^2$□□ 171 | \quad\hbox{\kanjiskip=0pt\xkanjiskip=.25zw (この版)} 172 | \end{quote} 173 | となる。つまり、$\beta7$版では数式内部の文字と直前の文字を比較しているため、 174 | 前側に漢字間スペースが入り、後側に四分アキが入る。 175 | 一方、$\beta8$版では数式内部の文字に関係なく、両側に四分アキが入る。 176 | 177 | なお、両者の違いは、次のように\cs{hbox}を用いたときにも現れる。 178 | \begin{verbatim} 179 | \kanjiskip=4pt \xkanjiskip=8pt 180 | □□$\hbox{表面積}$□□ 181 | \end{verbatim} 182 | これを処理すると、$\beta7$版は目指すべき仕様とは異なり、 183 | 後ろに何も入らない(バグ)。$\beta8$版では仕様どおりに両側に四分アキが入る。 184 | \begin{quote} 185 | \kanjiskip=4pt \xkanjiskip=8pt 186 | □□\kern\xkanjiskip$\hbox{表面積}$\kern0pt □□ 187 | \quad ($\beta7$\kern.25zw 版)\\ 188 | □□\kern\kanjiskip$\hbox{表面積}$\kern\kanjiskip □□ 189 | \quad\hbox{\kanjiskip=0pt($\beta7$\kern.25zw 版を修正した場合)}\\ 190 | □□\kern\xkanjiskip$\hbox{表面積}$\kern\xkanjiskip □□ 191 | \quad ($\beta8$\kern.25zw 版)\\ 192 | □□$\hbox{表面積}$□□ 193 | \quad\hbox{\kanjiskip=0pt\xkanjiskip=.25zw (この版)} 194 | \end{quote} 195 | 196 | 実際には、p\TeX, p\LaTeX のデフォルトの設定では\cs{kanjiskip}と\cs{xkanjiskip}% 197 | の値はもっと小さいので、違いはそれほど目立たないかもしれない。 198 | しかし、縦組にした場合は、つぎのような結果となる。 199 | \begin{quote} 200 | \begin{minipage}{16zw} 201 | △△\kern\kanjiskip$表面積=4\pi r^2$\kern\xkanjiskip\raisebox{-.25zw}{△△} 202 | \quad($\beta7$\kern.25zw 版)\\ 203 | \\ 204 | △△\kern\kanjiskip$表面積=4\pi r^2$\kern\xkanjiskip △△\\ 205 | \hfill($\beta7$\kern.25zw 版を修正した場合)\\ 206 | \\ 207 | △△\kern\xkanjiskip$表面積=4\pi r^2$\kern\xkanjiskip △△ 208 | \quad($\beta8$\kern.25zw 版)\\ 209 | \\ 210 | △△$表面積=4\pi r^2$△△ 211 | \quad\hbox{\kanjiskip=0pt\xkanjiskip=.25zw (この版)} 212 | \end{minipage} 213 | \end{quote} 214 | $\beta7$の結果を見ると文字間のスペースは仕様どおりになっている。 215 | しかし、ベースラインの調整量が数式の後ろで戻っていないというバグがある。 216 | たとえバグを修正したとしても、決して読みやすいとは思えない。 217 | 218 | 以上の結果を比較すると、$\beta8$の挿入方法のほうが自然で、読みやすいように 219 | 思える。また、挿入されるスペースも前後の文字、数式内の文字に関係なく、 220 | 四分アキと決まっているので結果がわかりやすい。 221 | そこで、$\beta8$では、この節の冒頭で述べた、 222 | \begin{center} 223 | 単純に、テキスト数式の前後に四分アキを入れる 224 | \end{center} 225 | という仕様で実装している。 226 | 227 | \subsection{別の問題} 228 | $\beta7$の実装では、完全に数式にだけ影響するようにしていなかったため、 229 | 通常の文章内でのボックスに対する動作も変わってしまっていた。たとえば、 230 | \begin{quote} 231 | \begin{verbatim} 232 | □□\AA △△△△\hbox to0pt{ABC\hss}○○○○\hbox{}A\hbox{}□□□□ 233 | \end{verbatim} 234 | \end{quote} 235 | が 236 | \begin{quote} 237 | \setbox0=\hbox{h}\dimenA=\ht0 \advance\dimenA-1ex 238 | □□ 239 | \leavevmode\rlap{\raise.67\dimenA\hbox{\char'27}}\kern\xkanjiskip A% 240 | \kern\xkanjiskip △△△△ 241 | \setbox0\hbox{ABC}\dimenA=\wd0\advance\dimenA-\xkanjiskip 242 | \kern\xkanjiskip ABC\kern-\dimenA ○○○○ 243 | \kern\xkanjiskip A\kern\xkanjiskip □□□□ 244 | \end{quote} 245 | となる。先ほどのリストを処理して期待する結果は、次のようだと思われる。 246 | \begin{quote} 247 | \setbox0=\hbox{h}\dimenA=\ht0 \advance\dimenA-1ex 248 | □□ 249 | \kern\xkanjiskip 250 | \leavevmode\rlap{\raise.67\dimenA\hbox{\char'27}}\kern0pt A% 251 | \kern\xkanjiskip △△△△ 252 | \setbox0\hbox{ABC}\dimenA=\wd0% 253 | \kern\xkanjiskip ABC\kern-\dimenA ○○○○ 254 | \kern0pt A\kern0pt □□□□ 255 | \end{quote} 256 | この版では、 257 | \begin{quote} 258 | □□\AA △△△△\hbox to0pt{ABC\hss}○○○○\hbox{}A\hbox{}□□□□ 259 | \end{quote} 260 | となる。 261 | \AA の前に四分アキが入っていなければ、それはシフトされたボックスの前後に 262 | アキが入らないからである。$\beta7$の実装で``{\char'27}''と``A''の位置が 263 | ずれているのは、シフトされたボックスの前には入れないのは変わらないけれども、 264 | 後ろで必ず入れないようにするのをやめたためである。 265 | また、$\beta7$では、ボックスの中身の最後が文字以外でも、空でも四分アキの 266 | 挿入に影響をさせないようにしていたため、幅がゼロのボックスを作成しても、 267 | 参照点の位置が戻らないし、処理の抑制もされなくなっていた 268 | \footnote{これらの問題は$\beta11$で修正。}。 269 | 270 | \appendix 271 | \section{自動挿入されるスペースの種類} 272 | p\TeX{}では、日本語文書をきれいに組版するために、 273 | 和文と和文の間、和文と欧文の間に自動的にスペースを入れるように拡張している。 274 | 欧文と欧文の間は、\TeX{}のメカニズムそのままである。 275 | 276 | 和文と和文の間に入れるスペースの量は、\cs{kanjiskip}という長さレジスタに 277 | 設定をする。和文と欧文との間は\cs{xkanjiskip}という長さレジスタである。 278 | p\TeX{}のデフォルトでは、 279 | \begin{verbatim} 280 | \kanjiskip=0pt plus .4pt minus .4pt 281 | \xkanjiskip=.25zw plus 1pt minus 1pt 282 | \end{verbatim} 283 | となっている。この設定は、 284 | \cs{kanjiskip}は標準でゼロポイント、場合によって$\pm0.4$ポイント分だけ伸縮、 285 | \cs{xkanjiskip}は標準でその時点の和文フォントの幅の$1/4$、 286 | 場合によって$\pm1$ポイント分だけ伸縮しても良いということを意味している。 287 | 288 | \cs{kanjiskip}も\cs{xkanjiskip}も、段落の終わりか、\cs{hbox}の最後の時点 289 | の値が有効となる。したがって、ひとつの段落内や\cs{hbox}内で複数回指定を 290 | しても、その最後の指定によって処理される。 291 | 292 | ただし「、」や「(」のように、特定の文字が連続する場合、そのまま全角幅 293 | で並べ、間に\cs{kanjiskip}を挿入すると文字の間が離れすぎてしまう。 294 | このときには、\cs{kanjiskip}ではなく、JFM(Japanese Font Metric)で設定 295 | されているスペースの量が使われる。 296 | 297 | \cs{xkanjiskip}に関しても、和文と「;」、「(」と和文、欧文と「。」、 298 | 「…」と前後の欧文のような箇所には、スペースを挿入しないほうがきれいに 299 | 見える。そこで、特定の欧文の文字に対して、\cs{xkanjiskip}の挿入を制御 300 | するために\cs{xspcode}が用意されている。 301 | 特定の和文に対しては\cs{inhibitxspcode}を用いて制御する。 302 | 303 | 304 | \section{スペースに関するプリミティブ} 305 | p\TeX{}で拡張した、スペースに関するプリミティブは以下のとおり。 306 | 307 | \subsection{\cs{kanjiskip}, \cs{autospacing}, \cs{noautospacing}} 308 | \cs{kanjiskip}は、 309 | 漢字と漢字の間に自動的に挿入するスペースの量を格納する長さレジスタである。 310 | 311 | \cs{autospacing}と\cs{noautospacing}は、 312 | 漢字と漢字の間にスペースを挿入するかどうかを指定するのに用いる。 313 | \cs{autospacing}を指定すると自動的に挿入される。 314 | \cs{noautospacing}を指定すると漢字間へのスペース挿入は抑制される。 315 | 316 | \subsection{\cs{xkanjiskip}, \cs{autoxspacing}, \cs{noautoxspacing}} 317 | \cs{xkanjiskip}は、 318 | 漢字と英字の間に自動的に挿入するスペースの量を格納する長さレジスタである。 319 | 320 | \cs{autoxspacing}と\cs{noautoxspacing}は、 321 | 漢字と英字の間にスペースを挿入するかどうかを指定するのに用いる。 322 | \cs{autoxspacing}を指定すると自動的に挿入される。 323 | \cs{noautoxspacing}を指定すると漢字間へのスペース挿入は抑制される。 324 | 325 | \subsection{\cs{xspcode}} 326 | \cs{xspcode}は、指定した英字と漢字との間のスペース挿入を 327 | どのように\textgt{許可}するかの設定をするプリミティブである。 328 | 動作は、つぎのいずれかの数値で指定をする。 329 | 330 | \begin{center} 331 | \begin{tabular}{ll} 332 | 0 & 前後の漢字との間へのスペースの挿入を禁止する。\\ 333 | 1 & 直前の漢字との間にだけスペースの挿入を許可する。\\ 334 | 2 & 直後の漢字との間にだけスペースの挿入を許可する。\\ 335 | 3 & 前後の漢字との間にスペースの挿入を許可する。\\ 336 | \end{tabular} 337 | \end{center} 338 | 339 | 初期値は、\texttt{[0-9A-Za-z]}は3、それ以外はゼロになっている。 340 | ただし、以下の文字については、kinsoku.texで別の値に初期化されている。 341 | 括弧内はASCII文字コード(16進数)である。 342 | 343 | \begin{center} 344 | \begin{tabular}{l@{\hspace{2.5zw}}l@{\hspace{2.5zw}}l@{\hspace{2.5zw}}l} 345 | \texttt{(}=1 (\hex{28}) & \texttt{)}=2 (\hex{29}) & 346 | \texttt{[}=1 (\hex{5B}) & \texttt{]}=2 (\hex{5D})\\ 347 | \texttt{`}=1 (\hex{60}) & \texttt{'}=2 (\hex{27}) & 348 | \texttt{;}=2 (\hex{3B}) & \texttt{,}=2 (\hex{2C})\\ 349 | \texttt{.}=2 (\hex{2E}) \\ 350 | \end{tabular} 351 | \end{center} 352 | 353 | ただし、\cs{xspcode}の設定は、文字コードに対してであり、フォントによって 354 | 異なる値を指定することはできない。したがって\hex{60}の位置にある文字は、 355 | cmr10では``\textrm{`}'', cmmi10では``$\ell$'', cmex10では``$\coprod$''で 356 | あるが、これらの文字はすべて\cs{xspcode}=1として処理される。 357 | 358 | \subsection{\cs{inhibitxspcode}} 359 | \cs{inhibitxspcode}は、指定した漢字と英字の間のスペース挿入を 360 | どのように\textgt{抑制}するかの設定をするプリミティブである。 361 | 動作は、つぎのいずれかの数値で指定をする。 362 | 363 | \begin{center} 364 | \begin{tabular}{ll} 365 | 0 & 漢字と英字との間のスペースの挿入を禁止する。\\ 366 | 1 & 直前の英字との間のスペースの挿入を禁止する。\\ 367 | 2 & 直後の英字との間のスペースの挿入を禁止する。\\ 368 | 3 & 前後の英字との間のスペースの挿入を許可する。\\ 369 | \end{tabular} 370 | \end{center} 371 | 372 | 初期値は、すべての漢字について3である。 373 | ただし、以下の文字については、kinsoku.texで別の値に初期化されている。 374 | 375 | \begin{center} 376 | \begin{tabular}{l@{\hspace{2.5zw}}l@{\hspace{2.5zw}}l@{\hspace{2.5zw}} 377 | l@{\hspace{2.5zw}}l@{\hspace{2.5zw}}l} 378 | 、=1 & 。=1 & ,=1 & .=1 & ;=1 & ?=1\\ 379 | (=2 & )=1 & [=2 & ]=1 & {=2 & }=1\\ 380 | ‘=2 & ’=1 & “=2 & ”=1 & 〔=2 & 〕=1\\ 381 | <=2 & >=1 & 《=2 & 》=1 & 「=2 & 」=1\\ 382 | 『=2 & 』=1 & 【=2 & 】=1 & −=0 & 〜=0\\ 383 | …=0 & ¥=0 & °=0 & ′=1 & ″=1\\ 384 | \end{tabular} 385 | \end{center} 386 | 387 | \end{document} 388 | --------------------------------------------------------------------------------