davidc
davidc

Reputation: 91

How can I create a horizontal rule (similar to `\rule{len}{width}`in LaTeX) in Typst?

I'm migrating from LaTeX to Typst and I am trying to find a function that will give me a fill-in-the-blank horizontal rule that is equivalent to the LaTeX macro \rule{20pt}{1pt}

I can use something akin to this:

This $underline("           ")$ day of September

However, I'd like to be able to specify a length (e.g. 20pt) or a number of spaces to determine the line's width.

Upvotes: 1

Views: 124

Answers (1)

ntjess
ntjess

Reputation: 1470

Typst offers the line function for this purpose:

This #box(line(length: 20pt)) day of September

program output

You can provide additional stroke settings to change the line thickness/color/etc.

Note that a box is placed around the line, otherwise it will appear in its own paragraph. box allows block elements (content that creates its own "block" of text") to be rendered in-line with surrounding text.

Upvotes: 2

Related Questions