docx_plus.publishing.figures¶
Table of Figures via the TOC \c "<caption_type>" complex field.
Structurally identical to a Table of Contents but driven by SEQ
caption names instead of paragraph outline levels — the
caption_type must match the value passed to
docx_plus.publishing.add_caption.
Architecture walkthrough: ARCHITECTURE.md §7.10.
docx_plus.publishing.figures ¶
Table of Figures — TOC \c "Figure" complex field.
A Table of Figures is structurally the same as a Table of Contents,
except the field instruction uses the \c "<caption_type>" switch
to collect SEQ captions of the named type instead of paragraphs
with outline levels. The caption helpers in
docx_plus.publishing.captions produce the entries this table
picks up.
This module imports only from docx_plus.core (SPEC §9.1).
add_table_of_figures ¶
add_table_of_figures(
paragraph: Paragraph,
*,
caption_type: str = "Figure",
hyperlink: bool = True,
) -> etree._Element
Append a Table of Figures complex field to paragraph.
The field lists every caption whose SEQ name equals
caption_type. Word populates the result on next open; call
:func:docx_plus.fields.mark_fields_dirty before saving so the
table fills in automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paragraph
|
Paragraph
|
A python-docx :class: |
required |
caption_type
|
str
|
|
'Figure'
|
hyperlink
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
_Element
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
from docx import Document from docx_plus.publishing import add_caption, add_table_of_figures from docx_plus.fields import mark_fields_dirty doc = Document() doc.add_paragraph("List of Figures") add_table_of_figures(doc.add_paragraph())
... captions added elsewhere via add_caption(..., caption_type="Figure")¶
mark_fields_dirty(doc)