Chic-header (chic-hdr) is a Typst package for creating elegant headers and footers
To use this library through the Typst package manager (for Typst 0.6.0 or greater), write #import "@preview/chic-hdr:0.4.0": *
at the beginning of your Typst file. Once imported, you can start using the package by writing the instruction #show: chic.with()
and giving any of the chic functions inside the parenthesis ()
.
Important: If you are using a custom template that also needs the #show
instruction to be applied, prefer to use #show: chic()
after the template's #show
.
For example, the code below...
#import "@preview/chic-hdr:0.4.0": *
#set page(paper: "a7")
#show: chic.with(
chic-footer(
left-side: strong(
link("mailto:[email protected]", "[email protected]")
),
right-side: chic-page-number()
),
chic-header(
left-side: emph(chic-heading-name(fill: true)),
right-side: smallcaps("Example")
),
chic-separator(1pt),
chic-offset(7pt),
chic-height(1.5cm)
)
= Introduction
#lorem(30)
== Details
#lorem(70)
...will look like this:
Note: For a detailed explanation of the functions and parameters, see Chic-header's Manual.pdf.
While using #show: chic.with()
, you can give the following parameters inside the parenthesis:
width
: Indicates the width of headers and footers in all the document (default is100%
).skip
: Which pages must be skipped for setting its header and footer. Other properties changed withchic-height()
orchic-offset()
are preserved. Giving a negative index causes a skip of the last pages using last page as index -1(default is()
).even
: Header and footer for even pages. Here, onlychic-header()
,chic-footer()
andchic-separator()
functions will take effect. Other functions must be given as an argument ofchic()
.odd
: Sets the header and footer for odd pages. Here, onlychic-header()
,chic-footer()
andchic-separator()
functions will take effect. Other functions must be given as an argument ofchic()
...functions()
: These are a variable number of arguments that corresponds to Chic-header’s style functions.
chic-header()
- Sets the header content.v-center
: Whether to vertically align the header content, or not (default isfalse
).side-width
: Custom width for the sides. It can be an 3-element-array, length or relative length (default isnone
and widths are set to1fr
if a side is present).left-side
: Content displayed in the left side of the header (default isnone
).center-side
: Content displayed in the center of the header (default isnone
).right-side
: Content displayed in the right side of the header (default isnone
).
chic-footer()
- Sets the footer content.v-center
: Whether to vertically align the header content, or not (default isfalse
).side-width
: Custom width for the sides. It can be an 3-element-array, length or relative length (default isnone
and widths are set to1fr
if a side is present).left-side
: Content displayed in the left side of the footer (default isnone
).center-side
: Content displayed in the center of the footer (default isnone
).right-side
: Content displayed in the right side of the footer (default isnone
).
chic-separator()
- Sets the separator for either the header, the footer or both.on
: Where to apply the separator. It can be"header"
,"footer"
or"both"
(default is"both"
).outset
: Space around the separator beyond the page margins (default is0pt
).gutter
: How much spacing insert around the separator (default is0.65em
).- (unnamed): A length for a
line()
, a stroke for aline()
, or a custom content element.
chic-styled-separator()
- Returns a pre-made custom separator for using it inchic-separator()
color
: Separator's color (default isblack
).- (unnamed): A string indicating the separator's style. It can be
"double-line"
,"center-dot"
,"bold-center"
, or"flower-end"
.
chic-height()
- Sets the height of either the header, the footer or both.on
: Where to change the height. It can be"header"
,"footer"
or"both"
(default is"both"
).- (unnamed): A relative length (the new height value).
chic-offset()
- Sets the offset of either the header, the footer or both (relative to the page content).on
: Where to change the offset It can be"header"
,"footer"
or"both"
(default is"both
).- (unnamed): A relative length (the new offset value).
chic-page-number()
- Returns the current page number. Useful for header and footersides
. It doesn’t take any parameters.chic-heading-name()
- Returns the next heading name in thedir
direction. The heading must have a lower or equal level thanlevel
. If there're no more headings in that direction, andfill
istrue
, then headings are sought in the other direction.dir
: Direction for searching the next heading:"next"
(from the current page, get the next heading) or"prev"
(from the current page, get the previous heading). Default is"next"
.fill
: If there's no more headings in thedir
direction, indicates whether to try to get a heading in the opposite direction (default isfalse
).level
: Up to what level of headings should this function search (default is2
).
Header with chic-heading-name()
at left, and chic-page-number()
at right. There's a chic-separator()
of 1pt
only for the header.
Footer with chic-page-number()
at right, and a custom chic-separator()
showing "end of page (No. page)" between 9 ~
symbols at each side.
- Initial release
- Implemented
chic-header()
,chic-footer()
,chic-separator()
,chic-height()
,chic-offset()
,chic-page-number()
, andchic-heading-name()
functions
Thanks to Slashformotion (https://github.com/slashformotion) for noticing this version bugs, and suggesting a vertical alignment for headers.
- Fix alignment error in
chic-header()
andchic-footer()
- Add
v-center
option forchic-header()
andchic-footer()
- Add
outset
option forchic-separator()
- Add
chic-styled-separator()
function
- Add
side-width
option forchic-header()
andchic-footer()
Thanks to David (https://github.com/davidleejy) for being interested in the package and giving feedback and ideas for new parameters
- Update
type()
conditionals to met Typst 0.8.0 standards - Add
dir
,fill
, andlevel
parameters tochic-heading-name()
- Allow negative indexes for skipping final pages while using
skip
- Include some panic alerts for types mismatch
- Upload manual code in the package repository