Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ComFreek/da714a427be7b174ea428f881dc91902 to your computer and use it in GitHub Desktop.
Save ComFreek/da714a427be7b174ea428f881dc91902 to your computer and use it in GitHub Desktop.
Make LaTeX colons have the spacing of \colon, e.g. for typing judgements.tex
\documentclass[]{article}
% Make `:` behave as if you typed `\colon`.
% In particular, this allows you to concisely write `t: A` for a typing assertion while still
% getting the correct spacing of `\colon`.
%
% source: <https://chat.stackexchange.com/transcript/message/56900862#56900862>
% author: Skillmon <https://tex.stackexchange.com/users/117050/skillmon>
\begingroup
\lccode`\~=`\:
\lowercase{\endgroup\def~}{\colon}
\AtBeginDocument{\mathcode`\:="8000 }
\begin{document}
% Both lines have the same spacing
$a\colon b$\par
$a: b$\par
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment