docxmath

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Blank     = ""
	Backslash = "\\"
	Aln       = "&"
	Brk       = "\\\\"
	FuncPlace = "{fe}"
)
View Source
const ARR = "\\begin{{array}}{{c}}{text}\\end{{array}}"

ARR is the array template.

View Source
const D_TEMPLATE = "\\left{left}{text}\\right{right}"

D_TEMPLATE is the delimiter template.

View Source
const F_DEFAULT = "\\frac{{{num}}}{{{den}}}"

F_DEFAULT is the default fraction format.

View Source
const LIM_UPP = "\\overset{{{lim}}}{{{text}}}"

LIM_UPP is the upper limit template.

View Source
const M_TEMPLATE = "\\begin{{matrix}}{text}\\end{{matrix}}"

M_TEMPLATE is the matrix template.

View Source
const OMML_NS = "http://schemas.openxmlformats.org/officeDocument/2006/math"
View Source
const RAD = "\\sqrt[{deg}]{{{text}}}"

RAD is the radical template with degree.

View Source
const RAD_DEFAULT = "\\sqrt{{{text}}}"

RAD_DEFAULT is the radical template without degree.

View Source
const SUB = "_{{{0}}}"

SUB is the subscript template.

View Source
const SUP = "^{{{0}}}"

SUP is the superscript template.

Variables

View Source
var CHR = map[string]string{

	"\u0300": "\\grave{{{0}}}",
	"\u0301": "\\acute{{{0}}}",
	"\u0302": "\\hat{{{0}}}",
	"\u0303": "\\tilde{{{0}}}",
	"\u0304": "\\bar{{{0}}}",
	"\u0305": "\\overbar{{{0}}}",
	"\u0306": "\\breve{{{0}}}",
	"\u0307": "\\dot{{{0}}}",
	"\u0308": "\\ddot{{{0}}}",
	"\u0309": "\\ovhook{{{0}}}",
	"\u030a": "\\ocirc{{{0}}}}",
	"\u030c": "\\check{{{0}}}}",
	"\u0310": "\\candra{{{0}}}",
	"\u0312": "\\oturnedcomma{{{0}}}",
	"\u0315": "\\ocommatopright{{{0}}}",
	"\u031a": "\\droang{{{0}}}",
	"\u0338": "\\not{{{0}}}",
	"\u20d0": "\\leftharpoonaccent{{{0}}}",
	"\u20d1": "\\rightharpoonaccent{{{0}}}",
	"\u20d2": "\\vertoverlay{{{0}}}",
	"\u20d6": "\\overleftarrow{{{0}}}",
	"\u20d7": "\\vec{{{0}}}",
	"\u20db": "\\dddot{{{0}}}",
	"\u20dc": "\\ddddot{{{0}}}",
	"\u20e1": "\\overleftrightarrow{{{0}}}",
	"\u20e7": "\\annuity{{{0}}}",
	"\u20e9": "\\widebridgeabove{{{0}}}",
	"\u20f0": "\\asteraccent{{{0}}}",

	"\u0330": "\\wideutilde{{{0}}}",
	"\u0331": "\\underbar{{{0}}}",
	"\u20e8": "\\threeunderdot{{{0}}}",
	"\u20ec": "\\underrightharpoondown{{{0}}}",
	"\u20ed": "\\underleftharpoondown{{{0}}}",
	"\u20ee": "\\underledtarrow{{{0}}}",
	"\u20ef": "\\underrightarrow{{{0}}}",

	"\u23b4": "\\overbracket{{{0}}}",
	"\u23dc": "\\overparen{{{0}}}",
	"\u23de": "\\overbrace{{{0}}}",

	"\u23b5": "\\underbracket{{{0}}}",
	"\u23dd": "\\underparen{{{0}}}",
	"\u23df": "\\underbrace{{{0}}}",
}

CHR maps Unicode accent characters to LaTeX format strings. The {0} placeholder is replaced by the content.

View Source
var CHR_BO = map[string]string{
	"\u2140": "\\Bbbsum",
	"\u220f": "\\prod",
	"\u2210": "\\coprod",
	"\u2211": "\\sum",
	"\u222b": "\\int",
	"\u22c0": "\\bigwedge",
	"\u22c1": "\\bigvee",
	"\u22c2": "\\bigcap",
	"\u22c3": "\\bigcup",
	"\u2a00": "\\bigodot",
	"\u2a01": "\\bigoplus",
	"\u2a02": "\\bigotimes",
}

CHR_BO maps Unicode big operator characters to LaTeX commands.

View Source
var CHR_DEFAULT = map[string]string{
	"ACC_VAL": "\\hat{{{0}}}",
}

CHR_DEFAULT stores default character values.

View Source
var D_DEFAULT = map[string]string{
	"left":  "(",
	"right": ")",
	"null":  ".",
}

D_DEFAULT stores default delimiter values.

View Source
var F = map[string]string{
	"bar":   "\\frac{{{num}}}{{{den}}}",
	"skw":   "^{{{num}}}/_{{{den}}}",
	"noBar": "\\genfrac{{}}{{}}{{0pt}}{{}}{{{num}}}{{{den}}}",
	"lin":   "{{{num}}}/{{{den}}}",
}

F maps fraction types to LaTeX format strings.

View Source
var FUNC = map[string]string{
	"sin":    "\\sin({fe})",
	"cos":    "\\cos({fe})",
	"tan":    "\\tan({fe})",
	"arcsin": "\\arcsin({fe})",
	"arccos": "\\arccos({fe})",
	"arctan": "\\arctan({fe})",
	"arccot": "\\arccot({fe})",
	"sinh":   "\\sinh({fe})",
	"cosh":   "\\cosh({fe})",
	"tanh":   "\\tanh({fe})",
	"coth":   "\\coth({fe})",
	"sec":    "\\sec({fe})",
	"csc":    "\\csc({fe})",
}

FUNC maps function names to LaTeX templates.

View Source
var LIM_FUNC = map[string]string{
	"lim": "\\lim_{{{lim}}}",
	"max": "\\max_{{{lim}}}",
	"min": "\\min_{{{lim}}}",
}

LIM_FUNC maps limit function names to LaTeX templates.

View Source
var LIM_TO = [2]string{"\\rightarrow", "\\to"}

LIM_TO defines the replacement pair for limit arrows.

View Source
var POS = map[string]string{
	"top": "\\overline{{{0}}}",
	"bot": "\\underline{{{0}}}",
}

POS maps bar position to LaTeX format strings.

View Source
var POS_DEFAULT = map[string]string{
	"BAR_VAL": "\\overline{{{0}}}",
}

POS_DEFAULT stores default position values.

View Source
var T = map[string]string{}/* 113 elements not displayed */

T maps Unicode math characters to LaTeX text representations.

Functions

func ConvertOMML

func ConvertOMML(elm *OMMLElement) string

ConvertOMML converts an oMath XML element to LaTeX.

func ConvertOMMLString

func ConvertOMMLString(xmlStr string) ([]string, error)

ConvertOMMLString parses an OMML XML string and converts all oMath elements to LaTeX.

func EscapeLatex

func EscapeLatex(s string) string

EscapeLatex escapes LaTeX special characters in a string.

Types

type OMMLElement

type OMMLElement struct {
	XMLName  xml.Name
	Attrs    []xml.Attr    `xml:",any,attr"`
	Children []OMMLElement `xml:",any"`
	Content  string        `xml:",chardata"`
}

OMMLElement represents a parsed OMML XML element.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL