Basic Usage

The SnuggleEngine

To use SnuggleTeX, you first need to create a SnuggleEngine:

SnuggleEngine engine = new SnuggleEngine();

Once configured. an instance of a SnuggleEngine is thread-safe and can be used to perform as many conversions as you like. It houses a number of defaults, options, command and environment definitions that can be set if you want to perform a number of very similar conversion processes. See the API Docs  for more information.

Despite its heavy-weight name, creating and setting up a SnuggleEngine is not expensive so don’t worry about that!

The SnuggleSession

A SnuggleSession represents a single SnuggleTeX conversion "job", which typically consists of the following steps:

  1. Parse one or more SnuggleInputs.
  2. Generate one or more Outputs (either XML/DOM Outputs or Web Pages).
  3. (Check for any errors in the LaTeX reported by the above processes…)

You create a new SnuggleSession from your SnuggleEngine as follows:

SnuggleSession session = engine.createSession();

This creates a fresh job using the current default settings in your SnuggleEngine. You can then call methods described in Inputs, Error Reporting and Creating XML/DOM Outputs or Creating Web Pages to do whatever it is you want to do.

You can discard a SnuggleSession once it has done everything you need. Note that a SnuggleSession is not thread safe.

See the Examples for various examples of how everything comes together.