Site icon texblog

Whitespace in math mode

There are a number of predefined commands to add whitespace in LaTeX math mode. These are summarized in the list below.

 

Example usage of medium space \:

Here, we use whitespace to separate symbols from regular text. Whitespace commands are available by default. Additional packages are necessary to produce natural number symbol and \text command.

\usepackage{amsmath, amsfonts}

$a\:\text{and}\:b \in \mathbb{N}$

 

List of whitespace commands in math mode
% thin space
\,
\thinspace

% negative thin space
\!

% medium space
\:

% large space
\;

% 0.5em space
\enspace

% 1em space
\quad

% 2em space
\qquad

% custom space
\hspace{3em}

% fill empty space
\hfill

 

Illustration of whitespace commands

\documentclass[11pt]{article}
\usepackage{xcolor}

\newcommand\rlArrow[1]{$\color{red}{abc \rightarrow} #1 \color{blue}{\leftarrow} abc$\\}

\begin{document}

\begin{tabular}{lll}
	\hline
	Name & Command & Example\\
	\hline
	default space & & \rlArrow{}\\
	thin space & \verb|\,| & \rlArrow{\,}\\
	thin neg. space & \verb|\!| & \rlArrow{\!}\\
	medium space & \verb|\:| & \rlArrow{\:}\\
	large space & \verb|\;| & \rlArrow{\;}\\
	0.5em space & \verb|\enspace| & \rlArrow{\enspace}\\
	1em space & \verb|\quad| & \rlArrow{\quad}\\
	2em space & \verb|\qquad| & \rlArrow{\qquad}\\
	custom space & \verb|\hspace{3em}| & \rlArrow{\hspace{3em}}\\
	fill empty space & \verb|\hfill| & $\color{red}{abc \rightarrow} \color{black}\cdots$\\
	\hline
\end{tabular}

\end{document}
Exit mobile version