I find that \diamondsuit in ntxsy is too small, so I want to define a macro that will enlarge it and take into account the current font size being used. To illustrate below, I have a partial attempted fix using cmsy10 instead.The problem is that the \advance is causing an error where is appears in \mathchoice, namely, ! Missing number, treated as zero. What's the fix?

\font\twelvesy=cmsy10 at 12pt
\font\elevensy=cmsy10 at 11pt

\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 } 


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

  • the logic of the whole thing is hard to understand, you try to change \textfont2 which is used in in displaystyle and textstyle from within a \mathchoice which sets up things also for script and scriptscriptstyle ?
    – user4686
    Nov 5 '15 at 17:30
  • I may be using the wrong logic, but this is how I tried it. I defined \diamondsuitbig to be the proper symbol I want, as illustrated in the file--it works. However, it takes an argument, which gives the proper size. That size is determined by \mathchoice, as that's the only way I know to do it. Everything would work if I didn't have to change a count inside \mathchoice.
    – Russ Lyons
    Nov 5 '15 at 17:45
  • You're doing \ifcase \advance \biggercurrentfontsize by 2 \number\biggercurrentfontsize which makes no sense.
    – egreg
    Nov 5 '15 at 17:52
  • I had tried adding \expandafter before the call to \diamondsuitbig, but that didn't help. What do you suggest?
    – Russ Lyons
    Nov 5 '15 at 17:54
  • Using \numexpr you could do the +2 correctly for the \ifcase but you are optimistic thinking that was the only problem. And setting \textfont2 from within \mathchoice simply can not work. I said it was illogical because it is strange to try to change the font for textstyle from within a subscript or exponent mathchoice specification, as even if that could work, that would not change the size for the subscript or exponent.
    – user4686
    Nov 5 '15 at 18:04

You're taking the wrong approach; you just need to choose the appropriate font.

\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


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

\textfont2=\ntxsyx % ntxsy for symbols

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



enter image description here

If you want to avoid \numexpr to be compatible with Knuth TeX (I don't know why you'd want it, though), you can simply do

    \advance\currentfontsize #1\relax
    \csname ntxsy\romannumeral\currentfontsize\endcsname\diamondsuitchar

The assignment to \currentfontsize will disappear as soon as the \hbox has ended.

  • Wow! This uses \numexpr, which is not part of plain TeX (it is in e-TeX). But I can either incorporate it or substitute for it, I suppose.
    – Russ Lyons
    Nov 5 '15 at 20:43
  • @RussLyons I was thinking to it; avoiding \numexpr is not really difficult. Added.
    – egreg
    Nov 5 '15 at 20:45

A completely different approach should be taken.

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

\textfont        \bigsyfam =\twelvesy 
\scriptfont      \bigsyfam =\tensy
\scriptscriptfont\bigsyfam =\eightsy


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

\mathchardef\diamondsuit=\count 255

new: $\diamondsuit$ 

old: $\olddiamondsuit$ 

test: $\textfont2=\twelvesy \olddiamondsuit$







  • Sorry, I just saw your answer; I don't know why it didn't load earlier. However, your solution is to define a new font family. I'd rather not, for then I would have to delete an existing family. Besides, this is only for one character. The other problem with your solution is that it works only in default 10pt; sometimes I declare \ninepoint or smaller, and I want this to adapt automatically.
    – Russ Lyons
    Nov 5 '15 at 18:14
  • 1
    Yes, I agree this is the defect of this approach. Do you already have 16 families ? Could you please state more precisely what you try to achieve. You want the symbol to identify the current font size and change its own size according to that, in complete generality ? You will need to escape from mathmode via a \hbox, change math fonts, recreate a math group $..$ and put your symbol in there. Furthermore you need to know in which math style you are. Much complications. \mathchoice constructs boxes (I think) there is simply no way you can use it in a "dynamic" way you seem to have hoped
    – user4686
    Nov 5 '15 at 18:20
  • you could also try \resizebox, but again would have to handle all complications of the math spacings, of whether you are in textstyle, scriptstyle, scripscriptstyle...
    – user4686
    Nov 5 '15 at 18:23
  • the objection about \ninepoint does not really hold, because whatever this macro does it must change the sizes of the fonts, in particular the math fonts. Hence the \bigsyfam family would simply have to get redefined as part of the job of \ninepoint. Like in LaTeX after a command such as \Large there is a whole mechanism next time one enters math mode to change all fonts!
    – user4686
    Nov 5 '15 at 18:32
  • Yes, that objection was superfluous; sorry. I believe \resizebox is not part of plain TeX; however, it is can be used with eplain, I believe, which is fine with me. I'll have to check that out. --- Yes, I am already using 16 families, though some are defaults that I don't make use of. However, I would like a solution that avoids a new family. I think you understand exactly what I am trying to do. I believe I could do it by defining this differently for \tenpoint, \ninepoint, etc. It would be nice if I could do this only once.
    – Russ Lyons
    Nov 5 '15 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.