Skip to content

Quick Start

Create your first professional document in under a minute.

Your First Document

from papersmith import SmithDocument

# 1. Create a document with a style preset
doc = SmithDocument(preset="academic")

# 2. Add a cover page
doc.add_cover_page(
    title="Getting Started with papersmith",
    author="Your Name",
    institution="Your University",
)

# 3. Add content
doc.add_heading("Introduction", level=1)
doc.add_text("papersmith makes document generation simple and elegant.")

doc.add_heading("Key Concepts", level=2)
doc.add_bullet_list([
    "Fluent, chainable API",
    "Built-in style presets",
    "Native LaTeX equation rendering",
])

# 4. Add an equation
doc.add_heading("Math Support", level=2)
doc.add_text("Inline math works with dollar signs: $E = mc^2$.")
doc.add_text("Display equations use the dedicated method:")
doc.add_equation(r"F = G \frac{m_1 m_2}{r^2}")

# 5. Add a table
doc.add_heading("Comparison", level=2)
doc.add_table(
    headers=["Feature", "Supported"],
    rows=[
        ["LaTeX Equations", "✓"],
        ["Citations", "✓"],
        ["Charts", "✓"],
        ["PDF Export", "✓"],
    ],
)

# 6. Set metadata and save
doc.set_metadata(author="Your Name", title="Getting Started", scrub=True)
doc.save("my_first_document.docx")

Method Chaining

All content methods return self, so you can chain them:

doc = SmithDocument(preset="modern")
(
    doc.add_heading("Chained API", level=1)
    .add_text("Methods return self for chaining.")
    .add_equation(r"a^2 + b^2 = c^2")
    .add_page_break()
    .add_heading("Next Section", level=1)
    .add_text("Seamless document flow.")
    .save("chained.docx")
)

Opening Existing Documents

doc = SmithDocument.open("existing_report.docx")
doc.add_heading("Appendix", level=1)
doc.add_text("Added after the fact.")
doc.save("updated_report.docx")

What's Next?