[Haskell-cafe] LaTeX

tom tom at almostobsolete.net
Mon Jun 11 11:14:52 EDT 2007


I got this from the Literate Haskell page on the Emacs Wiki[1]:

\usepackage{listings}
\lstloadlanguages{Haskell}
\lstnewenvironment{code}
   {\lstset{}%
     \csname lst at SetFirstLabel\endcsname}
   {\csname lst at SaveFirstLabel\endcsname}
   \lstset{
     basicstyle=\small\ttfamily,
     flexiblecolumns=false,
     basewidth={0.5em,0.45em},
     literate={+}{{$+$}}1 {/}{{$/$}}1 {*}{{$*$}}1 {=}{{$=$}}1
              {>}{{$>$}}1 {<}{{$<$}}1 {\\}{{$\lambda$}}1
              {->}{{$\rightarrow$}}2 {>=}{{$\geq$}}2 {<-}{{$\leftarrow$}}2
              {<=}{{$\leq$}}2 {=>}{{$\Rightarrow$}}2
              {\ .}{{$\circ$}}2 {\ .\ }{{$\circ$}}2
              {>>}{{>>}}2 {>>=}{{>>=}}2
              {|}{{$\mid$}}1
   }

That replaces various strings (including ++) with their symbol
equivalents and generally makes things quite pretty.

Tom

[1]: http://haskell.org/hawiki/LiterateProgramming

On 6/8/07, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
> Does anybody know what the magical LaTeX command is to turn (say) "++"
> into two overprinted pluses? (As seems to be fashionable...)
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list