如何改变纯 TeX 中数学符号的大小?

如何改变纯 TeX 中数学符号的大小?

我发现\diamondsuit中的ntxsy太小了,所以我想定义一个宏来放大它并考虑当前使用的字体大小。为了说明这一点,我尝试使用 进行部分修复。cmsy10问题是 导致\advance中的 出现错误\mathchoice,即,! Missing number, treated as zero.如何修复?

\newcount\currentfontsize
\currentfontsize=10
\font\twelvesy=cmsy10 at 12pt
\font\elevensy=cmsy10 at 11pt
\let\olddiamondsuit=\diamondsuit


\newcount\biggercurrentfontsize
\def\diamondsuit{{\biggercurrentfontsize=\currentfontsize
\mathchoice{\diamondsuitbig{\advance \biggercurrentfontsize by
2 \number\biggercurrentfontsize}}{\diamondsuitbig{\advance \biggercurrentfontsize by
2 \number\biggercurrentfontsize}}{\diamondsuitbig{\advance \biggercurrentfontsize by
0 \number\biggercurrentfontsize}}{\diamondsuitbig{\advance \biggercurrentfontsize by
-2 \number\biggercurrentfontsize}}}}  % maybe need \hbox
\def\diamondsuitbig#1{\ifcase #1
   \relax \or  %0
   \relax \or  %1
   \relax \or  %2
   \relax \or  %3
   \relax \or  %4
   \relax \or  %5
   \relax \or  %6
   \relax \or  %7
   \textfont2=\tensy \olddiamondsuit \or  %8
   \textfont2=\elevensy \olddiamondsuit \or  %9
   \textfont2=\twelvesy \olddiamondsuit \or  %10
   \textfont2=\twelvesy \olddiamondsuit \or  %11
   \textfont2=\twelvesy \olddiamondsuit \else  %12
   \relax \fi } 

$\olddiamondsuit$
$\diamondsuitbig{8}$
$\diamondsuitbig{10}$

$\diamondsuit$ $\textfont2=\twelvesy \olddiamondsuit$

\bye

答案1

您采取了错误的方法;您只需要选择合适的字体。

\newcount\currentfontsize
\currentfontsize=10
\font\ntxsyxii=ntxsy at 12pt
\font\ntxsyxi=ntxsy at 11pt
\font\ntxsyx=ntxsy at 10pt
\font\ntxsyix=ntxsy at 9pt
\font\ntxsyviii=ntxsy at 8pt
\font\ntxsyvii=ntxsy at 7pt
\font\ntxsyvi=ntxsy at 6pt
\font\ntxsyv=ntxsy at 5pt

\let\olddiamondsuit\diamondsuit % for doing the comparison, not needed otherwise
\chardef\diamondsuitchar=\numexpr\diamondsuit-"200\relax

\def\diamondsuit{{%
  \mathchoice
    {\diamondsuitbig{2}}
    {\diamondsuitbig{2}}
    {\diamondsuitbig{0}}
    {\diamondsuitbig{-2}}
}}

\def\diamondsuitbig#1{%
  \hbox{\csname ntxsy\romannumeral\numexpr\currentfontsize+#1\endcsname\diamondsuitchar}%
}

\textfont2=\ntxsyx % ntxsy for symbols

Original: $\olddiamondsuit$; new: $\diamondsuit$

$\diamondsuit_{\diamondsuit_{\diamondsuit}}$

\bye

在此处输入图片描述

如果你想避免\numexpr与 Knuth TeX 兼容(虽然我不知道你为什么要这样做),你可以简单地这样做

\def\diamondsuitbig#1{%
  \hbox{%
    \advance\currentfontsize #1\relax
    \csname ntxsy\romannumeral\currentfontsize\endcsname\diamondsuitchar
  }%
}

\currentfontsize一旦\hbox结束,对的分配也将消失。

答案2

应该采取完全不同的方法。

\font\twelvesy=cmsy10 at 12pt
\font\elevensy=cmsy10 at 11pt
%\font\tensy=cmsy10 at 10pt
\font\eightsy=cmsy10 at 8pt % or rather =cmsy8

\newfam\bigsyfam 
%\def\bigsy{\fam\bigsyfam\twelvesy}
\textfont        \bigsyfam =\twelvesy 
\scriptfont      \bigsyfam =\tensy
\scriptscriptfont\bigsyfam =\eightsy

\let\olddiamondsuit=\diamondsuit

\count255 \bigsyfam
\multiply\count255 by 256
\advance\count255 by "7D

\mathchardef\diamondsuit=\count 255

new: $\diamondsuit$ 

old: $\olddiamondsuit$ 

test: $\textfont2=\twelvesy \olddiamondsuit$

\bigskip

new:
$\displaystyle\diamondsuit^{\diamondsuit_\diamondsuit}$


old: 
$\displaystyle\olddiamondsuit^{\olddiamondsuit_\olddiamondsuit}$

\nopagenumbers

\bye

引用

相关内容