Skip to content

Commit

Permalink
Feat/improved captions (#37)
Browse files Browse the repository at this point in the history
* feat: Bold figure caption

* feat: Revert table captions to bottom placement

* feat: List spacing

* fix: Add missing context
  • Loading branch information
otytlandsvik authored Nov 24, 2024
1 parent 4897b2f commit ee613a3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
54 changes: 45 additions & 9 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,29 @@
let h1 = counter(heading).get().first()
numbering("1.1", h1, n)
})

set figure.caption(separator: [ -- ])

// Place table captions above table
show figure.caption: c => {
if c.numbering == none {
c
} else {
text(weight: "bold")[
#c.supplement #context c.counter.display(c.numbering)
]
c.separator
c.body
}
}

// -- Tables --

// Break large tables across pages.
show figure.where(kind: table): it => {
set figure.caption(position: top)
// Break large tables across pages.
set block(breakable: true)
it
}

// -- Tables --

// Use lighter gray color for table stroke
set table(
inset: 7pt,
Expand All @@ -505,17 +516,42 @@

// Show a small maroon circle next to external links.
show link: it => {
// Workaround for ctheorems package so that its labels keep the default link styling.
if type(it.dest) == label {
return it
}
it
h(1.6pt)
super(
box(height: 3.8pt, circle(radius: 1.2pt, stroke: 0.7pt + rgb("#993333"))),
)
}

// -- Lists --

let list-spacing = 18pt
let nested-list-spacing = 12pt
set enum(indent: list-spacing, spacing: list-spacing)
set list(indent: list-spacing, spacing: list-spacing)
let show-list-enum(it) = {
// Reduce spacing for nested list
set enum(indent: nested-list-spacing, spacing: nested-list-spacing)
set list(indent: nested-list-spacing, spacing: nested-list-spacing)
// Reduce top and bottom padding for nested list
let padding-y = {
if it.spacing == list-spacing {
v(list-spacing / 2)
} else {
v(1pt)
}
}
padding-y
it
padding-y
}
show enum: it => {
show-list-enum(it)
}
show list: it => {
show-list-enum(it)
}

// -- Front matter --

// Display front page
Expand Down
5 changes: 3 additions & 2 deletions template/chapters/typst-basics.typ
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ As with headings, typst has syntactic sugar for lists so that we can use simple
- One list item
- Another list item
- A sub-item
- Another sub-item

...as well as ordered lists:
1. A numbered list item
2. Another one
+ A numbered list item
+ Another one
- Sub-items can go here too

== Other Nifty Features <subsec:nifty>
Expand Down
Binary file modified template/thesis.pdf
Binary file not shown.

0 comments on commit ee613a3

Please sign in to comment.