Text size to match font size in inline fraction

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}$};
\end{axis}
\end{tikzpicture}
\end{document}


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

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

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.

• Maybe \scriptsize? – David Purton Mar 14 '17 at 11:46
• Try $\scriptstyle\text{bar}$ or $\scriptstyle\mathrm{bar}$? – Bernard Mar 14 '17 at 11:50
• Thanks. I think \scriptsize is too small. – Ubiquitous Mar 14 '17 at 11:58
• Actually you just have to use \scriptsize bar. I've measured (precision: 0.1 pt). Unless you don't use a standard font (Computer Modern or Latin Modern). B.t.w. \scriptsize is not used in the same context as \scriptstyle. – Bernard Mar 14 '17 at 11:58
• @Ubiquitous, can you give full MWE? \scriptsize matches exactly for me. Note it should be {\scriptsize bar} not \scriptsize{bar}. – David Purton Mar 14 '17 at 12:02

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}$};
\end{axis}
\end{tikzpicture}
\end{document}


Here are the two words side by side