How do I change the size of raw text?

Here are some pro-tips.

You probably noticed that your code highlighting doesn’t look right, this is because you need to add typ language (or typc for code/typm for math). I believe it is shown the first time a user writes a post/comment.

```typ
Your Typst example.
```

To write a code block in Typst and show it in a code snippet on the forum, just use a greater amount of backticks, i.e.:

````typ
Code block:

```py
print()
```
````

It looks like using just a different amount of backticks doesn’t work, since you can’t use 4 backticks wrapped in 3 backticks. (To write the example above, I used 5 backticks to wrap the code snippet in a code block.)

For any show-set rules you don’t have to wrap inner set rule in a closure, like

#show raw: r => {
  set text(size: 15pt, purple)
  r
}

If you see this pattern, then simply drop the closure part:

#show raw: set text(size: 15pt, purple)
// Or a more narrow selector:
#show raw.where(block: true): set text(size: 15pt, purple)

Since text.size is a bit special, you can drop the size: part as well, if you like it more this way:

#show raw: set text(15pt, purple)

There is already an inline raw function, but if you need to use it on context:

#let my-raw = text.with(font: "Fira Code") // Monospaced font
#my-raw[content]
#my-raw("or string")
#raw("string-only")

Note that line spacing and font size settings (and some others) will be different between my-raw and raw.

I hope you will use this tips in your future posts to make them even better! :)

You can even try using some of them to improve your post.

@Tobias_Andersson_Gid, I’m sure you will find these useful too.

2 Likes