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.]
You won't be needing one big math environment for this. Further, it is a good idea to use siunitx
package for typesetting your units. Here is a sample:
\documentclass[]{scrreprt}
\usepackage{amsmath}
\usepackage[per-mode=symbol,detect-weight]{siunitx}
\DeclareSIUnit{\inHg}{inHg}
\DeclareSIUnit{\mmHg}{mmHg}
\begin{document}
\noindent
Molar Mass of Nitrogen\\
Bulb Volume: $\SI{13.7}{\centi\meter^{3}} = \SI{0.2317}{\litre}$\\
Internal bulb pressure: $\SI{0}{\inHg} = \SI{508}{\mmHg} = \SI{0.508}{\bar}$\\
Temperature: \SI{294.2}{\kelvin}\\[0.5\baselineskip]
$M = \dfrac{\rho}{P}RT$ \\[0.5\baselineskip]
$\rho = \dfrac{\SI{0.158}{\gram}}{\SI{0.2137}{\litre}} = \SI{0.739}{\gram\per\litre}$ \\[0.5\baselineskip]
$M = \dfrac{\SI{0.739}{\gram\per\litre}}{\SI{0.508}{\bar}} * \SI{0.083144}{\litre\bar\per\mole\per\kelvin} * \SI{294.2}{\kelvin} = \SI{35.6}{\gram\per\mol}$\\[0.5\baselineskip]
Calculation of Volume by van der Waals Equation with Successive Approximations \\[0.5\baselineskip]
$V = \dfrac{nRT}{P + \dfrac{n^{2}a}{V^{2}}} + nb$\\[0.5\baselineskip]
$a = \SI{1.408}{\square\litre\bar\per\mol^{2}}$\\[0.5\baselineskip]
$b = \SI{0.03913}{\litre}$\\[0.5\baselineskip]
$V \approx \dfrac{nRT}{P} + nb \approx \dfrac{nRT}{P}$\\[0.5\baselineskip]
$n = \dfrac{m}{M} = \dfrac{\SI{0.158}{\gram}}{\SI{21.35}{\gram\per\mol}} = 7.4*10^{-3}\si{\mol}$\\[0.5\baselineskip]
$V = \dfrac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\litre\bar\per\mol\per\kelvin} * \SI{0294.2}{\kelvin}}{\SI{0.508}{\bar}} = \SI{0.2138}{\litre}$\\[0.5\baselineskip]
\begin{flalign*}
V &= \dfrac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\litre\bar\per\mol\per\kelvin} * \SI{294.2}{\kelvin}}{\SI{0.508}{\bar}}&& \\
& \quad + \dfrac{(7.4*10^{-3}\si{\mol})^{2}* \SI{1.408}{\square\litre\bar\per\square\mol}} {(\SI{0.2138}{\litre})^{2} + 7.4*10^{-3}\si{\mol} * \SI{0.03913}{litre}} &&\\
&= \SI{0.2137}{\litre}
\end{flalign*}
\end{document}
For details you can texdoc mathmode
texdoc amsldoc
and texdoc siunitx
from the terminal.
As a side note, I would also use \cdot
or \times
to show multiplication, but not *
. This, I didn't change in the above example.
Best Answer
You might be looking for the following, but i am really not sure.