Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX, tildes and verbatim mode

Tags:

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.

like image 560
Sam Avatar asked Mar 25 '09 15:03

Sam


People also ask

How do you write verbatim in LaTeX?

You can do this with the verbatim environment. That is, if you put the command \begin{verbatim} at the beginning of some text and \end{verbatim} at the end, then LATEX will reproduce the text in the output, in typewriter style, exactly as it is typed in the input.

How do you put a tilde over text in LaTeX?

You can write a tilde (sometimes called “twiddle”) in a LaTeX document by using \(\sim \) or $\sim$ (sim stands for similar). As an alternative you can use \texttildelow from thetextcomp package. If you want to write a letter with a tilde on top of the letter, you can write $\tilde{x}$ .

What does tilde in LaTeX do?

The tilde generates a nonbreaking space To create a tilde in the output, use \verb or the verbatim environment (or cheat by using \~{}, i.e., placing a tilde accent over a "blank" letter).


1 Answers

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.

like image 135
Jouni K. Seppänen Avatar answered Oct 16 '22 03:10

Jouni K. Seppänen