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.

StyleFnFor

StyleFnFor<K>: K extends StyleKey ? StyleMap[K] extends Styler<infer S, infer A> ? StylerFn<S, A> : StyleMap[K] : never

Type parameters

StyleFnMap

StyleFnMap: {}

Type declaration

StyleKey

The valid style keys to be used with setStyle.

StyleKeyData

StyleKeyData: "exponentStyle" | "numberSpecials" | "numberPrecision" | "numberFormat" | "numberTrimTrailingZero"

StyleKeyStyler

StyleKeyStyler: "applyUnit" | "applyUnitFunction" | "function" | "variable" | "unit" | "unitSymbol" | "unitFraction" | "number" | "call"

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

StylerFn

StylerFn<I, R>: (ctx: StyleContext, arg: I, ...rest: R) => string

Type parameters

  • I

  • R: any[]

Type declaration

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>;})()

Const exponentStyle

exponentStyle: Style = Object.freeze(new Style({unit: exponentError,unitFraction: exponentError,unitSymbol: exponentError,function: () => DEFAULT_STYLE_FNS.function,call: () => DEFAULT_STYLE_FNS.call,variable: () => DEFAULT_STYLE_FNS.variable,applyUnit: exponentError,applyUnitFunction: exponentError,number: chain(specialNumber, formatNumber),numberFormat: NumberFormat.normal,numberPrecision: 0,numberSpecials: SPECIAL_NUMBERS,numberTrimTrailingZero: true,exponentStyle: 'self'}))

Const specials

specials: Array<[number, string]> = [[Math.PI, tex`\pi`],[Math.sqrt(2), tex`\sqrt{2}`],[Math.E, tex`\mathrm{e}`]]

Functions

Const chain

Const colorStyler

Const exponentError

  • exponentError(): (Anonymous function)

Const formatNumber

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

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)

Object literals

Const DEFAULT_STYLE_FNS

DEFAULT_STYLE_FNS: object

exponentStyle

exponentStyle: "exponent" = "exponent"

numberFormat

numberFormat: scientific = NumberFormat.scientific

numberPrecision

numberPrecision: number = 4

numberSpecials

numberSpecials: Map<number, string> = SPECIAL_NUMBERS

numberTrimTrailingZero

numberTrimTrailingZero: true = true

applyUnit

applyUnitFunction

call

function

number

unit

unitFraction

  • unitFraction(_ctx: StyleContext, numer: string, denom: string): string

unitSymbol

variable

Generated using TypeDoc