[Tex/LaTex] Best unicode font to work with minted in xelatex/lualatex

mintedxetex

I have a bunch of unicode heavy (Julia) code that I want to plot with minted and am having trouble getting the unicode to display. For example, take the following code

f(x) = x.^2 + π
const ⊗ = kron
const Σ = sum
# Calculate Σ_{j=1}^5 j^2
Σ([j^2 for j ∈ 1:5])

Now, put this in a xelatex file

% !TEX engine = xelatex
\documentclass[12pt]{article}
\usepackage[letterpaper]{geometry}
\usepackage{fontspec,unicode-math}
\usepackage{xunicode}
\setmonofont{Consolas} %Might be better ones?
\usepackage{minted}
\begin{document}
\begin{minted}{julia}
f(x) = x.^2 + π
const ⊗ = kron
const Σ = sum # Although `sum` may be just as good in the code.
# Calculate Σ_{j=1}^5 j^2
Σ([j^2 for j ∈ 1:5])
\end{minted}
\end{document}

If you compile this, you will see that the $\pi$ and $\Sigma$ work fine, but the \odot and $\in$ do not. Is this something that I need to pick a better monofont for? Do I need other packages? Etc.

Best Answer

You can fill in the gaps by making the characters active with a suitable definition

enter image description here

% !TEX engine = xelatex
\documentclass[12pt]{article}
\usepackage[letterpaper]{geometry}
\usepackage{fontspec,unicode-math}
\usepackage{newunicodechar}
\newunicodechar{∈}{\makebox[\fontcharwd\font`a]{$\in$}}
\newunicodechar{⊗}{\makebox[\fontcharwd\font`a]{$\otimes$}}
\setmonofont{Consolas} %Might be better ones?
\usepackage{minted}
\begin{document}
\begin{minted}{julia}
f(x) = x.^2 + π
const ⊗ = kron
const Σ = sum # Although `sum` may be just as good in the code.
# Calculate Σ_{j=1}^5 j^2
Σ([j^2 for j ∈ 1:5])
\end{minted}
\end{document}
Related Question