0

I would like to change the fonts for + and = in text mode (NOT math font)

I mainly use both article and beamer document classes.

For beamer class, instead of lmodern font, I like nimbussans package for generic fonts, except for how it writes + and =.

For example, lmodern font renders

\begin{frame}{}
\[\text{1+1=2}\]
\[\text{1$+$1$=$2}\]
\[1+1=2\]
\end{frame}

to

enter image description here

while nimbussans font renders it to

enter image description here

I can add the following lines to change the math fonts for + and =

\DeclareSymbolFont{myoperators}{OT1}{lmr}{m}{n}
\SetSymbolFont{myoperators}{bold}{OT1}{lmr}{bx}{n}
\DeclareMathSymbol{+}{\mathbin}{myoperators}{"2B}
\DeclareMathSymbol{=}{\mathrel}{myoperators}{"3D}

to get

enter image description here

However, I don't know how to change text font for + and =.

For article class, I like newtxtext package for generic fonts, but it has the same problem (problem for me):

enter image description here


MWE

% article MWE
\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
%\usepackage{lmodern}   %option1
\usepackage{newtxtext}  %option2
\begin{document}
\[\text{1+1=2}\]
\[\text{1$+$1$=$2}\]
\[1+1=2\]
\end{document}

% beamer MWE \documentclass[10pt]{beamer} \usepackage[T1]{fontenc} \usepackage{amsmath} \usepackage{lmodern} %option1 \usepackage[scaled=0.95]{nimbussans} %option2 \DeclareSymbolFont{myoperators}{OT1}{lmr}{m}{n} \SetSymbolFont{myoperators}{bold}{OT1}{lmr}{bx}{n} \DeclareMathSymbol{+}{\mathbin}{myoperators}{"2B} \DeclareMathSymbol{=}{\mathrel}{myoperators}{"3D}

\begin{document} \begin{frame}{} [\text{1+1=2}] [\text{1$+$1$=$2}] [1+1=2] \end{frame} \end{document}


EDIT

Based onuser202729's comment, I could come up with the following solution

\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
%\usepackage{lmodern}   %option1
\usepackage{newtxtext}  %option2
\DeclareSymbolFont{myoperators}{OT1}{lmr}{m}{n}
\SetSymbolFont{myoperators}{bold}{OT1}{lmr}{bx}{n}
\DeclareMathSymbol{\myplus}{\mathbin}{myoperators}{"2B}
\DeclareMathSymbol{\myequal}{\mathrel}{myoperators}{"3D}
\catcode`+=\active
\catcode`==\active
\def+{\ensuremath{\myplus}}
\def={\ensuremath{\myequal}}
\begin{document}
\[\text{1+1=2}\]
\[\text{1$+$1$=$2}\]
\[1+1=2\]
\end{document}

But I'm not sure whether this solution only works well in this MWE, or it will work well even with many other packages. Also I'm not sure this is the efficient/appropriate implementation.

0 Answers0