Hi everyone,
I’m currently using the latest version of the theoretic package, which generally works incredibly well (thanks @nleanba!).
However, I’ve run into a slight issue with my editor workflow. The package uses a syntax where labels are passed as arguments inside parentheses, rather than using standard Typst labels: one writes
#theorem(<thm:name>)[...]
rather than the standard
#theorem[...] <thm:name>
Because of this, the labels don’t show up in the Tinymist label view in VS Code.
Does anyone have any good workarounds to get Tinymist to recognize these custom labels, or is there an alternative way to write them so both the package and the extension pick them up?
Thanks in advance.
Hello @isabeldahlgren,
Welcome to the forum.
If I understand correctly, you get this in Tinymist:
while using some code like:
#import "@preview/theoretic:0.3.1"
#import theoretic.presets.basic: *
#show ref: theoretic.show-ref
#theorem(<no-label-in-tinymist>)[Title][Body]
TL;DR
- Tinymist seems to only list labels that are referenceable and not standalone.
- The
theoretic package uses a trick to create referenceable labels with metadata.
- Tinymist does not seem to catch that and does not display the label in the LABEL box.
- The package
theorion supports referenceable labels (through custom figures I presume).
More in Depth Explanation
More in Depth Explanation
Here is a MWE that I believe will reproduce what you are explaining:
#import "@preview/theoretic:0.3.1"
#import theoretic.presets.basic: *
#show ref: theoretic.show-ref
#theorem(<label>)[Title][Body]
As per @label ... or @label[!] or @label[--]
Note that the theoretic package documentation explains the way that labels are handled and the various options the user has to display the references. Worth citing:
NB: Simply putting a <label> after the #theorem[] does not work for referencing
If you try it, Tinymist will display the label in the LABEL box it but the reference won’t work (Typst will raise cannot reference sequence).
#theorem(<no-theoretic>)[Title][Body]<yes-but-broken>
Without digging into the theoretic package code, it seems that label is handled internally using a trick to reference labels with metadata:
Regarding Tinymist, it seems to include only labels that are referenceable as per the typst documentation.
This other example represents the situation:
#import "@preview/theoretic:0.3.1"
#import theoretic.presets.basic: *
#show ref: theoretic.show-ref
#set heading(numbering: "1")
#set math.equation(numbering: "1")
= Heading <yes-heading>
#figure(rect(), caption: [My Figure])<yes-figure>
$x+y$<yes-equation>
#footnote([Footnote])<yes-footnote>
*Strong* #label("no-standalone")
#theorem(<no-theoretic>)[Title][Body]
#show ref: it => {
if it != none and it.element.func() != metadata { return it; }
link(it.element.location(), quote(it.element.value))
}
#let my-block(title: [], label: none, body) = [#metadata(title)#label] + block({
strong(title)
h(1em, weak: true)
body
})
#my-block(title: [Foo], label: <no-metadata>, lorem(20))
One solution I could see for theoretic would be to use a custom figure instead of metadata, but I really haven’t looked at the code so this is more like a supposition.
Perhaps this Tinymist LABEL section should be named REFERENCE instead?
In any case, you could contact the respective authors @nleanba or @Myriad-Dreamin for more information, to report an issue or to request a new feature.
2 Likes
Using figures is deliberately not what I’m doing, as this has other side-effects. As soon as proper custom elements land in Typst, this should all get easier.
I feel like this is something that could be fixed more easily from the Tinymist side, not from the Theoretic side. For comparison, the Typst web-app successfully autocompletes the labels of theorems, so this should be possible for Tinymist to to also.
In fact, as far as I can tell tinymist explicitly disregards all labels in “code mode”: See tinymist/crates/tinymist-query/src/syntax/lexical_hierarchy.rs at 9a22ad48636312f2134a0ca07683ba3b4a424252 · Myriad-Dreamin/tinymist · GitHub
This means that the following label does show up in tinymist, even though it is not attached to anything at all: (and also not referenceable.
#[<yes-label-in-tinymist>]
Tinymists autocompletion works fine though, but the label view is weird:
#metadata("blah")<also-yes>
#metadata("blub")#label("this-one-doesnt-show-up")
#figure(rect())<figure-yes>
#figure(rect())#label("figure-no")
Both of the above are referenceable: @figure-yes or @figure-no.
but

I have experimented with making it so that #theorem[...]<thm:name> would also work (with similar tricks as I did for Marginalia) but this is very fragile and can very quickly lead to the document not converging.
4 Likes
Hi @nleanba and @vmartel08, thanks for your detailed responses – I understand! And yes, that’s right about the “Label” sidebar being empty, but theorem referencing working.