Why do I get error messages with template function arguments?

Hello fellow Typst users!

I’m in the process of replicating my faculty’s Master thesis template from overleaf in Typst (I plan to use it and make it available to colleagues).

I’m trying to wrap the document in a template function as suggested in Making a Template. This would be in a separate file, with multiple arguments for the fill-in info:

#let template(
  thesis_title: [Insert the title of the dissertation],
  thesis_author: [Author’s name, Arial Plain, 18],
  //course_name: [Course’s Name, Arial Plain, 12],
  department: [Department, Arial Plain, 10],
  faculty: [Faculty, Arial Plain, 10],
  year: [Year],
  thesis_type: [Dissertation carried out as part of
the [course's name], Arial Plain, 12],
  supervisor: [Supervisor’s Name, Category, Institution],
  co-supervisor: [Supervisor’s Name, Category, Institution],
  ext-supervisor: [Name, Professional status, Company’s name],
  doc
) = {
//function
doc 
}

And I’m importing the file and calling the function as:

#show: template.with(
  thesis_title: [title],
  …
  ext-supervisor: [name])

at the top of the document. However, no matter what argument order or type (named/positional) I use, the compiler cycles through errors like “Unexpected argument”, “[argument] is positional”, etc.

If I remove all arguments from the function call, sometimes it starts working again, but as soon as I have 4 or 5 in, it begins again.

Am I doing something wrong?

Hi @mezzogallium, could you maybe try to revise your post’s title to be a complete question as per the question guidelines:

Good titles are questions you would ask your friend about Typst.

We hope by adhering to this, we make the information in this forum easy to find in the future. Thanks!


Now to the question; I pasted your code into a new Typst documents (same file, but that shouldn’t make a difference) and didn’t get any errors, even, when adding named arguments (the ones that your template expects) to the call. So the error is likely with the specific parameters you provided or in the template function.

You should try to minify your problem until before it disappears: what parameters can you remove so that the error remains? What parts of the template function can you remove without the error disappearing?

As a last resort, you can just post the code with errors present, but the less code is necessary to demonstrate the problem, the better.

Thank you for the tips. I removed all the arguments and re-added them one by one and the errors stopped, so now everything’s working.