# How to change / to be horizontal?

I like to change a/b to be

a
-
b


how to do that?

• yes,I only can use / now.
– sam
Jun 18, 2011 at 13:34
• See my answer below. But really, since you ask this very elementary question, I guess you do not have access to any form of documentation? You need to remedy that. LaTeX is too complex to use without documentation. Jun 18, 2011 at 13:36
• Or have a look at this one: en.wikibooks.org/wiki/LaTeX Jun 18, 2011 at 13:42

\frac{a}{b}, in math mode of course.

For fractions use $\frac{a}{b}$, like Harald Hanche-Olsen said. For inline-math I still like fractions that use / because a \frac is often too tall. Here is a definition for a nicer fraction that uses /:

\def\nicefrac#1#2{\leavevmode%
\raise.5ex\hbox{\small #1}%
\kern-.1em/\kern-.15em%
\lower.25ex\hbox{\small #2}}


It is used like this:

\nicefrac{a}{b}

• The nicefrac package, or the units package, also offer a \nicefrac command. Jun 18, 2011 at 13:46
• The xfrac package seems to be the better choice. Jun 18, 2011 at 13:51
• Is this kind of command can be used on MathJaX? Because I can't try success on Statistical Analysis board.
– sam
Jun 18, 2011 at 13:52
• You can also use $\dfrac{a}{b}$ if you want a larger fraction in inline math mode. Jun 18, 2011 at 14:51
• @Peter: using \dfrac in inline math is not very good because it changes the space between lines and by default LaTeX uses smaller fractions in inline math just to avoid this. Jun 18, 2011 at 15:16