/jatex

A library for writing LaTeX from within Java.

Primary LanguageJavaMIT LicenseMIT

Jatex

DOI Maven Central

Jatex is a Java library designed to programmatically write LaTeX files and run them. It is designed to allow generic LaTeX documents, but provide reasonable defaults for ease of use. Some of the supported features include:

  • pdflatex, lualatex (default), xetex, ...
  • biblatex support
  • tikz/pgfplots, including tikzexternalize
  • amsmath, including all types of equation environments, including starred environments
  • figures, including wrapfig
  • tables, including longtable
  • warns about incompatible packages (if metadata is correctly incorporated)

Example usage for pgfplots:

PgfPlots.contourOf(x, y, pdfvalues, Map.of("contour filled", "{number=20}"))
        .xlabel("$\\ell_{x}$")
        .ylabel("weight in kg")
        .clabel("$P(A|D)$")
        .exec("yourPathToSaveTo");

wherein x and yare 1D double arrays and pdfvalues is a 2D array of size [x.length][y.length]. This produces a pdf looking as follows:

example pgfplot

Furthermore, a convenience class for writing letters (via scrlttr2) is provided. Example usage:

KomaLetter.as("yourPathToSaveTo")
          .user(JohnDoe.defaults()) // fill in specifics for yourself
          .toName("Mr. Bob Doe")
          .cc("Jane Doe")
          .toStreet("Wendelsteinstraße 1")
          .toCity("D-12345 Entenhausen")
          .yourMail("1970-01-01")
          .subject("subject")
          .opening("Dear Testreader,")
          .write("This letter is not really a letter. I just test for example if the paragraph building works.",
                 "Let's see\\ldots")
          .closing("Mit freundlichen Grüßen,")
          .encl("Document1.pdf", "Document2.pdf")
          .exec();

producing

example KOMA letter

Installation

The artifact can be found at maven central:

<dependency>
    <groupId>eu.hoefel</groupId>
    <artifactId>jatex</artifactId>
    <version>1.3.4</version>
</dependency>

Requirements

Jatex is designed to work with Java 17+. It also needs a LaTeX distribution, like e.g. MikTeX.