Spacing
- Spaces are often ignored when typing KaTEX in either inline or display mode.
P( x ) = x^2 - x + 1
- To format spaces, we use escape characters and specific commands for that.
- For example, using
\,will allow us to space our characters byem space:
- For example, using
- Here’s an example of different spacing commands and their equivalent units.
| Command | Alternate Command | Width | Example | Output |
|---|---|---|---|---|
\, | \thinspace | a \,\, b | ||
\> or \: | \medspace | a \>\: b | ||
\; | \thickspace | a \;\; b | ||
\enspace | a \enspace b | |||
\quad | a \quad b | |||
\qquad | a \qquad b |
Negative Spacing
- Negative spacing allows you to remove spacing between two characters
a \negthinspace bdisplays as
| Command | Width | Example | Output |
|---|---|---|---|
\negthinspace | (a + b) \negthinspace (b + a) | ||
\negmedspace | (a + b) \negmedspace (b + a) | ||
\negthickspace | (a + b) \negthickspace (b + a) |
Custom Spacing
-
Aside from predefined spacing commands, KaTEX also supports custom spacing with KaTEX units using the command
\hspace{length}. -
a \hspace{10ex} b
-
The
lengthargument accepts any positive or negative spacing values, or in terms of other units such as the CSS em, or CSS ex.- You may want to see here for more precise units that are natively supported by KaTEX.
Text
- If we want to display text in math mode, we would use the
\text{}command.- Anything displayed inside the
\textcommand will be displayed as normal text.
- Anything displayed inside the
\frac{1}{(ax +b)(cx + d)} = \frac{A}{ax + b} + \frac{B}{cx + d} \qquad \text{Partial Fraction Decomposition}