Back

Typst basics

This is a continuation of the good LaTeX beginner guide, and is a collection of how to format simple things in Typst, mostly stuff that a novice may miss. It's to be used mostly as a simple guide or reference, especially when getting started.

Contents:

Basic formatting

Example:

_italic_
*bold*
`monospace`
#underline[underline]

Images

Use the following snippet to insert images

#figure(
  image("path/to/image", width: 80%),
  caption: [Description of the image]
) <fig:unique-name>

Captions, labels, and references

Remember this:

Labels can also be given to code listings, sections, subsections, tables, and so on.

Example:

= Lorem ipsum <sec:lorem-ipsum>

As seen in @fig:figure-x and as described
in @sec:lorem-ipsum.

What you're referencing (section, figure, and so on) is done automatically.

Citing sources

It's exactly the same as the previous section, so you use @id to cite some source.

You can use BiBTex!

If you have a bib file like this

@article{article-id,
  title = {Article title},
  author = {John Smith},
  year = {2013},
}

Then you can cite it like

@article-id

Quotes

You can just use ' and " directly.

Lists

Choose between numbered and non-numbered lists.

// Non-numbered lists
- Item 1
- Item 2
- Item 3

// Numbered lists
+ Item 1
+ Item 2
+ Item 3

Accents

Use directly the normal accents, e.g., È, é, and so on.

Paragraphs and newlines

Use a double newline to introduce a new paragraph. The new paragraph is often indented. Use \ to force a newline inside a paragraph.

Unbreakable space

As in LaTeX, the character ~ is an unbreakable space. This means that a~b appears the same as a b, but the two won't break over different lines.

Listings

Listings are used to show code. You can use a triple backtick as in markdown with the language name.

Math

To insert math you have to go into math mode. You can just use $ ... $ to insert math, either inline or in a block.

Once in math mode, you can do a lot of things.