Generate PDF-Latex Add On

This add-on generates a latex file for a specified topic, and/or the PDF output of pdflatex processing this latex file. The goal is to provide PDF versions of TWiki topics with nicely rendered mathematics, using a latex document preparation environment installed on the TWiki server.

The goal of this package development is to provide a mechanism for groups to edit and produce latex documents suitable for publication submission. The use of this package on a TWiki installation provides the following advantages:

there is no need for each user to install a latex environment themselves,

one can leverage the revision control (and diff rendering) provided by TWiki,

document templates, in the form of latex style files, required by publishers or conference organizers can be easily employed.

Usage

This package provides a new cgi script genpdflatex.

The first call to this script produces a form through which latex/pdflatex file generation options can be set, (e.g. single or dual columns, draft settings, latex document style, etc.)

subsequent calls to the cgi script from this form will produce either a raw latex file or the associated PDF file.

Startup Form

This add on uses an intermediate form to declare the latex/pdflatex rendering options, including documentclass to be used, single or double column, etc... A default form is provided with the script. A custom form can be used by declaring GENPDFLATEX_OPTIONSPAGE somewhere within the twiki or web preferences (or in the GenPDFLatexPlugin topic). If the following strings appear in the form, $web, $topic, $style, and $packages, these strings will be respectively replaced by %WEB%, %TOPIC%, and the option arguments described below.

Topic Syntax

The following TWiki topic syntax commands are provided through the included
GenPDFLatexPlugin:

The tag %PDFLATEXLINK{options}% will render as a link to the genpdflatex script. The available options are

In each case, content in the [tex] region will only appear in the PDF/Latex rendered file, and content in the [html] region will only appear in HTML renderings (i.e. a standard TWiki view).

Most notably, this is useful for declaring the titlepage in the latex rendering. This conditional allows one to use, for example, a professional name in the latex file and a TWiki username in the HTML topic rendering.

genpdflatex script parameters

The following html2latex parameters are available for passing latex options to genpdflatex:

as user root or nobody, run texhash /home/nobody/texmf to create the ls-R latex database file for the /home/nobody/texmf/ tree.

Setup the add on

Download the ZIP file from the Add-on Home (see below) Note: versions 2.0 and above are compatible only with TWiki 4.x.x. If you are running an earlier version of TWiki, (i.e. Cairo) download v1.4 instead.

replace view with genpdflatex in the url, and reload the page.(At this point, you should see the GenPDFLatex form)

select file generation options

press the 'Produce PDF/Latex' button and view the returned .tex/.pdf file.

Package particulars

To convert the topic HTML code generated by twiki into a latex source file, this add-on uses a modified version of HTML::Latex from CPAN, renamed HTML::LatexLMP and included with the html2latexLMP package attached to this topic. The modifications are minor, providing two new HTML tag handlers (for 'font' and 'a') and changes to the default HTML tag to Latex mark-up mapping configuration.

Image sizing

The relative size and placeement of images in HTML doesn't not generally translate well to latex documents. Thus, with rev 1.4 of html2latexLMP, a few hooks were added to allow greater control of the image rendering in the latex document. Standard html2latex provides an image scale parameter. The LMP version allows two new attributes, texwidth and texheight, to be declared in the html img tag. For example, a standard HTML tag for the attached screen shot image would read:

The latex preamble

The latex preamble generated by the LatexModePlugin during HTML rendering is included in the latex/pdf file generated by this add-on.

Color in the latex/pdf output is possible, with a few caveats. First, the rendered color is currently drawn from HTML <font> tags, not the LatexModePlugin option or cascading style sheets. This may seem counterintuitive, but bear with us. The LatexModePlugin color option was introduced to enable rendered mathematics images with font-color consistent with normal font color declarations. It is assumed that any color option specified in a %BEGINLATEXMODE{}% TWiki tag is embedded in a font-color block. Second, the \usepackage{color} call needs to be in the latex preamble. This will happen automatically if using colors defined by the LatexModePlugin.

This code is still very much under development. All syntax calls,
e.g. equations, figures, and tables, in the LatexModePlugin are supported.
The TWiki:Plugins.BibtexPlugin can be used for bibliography support.