LaTeX Breaking Spaces, Non-Breaking Spaces, and Math Spacing Commands

Nov. 12, 2025 in Buffalo, United States • Updated Nov. 15, 2025

In LaTeX, I always use a space character to add a blank space between the text, and sometimes commands \ , \quad, and \qquad to add some spacing between contents in math environments. Technically, all of them are breaking spaces1:

image-20251112221729896

which means that LaTeX can make a new line there if needed. In addition to them, there are some non-breaking spaces (sometimes called ties), where making a new line is not allowable, such as: \thinspace (\,), \negthinspace (\!, a kind of negative distance), \enspace, and \nobreakspace (~, which is the most classic tie):

image-20251112221714594

Then, let’s test these commands one by one:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
\documentclass[12pt]{article}
\usepackage{forloop}
\usepackage{showframe}
\usepackage{xcolor}

\newcounter{x}

\newcommand{\helpertestblank}[1]{%
	\forloop{x}{0}{\value{x} < 30}{123#1}%
}

\begin{document}
\thispagestyle{empty}

% =====Breaking spaces====
\noindent{\color{red}\verb*| |}
\helpertestblank{ }

\noindent {\color{red}\verb*|\quad|}
\helpertestblank{\quad}

\noindent {\color{red}\verb*|\qquad|}
\helpertestblank{\qquad}

\noindent {\color{red} \verb*|\enskip|}
\helpertestblank{\enskip}

\noindent {\color{red}\verb*|\ |}
\helpertestblank{\ }

% ========================

% =====Non-breaking spaces====
\noindent {\color{red}\verb*|\thinspace|}
\helpertestblank{\thinspace}

\noindent {\color{red}\verb*|\,|}
\helpertestblank{\,}

\noindent {\color{red}\verb*|\negthinspace|}
\helpertestblank{\negthinspace}

\noindent {\color{red}\verb*|\!|}
\helpertestblank{\!}

\noindent {\color{red}\verb*|\enspace|}
\helpertestblank{\enspace}

\noindent {\color{red}\verb*|\nobreakspace|}
\helpertestblank{\nobreakspace}

\noindent {\color{red}\verb*|~|}
\helpertestblank{~}
% ========================

\end{document}

png-1


Above non-breaking spaces are useful in some cases, improving our writing details and making article look more professional, such as1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
\documentclass{article}
\usepackage{amsmath}

\begin{document}

Question~1

Donald~E. Knuth % In the first name and middle initial

Mr.~Knuth

function~$f(x)$

1,~2, and~3
\end{document}

image-20251114195252018

And among which, command \! can be used to generate a negative distance, and is frequently used in math environments, here are some examples1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator\dif{d\!} % For differential symbols

\begin{document}

\renewcommand{\arraystretch}{2}
\begin{tabular}{ll}
	With adjustment by \verb*|\!| & Without adjustment\\
	$ \int_0^1 f(t) \dif t
	= \iint_D g(x,y) \dif x \dif y $ & $ \int_0^1 f(t) \dif t
	= \iint_D g(x,y) \mathrm{d} x \mathrm{d} y $\\
	$ x^2 \! / 2 $ & $ x^2 / 2 $\\
	$ |\!{\gets} 5 {\to}\!| $ & $| {\gets} 5 {\to}|$\\
	$ A^{\!T} $ & $ A^T $ 
\end{tabular}

\end{document}

image-20251114200227768

Honestly, I totally didn’t notice these details before!!!

In above cases, note how we type a differential symbol:

1
2
3
4
5
\usepackage{amsmath}
\DeclareMathOperator\dif{d\!} % For differential symbols
% ...
$ \int_0^1 f(t) \dif t
	= \iint_D g(x,y) \dif x \dif y $

A modified \dif command is declared in the preamble, which preserves the spacing before the differential symbol and simultaneously shrink the spacing after that1. It’s much more elegant than the way \mathrm{d} I always used before!!!


Besides, there are also three spacing commands that can be used in math environments, i.e., \:, \>, and \;1:

image-20251113154513028

such as:

1
2
3
4
5
6
7
8
9
10
\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
aa\:a\>a\;a
\]

\end{document}

image-20251114201527886

In addition, we can use \setlength command to specify the spacing value of above math spacing commands1:

  • \thinmuskip for thin-space command \, and \! (default 3mu)
  • \medmuskip for medium-space command \: and \> (default 4mu plus 2mu minus 4mu)
  • \thickmuskip for thick-space command \; (default 5mu plus 5 mu)

For example,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
aa\,a\!a\:a\>a\;a
\]

\setlength{\thinmuskip}{7mu}
\setlength{\medmuskip}{19mu plus 2mu minus 4mu}
\setlength{\thickmuskip}{23mu plus 5 mu}

\[
aa\,a\!a\:a\>a\;a
\]

\end{document}

image-20251114203132870


References

  1. LaTeX入门, 刘海洋编著, p. 57, p. 86, p. 248, p. 279, p. 282. ˄ ˄2 ˄3 ˄4 ˄5 ˄6