[Tex/LaTex] Unusual custom math accent

accentsmath-modesymbols

I want to introduce a new type of math accent that is basically an overbar, but also has small (scriptscriptsize?) text set to the right of the bar. Basically something like

$\bar{A}^{\mathrm{co}}$

but I'd like the text to be set higher—preferably centered vertically on the bar. And I'd like to not have to tweak the height because I'll be making arbitrarily many of these. Is this feasible?

The context is: I'm working on some math that requires an unusually large number of operations similar to complex conjugation. There is no consensus in the literature on which symbols to use for which operations (Hermitian dagger, overbar, overtilde, overset smiley, etc.), which is endlessly confusing. I want to introduce a new notation. My goal is to use an overbar for everything, but also have a short string describing which type of conjugate this is. The string will always be just two or three characters; co in the example above.

Best Answer

Here is an option that uses a combination of things:

enter image description here

\documentclass{article}
\usepackage{amsmath,graphicx}% http://ctan.org/pkg/{amsmath,graphicx}
\makeatletter
\newcommand*{\math@auxii}[2][3]{{}\mkern#1mu\overline{\mkern-#1mu#2}}
\newcommand*{\math@auxi}[3][3]{\overset{\mkern#1mu\text{\scalebox{0.7}{#3}}\mkern-#1mu}{\smash{\math@auxii[#1]{#2}}\vphantom{#2}}}
\newcommand*{\mathco}[2][3]{\math@auxi[#1]{#2}{co}}
\newcommand*{\mathabc}[2][3]{\math@auxi[#1]{#2}{abc}}
\makeatother
\begin{document}
$\bar{A}^{\mathrm{co}} \quad \mathco{A} \quad \mathabc{A} \quad \mathco{XYZ} \quad \mathabc{A}_{\mathabc{B}_{\mathabc{C}}}$
\end{document}

The text in the "accent" (the operation) is scaled to 70% of its original using graphicx's \scalebox{<factor>}{<stuff>}. The \bar is replaced with a "slanted" \overline, pushed to the right a default of 3mus.

Using it in subscripts is not the best... bit I'm not sure whether your use would extend that far.