[Tex/LaTex] Proper typewriter font for math symbols (∀, ∃, →), e.g. in verbatim environment

fontstypewriterunicode

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 with cmtt. The code below assumes you use the characters either in math mode or in Verbatim.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyvrb}
\usepackage{newunicodechar}

\DeclareFontFamily{U}{cmtex}{}
\DeclareFontShape{U}{cmtex}{m}{n}{
 <-> cmtex10
}{}
\newcommand{\cmtex}[1]{{%
  \usefont{U}{cmtex}{m}{n}\symbol{#1}%
}}

\newcommand{\ttexists}{\cmtex{"15}}
\newcommand{\ttforall}{\cmtex{"14}}
\newcommand{\ttrightarrow}{\cmtex{"19}}
\newcommand{\ttlor}{\cmtex{"1F}}
\newcommand{\ttland}{\cmtex{"04}}

\newunicodechar{∃}{\ifmmode\exists\else\ttexists\fi}
\newunicodechar{∀}{\ifmmode\forall\else\ttforall\fi}
\newunicodechar{→}{\ifmmode\expandafter\rightarrow\else\ttrightarrow\fi}
\newunicodechar{∨}{\ifmmode\lor\else\ttlor\fi}
\newunicodechar{∧}{\ifmmode\land\else\ttland\fi}

\begin{document}

$∃∀→∨∧$

\begin{Verbatim}
∃∀→∨∧
abcde
\end{Verbatim}

\end{document}

enter image description here

This is the font table, so you can extend the set in the same fashion.

enter image description here