Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a LaTeX table to display results


This recipe will create a table in LaTeX programmatically to facilitate document creation. We can create a PDF out of the LaTeX code and share it as we please.

Getting Ready

Install HaTeX, the Haskell LaTeX library, from cabal:

$ cabal install LaTeX

How to do it…

Create a file named Main.hs and follow these steps:

  1. Import the libraries as follows:

    {-# LANGUAGE OverloadedStrings #-}
    import Text.LaTeX
    import Text.LaTeX.Base.Class
    import Text.LaTeX.Base.Syntax
    import qualified Data.Map as M
  2. Save a LaTeX file with our specifications as follows:

    main :: IO ()
    main = execLaTeXT myDoc >>= renderFile "output.tex"
  3. Define the document, which is split up into a preamble and a body, as follows:

    myDoc :: Monad m => LaTeXT_ m
    
    myDoc = do
      thePreamble
      document theBody
  4. The preamble contains author data, title, and formatting options, among other things, as presented in the following code:

    thePreamble :: Monad m => LaTeXT_ m
    
    thePreamble = do
      documentclass ...