Notes, links and navigation
Footnotes, endnotes, hyperlinks, bookmarks, cross-references, table of contents, captions, tab stops and line numbers.
Footnotes and Endnotes#
| Method | Parameters | Description |
|---|---|---|
addFootnote() | text, footnoteContent, options | Inline text with a superscript footnote reference |
addEndnote() | text, endnoteContent, options | Inline text with an endnote reference |
registerFootnote() | footnoteContent | Register a note, return its ID for use in addRichParagraph |
registerEndnote() | endnoteContent | Register an endnote, return its ID |
The footnoteContent / endnoteContent argument accepts either:
- A plain string — simple unformatted note body
- A list of
[text, options]run pairs — rich formatted body with per-run bold, italic, colour, size, and font (same format asaddRichParagraph)
# 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"]]
],
[]
)Tip: Use registerFootnote(content) to attach a note to a specific run inside addRichParagraph() via :footnoteId on the run options.
Hyperlinks, Bookmarks, and Cross-References#
Hyperlinks#
doc.addHyperlink("Ring Language Website", "http://ring-lang.github.io")
doc.addHyperlink("Send Email", "mailto:info@ring-lang.github.io")Bookmarks#
| Method | Parameters | Description |
|---|---|---|
addBookmarkedParagraph() | name, text, options | Paragraph with an invisible named bookmark anchor |
addBookmark() | name | Zero-width anchor inserted at the current position |
# 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.
doc.addCrossRef("bm_intro", "see Introduction on page ")
# → renders as: 'see Introduction on page 3' after F9Table of Contents#
addTableOfContents() inserts a Word TOC field that collects all Heading 1–3 paragraphs.
doc.addTableOfContents("Table of Contents")
doc.addPageBreak()
doc.addHeading("Chapter 1", 1)
doc.addHeading("1.1 Background", 2)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#
# 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 versionsTable of Figures and Table of Tables#
Caption entries are pre-populated from captions already added — lists are visible immediately on open without pressing F9.
# 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")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#
# 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 option | Values | Description |
|---|---|---|
:pos | Number (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#
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 paragraphsenableLineNumbers option | Type | Description |
|---|---|---|
:start | Number | First line number. Default: 1 |
:step | Number | Show number every N lines. Default: 1 |
:distance | Number | Gap from text margin in twips. Default: 360 |
:restart | String | "newPage", "newSection", "continuous" |