1 About HaTeX
HaTeX is a package wich lets you to write LaTeX code from Haskell.
HaTeX page: http://ddiaz.asofilak.es/packages/HaTeX
Here a link to the package in Hackage: http://hackage.haskell.org/package/HaTeX
2 How to use HaTeX
If you know how to use LaTeX, you will easily understand how to use HaTeX. Otherwise, you will need to read well the documentation.
A first step may be to know the LaTeX file structure.
3 LaTeX file structure
A LaTeX file has two parts:
- A preamble where you define general settings (document class, page style, use of extern packages, ...) of your document.
- The document's content.
4 A simple example
We're going to write an example, the best for understanding.
documentclassis used for determining if our document is an
authoris used for specify document's authory.
titlefor document's title.
Then, with this three functions, we will define a preamble in the
LaTeX is a writer monad that concatenates the text generated by the programmer.
Usually, the text is generated simply writing it, or by functions.
example = do documentclass  article author "Daniel Diaz" title "Example"
The first argument of
documentclass is used for change certain settings of the class.
For example, you can set the document's main font size to 12pt, writing:
documentclass [pt 12] article
Or set paper size to A4:
documentclass [pt 12,a4paper] article
Now, I will write a content:
hello = "Hello, world!"
To insert the content into the document, we have the function
document. Completing our first example:
example = do documentclass  article author "Daniel Diaz" title "Example" document $ do maketitle hello
maketitle doesn't work in some document classes.
At first glance, it seems that
document receive a
String as argument.
Really, they require a
LaTeX is the type that represents texts in HaTeX.
So, I recommend to use Overloaded Strings
5 Enriching your text
There are numerous functions to enrich your document. One feature is change your font format. For example, in:
texttt sets as monospaced font his content. Or composing:
texttt $ textbf "Hello!"
textbf sets as bold font the monospaced font of
If you only want
"ll" with bold format:
texttt $ do "He" textbf "ll" "o!"
Applying the function to only part of the text, we achieve modify just that part.
6 Performing monadic computations
All computations in HaTeX take place in the
LaTeXT monadic transformer.
To includes a monadic computation, use
gtime = do t <- mlx getClockTime ...
IO computations are predefined in Text.LaTeX.IO.
7 Adding sections
Commands to adding sections are included in Text.LaTeX.Commands. Examples are
If you want sections without number, use
section_. This also avoid showing the section into the table of contents.
If you want title of section to be different in the context than in the table of contents, use
8 HaTeX Support
You can report any bug or suggestion at: