How to neatly space the equals sign when using probabilities?
It's straightforward to define a macro such as \newcommand\myeq{\mkern1.5mu{=}\mkern1.5mu}
-- choose the argument of \mkern
to suit your personal preferences -- and thus to rewrite your equation as
\Pr(A\myeq a) &= \Pr(B\myeq b \mid C\myeq c)
In the TeXbook (p. 174, near bottom of page), though, DEK suggests not reducing the whitespace around the =
symbols but, instead, adding more whitespace elsewhere in the full equation via judiciously-placed \,
directives:
\[ \Pr(\, A=a \,) = \Pr(\, B=b \mid C=c \,) \]
A full MWE:
\documentclass{article}
\newcommand\myeq{\mkern1.5mu{=}\mkern1.5mu}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\Pr(A=a) &= \Pr(B=b \mid C=c) \\ % original form
\Pr(A\myeq a) &= \Pr(B\myeq b \mid C\myeq c) \\ % less whitespace around "="
\Pr(\, A=a \,) &= \Pr(\, B=b \mid C=c \,) % *more* whitespace
\end{align*}
\end{document}
I turn my comment to an answer since I think it is an adequate solution, in particular in this situation, and it is simpler than the other approaches. I also find no flaw in its visual appearance. It also makes sense to me logically, since A=a
can be viewed as a compound label for an event, not necessarily as an equation. Even if it's an equation, it's just too tiny to be granted the same rights as other equations.
\documentclass{article}
\begin{document}
\[ \Pr(A{=}a) = \Pr(B{=}b \mid C{=}c) \]
\end{document}
This reduces by half the space around the equals sign in the argument to \Pr
; it also has the advantage of being able to set the size of the delimiters in an optional argument.
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiterX\PrArg[1]{(}{)}{%
\renewcommand\given{\Conditional{\delimsize}}%
\begingroup\lccode`~=`= \lowercase{\endgroup\let~}\reducedequals
\edef\equals{\mathchar\the\mathcode`= }%
\mathcode`="8000
#1%
}
\providecommand\given{}
\newcommand{\Conditional}[1]{%
\nonscript\;#1\vert\nonscript\;\mathopen{}%
}
\renewcommand{\Pr}{\operatorname{Pr}\PrArg}
\newcommand{\reducedequals}{%
\mskip-.5\thickmuskip
\equals
\mskip-.5\thickmuskip
\nobreak
}
\begin{document}
$\Pr{A=a} = \Pr{B=b \given C=c}$
$\Pr[\big]{A=\frac{1}{2}} = \Pr[\Big]{B=b \given C=\sqrt{\frac{a^{2^n}}{b}}}$
\end{document}