I want to write an X with a bar on top. The X should be upright, but in headings it should be italics. The bar should be in the correct position. So my question is a variant of Aligning \overline to "italics" font. I started to play with jfbu's solution but cannot get the original upshape position to work.

enter image description here




\def\getslant #1{\strip@pt\fontdimen1 #1}

\def\skoverline #1{\mathchoice
 {{\setbox\usefulbox=\hbox{$\m@th\displaystyle #1$}%
    \dimen@ \getslant\the\textfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
 {{\setbox\usefulbox=\hbox{$\m@th\textstyle #1$}%
    \dimen@ \getslant\the\textfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
 {{\setbox\usefulbox=\hbox{$\m@th\scriptstyle #1$}%
    \dimen@ \getslant\the\scriptfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
 {{\setbox\usefulbox=\hbox{$\m@th\scriptscriptstyle #1$}%
    \dimen@ \getslant\the\scriptscriptfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}%




\emph{\xbar-Theory} (correct)

\xbarup-Theory (correct)


  • the way you're using it, the X with overbar is text, not math. unfortunately, the usual text accent \= isn't long enough. what is needed is a diacritic equivalent to unicode U+0305. this may be available in the xits fonts. – barbara beeton Mar 1 '18 at 14:35
  • Hm, but then the X may be different from my X, which is Linux Libertine. – Stefan Müller Mar 1 '18 at 15:34
  • i wasn't suggesting to use another font entirely. it should be potentially possible to access just one or a few characters from an "extra" font, similarly to what is done here (although this example is for a math symbol): Importing a single symbol from a different font – barbara beeton Mar 1 '18 at 16:30
  • Yes, but the X would be different. – Stefan Müller Mar 2 '18 at 6:55
  • If there was a way to detect whether I am in \emph or not, I could use either of the macros. – Stefan Müller Mar 2 '18 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.