Is there a way to make the fraction line look like the equality (=) sign, i.e., to have two parallel horizontal lines with a little gap in between? Many thanks!
[Tex/LaTex] Fraction with doubled line
fractions
Related Solutions
Such a big formula doesn't find its place in line; you could set (maybe locally) \lineskip
to 2pt instead of the default 1pt:
... end of the previous paragraph.
\begingroup
\setlength{\lineskip}{2pt}
The paragraph with the big $\dfrac{\Pr(X-a)}{\Pr(X-b)}$ which
spoils the appearance of the page.
\endgroup
(Note the blank line before \endgroup
to end the paragraph.)
However, the best way to typeset large formulas is to display them:
The paragraph with the big
\[
\frac{\Pr(X-a)}{\Pr(X-b)}
\]
which doesn't spoil the appearance of the page and
is clearer for the reader.
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.]
Best Answer
Use either
\Tfrac
or\Dfrac
(short for Text and Display style "equal fraction") in the following:For a short course on
\ooalign
, see\subseteq
+\circ
as a single symbol (“open subset”).Here is a slightly modified set of commands:
\Efrac
and\efrac
. While both adjust their fraction size based on the math style automatically (using\mathchoice
), the former is vertically higher (set based on the height of the two outer black fraction lines) than the latter (set based on the height of a regular fraction).