Best unicode font to work with minted in xelatex/lualatex

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}

If you want to avoid having to define characters, you could switch to a font that has those characters. The GNU FreeMono font is a good one since it is free and has over 4,000 characters. It has a much larger character set than most monospace fonts, including the previously missing math characters you needed. You can download it here: https://www.gnu.org/software/freefont/

This is an updated example using the FreeMono font that displays the missing characters.

% !TEX engine = xelatex
\documentclass[12pt]{article}
\usepackage[letterpaper]{geometry}
\usepackage{fontspec,unicode-math}
\usepackage{xunicode}
\setmonofont{FreeMono} %switched to FreeMono
\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}

FreeMono output

Tags:

Xetex

Minted