Skip to content

neuralpain/edgeframe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

edgeframe

Edgeframe is a Typst package designed for rapid document scaffolding: handling headers, footers, margins, watermarks, and typography rules, all in a single, flexible function.

It's particularly powerful for creating papers, reports, or drafts where you need dynamic headers (different on first/last/odd/even pages) without spending time writing or copying the logic yourself.

Quick Start

This is an example of a simple document config using Edgeframe.

#import "@preview/edgeframe:0.3.0": *

// Apply defaults and start writing
#show: ef-document.with(..ef-defaults)

= My Title
Start writing your content here...

This is, of course, very simple, but it can be configured with a lot more.

View some example documents available on the Github repository:


Configuration

1. Paper, Layout, and Cover

Settings for the physical page, margins, and the cover page.

Parameter Type Default Description
paper string "us-letter" The paper size
margin dictionary margin.normal The page margins. Use options from the margin utility or a standard dictionary (top: 1cm, ...).
cover-page content none Content to be displayed on a dedicated cover page. Resets page numbering automatically.
text-font string "Libertinus Serif" Document font.
text-size length 11pt Document font size.

2. Table of Contents

Edgeframe can now manage your outline generation automatically. Configure it via the toc dictionary. It follows the same keys for the outline function with additions of an enabled key/switch to quickly toggle the page.

Key Type Default Description
enabled boolean false Whether to generate a Table of Contents.
title content auto The title of the TOC (e.g., [Contents]).
depth integer none How deep the outline should go.
indent length auto Indentation of outline entries.

Example:

#show: ef-document.with(
  toc: (
    enabled: true,
    title: [Table of Contents],
    depth: 2
  )
)

3. Headers and Footers

Edgeframe uses a robust system for headers and footers. You can pass a simple string/content, or a dictionary for granular control over specific pages.

Header & Footer Text Display

Key Type Description
hf-flex boolean true
hf-text-size length none

The Content Array: When defining content for a header or footer, you can provide a single item (centered) or an array of three items: ([Left], [Center], [Right]).

Header & Footer Configuration (header: (...), footer: (...))

Key Type Description
content content, array The default content. Can be [Center] or ([Left], [Center], [Right]).
first-page content, array Content specific to the first page.
last-page content, array Content specific to the last page.
odd-page content, array Content specific to odd pages (useful for double-sided printing).
even-page content, array Content specific to even pages.
alignment alignment Default alignment (e.g., center).

Example 1:

#show: ef-document.with(
  ..ef-defaults,
  header: [Edgeframe],
  footer: ([Copyright 2025], [v0.4.0])
)

Example 2:

#show: ef-document.with(
  ..ef-defaults,
  header: (
    content: [Edgeframe],
    first-page: ([First], [], [Page]),
  ),
  footer: (
    content: ([Copyright 2025], [v0.4.0]),
    even-page: [Even Page Footer],
  )
)

4. Page Numbering

Manage automatic page counting and its position.

Parameter Type Default Description
page-count boolean false If true, adds page numbers to the footer.
page-count-first-page boolean true Whether to show the number on the first page.
page-count-position alignment center Where to place the number (left, center, or right).

Note: Enabling page-count will automatically replace the corresponding slot in your footer content array with the page counter.

5. Watermarks and Overlays

Add drafts stamps, confidentiality warnings, or decorative overlays.

Parameter Type Default Description
draft boolean false Shortcut. If true, adds a "DRAFT" watermark.
confidential boolean false Shortcut. If true, adds a large "CONFIDENTIAL" watermark.
watermark content "" Custom text or content for the background.
watermark-color color luma(0, 20%) Color and transparency of the watermark.
watermark-rotation angle -45deg Rotation angle.
overlay content none Content placed in the foreground (top of page).

6. Typography (Paragraphs & Lists)

Edgeframe wraps standard Typst styling for paragraphs and lists so you can configure them in one place.

Paragraphs (paragraph: (...))

Key Type Default Description
justify boolean false Justify text.
leading length 0.75em Spacing between lines.
spacing length 1em Spacing between paragraphs.
first-line-indent length 0em Indentation for the first line of a paragraph.

Lists (bullet-list and number-list)

Both list types accept dictionaries with the following keys: indent, body-indent, spacing, and tight.

bullet-list specific:

  • marker (an array of symbols, e.g., ([•], [‣], [–])).
  • numbering (e.g., "1."), start, full, and reversed.

Advanced Usage

Creating Custom Defaults

These are the current defaults for edgeframe:

// Biased defaults for documents
#let ef-defaults = (
  paper: "a4",
  margin: margin.a4,
  paragraph: (
    justify: false,
    leading: 0.8em,
    spacing: 1.5em,
    first-line-indent: 0em,
  ),
)

If you frequently use a specific setup you can create a dictionary and pass it as an argument sink to ef-document.

#import "@preview/edgeframe:0.4.0": *

#let my-notebook-style = (
  paper: "a5",
  margin: margin.wide,
  page-count: true,
  paragraph: (
    justify: true,
    first-line-indent: 2em
  )
)

#show: ef-document.with(
  ..my-notebook-style,
  watermark: "PERSONAL" // You can still edit specific keys
)

If you've created a default setup by standard international convention, you can submit it to the project on Github via Github Issues. It can be added to Edgeframe for use in a future release.

Complex Header Example

This example demonstrates a document with specific requirements: a different header on the first page, specific headers for the last page, and page numbers on the right.

#show: ef-document.with(
  ..ef-defaults,
  paper: "us-letter",
  page-count: true,
  page-count-position: right,
  header: (
    content: ([Project Alpha], [], [2025]),
    first-page: strong[EXECUTIVE SUMMARY],
    last-page: (none, [End of Document], none)
  ),
  footer: (
    // Page count takes the 'right' slot, we define the left slot here
    content: ([Confidential], [], []),
  )
)

Utilities

The package exports a margin utility object containing common presets based on Microsoft Word layout settings:

  • normal
  • narrow
  • moderate
  • wide
  • a4
  • a5

Line breaks and page breaks:

There are a couple extra tools that can be used for niche solutions:

  • xlinebreak(n): allows an n amount of linebreaks() with a single function.
  • xpagebreak(n): allows an n amount of pagebreaks() with a single function.

These are useful when you want to don't want a single function making your project look messy in repetition (like I said, niche). They can be used normally and it's easy to switch between this and the regular function by using the x prefix.

About

For quick paper setups in Typst.

Resources

License

Stars

Watchers

Forks

Contributors