latex

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package latex renders a doctree.Element into a standalone LaTeX document, meant as input to a LaTeX engine such as go-tex.

Deliberately NOT a port of docutils' latex2e writer (writers/latex2e/__init__.py, ~3486 lines): that writer supports multiple document classes, syntax-highlighted code listings, real LaTeX \footnote-machinery bridged across the doctree's separate footnote-definition/footnote-reference nodes via custom \DU... preamble macros, docinfo-to-titlepage conversion, and more — replicating it would be a second undertaking on the scale of the writer itself. This produces a fixed article-class document with a minimal preamble (hyperref only, for working links/anchors) using only vanilla LaTeX constructs, so it always compiles without a custom macro package.

SCOPE (v1): unlike html.Render (a fragment, meant to be embedded), Render here returns a COMPLETE, standalone, compilable .tex document — LaTeX has no equivalent to dropping a fragment into a hosting page, so a full document is the useful unit. A table's cell content is flattened to plain text (doctree.AsText) rather than walked recursively: a nested list or multi-paragraph cell needs a `p{width}` column + minipage to be valid LaTeX, not implemented here. A grid-table cell's column span (morecols) is rendered with `\multicolumn` (plain LaTeX, no package); its ROW span (morerows — a cell spanning multiple text rows) is NOT rendered specially at all: plain `tabular` has no rowspan primitive without the `multirow` package, which this writer deliberately never depends on (see the module doc comment) — a row-spanning grid-table cell's content still appears, just not merged, so a later row that relied on that merge to stay aligned may visually misalign. Real row/column spans work correctly in html.Render (`rowspan`/`colspan` are native HTML). Footnotes/citations don't use LaTeX's native \footnote (which wants inline content at the reference point, not docutils' separate reference/definition nodes) — a reference renders as a hyperref jump to a labeled paragraph where the definition appears in the document's normal flow, not a page-bottom note. A directive (including a substitution definition's embedded `replace::`) renders as a verbatim block labeled with its name, same non-silent-drop choice as html.Render. An unresolved reference/substitution falls back to plain text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(doc *doctree.Element) string

Render walks doc and returns a complete, standalone LaTeX document.

Types

This section is empty.

Jump to

Keyboard shortcuts

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