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
1 Answer
Reset to default 1The 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