I’m relatively new to typst
and am enjoying it so far, but am having a fundamental misunderstanding of something important.
To motivate my question, I propose that the following typst function calls are all the same and I would love to know why:
- #text(black)[my text]
- #text(11pt)[my text]
- #text(11pt,black)[my text]
- #text(black,11pt)[my text]
- #text(black,size:11pt)[my text]
- #text(size:11pt,black)[my text]
- #text(fill: black,size:11pt)[my text]
- #text(size:11pt,fill: black)[my text]
- #text("my text",size:11pt,fill: black)
- #text("my text",11pt,black)
- #text("my text",black,11pt)
- #text(black,"my text",11pt) // why does this work?
- #text(black,11pt,"my text") // why does this work?
- #text(fill:black,11pt,"my text") // why does this work?
- #text(fill:black,size:11pt,"my text") // why does this work?
When I look at the API documentation for the text function, I see a long list of named + non-required parameters followed by two positional + required parameters
I observe and assert (ready to be wrong):
#text(11pt)[my text]
is taking in a content block as its required positional parameter and11pt
(of typelength
) as the namedsize:
parameter though it seems like its being used a positional parameter.#text(black)[my text]
is taking in a content block as its required positional parameter andblack
(of typecolor
) as the namedfill:
parameter though it seems like its being used a positional parameter.fill:
andsize:
seem to be the only named parameters for thetext
function that are psuedo-positional. (I do not mean this term to be disparaging – only a convenient neologism)- Both these (
fill:
andsize:
) are optional parameters because I know I can do aset text(10pt)
or aset text(green)
and another documentation states quite clearly that “Only optional parameters of that function can be provided to the set rule” (reference).
If the heart of these assertions is true, then my fundamental question is
- How can I know (via documentation or code) which parameters are psuedo-positional?
Similar questions:
- Why can I do
#text(blue)[my text]
but not#highlight(blue)[my text]
? (both usefill:
as optional parameters) - Is there any way to see documentation (or access to code) that would allow me to find this out for myself?
Thanks for sticking with me this far.
daniel