#Generating multiple versions of a single document

21 messages · Page 1 of 1 (latest)

smoky fractal
#

Generating multiple versions of a single document

#

The thing is that currently, as the project function defines various page variables, and as I have a "shared" state, repeating simply the content will not cut it

slim plover
#

So, you want to generate many almost identical documents (say, separate PDFs) from the same source?

smoky fractal
#

yes, also by changing things a bit (randomizing stuff, passing variables)

#

(I can do that using CLI, probably, but maybe there is a way to do that on the web too)

slim plover
#

Oh okay

#

I was gonna suggest using the cli for this cuz it would be easier

#

Sys.inputs lets you pass cli parameters as variables

#

And with a script you can run the Typst compile command multiple times with different values

#

The web app doesn't support sys.inputs directly, but either way that wouldn't be very helpful since u can't run a script to automate the web app

#

Generally in the web app you just specify the variable's value directly (e.g. if the sys.inputs.name is missing , use this default value instead) since u can modify the source easily

#

Still that wouldn't be that helpful if u have many students or otherwise many compilations to make

#

Regarding randomization, you can pass an external seed through sys.inputs and use that in some simple pseudo-random function (e.g. LCG)

smoky fractal
#

thanks, i'll look at that

slim plover
#

Let me know if you need help with the script or with such a function

lavish solstice
#

@slim plover Do you know if it's possible to create a pdf with a different name while compiling with different sys.inputs? I want to have a print and a digital version of my document and it would be very convenient to create two pdfs instead of overwrite the compiled one.

slim plover
lavish solstice
#

Ah very nice thank you! But it's not changing the file name of my pdfs, just the pdf meta data. Is this also possible?

past root
#

you can set the output name on the command line: typst compile a.typ b.pdf