texp API Documentation

texp

DSL for outputting TeX expressions using S-expressions.

*escape‑table* (Variable)

Initial Value:

((#\& . "\\&") (#\% . "\\%") (#\$ . "\\$") (#\# . "\\#") (#\_ . "\\_")
 (#\{ . "\\{") (#\} . "\\}") (#\~ . "{\\textasciitilde}")
 (#\^ . "{\\textasciicircum}") (#\\ . "{\\textbackslash}"))

Description:

Alist mapping TeX special characters to quoted equivalent.

deftex (Macro)

Syntax:

— Macro: deftex name parameters &body forms

parameters::= ({var}*)

Arguments and Values:

name—a symbol or string.

formsforms.

var—a symbol.

Description:

deftex prints the definition of a TeX macro with name that expands to forms to *standard-output*. If name is a symbol it will be printed in lower case. Forms are evaluated as if by tex with each var in parameters bound to a numeric TeX parameter identifier.

Examples:

(deftex hello (name) "Hello " ($ name))
▷ \def \hello #1{Hello #1}

escape (Function)

Syntax:

— Function: escape string

Arguments and Values:

string—a string.

Description:

escape encodes string as defined by *escape-table*. E.g. it quotes TeX special characters.

tex (Macro)

Syntax:

— Macro: tex &rest expressions

expressions::= ↓expression*

expression::= ↓break-clause | ↓interpolation-clause | ↓brackets-clause | ↓braces-clause | ↓tex-clause | literal

break-clause::= (br)

interpolation-clause::= ($ form)

brackets-clause::= ([] {expression}*)

braces-clause::= ({} {expression}*)

tex-clause::= ( tex-macro {expression}*)

Arguments and Values:

literal—a string, symbol or number.

form—a form.

tex-macro—a symbol or a string.

Description:

tex compiles TeX expressions to *standard-output*.

A Literal is printed as follows:

  • a string is printed as it is
  • a symbol is printed in lower case
  • a number is printed readably

A tex-clause prints a TeX macro call of tex-macro followed by expressions.

A break-clause prints two newlines (e.g. a paragraph separator).

An interpolation-clause evaluates form and prints its result if the result is a string.

Bracket-clause and braces-clause print expressions surrounded by brackets ([, ]) and braces ({, }) respectively. If the readtable texp:syntax is used then bracket-clause and braces-clause can be written as [ expression* ] and { expression* }.