How do I keep things together on the same page?

Hi,

I want to keep things physically on the same page - if possible, but I think I’m misunderstanding Typst’s block syntax. I am trying to do this using markdown and cmarker, but the code below I put directly into typst

Below is my current cmarker setup, followed by the block I tried to use.
Can someone point out what I’m doing wrong?

#import "@preview/cmarker:0.1.4"
#import "toolkit.typ": *

// Pull in the markdown document
#counter(page).update(1)   // sets the page number to one (1)
#set enum(indent: 1em)     // set the indent for item-list numbering

#cmarker.render(
  read("input.md"),
  blockquote: leftbar,
  scope: (
    image: (path, alt: none) => image("assets/" + path, alt: alt),
  ),
  html: (
    cite: ("escapable-raw-text", (attrs, body) => ref(label(body))),
  ),
)

This block I am currently typing directly into typst. I am not putting it into markdown, but later I want to.

#block(
  split: never,               // keep everything together
  [
    #### Property Details -- Property Overview

    <https://home.lehighcounty.org/ORA.UI/Public/PropertyDetails?pinpar=548486569929%201&handshake=DEDEDD5E-077F-4CF5-8FE6-E889ADED971D#>

    #image("image32.png")
  ]
)

It would help if you could give a minimal but complete example that we can compile ourselves.

Maybe you’re looking for the block.breakable option?

1 Like

Create input.md - inside Typst

Lehigh County faces an ADA Title II regulation deadline, which requires all state and local government web content and apps to meet WCAG 2.1 AA criteria by April 24, 2026. Non-compliance after this date could result in the County being in violation of federal requirements. Note: The federal government may adjust this deadline as this administration increasingly discusses ADA compliance in the context of broader DEI (Diversity, Equity, and Inclusion) efforts.

#block(
  split: never,               // keep everything together
  [
    #### Property Details -- Property Overview

    <https://home.lehighcounty.org/ORA.UI/Public/PropertyDetails?pinpar=548486569929%201&handshake=DEDEDD5E-077F-4CF5-8FE6-E889ADED971D#>

    #image("image32.png")
  ]
)

Create Main.typ

#import "report_body.typ": *

#set page(
  width: 8.5in,
  height: 11in,
  margin: (
    top: 1in,
    bottom: 1in,
    left: 1in,
    right: 1in
  ),
  footer: context [
    #set align(left)
    #set text(10pt)
    Lehigh County Government Center · (610) 782-3082
  ]
)

// Call the main report
#report_body(report_title, report_date, org)

Create report_body.typ

#let report_body = (report_title, report_date, org) => [
  #pagebreak()

  // Main content begins here
  // This is how we bring in the markdown file
  #import "@preview/cmarker:0.1.3"
  #import "toolkit.typ": *

  // Pull in the markdown document
  #counter(page).update(1)   // sets the page number to one (1)
  #set enum(indent: 1em)     // set the indent for item list numbering

  #cmarker.render(
    read("input.md"),
    raw-typst: true,         // ← Must be here, after markdown and before html tuple
    blockquote: leftbar,
    scope: (
      image: (path, alt: none) => image("assets/" + path, alt: alt),
    ),
    html: (
      cite: ("escapable-raw-text", (attrs, body) => ref(label(body))),
      // other HTML handlers go here
    ),
  )
]

This still doesn’t compile. The package is outdated. The raw-typst usage is explained in the documentation, I don’t understand what is the problem.

#let input-md = ```md
Lehigh County faces an ADA Title II regulation deadline, which requires all state and local government web content and apps to meet WCAG 2.1 AA criteria by April 24, 2026. Non-compliance after this date could result in the County being in violation of federal requirements. Note: The federal government may adjust this deadline as this administration increasingly discusses ADA compliance in the context of broader DEI (Diversity, Equity, and Inclusion) efforts.

<!--raw-typst
#"####" Property Details -- Property Overview

https://home.lehighcounty.org/ORA.UI/Public/PropertyDetails?pinpar=548486569929%201&handshake=DEDEDD5E-077F-4CF5-8FE6-E889ADED971D#

#figure(image("image32.png"), caption: [Image 32])

#block(breakable: false)[
  #lorem(250)

  #lorem(250)
]
-->
```.text

//////////////////////////////////////////////////////////////////////

#import "@preview/cmarker:0.1.6"

#let report-body() = {
  pagebreak()
  cmarker.render(input-md, raw-typst: true, scope: (
    image: (path, alt: none) => rect(),
  ))
}

//////////////////////////////////////////////////////////////////////

#set page(
  paper: "us-letter",
  margin: 1in,
  footer: text(10pt)[Lehigh County Government Center · (610) 782-3082],
)

#report-body()

Second page:

I am trying to make sure that what I put stays together on one page when possible.

So

Header
Some text
Image

Stays on one page, when possible

Mark