Using Quarto/typst
In all my reports, I have to insert separate pdf files; preferably, keeping page numbering correct, but that’s a secondary issue that I know is problematic. Since some of the other threads drifted off, I start a new one here in the hope to get a state-of-the-art solution.
Threads
I have read the relevant threads:
and the use introduction of “eval” instead of query.
Insert as image
I currently use the following workaround
#let insert-pdf(document-name, pages) = context {
for i in range(1, pages+1) {
move(
image(
document-name,
page: i,
width: page.width,
height: page.height
),
dx: -here().position().x,
dy: -here().position().y,
)
}
}
but this uses images and my client does not like these non-searchable images.
Using pdftk
The alternative is to use pdftk, with a line in .ps1 like the following:
pdftk A=$inp B=$merge_with cat A1-$page B A$page1-end output $out
This works, but I have to find know $page in advance. I have a label into the document:
#label("fachinformation_pdf")
but I could not find the page of the label by program.
Finding label page
Claude suggests using
typst eval "query(<fachinformation>).first().location().page()" --in index.typ
This give a strange error message:
typst eval "query(<fachinformation>).first().location().page()" --in index.typ
error: array is empty
┌─ <input-expression>:1:0
│
1 │ query(<fachinformation>).first().location().page()
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unknown font family: font awesome 6 free
┌─ @preview/fontawesome:0.5.0/lib-impl.typ:51:10
│
51 │ font: default_fonts, // If you see warning here, please check whether the FA font is installed
│ ^^^^^^^^^^^^^
Note: the report builds without problems
Questions
- Any better alternatives to insert a pdf as of today?
- How to find the location of a label with eval?
- Secondary (maybe impossible): Get page numbering right? Note that the pdf is inserted into the middle of the main document.
