Options
All
  • Public
  • Public/Protected
  • All
Menu

Module LaTeX

Support for LaTex formatting of our expressions and data.

Index

Type aliases

RGB6Color

RGB6Color: string

We take our colors in 6 RGB hex digits, e.g. RRGGBB, {RR, GG, BB} ∈ 00..FF.

StyleKey

StyleKey: StyleKeyStyler | StyleKeyData

The valid style keys to be used with setStyle.

StyleMap

StyleMap: { applyUnit: Styler<string | number, [IUnitBase]>; applyUnitFunction: Styler<string | number, [IUnitBase]>; call: Styler<IPFunction, [Variable[]]>; exponentStyle: Style | "self" | "exponent"; function: Styler<IPFunction>; number: Styler<number>; numberFormat: NumberFormat; numberPrecision: number; numberSpecials: Map<number, string>; numberTrimTrailingZero: boolean; unit: Styler<IUnitBase>; unitFraction: Styler<string, [string]>; unitSymbol: Styler<IUnitBase>; variable: Styler<Variable> }

A type map of StyleKey to Styler (plus the supporting data items).

Type declaration

Styler

Styler<I, R>: (continuation: StylerFn<I>, thisStyle: Style) => StylerFn<I, R>

A styler takes a LaTeX fragment and transforms it in some way.

A Styler is required to be synchronous; no use of await or promises is allowed.

Type parameters

  • I

  • R: any[]

Type declaration

    • (continuation: StylerFn<I>, thisStyle: Style): StylerFn<I, R>
    • Parameters

      • continuation: StylerFn<I>
      • thisStyle: Style

      Returns StylerFn<I, R>

Variables

Const DEFAULTS

DEFAULTS: StyleMap = Object.freeze({unit: colorStyler('ff0000'),unitFraction: () => DEFAULT_STYLE_FNS.unitFraction,unitSymbol: () => DEFAULT_STYLE_FNS.unitSymbol,function: () => DEFAULT_STYLE_FNS.function,call: () => DEFAULT_STYLE_FNS.call,variable: () => DEFAULT_STYLE_FNS.variable,applyUnit: () => DEFAULT_STYLE_FNS.applyUnit,applyUnitFunction: () => DEFAULT_STYLE_FNS.applyUnitFunction,number: chain(specialNumber, formatNumber),numberFormat: NumberFormat.scientific,numberPrecision: 4,numberSpecials: SPECIAL_NUMBERS,numberTrimTrailingZero: true,exponentStyle: exponentStyle})

The stylers. These handle adding style formatting to the syntactic expressions components.

Const INITIAL_STYLE

INITIAL_STYLE: Style = new Style(DEFAULTS)

The initial [[DEFAULT_STYLE]].

Const LATEX_STYLE_KEYS

LATEX_STYLE_KEYS: StyleKey[] = Object.keys(DEFAULT_STYLE) as StyleKey[]

List of the valid style keys for setStyle.

Let SPECIAL_NUMBERS

SPECIAL_NUMBERS: Map<number, string> = ((m = new Map<number, string>()) => {for (const [numer, denom] of fractions()) {if (denom) {m.set(numer / denom, tex`\frac{${numer}}{${denom}}`);}for (const [v, sym] of specials) {if (!denom) {// Integerm.set(numer * v, numer === 1 ? sym : tex`${numer}${sym}`);} else {m.set(numer * v / denom,numer === 1? tex`\frac{${sym}}{${denom}}`: tex`\frac{${numer}${sym}}{${denom}}`);}}}return Object.freeze(m) as Map<number, string>;})()

Functions

Const chain

Const colorStyler

fractions

  • fractions(max?: number, maxDenom?: number): Generator<number[], void, unknown>
  • Parameters

    • Default value max: number = 10
    • Default value maxDenom: number = 10

    Returns Generator<number[], void, unknown>

Const setStyle

Const specialNumber

  • specialNumber(continuation: StylerFn<number>, _style: Style): (Anonymous function)
  • Parameters

    • continuation: StylerFn<number>
    • _style: Style

    Returns (Anonymous function)

Generated using TypeDoc