\documentclass{article} %include lhs2TeX.fmt \setlength{\parindent}{0mm} \addtolength{\parskip}{0.25\baselineskip} \begin{document} \section{Basic features} \paragraph{Plain text} Text is just entered like text: \begin{verbatim} Text is just entered like text: \end{verbatim} \paragraph{Code} Code blocks: \begin{code} module Main where main = putStrLn ("Hi " ++ foo 2 ++ "!") \end{code} entered with: \begin{verbatim} \begin{code} module Main where main = putStrLn ("Hi " ++ foo 2 ++ "!") \end{code} \end{verbatim} \paragraph{Compilation to documentation} Compiled to produce documentation: \begin{verbatim} $ lhs2TeX --poly lhsexample.lhs > lhsexample.tex $ pdflatex lhsexample.tex \end{verbatim} \paragraph{Compilation to program} Compiled to produce code: \begin{verbatim} $ lhs2TeX --code lhsexample.lhs > Main.hs $ ghc --make Main.hs \end{verbatim} \section{`Luxury' features} \paragraph{Formatting} Code fragments are formatted according to formatting definitions, e.g. no formatting for @foo@ in the code block using @foo@: \begin{verbatim} \begin{code} foo x = bar 2 3 \end{code} \end{verbatim} results in \begin{code} foo x = bar x 3 \end{code} but with \begin{verbatim} %format foo = "\mathbf{foo}" \end{verbatim} it results in: %{ %format foo = "\mathbf{foo}" \begin{code} foo x = bar x 3 \end{code} %} \paragraph{Indentation} |>= 2| consecutive spaces are interpreted as starting a new column: \begin{verbatim} \begin{code} b 22 3 = 22 + 3 b x _ = x bar x y = show (b x y) \end{code} \end{verbatim} gives: \begin{code} b 22 3 = 22 + 3 b x _ = x bar x y = show (b x y) \end{code} \paragraph{Inlined formatting} Formatting and verbatim can be done during plain text, respectively by using vertical bars @|@ and at symbols |@|: \begin{itemize} \item \verb+|foo|+ gives |foo|. \item \verb+@foo@+ gives @foo@. \end{itemize} \section{And then...} ... there is the rest explained in the |lhs2TeX| documentation. \end{document}