Idraluna Archives

Typst Pocketmod Template

Since I first posted about Typst, it has completely replaced LaTeX (and to some extent Markdown!) in my TTRPG projects. I've gradually been upgrading my various LaTeX templates to Typst equivalents, and today I got around to my code for making 6-spell pocketmod spellbook handouts. (In this case, the template works for any pocketmod, not just spellbooks).

This template function can be loaded into other files (example below). It uses content blocks as inputs, so you can insert pretty much any Typst styling into a page (images, tables, diagrams, etc.). The interior pages are provided as an array to make it slightly less fiddly when mapping lines from an external .csv file.

/// This defines a template function that can be loaded into other files
#let pocketmod(  
  title: [#set align(center); #v(1fr)
          #set text(size: 16pt); *Grimoire Title* #v(1fr)],  // This is the content block that will go on the cover page
  back: [#set align(center); #v(1fr) #scale(x:500%, y:500%)[#sym.floral] #v(1fr)],  // Content block for the back page
  pages: ([Spell 1], [Spell 2], [Spell 3], [Spell 4], [Spell 5], [Spell 6]),  // Array of content blocks for the pages, in order
  cont  // should be empty
) = {
  set page(paper: "us-letter", margin: 0pt, flipped: true)  // Adjust for a4

  rotate(180deg)[#block(width: 11in, height: 4.25in, below: 0pt)[
    #grid(
      columns: (1fr, 1fr, 1fr, 1fr),
      grid.cell(stroke: 0pt, inset: 1em)[#pages.at(0)],
      grid.cell(stroke: 0pt, inset: 1em)[#pages.at(1)],
      grid.cell(stroke: 0pt, inset: 1em)[#pages.at(2)],
      grid.cell(stroke: 0pt, inset: 1em)[#pages.at(3)],
    )    
  ]]

  block(width: 11in, height: 4.25in, above: 0pt)[
    #grid(
      columns: (1fr, 1fr, 1fr, 1fr),
      grid.cell(stroke: 0pt, inset: 1em)[#pages.at(4)],
      grid.cell(stroke: 0pt, inset: 1em)[#pages.at(5)],
      grid.cell(stroke: 0pt, inset: 1em)[#back],
      grid.cell(stroke: 0pt, inset: 1em)[#title],
    )    
  ]
}

Here's what it looks like for a quick & dirty sample spellbook:

#import "../Pocketmod.typ": pocketmod
#show pocketmod.with(
  title: [#set align(center); #v(1fr)
          #set text(size: 16pt); *Salutary Spells* \ #text(size:12pt)[_from the_] \ #text(size:18pt)[*#sym.floral.l Sea of Fog #sym.floral.r*] #v(1fr)],
  back: [#set align(center); #v(1fr) #image("../Illustrations/Grimoires/Sea_of_fog.jpg") #v(1fr)],
  pages: ([
    == Creed of Corporeal Nebulation (III)
    Transforms the caster's body into a cloud of silvery vapor, lasting L turns. The caster can drift at a speed of 3" and slip past non-airtight barriers. If caught in a strong wind, the caster will be unable to coalesce at the end of the spell.
  ], 
  [
    == Exhortation of Atmospheric Viscosity (III)
    Causes the air to become swimmably thick (but breathable) within 12" for L turns.
  ], 
  [
    == Waylay the Welkin's Warden (I)
    Summons a sylph (not guaranteed to do the caster's bidding).
  ], 
  [
    == Expunge Memory (IV)
    Eliminates a memory of a specific person, place, or event. Unwilling subjects get a save.
  ], 
  [
    == Manifest Murk & Mist (II)
    Causes fog to appear in a 24" radius for L turns.
  ], 
  [
    == Summon Fog Elemental (V)
    Conjures a 16 HD Fog elemental lasting until concentration broken or dispelled.
  ])
)

And the result:

#DIY #Typst