# Math operator names in sans serif with accents using eulerpx

This is a follow-up of a previous question I asked before.

I am using newpxtext and eulerpx packages, and I want to change the typesetting of operator names to use sans serif type. I implemented egreg's answer:

\documentclass{amsart}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools,newpxtext,eulerpx}

% a new symbol font for names of operators
\DeclareSymbolFont{sfoperators}{OT1}{cmss}{m}{n}
% don't waste a math group
\DeclareSymbolFontAlphabet{\mathsf}{sfoperators}
% tell LaTeX to use sfoperators for names of operators
\makeatletter
\renewcommand{\operator@font}{\mathgroup\symsfoperators}
\makeatother


This works for already defined operator names (\max,\sin,etc.) and also for custom-defined operatornames (via DeclareMathOperator). The problem arises when I try to define an operator name involving accents: concretely, I want to define the operator name "máx" (which stands for "máximo", which means "maximum" in Portuguese). The following code

\DeclareMathOperator{\grau}{grau}
\DeclareMathOperator{\mAx}{máx}

\begin{document}
$\deg\quad\grau\quad\max\quad\mAx$
\end{document}


has output

which, besides the fact that the accented "a" is not appearing in sans serif type, generates the warning

'Command \' invalid in math mode on input line ** ',

which is expected, because we must work in math mode instead of text mode. If I use

\DeclareMathOperator{\mAx}{m\acute{a}x}


instead, the output has the same problem as in my previous question:

Trying to implement Davislor's solution

\DeclareMathOperator{\mAx}{m\acute{\mathsf a}x}


does not work, either: it has exactly the same output as before.

Finally, here is a brute-force alternative that works:

\DeclareMathOperator{\mAx}{m\mbox{$\acute{\mathsf a}$}x}


(Obviously, I don't want to resort to this ugly method). Is there some way to solve this issue?

• Can someone please create the eulerpx tag? Thanks. – Matemáticos Chibchas Mar 24 at 21:50
• @egreg that is not the same a as the non-accented operator (both sans serif, but different). – Marijn Mar 24 at 22:26

# The Source of Your Problem

You defined your symbol font as \DeclareSymbolFont{sfoperators}{OT1}{cmss}{m}{n}, using the OT1 encoding. However, you selected \usepackage[T1]{fontenc}, which sets the default encoding to T1. In T1, the slot for the acute accent is "01, but you told LaTeX to use the glyph from a OT1 font, where that slot contains Δ.

The solution is to switch to a consistent encoding. (If you needed to mix font encodings, there are various other tricks you might do, but you don’t.)

# In the Modern Toolchain

The unicode-math package allows you to change the \mathrm alphabet, used for words in math mode such as operator names, separately from the \symup alphabet. The command for this is \setmathrm from fontspec. This example sets Euler’s identities in ISO style, with constants in Neo Euler, operator names in Classico, and digits and variables from Asana Math. These are clones of AMS Euler, Optima and Palatino, respectively, all of which are the work of Hermann Zapf.

\documentclass[varwidth=5cm, preview, 12pt]{standalone}
\usepackage{mathtools}
\usepackage{unicode-math}

\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont{TeX Gyre Pagella}[
Scale=1.0,
Ligatures={Common, Discretionary, TeX}]
\setsansfont{URW Classico}
\setmathfont{Asana Math}
\setmathfont[range={up/{Latin,latin,Greek,greek},
bfup/{Latin,latin,Greek,greek},
cal, bfcal, frak, bffrak},
script-features={},
sscript-features={}
]{Neo Euler}
\setmathrm{URW Classico}

\newcommand\upi{\symup{i}}
\newcommand\upe{\symup{e}}

\begin{document}
\begin{align*}
\upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
\upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}


## In PDFLaTeX

Select a sans-serif family that supports the T1 encoding, and preferably TS1. The eulerpx package recommends Palatino as the serif font and Optima as the sans-serif font, so this uses the clones Pagella and Classico:

\documentclass[varwidth=5cm, preview, 12pt]{standalone}

\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\usepackage[type1]{classico}
\usepackage{tgpagella, eulerpx}
\usepackage{mathtools}

\DeclareSymbolFont{sfoperators}{T1}{URWClassico-LF}{m}{n}
\SetSymbolFont{sfoperators}{bold}{T1}{URWClassico-LF}{b}{n}

\makeatletter
\renewcommand{\operator@font}{\mathgroup\symsfoperators}
\makeatother

\DeclareMathOperator{\grau}{grau}
\DeclareMathOperator{\mAx}{máx}

\begin{document}
\begin{align*}
e^{i x} &= \cos{x} + i \sin{x} \\
e^{i \pi} + 1 &= 0
\end{align*}
$\deg \grau \mAx$
\end{document}


If you do not wish to use URW Classico (or if you want to use this document commercially, which the font license does not allow), you can substitute another font family such as {T1}{cmss}{m}{n}, so long as the encoding matches the one you are using.