[Tex/LaTex] Text size to match font size in inline fraction

fontsizefractions

Suppose I type $\frac{\text{foo}}{2}$ to produce a fraction with the text "foo" in the numerator. The "foo" text is smaller than the body text of the document if the math is inline.

Now I would like to type "bar" in plain text and have it be the same font size as the "foo" in the fraction. Is there a way to achieve this that works independently of the font packacge being used?

Four fouriernc, \small{bar} and \footnotesize{bar} look too big. \scriptsize looks too small.


To be clearer about my specific application, here is an MWE:

\documentclass{article}
\usepackage{amsmath,pgfplots,fouriernc}
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[axis lines=left,clip=false]
    \addplot{x} node [right] {$\frac{\text{foo}}{2}$};
    \addplot{x/2} node [right] {\scriptsize foo};
    \end{axis}
    \end{tikzpicture}
\end{document}

Which produces the following plot. Note that the text in the labels appears to be different in size.

enter image description here

To confirm this, I check the size of the two labels in photoshop:

enter image description here


Update: I realise that this indeed works in computer modern, but not for fouriernc, which is the font I am using. I changed the question accordingly.

Best Answer

Use \scriptsize for both and \dfrac.

\documentclass{article}
\usepackage{amsmath,pgfplots,fouriernc}
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[axis lines=left,clip=false]
    \addplot{x} node [right] {\scriptsize$\dfrac{\text{foo}}{2}$};
    \addplot{x/2} node [right] {\scriptsize foo};
    \end{axis}
    \end{tikzpicture}
\end{document}

Here are the two words side by side

enter image description here enter image description here

enter image description here

Related Question