Quick question. When I type $e^{\frac{1}{2x}}$
it makes the fraction very small and hard to read. However when I type $e^{\displaystyle\frac{1}{2x}}$
it makes the fraction way to big. I guess in either case they do not look good to me. Is there a nice way to make fractions in powers look good?
You can also use the xfrac
package which provides \sfrac
which works in text and math mode:
Note:
I stopped using
\sfrac
when I realized that it was resulting in really slow compiles when used in conjunction with themicrotype
package as per:- Why does the use of microtype and xfrac lead to a long compile time?
- Disable microtype for a portion of a document
I think these problems are supposed to have been fixed with
microtype
v2.5, but in case you encounter really slow compile times you may want to try it without themicrotype
package or without\sfrac{}
.
Code:
\documentclass{article}
\usepackage{xfrac}
\begin{document}
Works in text mode \sfrac{1}{2} and in math mode $\sfrac{1}{2}$.
In exponents: $e^{\sfrac{1}{2}}$
\end{document}
Your question was:
While in text mode (aka inline math mode), how does one make fractions in powers look good?
A very important objective in fine typography is to keep the "color" -- really, the "average grayness" -- of paragraphs uniform within a page and across pages. One important aspect of "color" is the line spacing and, in particular, its uniformity: If interline spacing varies noticeably within a paragraph and across paragraphs, "color" is jeopardized and the document is going to look awful, at least from a typographic standpoint.
Unless you have something like doublespacing
in place (and have therefore ruined the look of the paragraph anyway), having math terms with fractional exponents inside running text requires TeX to insert a considerable amount of extra vertical whitespace relative to the preceding line, ruining the paragraph's color. That's a good reason for trying to avoid using any terms in subscript and superscript positions that force TeX to insert extra interline spacing, right? In the TeXbook, Knuth recommends using inline-style fractional expressions, e.g., $1/2$
instead of \frac{1}{2}
, for just this situation.
As you've noted, writing $e^{\frac{1}{2x}}$
renders the material in the numerator and denominator in scriptscriptstyle
(50% linear reduction from textstyle
), which makes it potentially hard to decipher. Some potential fixes:
Using inline fractional math notation, i.e., writing
$e^{1/2x}$
, renders the material in the exponent inscriptstyle
(30% linear reduction fromtextstyle
), which should be no problem for legibility.The
\nicefrac
macro (provided by thenicefrac
package), when used in an exponent, makes the fractional term look a lot less cramped than if\frac
were used; however, it also renders the numerator and denominator inscriptscriptstyle
, re-raising the issue of basic legibility.If the term in the exponent is too complicated to be displayed easily in superscript position, consider typing
$\exp(\sfrac{1}{2x})$
. (The\nicefrac
and\sfrac
macros typeset their argument very similarly, by the way.)
In the following screenshot, the \dfrac
solution is shown mostly to illustrate what should not be done under any circumstance. My personal preference would be for either the third or the fifth solution.
\documentclass{article}
\usepackage{xfrac} % for \xfrac macro
\usepackage{nicefrac} % for \nicefrac macro
\usepackage{amsmath} % for \dfrac macro
\newcommand{\e}{\mathrm{e}}
\begin{document}
some words $\e^{\frac{1}{2x}}$ $\e^{\dfrac{1}{2x}}$ $\e^{1/2x}$
$\e^{\nicefrac{1}{2x}}$ $\exp(\sfrac{1}{2x})$ some more words
\end{document}
Here are the variants to choose
\documentclass{article}
\usepackage[nice]{nicefrac}
\begin{document}
$e^{1/2}$ $e^{(1/2)}$ $e^{0.5}$
With \verb|nicefrac|
$e^{\nicefrac{1}{2}}$
\end{document}
With ugly
option to nicefrac
:
\documentclass{article}
\usepackage[ugly]{nicefrac}
\begin{document}
With \verb|nicefrac|
$e^{\nicefrac{1}{2}}$
\end{document}
nicefrac
package might help as well:$e^{\nicefrac{1}{2}}$
– pablos Sep 21 '14 at 2:50$e^{1/2x}$
or$\exp(1/2x)$
. – Andrew Swann Sep 25 '14 at 11:38tfrac
. – Watson Dec 27 '20 at 12:32