# Recentering \bar over to account for integral alignment

I'm trying to write an integral with upper and lower bounds denoted with over- and under-bars respectively. The issue is that because the integral is slanted, it makes it hard to line up the symbols correctly. \underaccent works beautifully (maybe accidentally) to line up the letter and the bar, but \bar puts the accent too far to the left. See below

    \documentclass{beamer}
\usepackage{amsmath}
\usepackage{accents}
\begin{document}
\begin{frame}{My Integral}
$\int_{\underaccent{\bar}{c}}^{\bar{ c}} x(c_j) dF(c_j)$
\end{frame}
\end{document}


It seems like there should be a way to move the bar over... but my attempts to recenter the bar using added white space were foiled by math mode's removal of spaces. I'd love to hear your thoughts.

• Welcome to TeX.SE! Please always provide an MWE (Minimal Working Example, a smal complete document, beginning with \documentclass and ending with \end{document}. – Zarko Jan 26 at 2:57
• @jsbibra the linked question seems to be asking about putting bars and underbars on the integral symbol itself. This one seems to be about alignment of the bars and underbars which are placed on the limits of the integration. – Willie Wong Jan 26 at 4:31
• – Werner Jan 26 at 6:36
• Thanks. I've been lurking for years, but I guess there are some things you only pick up by doing. How does the question look now? – M D Ricks Jan 27 at 15:05

The sansmathaccent package (which in a modern distribution is already loaded by default by beamer) corrects the default bad placement of math accents for sans-serif letters, see Bad positioning of math accents for the beamer standard font. However, the accents package re-implements the math accents, thus destroying the effect of sansmathaccent; in order to avoid this, the accents package can be loaded with the single option. To try and correct the effect of \underaccent one may insert some kerning, such that accents does not try to shift the \bar in the "correct" (from its point of view) position:

\documentclass{beamer}

\usepackage{amsmath}
\usepackage[single]{accents}
\newcommand*{\ubar}[2][0.5]{\underaccent{\bar}{\mkern-#1mu #2 \mkern#1mu}} % optional argument for fine tuning
% \usepackage{sansmathaccent} % shouldn't be necessary nowadays

\begin{document}
\begin{frame}{Accents}
$\bar{c} \quad \ubar{c} \quad \int_{\ubar{c}}^{\bar{c}} x(c_j)\,dF(c_j)$
\end{frame}
\end{document}


I'm not sure what the notation should mean.

Anyway, there are much simpler examples to see that this does not depend on the integral sign.

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{accents}

\begin{document}

\begin{frame}
$\bar{c}+\underaccent{\bar}{c}$
\end{frame}

\end{document}


Compare with

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}

\begin{document}

$\bar{c}+\underaccent{\bar}{c}$

\end{document}


The fact is that the font used for letters in math mode is not tailored for being used in math, so the internal mechanism fails to properly move the \bar over the characters.

You get better results with arev:

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{accents}
\usepackage{arev,arevmath}

\begin{document}

\begin{frame}
$\bar{c}+\underaccent{\bar}{c}$
\end{frame}

\end{document}


If you're very fussy about the placement, you can use, also in your code, \skew:

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{accents}
\usepackage{arev,arevmath}

\begin{document}

\begin{frame}
$\skew{2}\bar{c}+\underaccent{\bar}{c}$
\end{frame}

\end{document}


\documentclass{beamer}
\usepackage{amsmath}
\usepackage{accents}

\begin{document}

\begin{frame}
$\int_{\underaccent{\bar}{c}}^{\skew{3}\bar{c}}x(c_j)\,dF(c_j)$
\end{frame}

\end{document}


(don't forget the thin space in front of the differential).

• I love palindromes: rep 798897 :-) But that won't last long :-D – campa Jan 27 at 15:51
• – egreg Jan 27 at 16:37

Quick and dirty:

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{accents}
\newcommand{\mybar}[1]{\bar{#1\hphantom{\:}}\mkern-4mu}
\begin{document}
\begin{frame}{Accents}
$\int_{\underaccent{\bar}{c}}^{\mybar{c}} x(c_j)\,dF(c_j)$
\end{frame}
\end{document}


• That nonslanted d is sooo dirty :P. – manooooh Jan 26 at 7:32
• @manooooh There are different schools of thought on it, so I left it as the OP wrote it: tex.stackexchange.com/questions/14821/… – CarLaTeX Jan 26 at 7:41
• Thanks. This looks great aesthetically. I haven't used \hphantom before, but from my reading this makes a hightless space about 2 mu long to recenter the bar, then reduces the kerning so that the integrand isn't too far away. Am I missing any nuances? – M D Ricks Jan 27 at 15:10
• @manooooh I deliberated about whether I wanted to get into that--trust that that's not what it'll look like in the final version :P – M D Ricks Jan 27 at 15:11
• @MDRicks See campa's answer. It is the correct way to go. – CarLaTeX Jan 27 at 16:00