Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing is using "link" instead of "ref" #20

Open
gdahia opened this issue Jan 13, 2024 · 4 comments
Open

Referencing is using "link" instead of "ref" #20

gdahia opened this issue Jan 13, 2024 · 4 comments

Comments

@gdahia
Copy link

gdahia commented Jan 13, 2024

Thanks for the great lib! I am using it a lot for my personal notes and for writing preliminary versions of papers.

That said, I was trying to customize the styling of a template, and realized that referencing for theorems is using the link function instead of the ref function with a custom kind. This makes these references follow the link show rules instead of the ref ones, and so in template customization either we get links with this custom style, or theorem references that do not match the style of the normal text.

I think I figured it out how to do this without changing lemmify by customizing the ref-styling configuration, but I think this changing this inside the core lib might be useful to others. What do you think?

@Marmare314
Copy link
Owner

Hi, thank you! It should be using the ref function:

#import "@preview/lemmify:0.1.5": default-theorems

#let (theorem, rules: thm-rules) = default-theorems("thm-group")
#show: thm-rules

#show ref: text.with(red)
#theorem[Test] <thm>
@thm

and so in template customization either we get links with this custom style, or theorem references that do not match the style of the normal text.

I'm not sure what you mean, can you give an example?

@gdahia
Copy link
Author

gdahia commented Feb 28, 2024

I'm not sure what you mean, can you give an example?

Sure! The following renders "Section 1" in red, but "Theorem 1" in blue:

#import "@preview/lemmify:0.1.5": default-theorems

#let (theorem, rules: thm-rules) = default-theorems("thm-group")
#show: thm-rules

#show ref: text.with(red)
#show link: text.with(blue)
= Introduction
<introduction>
#theorem[Test] <thm>
@thm
@introduction

@Marmare314
Copy link
Owner

Ok so I looked into it and unfortunately I don't think there is much that can be done about this. The problem is that the ref function only accepts a target (ie a label) and a supplement and then basically just displays supplement + counter(label).display() and links this to the target. The problem however is that this package allows custom numberings based on the headings counter, which makes it impossible to use the ref function. So the only solution (I could come up with) is to use link instead, which results in this behaviour.

@gdahia
Copy link
Author

gdahia commented Mar 10, 2024

Perhaps we should take this issue to the maintainers of typst, then? Do you think that there is a good reason for the different behavior in ref and link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants