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

Make the returning function of thmenv an element function #17

Open
Roseleaves opened this issue Feb 23, 2024 · 4 comments
Open

Make the returning function of thmenv an element function #17

Roseleaves opened this issue Feb 23, 2024 · 4 comments

Comments

@Roseleaves
Copy link

I want to use the #set rule to change the background color of the axioms, however what I can do is only to change the source code where the axiom function is defined.

what the performance is:

#let axiom = thmbox(
  "axiom", "公理",
  inset: (x: 1.2em, top: 0em)
)

#set axiom(fill: rgb("cc99cc"))
@sahasatvik
Copy link
Owner

I don't think that typst supports defining custom element functions yet. What I can do is change the format function of the thmbox; when I get that done, you might be able to use something like this:

#let axiom = thmbox(
  "axiom", "公理",
  inset: (x: 1.2em, top: 0em)
)

#let axiom = axiom.with(fill: rgb("cc99cc"))

@sahasatvik
Copy link
Owner

The update (1.1.1) has gone through; now you can try something like this:

#import "@preview/ctheorems:1.1.1": *
#show: thmrules

#set page(width: 4in, height: auto, margin: 0.5cm)

#let axiom = thmbox(
  "axiom", "公理",
  inset: (x: 1.2em, y: 0.6em),
)

#axiom[
  Things which are equal to the same thing are also equal to one another.
]

#let axiom = axiom.with(fill: rgb("cc99cc"))

#axiom[
  If equals be added to equals, the wholes are equal.
]

// You can also do this now! Set block properties individually.
#axiom(fill: rgb("99cccc"))[
  If equals be subtracted from equals, the remainders are equal.
]

#axiom[
  Things which coincide with one another are equal to one another.
]

axiom

@Roseleaves
Copy link
Author

okay, that is great. I find myself still using the old 0.1.0 version :(
so I see there is a line below in the source code

      [#metadata(identifier) <meta:thmenvcounter>],

so does that means that the reference is auto-created? then how to use? like #link(<def11>) and #link(<ax42>)?

@sahasatvik
Copy link
Owner

You can use the usual <label> and @reference syntax; look at this example or the manual.

Btw, we're currently at version 1.1.2.

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