Code Monkey home page Code Monkey logo

latex.jl's Introduction

LaTeX

Build Status Build Status Build Status

This package allows to construct LaTeX documents programmatically.

Installation

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

Pkg.add("LaTeX")

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

Example

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
    a::Array{Int}
end
""")

openpdf(report(
    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

Advanced

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:

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

Todos

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

latex.jl's People

Contributors

rened avatar totalverb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.