Skip to content

同一级标题采用不同的格式

同一级标题采用不同的格式

请问, 同一级标题采用不同的格式, 应该看哪里的资料?

建议是搓两个 counter,自己写个函数处理

typst
#let chapter(title) = {
  heading(
    level: 1,
    {
      counter("chapter").step()
      counter("chapter").display("第一章")
      h(0.3em)
      title
    },
  )
}

#let subject(title) = {
  heading(
    level: 1,
    {
      counter("subject").step()
      counter("subject").display("专题一")
      h(0.3em)
      title
    },
  )
}

#chapter("对")
#chapter("对")
#chapter("对")

#subject("好")

#chapter("对")
#chapter("对")

#subject("好")
Typst compiled imageTypst compiled imageTypst compiled image
log
warning: `counter.display` without context is deprecated
  ┌─ <stdin>:8:6

8 │       counter("chapter").display("第一章")
  │       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  = hint: use it in a `context` expression instead

warning: `counter.display` without context is deprecated
   ┌─ <stdin>:20:6

20 │       counter("subject").display("专题一")
   │       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   = hint: use it in a `context` expression instead
What do you think?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v3.5.1

基于 MIT 许可发布