最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

quarto - Color header and footer in Typst - Stack Overflow

programmeradmin1浏览0评论

I want to style the header and footer of the page with some color. Currently, the page has the color of offwhite, which is what I want, but I want the header and footer space to have color. In the online documentation, I see I can use rect and specify color in fill, but that's not working.

rect (rect(
  width: 100%,
  height: 100%,
  fill: aqua)) 
#let title-page(title: none, author: none,
  date: none, name: none, body) = {
  
  set page(fill: rgb("#20746c"), margin: (top: 1.5in, rest: 1.5in))
  set text(font: "Source Sans Pro", size: 14pt)
  set heading(numbering: "1.1.1")
  line(start: (0%, 0%), end: (8.5in, 0%), stroke: (thickness: 2pt))
  
  align(center)[
    #text(size: 48pt, fill: white, strong(title)) 
    #v(1em)
    #text(size: 24pt, fill: white, strong(name))
    #v(1em)
    #text(size: 24pt, author) 
    #v(2em)
    #text(size: 16pt, date)
  ]
  
//   align(bottom)[
//   #line(start: (0%, 0%), end: (8.5in, 0%), stroke: (thickness: 2pt))
// ]


  pagebreak()
  set page(fill: rgb("#F2F0EF"), margin: auto, 
  rect(
  width: 100%,
  height: 100%,
  fill: aqua))
  

  align(horizon, outline(indent: auto))
  
  body
}

I've tried doing this but this isn't working.

#set page(
  background: (
    box(fill: blue, width: 100%, height: 2cm, y: 100% - 2cm),  // Top bar
    box(fill: blue, width: 100%, height: 2cm, y: 0cm),  // Bottom bar
  )
)

I want to style the header and footer of the page with some color. Currently, the page has the color of offwhite, which is what I want, but I want the header and footer space to have color. In the online documentation, I see I can use rect and specify color in fill, but that's not working.

rect (rect(
  width: 100%,
  height: 100%,
  fill: aqua)) 
#let title-page(title: none, author: none,
  date: none, name: none, body) = {
  
  set page(fill: rgb("#20746c"), margin: (top: 1.5in, rest: 1.5in))
  set text(font: "Source Sans Pro", size: 14pt)
  set heading(numbering: "1.1.1")
  line(start: (0%, 0%), end: (8.5in, 0%), stroke: (thickness: 2pt))
  
  align(center)[
    #text(size: 48pt, fill: white, strong(title)) 
    #v(1em)
    #text(size: 24pt, fill: white, strong(name))
    #v(1em)
    #text(size: 24pt, author) 
    #v(2em)
    #text(size: 16pt, date)
  ]
  
//   align(bottom)[
//   #line(start: (0%, 0%), end: (8.5in, 0%), stroke: (thickness: 2pt))
// ]


  pagebreak()
  set page(fill: rgb("#F2F0EF"), margin: auto, 
  rect(
  width: 100%,
  height: 100%,
  fill: aqua))
  

  align(horizon, outline(indent: auto))
  
  body
}

I've tried doing this but this isn't working.

#set page(
  background: (
    box(fill: blue, width: 100%, height: 2cm, y: 100% - 2cm),  // Top bar
    box(fill: blue, width: 100%, height: 2cm, y: 0cm),  // Bottom bar
  )
)
Share Improve this question edited Mar 17 at 12:50 Karma 5992 gold badges6 silver badges23 bronze badges asked Mar 14 at 3:02 PssPss 6631 gold badge6 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The page function has two parameters: header and footer. You can customize them by these two parameters.

A simple example is:

#set page(
  margin: (top: 40pt, bottom: 40pt),
  header: [
    #rect(
      fill: yellow,
      width: 100%,
      height: 100%
    )[
      Header in yellow block
    ]
  ],
  footer: [
    #rect(
      fill: red,
      width: 100%,
      height: 100%
    )[
      Footer in red block
    ]
  ]
)

#lorem(1000)


The rect function has an outset parameter, which can expand its size.

#set page(
  margin: (top: 40pt, bottom: 40pt),
  header: [
    #rect(
      fill: yellow,
      width: 100%,
      height: 100%,
      outset: 20%
    )[
      Header in yellow block
    ]
  ],
  footer: [
    #rect(
      fill: red,
      width: 100%,
      height: 100%,
      outset: 20%
    )[
      Footer in red block
    ]
  ]
)

#lorem(1000)

Here is the example in web app: https://typst.app/docs/reference/layout/page/#parameters-footer

发布评论

评论列表(0)

  1. 暂无评论