TeXBody

References
public sealed class TeXBody
Implementation of the TeX style glue-box-penalty model for a body of text, as outlined by Donald Knuth and Michael Plass in their seminal 1981 paper 'Breaking Paragraphs into Lines'. Append elements to this stream using the Add() methods and eventually break it into lines with the BestBreak() method.

Constructors

TeXBody

#
Create a new, empty text.
public TeXBody()

Properties

Count

#
Gets the number of elements in this text.
public int Count { get; }

Elements

#
Enumerate over all elements.
public IEnumerable<ITeXElement> Elements { get; }

WillBeginNewClause

#
Gets whether the next element to be appended will be the start of a new clause. This means the most recent element of type Box contains text ending in a clause terminator such as full stop, comma, or colon. Note that the first clause of a paragraph does not qualify as a new clause.
public bool WillBeginNewClause { get; }

WillBeginNewParagraph

#
Gets whether the next element to be appended will be the start of a new paragraph.
public bool WillBeginNewParagraph { get; }

Indexers

this[]

#
Gets the specified TeX element. When indexed outside of the valid range, this method always returns a Box with zero width.
public ITeXElement this[
index
] { get; }

Methods

Add

#
Append a TeX element to this text.
public void Add(
element
)

AddPlainContent

#
Parse and append text to this body. The text isn't interpreted in any way, only whitespace is replaced with the appropriate glue and penalties.
public void AddPlainContent(
text,
Font
font,
Color
colour,
spacing = null
)

AddRange

#
Append a collection of TeX elements to this text.
public void AddRange()

AddTeXContent

#
Parse and append TeX formatted content to this body. The text is interpreted using a subset of TeX macros: \emph{}, \code{}, \math{}, \sub{}, \super{}, \colour[name]{}, ...

Macro names are all lower case and are matched case-sensitively. An unrecognised macro renders as its own name, backslash included, in TeXStateMachine.InvalidColour, so that mistakes are visible rather than silently changing the formatting.

public void AddTeXContent(
text,
fonts,
spacing = null
)

AllBreaks

#
Get all valid ways of breaking this body into lines.
public TeXBreak[] AllBreaks(
settings,
demerits,
token
)

BestBreak

#
Gets the best way to break this body into lines.
public TeXBreak BestBreak(
settings,
demerits,
token
)

CreateFromElements

#
Create a text directly from TeX elements.
public static TeXBody CreateFromElements()

EnsureParagraphEnding

#
Ensure that the current text validly terminates in a paragraph ending so it can be properly broken into lines.
public void EnsureParagraphEnding()