# Slashed fraction instead of vertical one

##### Active member
Is there any way to nicely LaTeX a "slashed" fraction? In other words, if I want to write $a_1/a_2$ instead of $\frac{a_1}{a_2}$ or even $\dfrac{a_1}{a_2}$, is there a way to make it look nice?

#### Klaas van Aarsen

##### MHB Seeker
Staff member
You mean like $$\displaystyle ^{a_1}\!\!/\!_{a_2}$$?

It turns out that in real $\LaTeX$, you can use
Code:
\documentclass{article}
\usepackage{units}
\begin{document}

$\nicefrac{a_1}{a_2}$

\end{document}
which looks like:

Last edited:

##### Active member
I found this, which seems to be working a little better

LaTeX force slash fraction notation - Stack Overflow

A sample result:

What I like about this is that you get a nice fraction without changing the font size or extending the line.

I was also trying to find something that would work on MHB, if anything like that exists.

Last edited:

#### Klaas van Aarsen

##### MHB Seeker
Staff member
What works on MHB is ^{a_1}/_{a_2}.
See my previous post for how it looks (slightly adjusted with negative space \!).

#### Evgeny.Makarov

##### Well-known member
MHB Math Scholar
Is there any way to nicely LaTeX a "slashed" fraction? In other words, if I want to write $a_1/a_2$ instead of $\frac{a_1}{a_2}$ or even $\dfrac{a_1}{a_2}$, is there a way to make it look nice?
What exactly is ugly about $a_1/a_2$, i.e., what do you want to change? The nicefrac package makes the numerator and denominator smaller and moves them closer to the slash; that's what is calls "nice" as opposed to fractions with regular slash, which it calls "ugly". This is debatable. The StackOverflow method simply makes the height of the slash equal to the height of its arguments.

And how is $a_1/a_2$ different from the following example?

The TeXbook does not recommend any special care with slash in fractions. There is a subtlety, though:

"TEX does not treat $/$ as a binary operation, even though a slash stands for division (which qualifies as a binary operation on mathematical grounds). The reason is that printers traditionally put extra space around the symbols $+$, $−$, and $*$, but not around $/$. If TEX were to typeset $/$ as a binary operation, the formula ‘\$1/2\$’ would come out ‘$1\mathbin{/}2$’, which is wrong; so TEX considers $/$ to be an ordinary symbol."

Another advice from the TeXbook is not to overuse \frac (or, rather, \over in plain TeX). E.g., instead of $\dfrac{\frac{a}{b}}{2}$ it is recommended to type $\dfrac{a/b}{2}$.

#### Opalg

##### MHB Oldtimer
Staff member
Another advice from the TeXbook is not to overuse \frac (or, rather, \over in plain TeX). E.g., instead of $\dfrac{\frac{a}{b}}{2}$ it is recommended to type $\dfrac{a/b}{2}$.
That applies especially in exponents. I always write $x^{1/2}$ in preference to $x^{\frac12}$, also $$\displaystyle \int_{-\pi/2}^{\pi/2}f(t)\,dt$$ rather than $$\displaystyle \int_{-\frac\pi2}^{\frac\pi2}f(t)\,dt$$.

##### Active member
What exactly is ugly about $a_1/a_2$, i.e., what do you want to change? The nicefrac package makes the numerator and denominator smaller and moves them closer to the slash; that's what is calls "nice" as opposed to fractions with regular slash, which it calls "ugly". This is debatable. The StackOverflow method simply makes the height of the slash equal to the height of its arguments.
What annoys me is that the size of the slash doesn't adjust to the size of the numerator and denominator. To me, ${a_1}^2/{B_1^2}$ does not look pretty. I think the StackOverflow method captures my aesthetics.

I think I like Serena's approach is probably what I'll use here.

#### dwsmith

##### Well-known member
If you are really worried about the aesthetics, you could always do something like this:

Code:
\newcommand{\name}{% name is whatever you want to call it
\leavevmode
\begingroup
\setbox 2 = \hbox {\small $$a_1$$}%
\setbox 0 = \hbox {/}%
\dimen 0 = \ht 0  \advance \dimen 0 by -\ht 2
\raise \dimen 0 \box 2
\kern -0.3333\wd0/\kern -0.3333\wd 0
\lower \dp 0 \hbox {\small $$a_2$$}%
\endgroup
}
\begin{document}
something \name\space something
\end{document}

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Here's an overview, using MiKTeX.

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Huh?
What do you see?
As far as I can tell, you quoted the picture I uploaded.
That is, in your quote the picture shows normally.

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Anyway, here's the overview as far as it renders here.


Last edited:

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Let me retry the attachment.
I was fiddling with it before to get it to show neatly.

#### Attachments

• 18.6 KB Views: 21