3

I have a document with an overset like this:

\starttext
    \math{
        \overset{
            \text{Text A}
        }{
            \text{Text B}
        }
    }
\stoptext

"Text A" appears printed smaller than "Text B". I'd like some other text to also appear with the same size as "Text A". How can I set other text to match this same size? I tried setting it to "small" and "tiny". Setting other text to "small" produced text that was several pixels taller than "Text A". Setting it to "tiny" did not result in any font size change.

  • Overset is meant for placing something on top of an operator. What exactly do you want to do. Do you simply need stacking of text (would simply placing two hboxes in a vbox work?) or do you need to use this in a math environment? – Aditya Feb 9 '17 at 6:56
5

Let us dissect what is happening here. First of all we want to know more about \overset, which is defined in math-ali.mkiv

\unexpanded\def\overset#1#2%
  {\math_binrel_apply{#2}{\mathop{\kern\zeropoint#2}\limits\normalsuperscript{#1}}}

Aha! Apparently, the first argument is put inside \mathop and the second argument inside a superscript. Super- and subscripts are always typeset in \scriptstyle (unless \scriptstyle was active before, then it becomes \scriptscriptstyle). Therefore we conclude that we can typeset text in the same fontsize by using

\math{\scriptstyle\text{Foo}}

But we can go further. We could also find out what is the font size that is actually used inside the \text command. Therefore we look up the definition of \text and the associated macros in math-ini.mkiv:

\appendtoks \let\text\mathtext \to \everymathematics

\unexpanded\def\mathtext{\mathortext{\math_text_choice_font\relax}\hbox}

\def\math_text_choice_font#1#2#%
  {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}%
   \hbox#2\bgroup
   \bgroup
   \aftergroup\hss
   \aftergroup\egroup
   \hss
   \font_basics_switchtobodyfont\m_math_text_choice_face
   #1%
   \let\next}

Jackpot! That is what we are looking for. The line of interest here is

\font_basics_switchtobodyfont\m_math_text_choice_face

As is evident from the macro name this command switches the font size to whatever is currently in \m_math_text_choice_face. Some lines earlier this size is obtained using

\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}

The means we could query ourselves for the size of the script sized font and use it

\starttext
\normalizebodyfontsize\scriptsize{\mathstyleface\scriptstyle}
Text A \switchtobodyfont[\scriptsize] Text B
\stoptext

or, if we don’t want to use the additional \scriptsize macro

\starttext
Text A \switchtobodyfont[\thenormalizedbodyfontsize{\mathstyleface\scriptstyle}] Text B
\stoptext
  • I would have simply used oalign and ialign series of macros (from plain tex, also implemented in latex and context) – Aditya Feb 9 '17 at 23:17
  • @Aditya Yes, of course I would not use \overset to stack text but rather a table (allows more tweaking than plain \oalign and \ialign). However, OP asked what is the fontsize in the upper part of \overset which I think I answered. – Henri Menke Feb 10 '17 at 8:38

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.