In this revised solution, there is a 2pt gap above the bar and a 4 pt gap below it, as specified in the optional arguments to \stackon
and \stackunder
respectively. Obviously, those numbers can be tweaked (even to the point of being made negative) to deal with the specific characteristics of your font. If you want the division bar raised relative to the horizontal math axis, then the .5ex
argument of \raisebox
can be changed.
EDITED to load \ifthen
package explicitly, since it is no longer done automatically by stackengine
.
\documentclass{article}
\usepackage{stackengine}
\usepackage{ifthen}
\newlength\testwida
\newlength\testwidb
\newlength\mywidth
\newcommand\newfrac[2]{%
\setlength\testwida{\widthof{$#1$}}%
\setlength\testwidb{\widthof{$#2$}}%
\ifthenelse{\lengthtest{\testwida>\testwidb}}%
{\mywidth=\testwida}%
{\mywidth=\testwidb}%
\raisebox{.5ex}{%
\stackunder[4pt]{\stackon[2pt]{\rule{\mywidth}{.4pt}}{$#1$}}{$#2$}}%
}
\parskip 1ex
\begin{document}
\(x^3 \, \newfrac{x + y^2}{\sqrt{xy}}\)
\end{document}

ORIGINAL SOLUTION:
If I am understanding your problem, your font is causing "unnatural" vertical spacing. If that is so, you can use the stackengine
package to stack the items with any particular gap (above and below the crossline). In this example, I show the gap as the default (3pt), then as 1pt, and finally as 4pt. EDITED the answer to get the math axis correct.
\documentclass{article}
\usepackage[oldsyntax]{stackengine}
\usepackage{ifthen}
\newlength\testwida
\newlength\testwidb
\newlength\mywidth
\newcommand\newfrac[2]{%
\setlength\testwida{\widthof{$#1$}}%
\setlength\testwidb{\widthof{$#2$}}%
\ifthenelse{\lengthtest{\testwida>\testwidb}}%
{\mywidth=\testwida}%
{\mywidth=\testwidb}%
\raisebox{.5ex}{%
\stackunder{\stackon{\rule{\mywidth}{.4pt}}{$#1$}}{$#2$}}%
}
\parskip 1ex
\begin{document}
\(x^3 \, \newfrac{x + y^2}{\sqrt{xy}}\)
\Sstackgap=1pt
\(x^3 \, \newfrac{x + y^2}{\sqrt{xy}}\)
\Sstackgap=4pt
\(x^3 \, \newfrac{x + y^2}{\sqrt{xy}}\)
\end{document}

[EDIT: The second MWE uses obsolete stackengine syntax for setting stackgap lengths (e.g., \Sstackgap=1ex), which prevented scalable lengths from scaling under a fontsize change. Version 2 of the package (submitted 7/11/13) remedies the problem with a small syntax change.]
.tex
file, starting with\documentclass
and ending with\end{document}
? Then I can paste it into my editor, reproduce your situation on my machine, and start thinking about a solution.\mathchoice
, or set a different\fontdimen22
.\documentclass[11pt]{article} \usepackage{amsmath} \def\frazione#1#2{\raisebox{.85pt}{$\displaystyle{\frac{#1}{#2}}$}} \begin{document} $$ \bigg(\frazione{a+b}{c-d}+\frac{a+b}{c-d}\bigg) $$ Here, raising the whole fraction on the left seems have no--sense, but using symbols from {\sl mathematical pi font\/} (which I can't load here because they belong to my local tree), I need to do this. \end{document}
\fontdimen22
for the font you're using for the math symbols; however, without an example of your setup it's difficult to say how.