[Tex/LaTex] too little space between the bar on the denominator and the horizontal line

accentsfractions

Please see below:

enter image description here

There is too little space between the horizontal line from \frac and the bar from \bar{h_1}. So, it is a little hard to read. Any alternative way to represent the upper bar? And, it is short too.

ADDED:
This is inline mode. In the display math mode, it is quite better. But in the inline math mode, it looks pretty bad, even with \bar{h}_1.

Best Answer

I think the problem here is that you are using inline math mode $..$ as opposed to display mode \[...\]. Here is the comparison of the output between the two:

enter image description here

with the second one producing better spacing. To obtain that you need to either use one of the following

\[\frac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}\]

$\displaystyle \frac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}$

$\dfrac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}$

Note that \dfrac requires that the amsmath package be loaded, either by including it explictly \usepackage{amsmath}, or as part some other package that already includes amsmath, such \usepackage{mathtools}.

Here is the MWE. Note that the center environment was only used to simplify the image capture.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{center}
$\frac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}$
\end{center}

\[\frac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}\]

\begin{center}
$\displaystyle \frac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}$
\end{center}

\begin{center}
$\dfrac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}$
\end{center}
\end{document}

To make the bar wider you can use \overline as in:

$\dfrac{\overline{p}_1}{\overline{p}_1 + \overline{h}_1}$

or adapt the xoverline from The \bar and \overline commands with which you can adjust the spacing:

$\dfrac{\xoverline{p}_1}{\xoverline{p}_1 + \xoverline{h}_1}$

or specify you want it wider with:

$\dfrac{\xoverline[1.25]{p}_1}{\xoverline[1.25]{p}_1 + \xoverline[1.25]{h}_1}$

Here is a comparison between \bar{p}_1, \overline{p}_1, \xoverline[1.25]{p}_1}, and {\xoverline[1.50]{p}_1

enter image description here

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newsavebox\myboxA
\newsavebox\myboxB
\newlength\mylenA

\newcommand*\xoverline[2][1.00]{%
    \sbox{\myboxA}{$\m@th#2$}%
    \setbox\myboxB\null% Phantom box
    \ht\myboxB=\ht\myboxA%
    \dp\myboxB=\dp\myboxA%
    \wd\myboxB=#1\wd\myboxA% Scale phantom
    \sbox\myboxB{$\m@th\overline{\copy\myboxB}$}%  Overlined phantom
    \setlength\mylenA{\the\wd\myboxA}%   calc width diff
    \addtolength\mylenA{-\the\wd\myboxB}%
    \ifdim\wd\myboxB<\wd\myboxA%
       \rlap{\hskip 0.5\mylenA\usebox\myboxB}{\usebox\myboxA}%
    \else
        \hskip -0.5\mylenA\rlap{\usebox\myboxA}{\hskip 0.5\mylenA\usebox\myboxB}%
    \fi}
\makeatother


\begin{document}
$\dfrac{\bar{p}_1}{\bar{p}_1 + \bar{h}_1}$\quad
$\dfrac{\overline{p}_1}{\overline{p}_1 + \overline{h}_1}$\quad
$\dfrac{\xoverline[1.25]{p}_1}{\xoverline[1.25]{p}_1 + \xoverline[1.25]{h}_1}$
$\dfrac{\xoverline[1.50]{p}_1}{\xoverline[1.50]{p}_1 + \xoverline[1.50]{h}_1}$
\end{document}
Related Question