Skip to content

Notes: Basics

This page covers the core API of engrapha_notes: themes, headings, body, and footers. By the end of this page you'll be able to construct a structured PDF document.

Setting the theme

import engrapha_notes as en
en.set_theme(en.OCEAN_DARK)

Explore other themes: DARK, LIGHT, FOREST_DARK, SUNSET_DARK, MIDNIGHT_DARK, OCEAN_LIGHT, SEPIA, CATPPUCCIN_LATTE, CATPPUCCIN_MOCHA, NOTION, GITHUB, LINEAR, ACADEMIC, TEXTBOOK.

The story

All helpers append into a global story list. To use Engrapha with a custom story list, redirect it:

my_story = []
en.set_story(my_story)
# ... add content ...
en.build_doc("output.pdf")

You can inspect the current story with en.get_story(). Set en.bookmarks_enabled = False temporarily to suppress PDF outline/meta bookmarks without rewriting content.

This is useful for sandboxing multi-document compilations.

Headings

Helper Visual Auto-bookmarked?
part_box("Unit I", subtitle=..., topics=[...]) Large bordered card (Section Hero Page) No
chap_box("Chapter 1") Medium bordered card Yes
section("Subsection") Cyan-ruled heading Yes
subsection("Sub-subtopic") Smaller heading Yes

part_box serves as a premium section hero page when supplied with optional subtitle (str) and topics (list[str]). For example:

en.part_box(
    "Unit I: Basic Algorithms",
    subtitle="Big-O notation and sorting algorithms",
    topics=["Asymptotic Complexity", "Comparison Sorts", "Divide & Conquer"]
)

Body content

en.body("Justified paragraph with HTML tags.")
en.bullet(["First", "Second", "Third"])
en.sp(8)        # 8pt vertical space
en.rule()        # Cyan divider line
en.br()          # Page break

body() supports inline HTML tags: <b>, <i>, <font color="...">, etc.

Layout constants

PAGE_W = 595  # A4 width (pt)
PAGE_H = 842  # A4 height
PM     = 51.02 # 1.8 cm margins
CW     = 493.0 # Content width = PAGE_W - 2*PM

Footers and headers

# Global footer
en.set_global_footer(left="Course Notes", right="Session", show_page_num=True)

# Per-page footer override
en.footer(left="Page specific", show_page_num=False, page_only=True)

# Suppress footer/header on a single page
en.suppress_footer(page_only=True)

# Suppress footer for all pages after this point
en.suppress_footer()

# Three-column header
en.set_global_header(
    left="Algorithms",
    center="Unit I",
    right="Spring 2026"
)

# Per-page header override
en.header(
    left="Chapter 1",
    visible=True,
    page_only=True
)

Code blocks and tables

# Syntax-highlighted code block
en.code_block("""
public static void main(String[] args) {
    System.out.println("Hello, World!");
}
""", lang="java", theme="dracula")

Syntax-highlighting themes: dracula, monokai, github-dark, or any built-in NotesTheme name.

# Information table with custom column widths
en.info_table(
    ["Algorithm", "Best Case", "Worst Case"],
    [
        ["Quick Sort", "O(N log N)", "O(N^2)"],
        ["Merge Sort", "O(N log N)", "O(N log N)"],
    ],
    col_widths=["40%", "30%", "30%"]
)

Page borders

# Single-page border
en.page_border(enabled=True, margin=15.0, color="#ffffff", page_only=True)

# Global double concentric border
en.page_border(enabled=True, margin=15.0, gap=3.0)

Page numbering

# Default Arabic numerals
en.page_numbering(style="arabic")

# Roman numerals for front matter
en.page_numbering(style="roman")

# Reset counter on a new page
en.page_numbering(style="arabic", reset_to=1)

Cover pages

en.bookmark("Cover Page")
en.suppress_footer(page_only=True)
en.sp(40)
# Create a premium modern cover page
en.cover_card(
    title="Discrete Mathematics",
    subtitle="Unit I: Logic",
    style="modern",
    author="Bharat Dangi",
    date="Spring 2026",
    ornament="diamond"
)
en.br()

One-line cover_preset() bundles an icon, tags, and style for instant professional covers:

en.cover_preset("engineering", title="Computer Networks", subtitle="Complete Study Guide")
en.br()

en.cover_preset("networking", title="CCNA Notes", subtitle="Semester IV")
en.br()

Built-in presets: engineering, research-paper, course-notes, networking, database, programming.

Add a faint SVG background illustration with cover_image():

en.cover_image(
    "asset_images/network_topology.svg",
    opacity=0.06,
    placement="background"
)

Or use the convenience add_cover() helper which automates the bookmark/suppress/break boilerplate:

en.add_cover(
    title="My Notes",
    subtitle="Unit I",
    author="Bharat Dangi",
    style="modern",
    ornament="dots"
)

Supported cover page styles: linear, notion, academic_modern, catppuccin, hero, book, diagram, modern, minimal, corporate, gradient, standard, academic, textbook. Use cover_theme as a synonym for style when you prefer that naming. Supported ornaments: diamond, dots, line.

Building the document

en.build_doc("output.pdf", title="Algorithms Notes", author="Bharat Dangi")

Additional output formats:

en.build_html("output/")             # Writes index.html into output directory
en.build_pptx("output.pptx")         # PowerPoint with theme-matched slide backgrounds

Flashcard exports (.csv, .json, .apkg) are written automatically beside the PDF when en.flashcard() is used.

Next