Typst basics
07 Feb 2024This 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
- Images
- Captions, labels, and references
- Citing sources
- Quotes
- Lists
- Accents
- Paragraphs and newlines
- Unbreakable space
- Listings
- Math
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:
- The caption is the description that appears under (or above) an image.
- The label is an unique id that can be used to reference that image with
@ref.
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-idQuotes
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 3Accents
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.