I have a listing to be used in verbatim (acutally Verbatim
) that uses unicode characters such as ∀, ∃, →, ∨. Using
\DeclareUnicodeCharacter{2203}{\ensuremath\exists}
they do appear in the listing, but obviously in the wrong font.
For → I got the desired result using
\usepackage{textcomp}
\DeclareUnicodeCharacter{2192}{\ifmmode\to\else\textrightarrow\fi}
but I do not see how to do it for ∃, ∀ and ∨.
MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\DeclareUnicodeCharacter{2192}{\ifmmode\to\else\textrightarrow\fi}
\DeclareUnicodeCharacter{2203}{\ensuremath\exists}
\begin{document}
\begin{verbatim}
Make this → ∃ look nice!
\end{verbatim}
\end{document}
I’d like to stick to latex (i.e. not xetex). I would prefer to stick to the default type writer font (Computer Modern Typewriter), but if it only works with a different font (such as DejaVu Sans Mono), then that would be ok as well.
Best Answer
You can use the
cmtex10
font, that has several math symbols and is compatible withcmtt
. The code below assumes you use the characters either in math mode or inVerbatim
.This is the font table, so you can extend the set in the same fashion.