How can I adjust the heading style only for specific sections?

Hello,
I’d like to know how to make my “Introduction” and “Conclusion” parts have a specific heading. I’ve defined a manual style for the different chapters:

#show heading.where(level: 1): it => {
  place(top + right, dy: -4cm, line(
    length: 7.5cm,
    stroke: 2pt + maroon,
    angle: 90deg),)
    pad(top: 2cm, left: -1cm, right: 10pt, place(top + right, text(font: "Calibri", black, hyphenate: false,  it.body)))
    pad(top: 0.5cm, 10pt, place(top + right, dx: 0cm, dy: -3cm, text(15pt, font: "Calibri", "Chapter")))
    place(top + right, dx: 1.5cm, dy: 1cm, text(50pt, font: "Calibri", weight: "regular", context(counter(heading).get().first())))
    v(2cm)}

I’d like not to write “Chapter” nor the number (context(counter(heading).get().first()) for the introduction and conclusion.

Merci :slight_smile:
fdekerm

Generally, you would do this by setting the numbering attribute on Introduction and Conclusion to none.

Here’s the basic idea without any custom styling:

#set heading(numbering: "1.1")
// By default, numbers are displayed:
= Design
// Here, we explicitly remove it:
#heading(numbering: none)[Conclusion] 

Now, with your show-rule, the basic idea is the same, but you will need to check whether any numbering was provided:

#set heading(numbering: "1.1")

#show heading.where(level: 1): it => {
  set text(font: "Calibri")

  place(
    top + right,
    dy: -4cm,
    line(
      length: 7.5cm,
      stroke: 2pt + maroon,
      angle: 90deg,
    ),
  )
  pad(
    top: 2cm,
    left: -1cm,
    right: 10pt,
    place(top + right, text(fill: black, hyphenate: false, it.body)),
  )

  if it.numbering != none {
    pad(
      top: 0.5cm,
      10pt,
      place(
        top + right,
        dx: 0cm,
        dy: -3cm,
        text(15pt)[Chapter],
      ),
    )
    place(
      top + right,
      dx: 1.5cm,
      dy: 1cm,
      text(
        50pt,
        weight: "regular",
        counter(heading).display(it.numbering),
      ),
    )
  }

  v(2cm)
}

#heading(numbering: none)[Introduction]

#pagebreak()
= Design
1 Like

Thanks a lot, it works perfectly, even in the outline!