# The OpenJade TeX backend

### Created by David Megginson, Sebastian Rahtz and Kathleen Marszalek
Sponsored by Novare International Corp.

## Introduction

The TeX backend was initially written by David Megginson, but is now maintained by Sebastian Rahtz. In a development sponsored by Novare International (to whom many thanks!), Kathleen Marszalek drastically improved the table support.

The job of the backend is to map DSSSL flow-objects into generic TeX macro calls. Atomic flow objects appear as single `\insertOBJECT{}` macro calls, while non-atomic flow objects appear as nested pairs of `\OBJECT{}`..`\endOBJECT{}` macro calls.

The `\insertOBJECT` and `\OBJECT` calls receive a single argument, which is a list of definitions for inherited and non-inherited characteristics (see below). For example, the following DSSSL handler:

    (element P
      (make paragraph
    	start-indent: 6pt))

would generate the following TeX calls:

    \startPar{\def\StartIndent{6pt}}%
    CONTENTS
    \endPar{}

It is important to note that any characters with values >255 will appear as `\Character{value}` macro calls ie.

    \Character{1024}

In addition to nearly all of the flow-object classes currently supported by OpenJade, the TeX backend generates two pseudo flow-object macro calls:

- `\FOT{version}`
- `\endFOT{}`

These are guaranteed to appear at the very beginning and very end of the .tex output file, and give your macros a chance to grab control at both points. The argument to `\FOT` is the version of the TeX markup generated by the OpenJade backend (currently 2). Macro packages should check this for compatibility.

The output `.tex` file is not ready to be passed directly through TeX or LaTeX -- instead, it is necessary to have TeX macro definitions for all of the flow-object macros, and to set default values for the characteristics. The macros can use of TeX primitives, plain TeX, LaTeX, or any other format which is convenient.

A LaTeX macro package for use with the output of this backend has been developed by Sebastian Rahtz. The current stable release can be found on CTAN in macros/jadetex; experimental releases will be placed at http://www.tug.org/applications/jadetex/ at intervals.

## Characteristics

The SETTINGS argument to the flow-object macros will contain a series of \def statements for both inherited and non-inherited characteristics. These will appear only when the characteristic's value differs from the standard default (in the case of non-inherited characteristics) or from the current value (in the case of inherited characteristics). Since these statements appear as an argument, they will not take effect until you reference the parameter explicitly.

### Inherited Characteristics

The characteristics in the following table are inherited -- you should set these to their default values only once, at the beginning of the parse (but they should always revert to their previous values after a flow-object has finished):

Characteristic | Default Value | DSSSL Equivalent
--- | --- | ---
`\AsisWrapIndent` | `0 [#f]` |
`\BackgroundColor` | `0 [#f]` |
`\BackgroundLayer` | `-1` |
`\BackgroundTile` | `0 [#f]` |
`\BorderAlignment` | `center` |
`\BorderOmitAtBreak` | `0 [#f]` |
`\BorderPresent` | `1 [true]` |
`\BorderPriority` | `0` |
`\BottomMargin` | `0pt` |
`\BoxBorderAlignment` | `outside` |
`\BoxCornerRadius` | `0pt` | [note]
`\BoxOpenEnd` | `0 [#f]` |
`\BoxSizeAfter` | `4pt` |
`\BoxSizeBefore` | `8pt` |
`\BoxType` | `border` |
`\CellAfterColumnMargin` | `0pt` |
`\CellAfterRowMargin` | `0pt` |
`\CellBackground` | `0 [#f]` |
`\CellBeforeColumnMargin` | `0pt` |
`\CellBeforeRowMargin` | `0pt` |
`\CellCrossed` | `0 [#f]` |
`\CellRowAlignment` | `start` |
`\Color` | current gray |
`\Country` | `0 [#f]` |
`\DisplayAlignment` | `start` |
`\EndIndent` | `0pt` |
`\EndMargin` | `0pt` |
`\ExpandTabs` | `8` |
`\FieldAlign` | `start` |
`\FieldWidth` | `0pt` |
`\FillingDirection` | `top-to-bottom` |
`\FirstLineStartIndent` | `0pt` |
`\FloatOutLineNumbers` | `0 [#f]` |
`\FloatOutMarginalia` | `0 [#f]` |
`\FloatOutSidelines` | `0 [#f]` |
`\FontFamilyName` | `iso-serif` |
`\FontName` | `0 [#f]` |
`\FontPosture` | `upright` |
`\FontProportionateWidth` | `medium` |
`\FontSize` | `10pt` |
`\FontStructure` | `solid` |
`\FontWeight` | `medium` |
`\FooterMargin` | `0pt` |
`\GlyphAlignmentMode` | `font` |
`\GlyphReorderMethod` | `??` |
`\GlyphSubstMethod` | `??` |
`\HangingPunct` | `0 [#f]` |
`\HeaderMargin` | `0pt` |
`\Hyphenate` | `??` |
`\HyphenationKeep` | `0 [#f]` |
`\HyphenationLadderCount` | `0 [#f]` |
`\HyphenationMethod` | `??` |
`\HyphenationPushCharCount` | `2` |
`\HyphenationRemainCharCount` | `2` |
`\IgnoreRecordEnd` | `0 [#f]` |
`\ImplicitBidiMethod` | `0 [#f]` |
`\InhibitLineBreaks` | `0 [#f]` |
`\InputWhitespaceTreatment` | `??` |
`\JustifyGlyphSpaceMaxAdd` | `0pt` |
`\JustifyGlyphSpaceMaxRemove` | `0pt` |
`\Kern` | `??` |
`\KernMode` | `??` |
`\Language` | `0 [#f]` |
`\LastLineEndIndent` | `0pt` |
`\LastLineJustifyLimit` | `0pt` |
`\LastLineQuadding` | `relative` |
`\Layer` | `0` |
`\LeftMargin` | `0pt` |
`\Ligature` | `??` |
`\LineBreakingMethod` | `0 [#f]` |
`\LineCap` | `butt` |
`\LineCompositionMethod` | `0 [#f]` |
`\LineJoin` | `miter` |
`\LineNumberSep` | `??` |
`\LineNumberSide` | `??` |
`\LineRepeat` | `1` |
`\LineSep` | `1pt` |
`\LineSpacing` | `12pt` |
`\LineThickness` | `1pt` |
`\Lines` | `wrap` |
`\MarginaliaKeepWithPrevious` | `0 [#f]` |
`\MarginaliaSep` | `0pt` |
`\MarginaliaSide` | `start` |
`\MathDisplayMode` | `??` |
`\MinLeaderRepeat` | `1` |
`\NColumnsSpanned` | `1` |
`\NRowsSpanned` | `1` |
`\NumberedLines` | `1 [true]` |
`\OrphanCount` | `2` |
`\PageHeight` | sysdep |
`\PageWidth` | sysdep |
`\PositionPointShift` | `0pt` |
`\PrincipalModeSimultaneous` | `0 [#f]` |
`\Quadding` | `start` |
`\RightMargin` | `0pt` |
`\ScoreSpaces` | `1 [true]` |
`\SidelineSep` | required |
`\SidelineSide` | required |
`\Span` | `1` |
`\SpanWeak` | `0 [#f]` |
`\StartIndent` | `0pt` |
`\StartMargin` | `0pt` |
`\TableAutoWidthMethod` | `0 [#f]` |
`\TableCornerRadius` | `0pt` | [note]
`\TablePartOmitMiddleFooter` | `0 [#f]` |
`\TablePartOmitMiddleHeader` | `0 [#f]` |
`\TopMargin` | `0pt` |
`\WidowCount` | `2` |
`\WritingMode` | `left-to-right` |

#### Notes

1. `\BoxCornerRadius` combines the `box-corner-rounded` and `box-corner-radius` characteristics (its value is `0pt` if box-corner-rounded is `#f`).
2. `\TableCornerRadius` combines the `table-corner-rounded` and `table-corner-radius` characteristics (its value is `0pt` if `table-corner-rounded` is `#f`).

### Non-Inherited Characteristics

The characteristics in the following table are not inherited -- you should set these to their default values at the beginning of every relevant flow-object, before evaluating the SETTINGS argument:

Characteristic | Default Value | DSSSL Equivalent
--- | --- | ---
`\AlignLeader` | `1 [true]` |
`\BreakAfter` | `0 [#f]` |
`\BreakAfterPriority` | `0` |
`\BreakBefore` | `0 [#f]` |
`\BreakBeforePriority` | `0` |
`\Ch` | no default |
`\CoalesceId` | `0 [#f]` |
`\ColumnIndex` | contextual | `column-number [??]`
`\EntitySystemId` | required |
`\EscapementDirection` |  | `writing-mode`
`\GlyphId` | no default |
`\IdrefAddress` | `??` |
`\IsDisplay` | `0 [#f]` |
`\IsDropAfterLineBreak` | unspecified |
`\IsDropUnlessBeforeLineBreak` | unspecified |
`\IsPunct` | unspecified |
`\IsInputTab` | unspecified |
`\IsInputWhiteSpace` | unspecified |
`\IsRecordEnd` | unspecified |
`\IsSpace` | unspecified |
`\Keep` | `0 [#f]` |
`\KeepWithNext` | `0 [#f]` |
`\KeepWithPrevious` | `0 [#f]` |
`\Length` | context |
`\MathClass` | unspecified |
`\MathFontPosture` | unspecified |
`\MaxHeight` | contextual |
`\MaxWidth` | contextual |
`\MayViolateKeepAfter` | `0 [#f]` |
`\MayViolateKeepBefore` | `0 [#f]` |
`\NotationSystemId` | required |
`\Orientation` | required |
`\PositionPointX` | `??` |
`\PositionPointY` | `??` |
`\PositionPreference` | `0 [#f]` | `position-preference`
`\ScaleType` | `maxuniform` | `scale` [note]
`\ScaleX` | n/a | `scale` [note]
`\ScaleY` | n/a | `scale` [note]
`\ScoreLength` | `??` |
`\ScoreType` | required | `type`
`\Script` | unspecified |
`\SpaceAfterConditional` | `0 [#f]` | `space-after`
`\SpaceAfterForce` | `0 [#f]` | `space-after`
`\SpaceAfterMax` | `0pt` | `space-after`
`\SpaceAfterMaxFactor` | `0` | `space-after`
`\SpaceAfterMin` | `0pt` | `space-after`
`\SpaceAfterMinFactor` | `0` | `space-after`
`\SpaceAfterNominal` | `0pt` | `space-after`
`\SpaceAfterNominalFactor` | `0` | `space-after`
`\SpaceAfterPriority` | `0` | `space-after`
`\SpaceBeforeConditional` | `0 [#f]` | `space-before`
`\SpaceBeforeForce` | `0 [#f]` | `space-before`
`\SpaceBeforeMax` | `0pt` | `space-before`
`\SpaceBeforeMaxFactor` | `0` | `space-before`
`\SpaceBeforeMin` | `0pt` | `space-before`
`\SpaceBeforeMinFactor` | `0` | `space-before`
`\SpaceBeforeNominal` | `0pt` | `space-before`
`\SpaceBeforeNominalFactor` | `0` | `space-before`
`\SpaceBeforePriority` | `0` | `space-before`
`\StretchFactor` | `0` |
`\TableWidth` | contextual |
`\TruncateLeader` | `0 [#f]` |
`\Width` | required | [note]

#### Notes

1. `ScaleType`, `ScaleX`, and `ScaleY` are all the equivalent of the `scale` characteristic: if `ScaleType` is `0` [`#f`], then `ScaleX` and `ScaleY` become relevant.
2. The `Width` characteristic is not required if `table-auto-width` feature is present.