[Tex/LaTex] Space after semicolon

math-modespacing

\documentclass{beamer}

\begin{document}
\begin{frame}{Mutual Information}
\begin{align}
I(X;Y)&=H\left( {X} \right) -H\left( {X\mid Y} \right)\\
I(X{;}Y)&=H\left( {X} \right) -H\left( {X\mid Y} \right)
\end{align}

\end{frame}

\end{document}

In my opinion, the second equation is right but I prefer to write the first. Is it possible automatically?

Best Answer

It's easy to do it; but of course this changes all spacing around the semicolon in math mode. I left the second row for comparison.

\documentclass{beamer}

% punctuation is type 6
\mathcode`;=\numexpr\mathcode`;-"6000

\begin{document}

\begin{frame}{Mutual Information}

\begin{align}
I(X;Y)&=H(X) - H(X\mid Y)\\
I(X{;}Y)&=H(X) - H(X\mid Y)
\end{align}

\end{frame}

\end{document}

Note that your usage of \left and \right is wrong: there's no need for them here; also bracing the inner expressions is redundant.

enter image description here

Related Question