I want XeLaTeX/minted
to display all my mathematical characters from my .java source file.
More detailed: I file my programming homework in PDF documents in my university. I have been using LaTeX and listings
to import my source code. I do a lot of mathematical programming and use a lot of mathematical symbols in my comments. As listings doesn't support utf-8 characters I have slowly been switching to minted
+ XeLaTeX
. I keep common mathematical characters in a text file on my computer and copy them over to my .java files when commenting.
Let's consider following .tex file which I compile with $ xelatex -shell-escape minimal
.
\documentclass[a4paper,oneside]{article}
\usepackage{fontspec}
\usepackage{xunicode}
%\usepackage{unicode-math}
% default, bw, perldoc
\usepackage{minted}
\usemintedstyle{perldoc}
\begin{document}
Document symbols.
≠≤≥×·÷±∓√~≈≅⇔¬∧∨∀∃∅∈∉⊆⊂∪∩∆ℕℤℝℂ∞Σ∑∏∫π
\begin{minted}{java}
// Java code
// ≠≤≥×·÷±∓√~≈≅⇔¬∧∨∀∃∅∈∉⊆⊂∪∩∆ℕℤℝℂ∞Σ∑∏∫π
\end{minted}
\end{document}
It only displays the characters ×·÷±√~¬∞∑
(PDF). Why is that? And is there a solution?
Best Answer
The problem is that the font you're using, that is, Latin Modern, doesn't have the glyphs you want to be printed; you find in the log file something such as
The solution is to use a font that has these glyphs. The
~
has a special meaning in LaTeX, so either you input it as\string~
(not in theminted
context) or setbut this can break many constructs, so I don't recommend it.