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

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

Properties

Count

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

Elements

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

WillBeginNewClause

#
public bool WillBeginNewClause { get; }
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.

WillBeginNewParagraph

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

Indexers

this[]

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

Methods

Add

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

AddPlainContent

#
public void AddPlainContent(string text, Font font, Color colour, TeXSpacing spacing = null)
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.
text (string)
font (Font)
colour (Color)
spacing (TeXSpacing = null)

AddRange

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

AddTeXContent

#
public void AddTeXContent(string text, TeXFonts fonts, TeXSpacing spacing = null)
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.

text (string)
fonts (TeXFonts)
spacing (TeXSpacing = null)

AllBreaks

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

BestBreak

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

CreateFromElements

#
public static TeXBody CreateFromElements(IEnumerable<ITeXElement> elements)
Create a text directly from TeX elements.
elements (IEnumerable<ITeXElement>)

EnsureParagraphEnding

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