The Basics of Fractions in LaTeX

If you're writing math in LaTeX, you'll eventually need fractions. The standard way is the \frac command. It takes two arguments: the numerator and the denominator. \frac{a}{b} produces a fraction with a = a and b = b. That's it. There's not a whole lot to explain about the syntax. The command renders inline like this: a/b, or as a displayed equation it looks proper with a horizontal bar between numerator and denominator.

How To Do Fraction In Latex

Write \frac{numerator}{denominator} wherever you need one. If you want it in display mode, wrap it in dollar signs or use $$...$$. So: $\frac{3}{4}$ gives you 3/4 inline.

$$\frac{3}{4}$$ gives you the same thing but centered on its own line with slightly larger formatting. It handles simple cases fine. It also handles nested fractions, though those get ugly fast. You can stack them like \frac{1}{1 + \frac{1}{x}}, but honestly just don't do that unless your document demands it. Nobody wants to read that. One thing people miss: if your numerator or denominator has more than one character, you must use braces. \frac{x+1}{2} works because the braces group the numerator. Without them, LaTeX only takes the next token and you get errors or wrong output.

Get the Full Details

How do you write a fraction(a/b) in LaTeX?
How do you write a fraction(a/b) in LaTeX?

I spent a good hour once debugging a PDF where my fraction was rendering as x + 1/2 instead of (x+1)/2. I'd forgotten the braces around the numerator. Classic. That's three years of experience I'm never getting back.

Size and Style Issues

Here's something most tutorials skip. When \frac appears inside another fraction or in math mode that's already cramped, the nested fractions shrink automatically but sometimes end up looking terrible. The horizontal bar gets too thin, the characters get too small to read comfortably. The workaround is \displaystyle. Put it before your fraction like this: $\displaystyle\frac{a}{b}$

This forces LaTeX to render the fraction at full size regardless of context. It won't look cramped anymore. The tradeoff is that it can push line heights around and make your document layout jittery if you use it too aggressively. Another option is the amsmath package. It gives you \dfrac which does roughly the same thing as \displaystyle\frac but without affecting the surrounding text flow as much. I prefer \dfrac when I need big fractions in inline math because it keeps the text baseline from jumping around. There's also \tfrac for a tighter, text-sized fraction. Useful when you have a fraction inside running text and \dfrac makes the line too tall.

How to Write Fractions in LaTeX | Underleaf
How to Write Fractions in LaTeX | Underleaf

Alternatives to \frac

Sometimes you don't actually need a horizontal bar. The / slash works for inline fractions if you're okay with linear notation. a/b is perfectly readable in most contexts and doesn't mess with line spacing at all. For more complex expressions like continued fractions or when you want to avoid the visual clutter of stacked fractions, \over from plain TeX is available but I wouldn't recommend it. It's not standard LaTeX and can cause compatibility headaches if anyone else ever compiles your document. The gensymb or siunitx packages give you fraction-like notation for units, but that's a different use case entirely. Don't mix them up.

Common Pitfalls

Misplaced braces is the number one error. Every fraction needs exactly two brace groups after it. \frac{3}{4} is correct. \frac{3/4} is not. \frac34 is definitely not going to work the way you want. Another issue: fractions in subscripts and superscripts. By default, LaTeX shrinks them, which is usually fine but can make them illegible in dense equations. Use \displaystyle inside subscripts if you need clarity, though honestly it's often better to just restructure the equation so the fraction isn't nested there in the first place. If you're working with large denominators or multi-line numerators, consider using the aligned environment from amsmath inside your fraction. It gives you explicit control over alignment and spacing without fighting LaTeX's auto-sizing.

\frac{\begin{aligned} ... \\ ... \end{aligned}}{...} That's messy to type but sometimes necessary. I've used it for derivations where the numerator had multiple lines. The alternative is restructuring the whole equation, which usually works better in practice. Fractions in LaTeX are straightforward once you get past the brace discipline. The real work comes when the layout fights you, and that's when knowing \displaystyle and \dfrac matters. Keep it simple, check your braces, and don't nest more than two levels deep unless you have a good reason.

How to create Fractions in LaTeX/Overleaf - YouTube
How to create Fractions in LaTeX/Overleaf - YouTube