Skip to content

"error: unknown variable" if variable is used inside #include #4952

Answered by jamesrswift
jsx97 asked this question in Q&A
Discussion options

You must be logged in to vote

Each typst file exists in its own scope, and does not bring with it any definitions when included. I'd recommend creating a file that defines functions you intend to reuse:

/// preamble.typ
#let pseudoheading(body) = {
  set align(center)
  set par(justify: false)
  smallcaps(body)
}

and import it from your file

/// include.typ
#import "preamble.typ": pseudoheading

#pseudoheading[
  Lorem ipsum dolor sit ametxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, consectetur adipiscing elit
]

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by jsx97
Comment options

You must be logged in to vote
2 replies
@jsx97
Comment options

@hurzl
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants