#changing font style and size
1 messages · Page 1 of 1 (latest)
See the text function: https://typst.app/docs/reference/text/text/
Sorry, I don't understand to change the font size only for parts of the text, in the parts of the title or so. And blod face or emph is clear, but whats about sans serif? For me, the docu is not very helpful.
You can change the font to one without serifs. If you want a function that does that for you, you could define one yourself, that takes an argument and puts it into the text function with font set to your desired sans serif font
?r
#let textsf = text.with(font: "Arial")
Hello, this is in the default Font.
#textsf[Hello, this is in Arial Font]
#{
set text(font: "Bahnschrift")
[All text in this script block where the `set` rule was called will be in Bahnschrift]
}
#set text(font: "Comic Sans MS")
All text after the `#set` rule is now in Comic Sans
ah well the bot doesn't know the fonts
this is how that code looks for me
same thing with the size argument
?r
#let large = text.with(size: 30pt)
This text has the default font size
#large[This text is a little bigger]
#{
set text(size: 10pt)
[Text inside this block where `set` was applied to the text is a little smaller]
}
#set text(size: 40pt)
All text after this `set` rule is a lot bigger
Also see this: https://typst.app/docs/guides/guide-for-latex-users/#rules
Just as a comment: I guess the paradigm of "one serif font, one sans-serif font and one monospace font" is really a (La)TeX quirk. Depending on your design, you can choose to use a single font for headings and text, or two different sans-serif fonts, one for each. Typst just doesn't take over that aspect of LaTeX.
What you do want to have is the option of formatting different types of content (like headings, links or table cells) differently and uniformly, and that's what rules are for.
Just a comment too: it's not a quik, it's good typographic practice. For all other smear you can use Word etc. The documents will be not better. I think it's more complicated to change font style in typst than in LaTeX.
I think it's more complicated to change font style in typst than in LaTeX.
I think it is simpler to set the font style in Typst and OpenType fonts work right out of the box.
You just use the text() function in any of its forms. And you can always specify the exact font you want to use. And you can set a default whenever you want. And you can override as you need. Typst easily allows you to define commands like you use in LaTeX if that is what you want.
Or even better, set a defaults to all parts of the document as you wish (headings in one style, paragraphs in another, captions in another and so on). So you can just provide the structure and Typst does the rest. No restrictions at all. If you want to use just one or two typefaces, you can do so,.
Also, all text styles are set using the same text() command as opposed to LaTeX. You want to change font? Use text(). Size? Use text(). Switch to old-style figures? Use text(). Change font weight? Use text(). Very simple, it is all in the same command.
Thank you Ragaga, I have no idea to change from Libertinus (Serif) to Libertinus Sans. My font is Libertinus and in use is Serif, but how can I change? "#set text(style: sans) " doesn't work., sans is not known.
Okay, I found a way ...
Yea, you need to know the exact font family name and pass it to the text() function like text(font: "Comic Neue"). That only works if you have that particular font installed. And if you use the web app, it already has a nice set of fonts available and even suggests them when you are setting that property and you can just auto-complete them. Locally you might have a totally different set of available fonts.
See the documentation here: https://typst.app/docs/reference/text/text/
And also read through the tutorial: https://typst.app/docs/tutorial/ It also covers changing the text styling.
That style property you first used is used for different thing, see the doc page: https://typst.app/docs/reference/text/text/#parameters-style
It can be used to set italic style, for example.
?r
This is normal. #text(style: "italic")[This is italic.]