top | item 44356841

(no title)

msravi | 8 months ago

> Regarding point 2: you can put your settings in a file `settings.typ` and import it from multiple files.

Let's say I have 3 flavors of settings and 10 different typ files - normally I'd just have 3 flavors of top.typ (top1.typ, top2.typ, top3.typ) with the correct settings for each flavor with settings proagated to all 10 files. Compiling top1/top2/top3 would then create flavor1.pdf, flavor2.pdf, and flavor3.pdf

Now how do I do it with settings1.typ, settings2.typ and settings3.typ? I have to go into the 10 different files and include the appropriate settings file! Or employ hacks like creating a common settings.typ using bash in the Makefile and including the common settings.typ in the 10 different files.

Edit: This is an actual use case - I'm helping with a resume, and have 3 different resume styles - a resume, a cv, and a timeline - and different files like education, work experience, honors, awards, publications, projects, etc and the level of detail, style, and what is included or not in each is controlled by which resume style is active. In latex I did this using \newcommand and the ifthenelse package.

In typst, I have had to resort to passing these global settings as arguments to functions spread across these different files, so each resume item (function) instantiated from the top file has a bunch of parameters like detail_level = 1, audited_courses = true, prefix_year = false, event_byline = true, include_url = true, etc., which make the functions unweildy.

discuss

order

cbolton|8 months ago

Just have a master settings.typ that you import in top1.typ, top2.typ and top3.typ?

Alternatively, you can pass global settings at build time with `typst c --input name=value`

Maybe I misunderstood though, if you can link to an actual example (gist or something) I'd be happy to try and give a concrete solution.

msravi|8 months ago

> Just have a master settings.typ that you import in top1.typ, top2.typ and top3.typ?

Yes, but each included file (like education.typ, publications.typ, etc) should also get these settings propagated from top - which typst doesn't allow - the appropriate settings need to be included in each of these files.

> you can pass global settings at build time with `typst c --input name=value`

This is something I did not know - will check.