(click anywhere to close)

# [LaTeX] Display Styles & Scripts

category: Writing | course: LaTeX Math | difficulty:

In the first chapter we saw two different types of math environments: in line with the text (inline), or on its own line(s) (block). Besides changing the overall position, this also changes the way certain math symbols are displayed. The most prominent differences you’ll notice are:

• Some math operators, such as fractions and square roots, are displayed smaller in inline environments.
• Subscript and superscript components are displayed next to their element in inline environments, and underneath them in block environments. In other words, in block environments complex operators (such as sums and integrals) are promoted to a larger size.

These changes are made to make sure inline environments don’t get too big – an environment with large height would go through the text above and below it, making everything unreadable. Sometimes, however, you don’t want this to be decided for you, which is why you can set display styles.

## Display Styles

Four display style commands are available:

 Command Description \displaystyle Changes whatever comes after it to block environment style \textstyle Changes whatever comes after it to inline environment style \scriptstyle Same as the previous style, but smaller \scriptscriptstyle Same as the previous style, but even smaller

Just as the font size commands do with regular text, these influence everything after it, until a new command comes along.

This fraction $\frac{5}{4}$ is some regular inline math.

This fraction $\displaystyle \frac{5}{4}$ is big and bold!

This looks odd and small:
$$a^2 + \scriptscriptstyle b^2 = \scriptstyle c^2$$

An alternative is to promise LaTeX that everything is going to be fine, and that it can just ignore the extra height of some equations. This is done by placing the equation within the \smash{eq} command. If you dare to do this, it’s up to you to make sure the equations don’t interfere with the text.

## Subscripts & Superscripts

The reason these display styles are so important, is because subscripts and superscripts used very often in mathematical formulas. Typically, subscripts represent indices, while superscripts represent exponents, but there are many more moments to use them. Luckily, their syntax is easy.

For subscripts, use _{text}. For superscripts, use ^{text}. If something has both sub and super scripts, these can just be used right after each other, any order you like.

It's trivial to see that $a_1 + \ldots + a_n = b^{2n}$.

If text is only a single character, you can leave out the braces.

Sub and superscripts may also have sub and superscripts themselves – you can stack as much of them as you like, although it’s a questionable practice.

Alternatively, while not really a subscript, the A \atop B command can be used to place B exactly underneath A.

It's trivial to see that $a \atop b$ $= \binom{a}{b}$

## Font Size

The display style commands already provided ways to shrink or enlarge text size, but they can only be used inside of math environment, and don’t support many sizes. If you want to change the size of one (or multiple) complete equations, you can simply use all the font size commands for regular text (\tiny, \small, …). Note that you have to place these outside of the math environment – inside, they won’t work.

\tiny $\sqrt{x^2 + y^2}$
\large $\sqrt{x^2 + y^2}$

## Alternating Text and Math

There will be times you want to use some regular text within a math environment, and can’t quickly jump in and out of the environment to do so. For example, in the middle of an array environment, you can’t just break out of math mode to place some text. The \mbox{text} and \fbox{text} commands from the basic course provide this, but don’t support line breaks. Therefore, the more general \text{text} command is preferred.

Another difficulty often encountered using math and text next to each other, is that you’ve lost track of whether you’re inside a math environment at a certain point or not. For example, you could have started and closed an inline math environment with the dollar sign five times, but forget one somewhere in the middle, and now everything is typeset the wrong way. The \ensuremath{equation} command ensures that whatever’s inside is in math mode, no matter what happens around it.

$a = b \text{ if and only if } b = a$ \par
\ensuremath{\sqrt{x^2 + y^2}}

## Font Style

Besides the regular math letters, three other notations are available: bolded, calligraphic and script letters. For example, a bolded R is the symbol for the set of all real numbers, and a calligraphic A is often used for symmetric matrices.

To use these, the amsfonts package needs to be included. For calligraphic, you need the mathsfrs package.

The commands to use are: \mathbb{text}, \mathcal{text} and \mathscr{text}.

There are two alternative styles for bolded and calligraphic letters, \mathds{text} and \mathfrak{text} (fraktur letters). For these, however, you need to include the dsfont package as well.

CONTINUE WITH THIS COURSE
Do you like my tutorials?
To keep this site running, donate some motivational food!
Crisps
(€2.00)
Chocolate Milk
(€3.50)
Pizza
(€5.00)