4

The macro \prod in Plain TeX (probably also in LaTeX) behaves in distinct ways depending on whether it is used in display or text style. In display style super- and sub-scripts are placed above and below a big Greek letter pi (probably using the keyword \limits), while in text style, subscripts go in the usual place and the character size is not so big. I am trying to write a Plain TeX macro with these characteristics, but I am having trouble with it. My best bet is below, together with an attempt to use it, but it does not work:

\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.
0

1 Answer 1

10

The behaviour of subscripts that you describe is the default for a mathop if you do not use \limits

\prod is not a macro it is defined as

\mathchardef\prod="1351

in plain tex, which means that it does not have a macro definition but is a math operator from family 3 and character hex 51

If you use a \mathchardef it will also choose the correct larger character in displaystyle automatically (this is specified in the font metrics)

If you are using a different character that does not have a small/large pair specified in the metrics you can use \mathchoice as in the third example below.

enter image description here

\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
2
  • Thanks very much @David. Your \myprodc is precisely what I was looking for. Now I see that one should use \mathchoice only to choose the character and not the whole macro.
    – Ruy
    Commented Dec 13, 2016 at 18:08
  • @Ruy well it depends actually, sometimes it's better to pull the subscripts in to the mathchoice (so they can use letter specific kerning) but then it's harder to use the _ and ^ syntax, and here it doesn't seem needed, certainly not for the display case with limits setting Commented Dec 13, 2016 at 18:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .