DOCXLibWord documents for Ring

Notes, links and navigation

Footnotes, endnotes, hyperlinks, bookmarks, cross-references, table of contents, captions, tab stops and line numbers.

Footnotes and Endnotes#

MethodParametersDescription
addFootnote()text, footnoteContent, optionsInline text with a superscript footnote reference
addEndnote()text, endnoteContent, optionsInline text with an endnote reference
registerFootnote()footnoteContentRegister a note, return its ID for use in addRichParagraph
registerEndnote()endnoteContentRegister an endnote, return its ID

The footnoteContent / endnoteContent argument accepts either:

Ring
# Plain-text footnote (backward-compatible)
doc.addFootnote(
    "Ring is a multi-paradigm language.",
    "Ring Programming Language. ring-lang.github.io",
    []
)

# Rich footnote — bold author name, coloured URL, italic date
doc.addFootnote(
    "See the official documentation.",
    [
        [" See: ",            []],
        ["Mahmoud",     [:bold=true, :color="1B5E20"]],
        [", Ring Language, ", []],
        ["2016-2026",      [:italic=true, :color="666666"]],
        [". ring-lang.github.io",   []]
    ],
    []
)

# Rich endnote — italic title with underline, bold source
doc.addEndnote(
    "See the OOXML standard.",
    [
        ["Source: ",              []],
        ["OOXML Standard ECMA-376", [:italic=true, :underline=true]],
        [", 5th edition — ",      []],
        ["ISO/IEC 29500",         [:bold=true, :color="1A237E"]]
    ],
    []
)
Note

Tip: Use registerFootnote(content) to attach a note to a specific run inside addRichParagraph() via :footnoteId on the run options.

Ring
doc.addHyperlink("Ring Language Website", "http://ring-lang.github.io")
doc.addHyperlink("Send Email", "mailto:info@ring-lang.github.io")

Bookmarks#

MethodParametersDescription
addBookmarkedParagraph()name, text, optionsParagraph with an invisible named bookmark anchor
addBookmark()nameZero-width anchor inserted at the current position
Ring
# Bookmark an entire heading
doc.addBookmarkedParagraph("bm_intro", "1. Introduction", [:style = "Heading1"])

# Bookmark a specific point (no text)
doc.addParagraph("See the results ", NULL)
doc.addBookmark("results_anchor")

Cross-References#

addCrossRef() inserts a Word REF field that resolves to the page number of the named bookmark when the user presses F9.

Ring
doc.addCrossRef("bm_intro", "see Introduction on page ")
# → renders as: 'see Introduction on page 3' after F9

Table of Contents#

addTableOfContents() inserts a Word TOC field that collects all Heading 1–3 paragraphs.

Ring
doc.addTableOfContents("Table of Contents")
doc.addPageBreak()

doc.addHeading("Chapter 1", 1)
doc.addHeading("1.1 Background", 2)
Note

Note: Press F9 in Word to populate page numbers. The field uses TOC \o "1-3" \h \z \u and collects Headings 1 through 3.

Captions and Lists of Figures / Tables#

SEQ Captions#

Ring
# After an image:
doc.addImageCentered("arch.png", 12, 8)
doc.addFigureCaption("Ring VM architecture overview")
# → renders as:  Figure 1 — Ring VM architecture overview

# Above or below a table:
doc.addTableCaption("Feature comparison across Ring versions")
doc.addTable(data, options)
# → renders as:  Table 1 — Feature comparison across Ring versions

Table of Figures and Table of Tables#

Caption entries are pre-populated from captions already added — lists are visible immediately on open without pressing F9.

Ring
# Place these early in the document (before the figures/tables)
doc.addTableOfFigures("List of Figures")
doc.addTableOfTables("List of Tables")
doc.addPageBreak()

# For any custom SEQ label (Equation, Chart, Listing, etc.):
doc.addTableOfSeq("Equation", "List of Equations")
Note

Tip: Press F9 in Word to refresh page numbers. Caption text is always visible immediately; only the page numbers need updating.

Tab Stops and Line Numbers#

Tabbed Paragraphs#

Ring
# TOC-style dot leader:
tocTabs = [:tabStops = [[:pos=8500, :align="right", :leader="dot"]]]
doc.addTabbedParagraph(["Introduction",            "1"], tocTabs)
doc.addTabbedParagraph(["Chapter 1 — Background",  "3"], tocTabs)
doc.addTabbedParagraph(["Chapter 2 — Results",     "7"], tocTabs)

# Price list:
priceTabs = [:tabStops = [[:pos=8500, :align="right", :leader="dot"]]]
doc.addTabbedParagraph(["Ring Language",  "$0.00 (Open Source)"], priceTabs)
doc.addTabbedParagraph(["DOCXLib",    "$0.00 (Open Source)"], priceTabs)

# Multi-column layout:
multiTabs = [:tabStops = [
    [:pos=3000, :align="center", :leader="none"],
    [:pos=6000, :align="left",   :leader="none"],
    [:pos=9000, :align="right",  :leader="none"]
]]
doc.addTabbedParagraph(["Name", "Role", "Score", "Grade"], multiTabs)
Tab stop optionValuesDescription
:posNumber (twips)Distance from left margin. 1440 twips = 1 inch
:align"left" / "center" / "right" / "decimal"Alignment at the stop
:leader"none" / "dot" / "hyphen" / "underscore"Fill character between stops

Line Numbers#

Ring
doc.enableLineNumbers([
    :start   = 1,          # first line number
    :step    = 5,          # show number every 5 lines
    :restart = "newPage"   # restart on each page
])

doc.addParagraph("This paragraph shows line numbers.", NULL)
doc.addParagraph("This one is excluded.", [:suppressLineNumbers=true])

doc.disableLineNumbers()   # turn off for remaining paragraphs
enableLineNumbers optionTypeDescription
:startNumberFirst line number. Default: 1
:stepNumberShow number every N lines. Default: 1
:distanceNumberGap from text margin in twips. Default: 360
:restartString"newPage", "newSection", "continuous"
DOCXLib - Word documents for Ring, made with ringdoc.