Change the par example to underline

This commit is contained in:
Andrew Voynov 2025-03-04 14:33:39 +03:00
parent ec487298f7
commit 04055182bb
No known key found for this signature in database
GPG Key ID: 1BE92DD685700329

View File

@ -13,21 +13,12 @@ your report using Typst's styling system.
As we have seen in the previous chapter, Typst has functions that _insert_ As we have seen in the previous chapter, Typst has functions that _insert_
content (e.g., the [`image`] function) and others that _manipulate_ content that content (e.g., the [`image`] function) and others that _manipulate_ content that
they received as arguments (e.g., the [`align`] function). The first impulse you they received as arguments (e.g., the [`align`] function). The first impulse you
might have when you want, for example, to justify the report, could be to look might have when you want, for example, to underline text with dotted line, could
for a function that does that and wrap the complete document in it. be to look for a function that does that and wrap the desired text in it.
```example ```example
= Background Let's make a #underline(stroke: (dash: "dotted"))[simple] sentence example
#par(justify: true)[ and use it #underline(stroke: (dash: "dotted"))[here].
In the case of glaciers, fluid
dynamics principles can be used
to understand how the movement
and behaviour of the ice is
influenced by factors such as
temperature, pressure, and the
presence of other fluids (such as
water).
]
``` ```
Wait, shouldn't all arguments of a function be specified within parentheses? Why Wait, shouldn't all arguments of a function be specified within parentheses? Why
@ -37,27 +28,19 @@ do in Typst, there is special syntax for it: Instead of putting the content
inside the argument list, you can write it in square brackets directly after the inside the argument list, you can write it in square brackets directly after the
normal arguments, saving on punctuation. normal arguments, saving on punctuation.
As seen above, that works. The [`par`] function justifies all paragraphs within As seen above, that works. The [`underline`] function draws a dotted line under
it. However, wrapping the document in countless functions can quickly become the text. However, wrapping the document in countless functions (or just a
cumbersome. single bulky one) can quickly become cumbersome.
Fortunately, Typst has a more elegant solution. With _set rules,_ you can apply Fortunately, Typst has a more elegant solution. With _set rules_, you can apply
style properties to all occurrences of some kind of content. You write a set style properties to all occurrences of some kind of content. You write a set
rule by entering the `{set}` keyword, followed by the name of the function whose rule by entering the `{set}` keyword, followed by the name of the function whose
properties you want to set, and a list of arguments in parentheses. properties you want to set, and a list of arguments in parentheses.
```example ```example
#set par(justify: true) #set underline(stroke: (dash: "dotted"))
= Background Let's make a #underline[simple] sentence example and use it #underline[here].
In the case of glaciers, fluid
dynamics principles can be used
to understand how the movement
and behaviour of the ice is
influenced by factors such as
temperature, pressure, and the
presence of other fluids (such as
water).
``` ```
<div class="info-box"> <div class="info-box">