Is it possible to create an overline with a gap containing a symbol in the middle in math mode?
What I would like to achieve is something like this:
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communitySomething like this?
\documentclass{article}
\usepackage{amsmath}
\newcommand{\joverline}[2]{%
\mathord{% make sure we're in math mode
\vbox{\offinterlineskip
\halign{##\cr
\hrulefill$\,\scriptscriptstyle#1\,$\hrulefill\cr
\noalign{\kern.3ex}
$#2$\cr
}%
}%
}%
}
\begin{document}
$\joverline{n}{(Q,\emptyset)}$
\end{document}
Something more could be needed if you plan to use this construction also in sub/superscripts.
A version with the superscript centered vertically with respect to the rule:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\chrulefill}{%
\leaders\hrule height \dimexpr\fontdimen22\scriptscriptfont2+0.2pt\relax
depth -\dimexpr\fontdimen22\scriptscriptfont2-0.2pt\relax
\hfill}
\newcommand{\joverline}[2]{%
\mathord{% make sure we're in math mode
\vbox{\offinterlineskip
\halign{##\cr
\chrulefill$\,\scriptscriptstyle#1\,$\chrulefill\cr
\noalign{\kern.2ex}
$#2$\cr
}%
}%
}%
}
\begin{document}
$\joverline{n}{(Q,\emptyset)}$
\end{document}
You can change the spacing between the rule and the main part by modifying the \kern.2ex
; adjust at will.
The overset gap, currently set to 2pt, can be changed to suit.
\documentclass{article}
\usepackage{stackengine}
\usepackage{calc}
\newcommand\overlineset[2]{%
\stackengine{2pt}{$#1$}{\makebox[\widthof{$#1$}]{%
$\scriptscriptstyle\hrulefill\,#2\,\hrulefill$}}{O}{c}{F}{T}{S}%
}
\begin{document}
\(\overlineset{(Q,\emptyset)}{n}\)
\end{document}