[Tex/LaTex] Math symbol similar to $\Pi$ but with crossed legs

stacking-symbolssymbols

I would like to realize a symbol that looks similar to a \Pi, but with its two legs crossed, like in an \mathrm{X}. In other words, I want the bar in \overline{\mathrm{X}} to be moved down just a little bit, placing it on top of the \mathrm{X}. Here is what I achieved so far, using code from Moving the bar on hbar:

\documentclass{article}
\usepackage{mathtools}
\usepackage{xparse}
\makeatletter
\newcommand{\raisemath}[1]{\mathpalette{\raisem@th{#1}}}
\newcommand{\raisem@th}[3]{\raisebox{#1}{$#2#3$}}
\makeatother
\NewDocumentCommand{\crossedPi}{}{
  \ensuremath{\mathrlap{\raisemath{-1.6pt}{ 
    \overline{\phantom{\mathrm{X}}}}}\mathrm{X}}}
\begin{document}
  $\Pi \crossedPi$ \\
  $\mathrm{Set}_{\Pi} \mathrm{Set}_{\crossedPi}$
\end{document}

enter image description here

The \crossedPi symbol in normal position looks just as I want it to look, but when the symbol is used in index position, as in \mathrm{Set}_{\crossedPi}, the bar gets out of place.

What would be the perfect professional way to realize this symbol in a robust way, so that nothing gets out of place when used in index position?

Best Answer

\documentclass{article}
\usepackage{mathtools}

\makeatletter
\DeclareRobustCommand{\crossedPi}{%
  {\mathpalette\loweroverline{\mathrm{X}}}%
}
\newcommand{\loweroverline}[2]{%
  \sbox\z@{$\m@th#1#2$}%
  \dimen@=0.8\fontdimen 8
    \ifx#1\displaystyle\textfont\else
    \ifx#1\textstyle\textfont\else
    \ifx#1\scriptstyle\scriptfont\else
    \scriptscriptfont\fi\fi\fi 3
  \ooalign{%
    \vrule width 0.95\wd\z@ height \ht\z@ depth \dimexpr \dimen@-\ht\z@\relax\cr
    \hidewidth\box\z@\hidewidth\cr
  }%
}
\makeatother
\begin{document}

$\Pi \crossedPi \Pi \scriptstyle \Pi\crossedPi\Pi$

$\mathrm{Set}_{\Pi} \mathrm{Set}_{\crossedPi}$

\end{document}

The thickness of the overline is a fraction of the thickness used for fractions in the corresponding style.

Different fonts will probably need different figures.

enter image description here