latex-formulae-image-0.1.0.1: A library for rendering LaTeX formulae as images using an actual LaTeX installation

Safe HaskellNone
LanguageHaskell2010

Image.LaTeX.Render

Contents

Synopsis

Rendering Formulas

imageForFormula :: EnvironmentOptions -> FormulaOptions -> Formula -> IO (Either RenderError (Baseline, DynamicImage)) Source

Convert a formula into a JuicyPixels DynamicImage, also detecting where the typesetting baseline of the image is.

type Formula = String Source

A LaTeX formula, e.g x=frac{-bpmsqrt{b^2-4ac}}{2a} for the quadratic formula. Do not include any $s to denote the environment, just specify the environment in the FormulaOptions instead.

type Baseline = Int Source

Number of pixels from the bottom of the image to the typesetting baseline. Useful for setting your formulae inline with text.

Errors

data RenderError Source

This type contains all possible errors than can happen while rendering an equation. It includes all IO errors that can happen as well as more specific errors.

Constructors

ImageIsEmpty

The equation produced an empty image

CannotDetectBaseline

The baseline marker could not be found

LaTeXFailure String

latex returned a nonzero error code

DVIPSFailure String

dvips returned a nonzero error code

IMConvertFailure String

convert returned a nonzero error code

IOException IOException

An IOException occurred while managing the temporary files used to convert the equation

ImageReadError String

The PNG image from ImageMagick could not be read by JuicyPixels.

Options

Environment Options

data EnvironmentOptions Source

Constructors

EnvironmentOptions 

Fields

latexCommand :: String

Command to use for latex, default is latex

dvipsCommand :: String

Command to use for dvips, default is dvips

imageMagickCommand :: String

Command to use for ImageMagick's convert, default is convert

latexArgs :: [String]

Any additional arguments for latex

dvipsArgs :: [String]

Any additional arguments for dvips

imageMagickArgs :: [String]

Any additional arguments for convert

tempDir :: TempDirectoryHandling

How to handle temporary files

tempFileBaseName :: String

The base name to use for the temporary files.

defaultEnv :: EnvironmentOptions Source

Sensible defaults for system environments. Works if dvips, convert, and latex are recent enough and in your $PATH.

data TempDirectoryHandling Source

Constructors

UseSystemTempDir

A temporary directory with a name based on the given template will be created in the system temporary files location

Fields

nameTemplate :: String
 
UseCurrentDir

A temporary directory with a name based on the given template will be created in the current directory

Fields

nameTemplate :: String
 

Formula Options

data FormulaOptions Source

Constructors

FormulaOptions 

Fields

preamble :: String

LaTeX preamble to use. Put your usepackage commands here.@ commands here.

environment :: String

LaTeX environment in which the equation will be typeset, usually math or displaymath

dpi :: Int

DPI for the image to be rendered at. ~200 is good for retina displays, ~100 works OK for non-retina displays.

displaymath :: FormulaOptions Source

Use the amsmath package, the displaymath environment, and 200dpi.

math :: FormulaOptions Source

Use the amsmath package, the math environment, and 200dpi.