# Inserting uppercase greek directly into mathmode with fontspec

This solution for inserting lowercase greek directly in mathmode works just fine for me.

However I have not yet been able to use the same trick for uppercase letters.

What went wrong?

Here is a working example

\documentclass[a4paper]{article}
\usepackage{fontspec}

\mathcodeω=\omega
\mathcodeΩ=\Omega

\begin{document}

$$\omega=ω$$ %Just fine!

$$\Omega=Ω$$ %Will not work!

\end{document}

Do the assignments at begin document:

\documentclass[a4paper]{article}
\usepackage{fontspec}

\AtBeginDocument{%
\mathcodeω=\omega
\mathcodeΩ=\Omega
}

\begin{document}

$\omega=ω,\quad \Omega=Ω$

\end{document}

By the way, with unicode-math you need no special setup.

\documentclass[a4paper]{article}
\usepackage{unicode-math}

\begin{document}

$\omega=ω,\quad \Omega=Ω$

\end{document}