Typst - cunhapaulo/ReferenceCard GitHub Wiki

Oficial Tutorials and Documentation

Equivalent

  // The following syntaxes are equivalent
  #let f = (name) => "Hello, " + name
  #let f(name) = "Hello, " + name

Functions

#let enfase(objeto, fill: color.yellow) = {
  set text(style: "normal", weight: 600, fill: black)
  // rect(emph(objeto), fill: color.linear-rgb(250, 220, 55, 90), stroke: none, radius: (left:5pt, right:5pt))

  highlight(objeto,
      stroke: fill,
      radius: (left:5pt, right:5pt), 
      fill: fill,
      extent: 3pt
    )
}

#show cite: set text(blue)
// #show heading: set text(blue)

#show "mídias sociais" : enfase("mídias sociais", fill: color.yellow.lighten(50%))
#show "democracias liberais" : enfase("democracias liberais", fill: color.blue.lighten(80%))

Basic Page Styling

Command Description
#set page(paper: "a4, width: 15cm, margin: (left: 4cm, right: 4cm), numbering: "1") Defines page characteristics.
#set heading(numbering: "1.1") Defines section enumeration style.
#set par(first-line-indent: 1.5cm, justify: true) Defines paragraph characteristics.
#set list(indent: 1em)
#set enum(indent: 1em)

Some Interesting Functions

Here you can find the official list of Typst functions: Typst Official Reference

In Typst functions are called with the sign #.

Function Syntax Description Example
#outline() Generates a table of contents (like LaTeX)
#highlight[important] Highlights text with a background color image
#loren(50) Generates example text image
#link("https://typst.app/")[Typst] Link to something https://typst.app/
#[This is a content type] Creates a content type object and takes you out of code sections
#set ... Defines a rule for some other functions #set page(width: 15cm, margin: (left: 4cm, right: 4cm))
#set par(justify: true)

Lists with letters

#set enum(numbering: "a)")

+ A vulnerabilidade das instituições democráticas aos ataques digitais, [...]
+ A lógica algorítmica das plataformas, que favorece conteúdos polarizadores, [...]
+ A concentração de poder nas mãos de um número reduzido de corporações tecnológicas globais, [...]

image

Citation:

#cite(<Mounk2019>, form: "normal", supplement: "p.57");
@Mounk2019[p. 47];
Typst Result
#cite(<Mounk2019>, form: "normal", supplement: "p.57"); image
@Mounk2019[p. 47] image

Conversões LaTeX - Typst

LaTeX Typst
\vfill #v(1fr)
\section*{...} #heading(numbering: none)[somehting]
#let nonumhead = heading.with(numbering: none)
#let nonumhead(..args) = heading(numbering: none, ..args)
\onehalfspace set par(leading: 1.55em - 0.65em)
\simplespace #set par(leading: 0.5em)

Mesures

#let thing(body) = style(styles => {
  let size = measure(body, styles)
  [Width of "#body" is #size.width]
})

#thing[Hey] \
#thing[Welcome]

Resultado:

image

Figures

@tiger shows a tiger. Tigers
are animals.

#figure(
  image("../tiger.jpg", width: 80%),
  caption: [A tiger.],
) <tiger>

Resultado:

image

Inserir uma figura com legenda

#figure(
  image("finish.jpg", width: 70%),
  caption: [
   Linha de _chegada_.
  ],
)

Resultado:

image

Inserir um texto como figura

They told me to write a letter to you. Here it is:

#figure(
  text(size: 5em)[I],
  caption: [I'm cool, right?],
) 

Resultado:

image

Tabela

#set text(10pt, style: "italic")
#let cell = rect.with(
  inset: 8pt,
  fill: rgb("e4e5ea"),
  width: 100%,
  radius: 6pt
)
#grid(
  columns: (60pt, 1fr, 60pt),
  rows: (60pt, auto),
  gutter: 3pt,
  cell(height: 100%)[Easy to learn],
  cell(height: 100%)[Great output],
  cell(height: 100%)[Intuitive],
  cell[Our best Typst yet],
  cell[
    Responsive design in print
    for everyone
  ],
  cell[One more thing...],
)

Resultado:

image

Cabeçalho da Página

#set page(
  paper: "us-letter",
  header: align(right)[
    A fluid dynamic model for
    glacier flow
  ],
  numbering: "1",
)
#set par(justify: true)
#set text(
  font: "Linux Libertine",
  size: 11pt,
)

#lorem(600)

Resultado:

image

DUAS COLUNAS

#grid(
  columns: (1fr, 1fr),
  align(center)[
    Therese Tungsten \
    Artos Institute \
    #link("mailto:[email protected]")
  ],
  align(center)[
    Dr. John Doe \
    Artos Institute \
    #link("mailto:[email protected]")
  ]
)

Resultado:

image

Multiplas Colunas

  #show: rest => columns(2, rest)
⚠️ **GitHub.com Fallback** ⚠️