Using body font in formulae

You have to load fontspec with the no-math option.

\documentclass{article}
\usepackage[no-math]{fontspec}
%\setmainfont{RUBIK-REGULAR}[
%    Path=fonts/,
%    Extension=.ttf
%]
\setmainfont{Impact} % a random distinctive font on my system
\usepackage{mathastext}


\begin{document}

\[T=2\sqrt{\frac{D}{A}}\]

\begin{center}Body Text\end{center}

\end{document}

By the way, the command \center exists but

  • it has no argument
  • it should only be used implicitly via the center environment

enter image description here


You could also load

\usepackage[math-style=upright]{unicode-math}

And set the fonts to something like (if you’ve added a Rubik.fontspec file to your project directory):

\defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }
\setmainfont{Rubik}[Scale=1.0]
\setmathfont{Fira Math}
\setmathfont{Rubik}[range=up]

You can add to this any other characters the Rubik font contains, either with a hex code like "FF, a macro name, or a backtick literal. You can also do ranges, so if the font supports all of Latin-1, you could write range={up,"20-"FF}.

If the font you select does not have Greek letters, use instead:

\setmathfont{Rubik}[range=up/{Latin,latin,digits}]