From c38b71f6d6f7bc74ffc724bf26ae3d47be32bdf3 Mon Sep 17 00:00:00 2001 From: Bauke Date: Tue, 9 Jan 2024 13:29:04 +0100 Subject: [PATCH] Add the icon_with_text utility. --- utilities/icon-with-text.typ | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 utilities/icon-with-text.typ diff --git a/utilities/icon-with-text.typ b/utilities/icon-with-text.typ new file mode 100644 index 0000000..93562c9 --- /dev/null +++ b/utilities/icon-with-text.typ @@ -0,0 +1,15 @@ +#let icon_with_text(icon: "", icon_alt_text: "", icon_size: 1.25em, body) = { + // Use a box for the container so it is rendered inline. + box( + // Then use a grid inside to size and space the icon out perfectly. + grid( + // Take the icon size and add some extra space so it's not rendered + // directly against the text. + columns: (icon_size + 0.2em, auto), + // Render the image with the icon size as the wanted width. + image(icon, width: icon_size, alt: icon_alt_text), + // And finally vertically align the text. + align(horizon, body), + ), + ) +}