How do I fix the warning “counter.display without context is deprecated

New to typst,

when defining the appendix function:

// Define the appendix function
#let appendix = it => {
  appendix_counter.step(); // Increment the counter
  heading(numbering:none , supplement: "Appendix")[
    A#lower[ppendix] 
    #appendix_counter.display("A.")  #swiggly line here
    #h(5pt)
    #it
  ]
}

I keep getting this error:

caused this warning:
`counter.display `without context is deprecated

Use it in a `context` expression instead

What should I do?

Hello @This_isYE, please update your question your topic! I think something like “How do I fix the warning “counter.display without context is deprecated””? should do.

The fix is simple, you use a context expression!

#context appendix_counter.display("A.")

P.S.: don’t hesitate to provide a reproducible example, for example, your code is missing the variable appendix_counter. Removing any unnecessary parts of your code to produce a minimal example also helps.

Sorry for the nuisance, first time here,

How do I reproduce my issue here(how to run typst in question or reply ) ?

It is absolutely not a nuisance, sorry if I sounded harsh. I meant to give you advice on how to best receive an answer promptly!

You cannot run Typst on the forum, what I meant is that you should provide code that can run standalone. Basically, copy paste what you wrote in an editor and see if it compiles. If it does not, remove unnecessary elements that are not relevant to the question.

Don’t hesitate to ask more questions if you need to!

2 Likes

okey, so code is this(with your fix):

//defining rules and whatnot
....
// Define the appendix function
#let appendix = it => {
  appendix_counter.step(); // Increment the counter
  heading(numbering:none , supplement: "Appendix")[
    A#lower[ppendix] 
    #context appendix_counter.display("A.") 
    #h(5pt)
    #it
  ]
}

//body goes here

//example of appendix
#appendix[Global Result]
        #line(length: 100%, stroke: 0.7pt)

Result (this is an image, i still do not know how to make code run here

when calling outline it shows like this:

 #outline()

is there a way to get the A in appendix A to show also in the outline

Unfortunately, I cannot reproduce your issue with the outline, it shows up on my side.

can you provide code?