Skip to content

wisp3rwind/typst-scaffolder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tests

The scaffolder Package

Show borders around the main text area, header and footer in Typst documents.

This may be useful to understand and debug layout issues. The idea is similar to the LaTeX showframe package.

Additionally, some internal functions for resolving page and margin dimensions are exposed since they might be useful beyond this package.

Usage

The main entry point is the scaffolding method, which renders a grid to indicate text area, header and footer. It should be placed in the page's background:

#import "@preview/scaffolder:0.2.1": scaffolding
#set page(paper: "a6")

#set page(background: scaffolding())

#lorem(100)

#pagebreak()

#set page(
  background: scaffolding(stroke: blue + 1pt),
  columns: 2,
)

#lorem(100)

Output of the usage example, page 1 Output of the usage example, page 2

The following methods resolve the actual values of some parameters related to layout:

  • get-text-dir: Resolves text.dir to either ltr or rtl.
  • get-page-binding: Resolves page.binding to either left or right.
  • get-page-margins: Resolves page.margin to a dictionary with keys left, right, top and bottom.

All of the require context:

#import "@preview/scaffolder:0.2.1": get-text-dir, get-page-binding, get-page-margins

#context {
  let dir = get-text-dir()

  let binding = get-page-binding()

  let margins = get-page-margins()
}

Known issues

The following limitations are known, PRs to address them are always welcome!:

  • (none)

Feature ideas

The following are some ideas of functionality that might be added or improved in this package:

  • Further separate measuring and rendering steps in the implementation. This would allow to make the rendering more customizable e.g. like the cross markers in this related tex.SE question, or by not having contiguous lines but just rectangles around the main and margin text areas.

Acknowledgements

The following Typst issues and forum post inspired this package and informed its design and implementation:

A more general visual debug mode for Typst has also been proposed in typst/#5226.

LaTeX equivalents

About

Show borders around the main text area, header and footer in Typst documents.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors