๐Ÿ“– How to typeset two texts in parallel on pairs of facing pages?

But isnโ€™t this discussing something more fancy than what the LaTeX package is doing? I mean, if the user has to tag explicitly the content for each facing pages or facing paragraphs, itโ€™s easy to do in typst (apart from the line numbering).

Example for numbered paragraphs in parallel columns:

#set page(width: 9cm, height: 10cm, numbering: "1")
#set par(justify: true)

#let lr-blocks = state("lr-blocks", 0)
#let block-number() = context text(0.8em, numbering("1", lr-blocks.get()))

#let lr-columns(a, b) = {
  lr-blocks.update(x => x + 1)
  grid(columns: (1fr, 1fr), column-gutter: 2em,
    place(left, dx: -1.5em, block-number()) + a,
    place(right, dx: 1.5em, block-number()) + b,
  )
}

#counter(page).step()  // start with page 2 (left page)
#lr-columns[ #lorem(10) ][ #lorem(20) ]
#lr-columns[ #lorem(35) ][ #lorem(25) ]
#lr-columns[ #lorem(10) ][ #lorem(15) ]

Example with facing pages, and line numbering reset for each page:

#set page(width: 6cm, height: 7cm, margin: 1cm, numbering: "1")
#set par(justify: true)
#let lr-pages(a, b) = {
  pagebreak(weak: true)
  set par.line(numbering: "1", numbering-scope: "page", number-margin: left)
  a
  pagebreak()
  set par.line(numbering: "1", numbering-scope: "page", number-margin: right)
  set text(red)
  b
}

#counter(page).step() // start with page 2 (left page)
#lr-pages[ #lorem(25) ][ #lorem(20) ]
#lr-pages[ #lorem(18) ][ #lorem(22) ]
]

What would be more difficult is to let typst do the page breaks automatically, but I donโ€™t think the LaTeX package does that.

Also probably difficult would be to have continuous line numbering (not reset on every page).

2 Likes