LaTeX, tildes and verbatim mode

latex

Following on from this question, I'm totally stumped on getting LaTeX to give me a tilde when I'm in verbatim mode. It has to be a tilde because it's the type of a function!

sig symm : (Board, [(Int, Int)]) ~> Bool

Standard methods for displaying a tilde are printed verbatim, of course..

Any suggestions?

An edit to clarify: Typing a ~ in verbatim mode gives an accent above a blank space. I'm after a tilde as it appears at the beginning of this sentence.

Best Answer

If there are some characters that do not occur in your input, you can use fancyvrb and its commandchars option to insert TeX commands within verbatim text:

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\newcommand{\mytilde}{$\sim$}
\begin{Verbatim}[commandchars=\\\{\}]
sig symm : (Board, [(Int, Int)]) \mytilde> Bool
\end{Verbatim}
\end{document}

See the documentation of fancyvrb for more.