Plain TeX 宏“\prod”是如何定义的?

Plain TeX 宏“\prod”是如何定义的?

Plain TeX 中的宏\prod(可能 LaTeX 中也有)的行为方式取决于它是在显示样式还是文本样式中使用。在显示样式中,上标和下标位于大希腊字母 pi 的上方和下方(可能使用关键字 \limits),而在文本样式中,下标位于通常的位置,字符大小不是很大。我正在尝试编写具有这些特征的 Plain TeX 宏,但遇到了麻烦。我最好的选择是下面,并尝试使用它,但它不起作用:

\def \myprod {\mathchoice {\mathop {\mathchar "1359}\limits }
{\mathop {\mathchar "1351}} {NA} {NA}}

My macro in display style prints ${\displaystyle \myprod _{i=1}^n x_n}$, 
but it should print $\displaystyle \prod _{i=1}^n x_n$. Super/subscripts 
are completely off.

My macro in text style prints $\myprod _{i=1}^n x_n$, but it should print 
$\prod _{i=1}^n x_n$. Super/subscripts are slightly off.

答案1

如果你不使用,你描述的下标行为是 mathop 的默认行为\limits

\prod不是宏,它定义为

\mathchardef\prod="1351

以纯文本显示,这意味着它没有宏定义,但是是来自第 3 族和第 51 个字符十六进制的数学运算符

如果您使用 \mathchardef,它还将自动在 displaystyle 中选择正确的较大字符(这是在字体指标中指定的)

如果您正在使用一个不同的字符,该字符在度量中没有指定小/大对,您可以\mathchoice按照下面的第三个示例使用。

在此处输入图片描述

\def\myproda{\mathop {\mathchar "1359}}% \prod is 1351 not 1359
\mathchardef\myprodb "1351

\def\myprodc{\mathop{\mathchoice{E}{e}{\scriptstyle e}{\scriptscriptstyle e}}}

My macro in display style prints ${\displaystyle \myproda _{i=1}^n x_n}$, 
but it should print $\displaystyle \prod _{i=1}^n x_n$. Super/subscripts 
are completely off.

My macro in text style prints $\myproda _{i=1}^n x_n$, but it should print 
$\prod _{i=1}^n x_n$. Super/subscripts are slightly off.

\hrule


My macro in display style prints ${\displaystyle \myprodb _{i=1}^n x_n}$, 
but it should print $\displaystyle \prod _{i=1}^n x_n$. Super/subscripts 
are completely off.

My macro in text style prints $\myprodb _{i=1}^n x_n$, but it should print 
$\prod _{i=1}^n x_n$. Super/subscripts are slightly off.

\hrule


My macro in display style prints ${\displaystyle \myprodc _{i=1}^n x_n}$, 
but it should print $\displaystyle \prod _{i=1}^n x_n$. Super/subscripts 
are completely off.

My macro in text style prints $\myprodc _{i=1}^n x_n$, but it should print 
$\prod _{i=1}^n x_n$. Super/subscripts are slightly off.


\bye

相关内容