# sans-serif math wide П or Π in OTF font for xelatex?

I need a sans-serif math capital letter looking similar to the Greek Π or Cyrillic П but with a little bit more horizontal space between the vertical bars (assuming the same height) to fit the small Latin letter "o" inside on need. The letter П,Π, with and without the "o" inside, will be used as a function symbol, as in Π(x)=z. The symbol number 0e18c in STIXNonUnicode-Regular.otf is not wide enough, neither is the Cyrillic symbol number 041F in cmunss.otf. In general, I wish to compile with xelatex and would be happy if the solution would also work with lualatex (even if it involves an if-then-else-fi-checking of which engine is running).

Here are my attempts so far:

\documentclass{article}
\usepackage{unicode-math}
%%% General font set-up that fits the rest of the document typographically started.
\setmainfont[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic
]{texgyrepagella}
\setsansfont[
Extension = .otf,
UprightFont = *ss,
BoldFont = *sx,
ItalicFont = *si,
BoldItalicFont = *so
]{cmun}
\setmonofont[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic
]{texgyrecursor}
\setmathfont[Extension=.otf]{texgyrepagella-math}
\setmathfont[Extension=.otf,range={\setminus,\mathcal,\mathbfcal,\precneq,\olessthan,\llangle,\rrangle}]{Asana-Math}
\setmathfont[Extension=.otf,range={\smalltriangleleft},BoldFont = *bold]{xits-math}
%%% General font set-up that fits the rest of the document typographically finished.
%%% Now particular junk for the letter in question starts.
\newcommand{\mySymbol}{\textsf{\fontspec{STIXNonUnicode-Regular.otf}\symbol{"0E18C}}}%%% That's similar to what we want. But: in normal size the letter is a little bit too narrow to fit the "o" inside. Also, always puts a normalsize letter :-(.
%\setmathfont[Extension=.otf,
%  BoldFont = cmunsx,
%  ItalicFont = cmunsi,
%  BoldItalicFont = cmunso,
%  range={"041F}
%]{cmunss}%%% Won't work
%\newcommand{\mySymbol}{\textsf{\fontspec{cmunss.otf}\symbol{"041F}}}%%% That's also similar to what we want. But: in normal size the letter is a little bit too narrow to fit the "o" inside. Also, always puts a normalsize letter :-(.
%\newcommand{\mySymbol}{П}%%% Doesn't work at all.
%\newcommand{\mySymbol}{\mathsf{П}}%%% Cyrillic sans-serif П. Doesn't work either.
\newcommand\mySymbolOutputNormal{{%
\setbox0\hbox{\ensuremath{\mySymbol}}%
\rlap{\hbox to \wd0{\hss\ensuremath{\scriptstyle\mathrm{o}}\hss}}\box0%
}}
\newcommand\mySymbolOutputScript{{%
\setbox0\hbox{\ensuremath{\scriptstyle\mySymbol}}%
\rlap{\hbox to \wd0{\hss\ensuremath{\scriptscriptstyle\mathrm{o}}\hss}}\box0%
}}
\newcommand\mySymbolOutputScriptScript{{%
\setbox0\hbox{\ensuremath{\scriptscriptstyle\mySymbol}}%
\rlap{\hbox to \wd0{\hss\ensuremath{\scriptscriptstyle\mathrm{o}}\hss}}\box0%
}}
\newcommand{\mySymbolOutput}{\mathchoice{\mySymbolOutputNormal}{\mySymbolOutputNormal}{\mySymbolOutputScript}{\mySymbolOutputScriptScript}}

\begin{document}
$$\mySymbol(x)_{\mySymbol(y)_{\mySymbol(z)}}\ \mySymbolOutput(x)_{\mySymbolOutput(y)_{\mySymbolOutput(z)}}$$
$\mySymbol(x)_{\mySymbol(y)_{\mySymbol(z)}}\ \mySymbolOutput(x)_{\mySymbolOutput(y)_{\mySymbolOutput(z)}}$
\end{document}


In the output of xelatex below you see that this special symbol won't scale down in script and scriptscript. Further, there is not enough horizontal space for "o" in normalsize. How do I get all that to work?

• Every math font should have a bold sans-serif Pi as \mbfsansPi. You might also try \prod. Maybe see if GFS Neohellenic Math works for you? – Davislor Dec 6 '18 at 3:33
• Other options: draw the symbol geometrically with TikZ, put the lowercase o in a box and shrink it to fit your Pi symbol. – Davislor Dec 6 '18 at 3:34
• Then maybe the capital Pi from a wide, sans-serif text font with Scale=MatchUppercase? TeX Gyre Heros? – Davislor Dec 6 '18 at 3:41
• For example, \scalebox from graphicx. You could also load a font with a Scale= parameter. – Davislor Dec 6 '18 at 3:43
• This isn't a great time for me to make a MCVE, but basically, one way to do it would be to load something like \newfontface\tgheros{TeX Gyre Heros}[Scale=MatchUppercase]. Then, the symbol command would expand to something like \mbox{\tgheros Π}. You might change the math character class to match its usage, such as an operator rather than an ordinary variable. – Davislor Dec 6 '18 at 3:56

I can suggest a geometric construction, not depending on the engine.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\sqp}{s}
{
\IfBooleanTF{#1}
{
\mathord { \mathpalette \egreg_sqp:Nn { \mathrm{o} } }
}
{
\mathord { \mathpalette \egreg_sqp:Nn { } }
}
}

\box_new:N \l__egreg_sqp_temp_box
\dim_new:N \l__egreg_sqp_wd_dim % width
\dim_new:N \l__egreg_sqp_ht_dim % height
\dim_new:N \l__egreg_sqp_th_dim % thickness

\cs_new_protected:Nn \egreg_sqp:Nn
{% #1 = style declaration, #2 = maybe o
\group_begin:
\dim_zero:N \mathsurround
\hbox_set:Nn \l__egreg_sqp_temp_box { $#1\mathrm{o}$ }
\dim_set:Nn \l__egreg_sqp_wd_dim { \box_wd:N \l__egreg_sqp_temp_box }
\dim_set:Nn \l__egreg_sqp_th_dim { \box_wd:N \l__egreg_sqp_temp_box/4 }
\hbox_set:Nn \l__egreg_sqp_temp_box { $#1\Pi$ }
\dim_set:Nn \l__egreg_sqp_ht_dim { \box_ht:N \l__egreg_sqp_temp_box }

\mspace{1mu}
\tl_if_empty:nF { #2 }
{
\hbox_to_zero:n
{
\hbox_to_wd:nn { \l__egreg_sqp_wd_dim + 2\l__egreg_sqp_th_dim } { \hss $#1#2$ \hss }
\hss
}
}
\hbox_to_wd:nn { \l__egreg_sqp_wd_dim + 2\l__egreg_sqp_th_dim } { \__egreg_sqp_draw:N #1 \hss }
\mspace{1mu}
\group_end:
}

\cs_new_protected:Nn \__egreg_sqp_draw:N
{
\driver_draw_begin:
\driver_draw_moveto:nn { 0pt } { 0pt }
\driver_draw_lineto:nn { 0pt } { \l__egreg_sqp_ht_dim }
\driver_draw_lineto:nn { \l__egreg_sqp_wd_dim + 2\l__egreg_sqp_th_dim } { \l__egreg_sqp_ht_dim }
\driver_draw_lineto:nn { \l__egreg_sqp_wd_dim + 2\l__egreg_sqp_th_dim } { 0pt }
\driver_draw_lineto:nn { \l__egreg_sqp_wd_dim + \l__egreg_sqp_th_dim } { 0pt }
\driver_draw_lineto:nn { \l__egreg_sqp_wd_dim + \l__egreg_sqp_th_dim } { \l__egreg_sqp_ht_dim - 0.7\l__egreg_sqp_th_dim }
\driver_draw_lineto:nn { \l__egreg_sqp_th_dim } { \l__egreg_sqp_ht_dim - 0.7\l__egreg_sqp_th_dim }
\driver_draw_lineto:nn { \l__egreg_sqp_th_dim } { 0pt }
\driver_draw_closepath:
\driver_draw_fill:
\driver_draw_end:
}

\ExplSyntaxOff

\begin{document}

$\Pi\Pi\sqp\Pi\sqp*\Pi\sqp*(x)\sqp(x)$

$\scriptstyle \Pi\Pi\sqp\Pi\sqp*\Pi\sqp*(x)\sqp(x)$

$\scriptscriptstyle \Pi\Pi\sqp\Pi\sqp*\Pi\sqp*(x)\sqp(x)$

\end{document}


By simply changing

\dim_set:Nn \l__egreg_sqp_wd_dim { \box_wd:N \l__egreg_sqp_temp_box }


into

\dim_set:Nn \l__egreg_sqp_wd_dim { 0.8\box_wd:N \l__egreg_sqp_temp_box }


we get

• @user49915 No, but there's no Unicode symbol, so it doesn't really matter. – egreg Dec 6 '18 at 17:09
• @user49915 You could try with accsupp, but very few PDF viewers support it. – egreg Dec 6 '18 at 18:08
• @user49915 Sorry, no idea. – egreg Dec 9 '18 at 15:55