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?
\setmainfont{Some font name}
that has all the needed symbols. On Stackoverflow its correctly displayed on my desktop, and the font-family isConsolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif
so one of them is having the correct glyphs – Alex Oct 18 '12 at 22:01\setmainfont{DejaVu Sans Mono}
and then all characters except ~ are displayed in the document - but NOT in the minted code. I don't care about that because I can use the $ math mode. I also tried setting other fonts for minted output:\begin{minted}[fontfamily=x]{java}
(where tt, courier and helvetica are pre-defined for minted) but none of those produced any more of the math symbols. Is it possible to use other fonts in the minted code? My editor uses Monospace in my Ubuntu but I got error when trying\setmainfont{Monospace}
. – pegasus Oct 22 '12 at 10:57\setmainfont{FreeSerif}
and\setmonofont{FreeMono}
I get all the symbols in both situations. You can obtain the tilde in normal text with\string~
. The font used should have the symbols. – egreg Nov 3 '12 at 14:07