数式fam拡張マクロ for e-pTeX等

名前: 山本和義
日時: 2009-02-21 03:51:05
IPアドレス: 218.226.114.*

数式famの拡張マクロを普通の人が使えるように,最低限のパッケージの形にして みました.ofamex1.sty, ofamex2.sty, ofamex3.sty を下の方につけておきます. \usepackage{ofamex1,ofamex2} のようにして使います.まだまだ実験的なものなので,dtx とかは作ってありません (いや,実はよく知りません).また,latex.ltx レベルで使って fmt を作るという 野望(いや,手元ではそのようなことをしているだけ)があるので, \ProvidesPackage ではなく \ProvidesFile を用いています.fam256.sty なんて いう名前も考えたのですが,XeTeX拡張の \Umathchardef というのもあるようです ので,omega拡張 の o をつけることにしました(omega拡張のみに対応しています). 簡単な仕様とコードは以下の通りです. %% 仕様 %% omega拡張の形で math font family が拡張されている TeX においてのみ用いる ことができます.具体的には,e-pTeX with FAM256, omega, aleph, luaTeX を 用いた LaTeX2e で使用可能です. ofamex1.sty, ofamex2.sty, ofamex3.sty の順に使います.つまり,後のものを 使う場合には前のものが適用されていることが必要です. 1) ofamex1.sty \DeclareMathAlphabet で定義された \math?? の使用数の制限を緩めます. ! LaTeX Error: Too many math alphabets used in version normal. で苦しめられている人は,\usepackage{ofamex1} だけでだいぶ楽になります (ただし,制限がなくなるわけではありません).math font family が256個に 拡張されている TeX ならばたぶんうまく使えるでしょう.制限数を変えたいときは, 初めにある \mathchardef\max@mathgroup=\@cclvi の \@cclvi を好みの数に 変更します(使用する拡張版TeXの仕様に依存するので,現状では増やしても あまり意味は無いでしょう). 2) ofamex2.sty symbolfont の使用数の制限を緩めます.制限数は \max@mathgroup によります. 各種 mathsymbol の定義の下請けマクロ(\set@mathchar等)のみを変更して, math font family が16番以降になったときには omega拡張の \omathchardef等 を用いるようにしています.15番までは従来の \mathchardef等を用います. mathcode部分は8ビットであることを前提としてあります.\DeclareMathSymbol等で 8ビット超のものを与えた場合には誤動作します. ofamex1.sty, ofamex2.sty までなら,fmt作成時に組み込んでも十分実用的なもの になると思われます. 3) ofamex3.sty mathcode部分に16ビットを許すためのマクロです.現状では,ほぼ必要ないでしょう. \DeclareMathSymbol等の各種 mathsymbol の定義を書き換えて,omega拡張の \omathchardef等を用いるようにします.従来の \mathchardef等は一切使いません. \numexpr を使うと記述がとても楽になるのでそれを使っています.従って, omega拡張とe-TeX拡張がなされている TeX での使用が前提となります. この記述に関しては,\number なんてつけなくても正常動作するのですが, AMS関連のものをうまく動かすためにこのようにしています.全般的に書き換えた方が いいかもしれません.つまり,完全にテスト状態です. %% 仕様 終わり %% %%%% ofamex1.sty by ymt %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 1-st level: % \DeclareMathAlphabet で定義された \math?? の制限を緩める. % latex.ltx のマクロをほんの少し書き換えたものである. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ProvidesFile{ofamex1.sty}[2009/02/20 v0.01 extend mathgroup for mathalphabet] \mathchardef\max@mathgroup=\@cclvi% \@cclvi=256 \def\document@select@group#1#2#3#4{% \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi {% \ifmmode \ifnum\csname c@mv@\math@version\endcsname<\max@mathgroup \begingroup \escapechar\m@ne \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3% \globaldefs\@ne \math@fonts \endgroup \expandafter\extract@alph@from@version \csname mv@\math@version\expandafter\endcsname \expandafter{\number\csname c@mv@\math@version\endcsname}% #1% \global\advance\csname c@mv@\math@version\endcsname\@ne \else \let#1\relax \@latex@error{Too many math alphabets used in version \math@version}% \@eha \fi \else \expandafter\non@alpherr\fi #1{#4}% }% } \def\select@group#1#2#3#4{% \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi {% \ifmmode \ifnum\csname c@mv@\math@version\endcsname<\max@mathgroup \begingroup \escapechar\m@ne \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3% \globaldefs\@ne \math@fonts \endgroup \init@restore@version \xdef#1{\noexpand\use@mathgroup\noexpand#2% {\number\csname c@mv@\math@version\endcsname}}% \global\advance\csname c@mv@\math@version\endcsname\@ne \else \let#1\relax \@latex@error{Too many math alphabets used in version \math@version}% \@eha \fi \else \expandafter\non@alpherr\fi #1{#4}% }% } \endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% ofamex2.sty by ymt %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 2-nd level: % math symbol の family の制限を緩める. % 下請けマクロ \set@mathchar 等が fam>15 でもうまく動作するようにする. % ただし,mathcode は8bitのままとする. % fam>15 では omega拡張(\omathchardef等)がなされていなければならない. % 主に,互換性を保ったままの拡張が目的である. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ProvidesFile{ofamex2.sty}% [2009/02/20 v0.01 extend mathgroup for mathsymbol (omega style)] %\mathchardef\max@mathgroup=\@cclvi% \@cclvi=256 \def\new@mathgroup{\alloc@8\mathgroup\chardef\max@mathgroup} \def\set@mathchar#1#2#3#4{% \ifnum#1<\sixt@@n \global\mathcode`#2="\mathchar@type#3\hexnumber@#1#4\relax \else \global\omathcode`#2="\mathchar@type#3\hexnumber@@#100#4\relax \fi } \def\set@mathsymbol#1#2#3#4{% \ifnum#1<\sixt@@n \global\mathchardef#2"\mathchar@type#3\hexnumber@#1#4\relax \else \global\omathchardef#2"\mathchar@type#3\hexnumber@@#100#4\relax \fi } \def\set@mathaccent#1#2#3#4{% \ifnum#1<\sixt@@n \xdef#2{\mathaccent"\mathchar@type#3\hexnumber@#1#4\relax}% \else \xdef#2{\omathaccent"\mathchar@type#3\hexnumber@@#100#4\relax}% \fi } \def\set@mathdelimiter#1#2#3#4#5#6{% \@tempswatrue \ifnum#1<\sixt@@n\relax\else\@tempswafalse\fi \ifnum#2<\sixt@@n\relax\else\@tempswafalse\fi \if@tempswa \xdef#3{\delimiter"\mathchar@type#4\hexnumber@#1#5\hexnumber@#2#6\relax}% \else \xdef#3{\odelimiter"\mathchar@type#4\hexnumber@@#100#5% "\hexnumber@@#200#6\relax}% \fi } \def\set@@mathdelimiter#1#2#3#4#5{% \@tempswatrue \ifnum#1<\sixt@@n\relax\else\@tempswafalse\fi \ifnum#2<\sixt@@n\relax\else\@tempswafalse\fi \if@tempswa \global\delcode`#3="\hexnumber@#1#4\hexnumber@#2#5\relax \else \global\odelcode`#3="\hexnumber@@#100#4"\hexnumber@@#200#5\relax \fi } \def\DeclareMathRadical#1#2#3#4#5{% \expandafter\ifx \csname\expandafter\@gobble\string#1\endcsname \relax \let#1\radical \fi \edef\reserved@a{\noexpand\in@{\string\radical}{\meaning#1}}% \reserved@a \ifin@ \expandafter\in@\csname sym#2\expandafter\endcsname \expandafter{\group@list}% \ifin@ \expandafter\in@\csname sym#4\expandafter\endcsname \expandafter{\group@list}% \ifin@ \begingroup \count\z@=#3\relax \count\tw@\count\z@ \divide\count\z@\sixt@@n \count@\count\z@ \multiply\count@\sixt@@n \advance\count\tw@-\count@ \edef\reserved@c{% \hexnumber@{\count\z@}\hexnumber@{\count\tw@}}% \count\z@=#5\relax \count\tw@\count\z@ \divide\count\z@\sixt@@n \count@\count\z@ \multiply\count@\sixt@@n \advance\count\tw@-\count@ \edef\reserved@d{% \hexnumber@{\count\z@}\hexnumber@{\count\tw@}}% \expandafter\set@mathradical \csname sym#2\expandafter\endcsname \csname sym#4\endcsname #1\reserved@c\reserved@d \endgroup \else \@latex@error{Symbol font `#4' is not defined}\@eha \fi \else \@latex@error{Symbol font `#2' is not defined}\@eha \fi \else \@latex@error{Command `\string#1' already defined}\@eha \fi } \def\set@mathradical#1#2#3#4#5{% \@tempswatrue \ifnum#1<\sixt@@n\relax\else\@tempswafalse\fi \ifnum#2<\sixt@@n\relax\else\@tempswafalse\fi \if@tempswa \xdef#3{\radical"\hexnumber@#1#4\hexnumber@#2#5\relax}% \else \xdef#3{\oradical"\hexnumber@@#100#4"\hexnumber@@#200#5\relax}% \fi } \@onlypreamble\set@mathradical \def\mathhexbox#1#2#3{% \ifnum"#1<\sixt@@n \mbox{$\m@th \mathchar"#1#2#3$}% \else \mbox{$\m@th \omathchar"#100#2#3$}% \fi } \def\org@hexnumber@#1{\ifcase\number#1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or A\or B\or C\or D\or E\or F\fi} \def\hexnumber@#1{% \ifnum\number#1<\sixt@@n \org@hexnumber@{#1}% \else \hexnumber@@{#1}% \fi } \def\hexnumber@@#1{\ifcase\number#1 00\or 01\or 02\or 03\or 04\or 05\or 06\or 07\or 08\or 09\or 0A\or 0B\or 0C\or 0D\or 0E\or 0F\or 10\or 11\or 12\or 13\or 14\or 15\or 16\or 17\or 18\or 19\or 1A\or 1B\or 1C\or 1D\or 1E\or 1F\or 20\or 21\or 22\or 23\or 24\or 25\or 26\or 27\or 28\or 29\or 2A\or 2B\or 2C\or 2D\or 2E\or 2F\or 30\or 31\or 32\or 33\or 34\or 35\or 36\or 37\or 38\or 39\or 3A\or 3B\or 3C\or 3D\or 3E\or 3F\or 40\or 41\or 42\or 43\or 44\or 45\or 46\or 47\or 48\or 49\or 4A\or 4B\or 4C\or 4D\or 4E\or 4F\or 50\or 51\or 52\or 53\or 54\or 55\or 56\or 57\or 58\or 59\or 5A\or 5B\or 5C\or 5D\or 5E\or 5F\or 60\or 61\or 62\or 63\or 64\or 65\or 66\or 67\or 68\or 69\or 6A\or 6B\or 6C\or 6D\or 6E\or 6F\or 70\or 71\or 72\or 73\or 74\or 75\or 76\or 77\or 78\or 79\or 7A\or 7B\or 7C\or 7D\or 7E\or 7F\or 80\or 81\or 82\or 83\or 84\or 85\or 86\or 87\or 88\or 89\or 8A\or 8B\or 8C\or 8D\or 8E\or 8F\or 90\or 91\or 92\or 93\or 94\or 95\or 96\or 97\or 98\or 99\or 9A\or 9B\or 9C\or 9D\or 9E\or 9F\or A0\or A1\or A2\or A3\or A4\or A5\or A6\or A7\or A8\or A9\or AA\or AB\or AC\or AD\or AE\or AF\or B0\or B1\or B2\or B3\or B4\or B5\or B6\or B7\or B8\or B9\or BA\or BB\or BC\or BD\or BE\or BF\or C0\or C1\or C2\or C3\or C4\or C5\or C6\or C7\or C8\or C9\or CA\or CB\or CC\or CD\or CE\or CF\or D0\or D1\or D2\or D3\or D4\or D5\or D6\or D7\or D8\or D9\or DA\or DB\or DC\or DD\or DE\or DF\or E0\or E1\or E2\or E3\or E4\or E5\or E6\or E7\or E8\or E9\or EA\or EB\or EC\or ED\or EE\or EF\or F0\or F1\or F2\or F3\or F4\or F5\or F6\or F7\or F8\or F9\or FA\or FB\or FC\or FD\or FE\or FF \fi } \endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% ofamex3.sty by ymt %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 3-rd level: % \DeclareMathSymbol 等を直接拡張し,omega拡張に合うものにする. % omega拡張(\omathchardef等)と e-TeX拡張(\numexpr等)がなされていないと % 正常に動作はしない. % latex.ltx のマクロを書き換えて作成している. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ProvidesFile{ofamex3.sty}% [2009/02/20 v0.01 wide mathsymbol (omega style, 256FAM, 65536MATHCODE)] %\mathchardef\max@mathgroup=\@cclvi% \@cclvi=256 \def\DeclareMathSymbol#1#2#3#4{% \expandafter\in@\csname sym#3\expandafter\endcsname \expandafter{\group@list}% \ifin@ \begingroup \if\relax\noexpand#1% is command? \edef\reserved@a{\noexpand\in@{\string\mathchar}{\meaning#1}}% \reserved@a \ifin@ \oset@mathsymbol{#1}{#2}{#3}{#4}% \@font@info{Redeclaring math symbol \string#1}% \else \expandafter\ifx \csname\expandafter\@gobble\string#1\endcsname \relax \oset@mathsymbol{#1}{#2}{#3}{#4}% \else \@latex@error{Command `\string#1' already defined}\@eha \fi \fi \else \oset@mathchar{#1}{#2}{#3}{#4}% \fi \endgroup \else \@latex@error{Symbol font `#3' is not defined}\@eha \fi } %\@onlypreamble\DeclareMathSymbol \def\oset@mathsymbol#1#2#3#4{% \global\omathchardef#1% \number \numexpr"1000000*\mathchar@type#2+"10000*\csname sym#3\endcsname+#4} \@onlypreamble\oset@mathsymbol \def\oset@mathchar#1#2#3#4{% \global\omathcode`#1=% \number \numexpr"1000000*\mathchar@type#2+"10000*\csname sym#3\endcsname+#4} \@onlypreamble\oset@mathchar \def\DeclareMathAccent#1#2#3#4{% \expandafter\in@\csname sym#3\expandafter\endcsname \expandafter{\group@list}% \ifin@ \begingroup \if\relax\noexpand#1% is command? \edef\reserved@a{\noexpand\in@{\string\mathaccent}{\meaning#1}}% \reserved@a \ifin@ \oset@mathaccent{#1}{#2}{#3}{#4}% \@font@info{Redeclaring math accent \string#1}% \else \expandafter\ifx \csname\expandafter\@gobble\string#1\endcsname \relax \oset@mathaccent{#1}{#2}{#3}{#4}% \else \@latex@error{Command `\string#1' already defined}\@eha \fi \fi \else \@latex@error{Not a command name: `\noexpand#1'}\@eha \fi \endgroup \else \@latex@error{Symbol font `#3' is not defined}\@eha \fi } %\@onlypreamble\DeclareMathAccent \def\oset@mathaccent#1#2#3#4{% \xdef#1{\omathaccent% \number \numexpr"1000000*\mathchar@type#2+"10000*\csname sym#3\endcsname+#4}} \@onlypreamble\oset@mathaccent %\def\DeclareMathDelimiter#1{% % \if\relax\noexpand#1% % \expandafter\@DeclareMathDelimiter % \else % \expandafter\@xxDeclareMathDelimiter % \fi % #1} %\@onlypreamble\DeclareMathDelimiter %\def\@xxDeclareMathDelimiter#1#2#3#4{% % \begingroup % \let\mathalpha\mathord % \ifnum7=\mathchar@type{#2}% % \endgroup % \expandafter\@firstofone % \else % \endgroup % \DeclareMathSymbol#1{#2}{#3}{#4}% % \expandafter\@firstoftwo % \fi % {\@xDeclareMathDelimiter#1}{#2}{#3}{#4}} %\@onlypreamble\@xxDeclareMathDelimiter \def\@DeclareMathDelimiter#1#2#3#4#5#6{% \expandafter\in@\csname sym#3\expandafter\endcsname \expandafter{\group@list}% \ifin@ \expandafter\in@\csname sym#5\expandafter\endcsname \expandafter{\group@list}% \ifin@ \begingroup \edef\reserved@a{\noexpand\in@{\string\delimiter}{\meaning#1}}% \reserved@a \ifin@ \oset@mathdelimiter{#1}{#2}{#3}{#4}{#5}{#6}% \@font@info{Redeclaring math delimiter \string#1}% \else \expandafter\ifx \csname\expandafter\@gobble\string#1\endcsname \relax \oset@mathdelimiter{#1}{#2}{#3}{#4}{#5}{#6}% \else \@latex@error{Command `\string#1' already defined}\@eha \fi \fi \endgroup \else \@latex@error{Symbol font `#5' is not defined}\@eha \fi \else \@latex@error{Symbol font `#3' is not defined}\@eha \fi } %\@onlypreamble\@DeclareMathDelimiter \def\@xDeclareMathDelimiter#1#2#3#4#5{% \expandafter\in@\csname sym#2\expandafter\endcsname \expandafter{\group@list}% \ifin@ \expandafter\in@\csname sym#4\expandafter\endcsname \expandafter{\group@list}% \ifin@ \oset@@mathdelimiter{#1}{#2}{#3}{#4}{#5}% \else \@latex@error{Symbol font `#4' is not defined}\@eha \fi \else \@latex@error{Symbol font `#2' is not defined}\@eha \fi } %\@onlypreamble\@xDeclareMathDelimiter \def\oset@mathdelimiter#1#2#3#4#5#6{% \begingroup \count\z@ \numexpr"1000000*\mathchar@type#2+"10000*\csname sym#3\endcsname+#4% \count\tw@ \numexpr"10000*\csname sym#5\endcsname+#6% \xdef#1{\odelimiter\number\count\z@\space \number\count\tw@}% \endgroup } \@onlypreamble\oset@mathdelimiter \def\oset@@mathdelimiter#1#2#3#4#5{% \begingroup \count\z@\numexpr"10000*\csname sym#2\endcsname+#3% \count\tw@\numexpr"10000*\csname sym#4\endcsname+#5% \global\odelcode`#1=\number\count\z@\space \number\count\tw@ \endgroup } \@onlypreamble\oset@@mathdelimiter \def\DeclareMathRadical#1#2#3#4#5{% \expandafter\ifx \csname\expandafter\@gobble\string#1\endcsname \relax \let#1\radical \fi \edef\reserved@a{\noexpand\in@{\string\radical}{\meaning#1}}% \reserved@a \ifin@ \expandafter\in@\csname sym#2\expandafter\endcsname \expandafter{\group@list}% \ifin@ \expandafter\in@\csname sym#4\expandafter\endcsname \expandafter{\group@list}% \ifin@ \oset@mathradical{#1}{#2}{#3}{#4}{#5}% \else \@latex@error{Symbol font `#4' is not defined}\@eha \fi \else \@latex@error{Symbol font `#2' is not defined}\@eha \fi \else \@latex@error{Command `\string#1' already defined}\@eha \fi } %\@onlypreamble\DeclareMathRadical \def\oset@mathradical#1#2#3#4#5{% \begingroup \count\z@\numexpr"10000*\csname sym#2\endcsname+#3% \count\tw@\numexpr"10000*\csname sym#4\endcsname+#5% \xdef#1{\oradical\number\count\z@\space \number\count\tw@}% \endgroup } \@onlypreamble\oset@mathradical \endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

この書き込みへの返事:

お名前
題名 
メッセージ(タグは <a href="...">...</a> だけ使えます。適宜改行を入れてください)