I’m gonna give a quick overview of the context, so it’s easier to see the issue.
I have a simple project in the root directory there are 3 folders and the main typst file. In folder called modules there is misc.typ that looks like this:
#let capitalize_first(s) = s.replace(s, upper(s.first())+s.trim(s.first()), )
#let heading(label_name, text) = [
\
#label(label_name)
=== #text
\
]
#let sort-section(name) = [
#let label_name = name+"-sort"
#label(label_name)
=== #capitalize_first(name) Sort
#let filename = "../sorts/" + name + ".typ"
#include filename
]
#let contents-point(name, width) = [
#let label_name = name+"-sort"
#let point_content = capitalize_first(name) + " Sort"
#h(width*10pt) -- #link(label_name)[#point_content] \
]
And in the main file I have something like this:
#import "modules/misc.typ" as misc
#set text(font: "FiraCode Nerd Font", size: 10pt)
#let sort-names = (
"bogo",
"quick",
"merge",
"heap",
"insert",
"bubble",
"select",
"counting",
"radix",
"shell",
"tim",
)
= Basic Algorithms
\
Contents:\
\
#link(<sorting-algorithms>)[Sorting Algorithms] \
#for name in sort-names {
misc.contents-point(name, 1)
}
However the links don’t work, I think it’s because the #link is not dynamic.
Almost forgot, but the labels for the links are also made kind of using the misc.typ file function but when i hard coded it in the main file like this:
#link(<sorting-algorithms>)[Sorting Algorithms] \
#h(10pt) -- #link(<bogo-sort>)[Bogo Sort] \
#h(10pt) -- #link(<quick-sort>)[Quick Sort] \
#h(10pt) -- #link(<merge-sort>)[Merge Sort] \
#h(10pt) -- #link(<heap-sort>)[Heap Sort] \
#h(10pt) -- #link(<insert-sort>)[Insert Sort] \
#h(10pt) -- #link(<bubble-sort>)[Bubble Sort] \
#h(10pt) -- #link(<select-sort>)[Select Sort] \
#h(10pt) -- #link(<counting-sort>)[Counting Sort] \
#h(10pt) -- #link(<radix-sort>)[Radix Sort] \
#h(10pt) -- #link(<shell-sort>)[Shell Sort] \
#h(10pt) -- #link(<tim-sort>)[Tim Sort] \
everything worked. Is there some sort of other workaround? Some other function?