Create LaTeX documents from within Julia, including image handling



Build Status Build Status Build Status

This package allows to construct LaTeX documents programmatically.


It is assumed that you have pdflatex installed. You can then install LaTeX.jl like this:


To be able to use code blocks with syntax highlighting, please install Pygments: easy_install -U Pygments.


using LaTeX

x = linspace(-6,6,100)
y = sin(x)./x

import Winston
w = Image([], 7, Winston.plot(x, y))

import Gadfly
g = Image(7, 7, Gadfly.plot(x = x, y = y))

# needs pygments to be installed
c = Code("""
type MyJuliaType

    Section("Results", {
        Section("Plots", Figure("Plot comparison",Tabular({w,g}))),
        Section("Code", c)

Available functions

content can always be either a single item or an array of items.

  • latex = report(content) assembles the LaTeX file
  • latex = document(content) gives more control over the look and feel of the document. See here for more.
  • openpdf(latex) compiles the LaTeX file and tries to open it
  • Section(title, content) creates a new section. A section is automatically translated to a Linux chapter, section or subsection according to its nesting
  • Figure(caption, content)
  • Table(caption content)
  • Tabular(content)
  • Code(content)
  • TOC() indicates a table of contents
  • Abstract(content) defines an abstract for the document
  • Image(height, width, Array or Winston.FramePlot or Gadfly.Plot), where the array can be either of size (m,n,1) or RGB (m,n,3), with the values in the range 0..1


To define a custom document, use the document function, in combination with the following declarations, some of which can be omitted:

  • DocumentClass("article", ["11pt", "letterpaper"]) declares the document class of the file. Settings are passed through a vector as the second parameter.
  • Title("A LaTeX Library for Julia") declares the title of the file.
  • Date(1999, 12, 31) declares the date of the file. Note that this is the same Date as in standard Julia.
  • Author("John Smith") declares the author of the file.

For example, the following is a minimal document:

    DocumentClass("article", ["11pt", "letterpaper"]),
    Date(2015, 11, 23),
    Title("A LaTeX Library for Julia"),
    Author("John Smith"),
    Section("Code", [Code("""# minimal example""")])])


  • make preamble configurable
  • adapt openpdf to linux
  • add tests

First Commit


Last Touched

5 days ago


5 commits

Used By: