How to insert an image into the header: Full width, borderless, overlay text

I want to use my company’s header image to create reports and guides as per our CI guide. I have tried out this solution, but didn’t get far with it.

The header I am talking about is a header bar, with a colored 3mm line at the very top, company logo and slogan on the right and some white space to fill with text about 75% of the rest. The header is 2-3cm in height and should fill the full page width of an A4 paper (210mm)

Here is an example of what I have accomplished so far, but as you can see, the header is not present on the title page and it’s misplaced and cut off on the following pages.
Interestingly though it looks different on the table of contents page versus the regular pages after.

How can I get the image into the header, so that it’s flush with the left, right and upper paper border without gaps and the option to put some text over it, like the current heading on the pages?

https://typst.app/project/rpAyYDX06J9t2R6jFoyfoX

Do you want to use the logo/image as is or do you want to add the line and the text with Typst?
If you just want to place the image at the top of the page you can use the background which uses the full width of the page. Since the background is just centered on the page by default, you have to wrap it in align(top, ..).
I also adjusted the top margin of the page to 4cm since the image is too high for the default margin. You should just adjust the spacing to whatever looks best in your opinion.

#set page(
  background: align(top, image("company_a4_header_portrait.png")),
  margin: (top: 4cm)
)

For skipping the title page there are two options. You can either use the page counter as you already did in your example or you can only apply the set rule for the background after the title page.

If you want to place additional text on top of the image, you can wrap the image in a block and use place().

2 Likes

Thank you so much! It is so much easier as I thought it would be!

Could you give an example for the set rule for the background after the title page?

The set rule will be applied starting from its position in the document. Adding the titlepage before the set rule will therefore give you a blank titlepage.

Put your titlepage here...

#set page(
  background: align(top, image("company_a4_header_portrait.png")),
  margin: (top: 4cm)
)

... and the rest of your document here.

This could be a lot more elegant if you create a template that generates the titlepage for you. In that case you would call a global show rule at the start of the document. If this sound interesting, you can check out this tutorial in the docs Making a Template – Typst Documentation.

1 Like