├── example.pdf ├── thumbnail.png ├── .gitignore ├── template ├── refs.bib └── main.typ ├── typst.toml ├── LICENSE ├── CHANGELOG.md ├── README.md └── lib.typ /example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vaibhavs10/ilm/main/example.pdf -------------------------------------------------------------------------------- /thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vaibhavs10/ilm/main/thumbnail.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pdf 2 | *.zip 3 | 4 | # Generated by bibtex-tidy (https://github.com/FlamingTempura/bibtex-tidy) 5 | *.bib.original 6 | -------------------------------------------------------------------------------- /template/refs.bib: -------------------------------------------------------------------------------- 1 | @misc{wikipedia_iosevka, 2 | title = {Iosevka}, 3 | year = 2024, 4 | month = mar, 5 | journal = {Wikipedia}, 6 | url = {https://en.wikipedia.org/w/index.php?title=Iosevka&oldid=1217127968}, 7 | urldate = {2024-06-18}, 8 | copyright = {Creative Commons Attribution-ShareAlike License}, 9 | note = {Page Version ID: 1217127968}, 10 | language = {en} 11 | } 12 | -------------------------------------------------------------------------------- /typst.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ilm" 3 | version = "1.2.1" 4 | compiler = "0.11.0" 5 | entrypoint = "lib.typ" 6 | repository = "https://github.com/talal/ilm" 7 | authors = ["Muhammad Talal Anwar <@talal>"] 8 | license = "MIT-0" 9 | description = "Versatile and minimal template for non-fiction writing. Ideal for class notes, reports, and books" 10 | keywords = ["notes", "script", "report", "book", "novel", "non-fiction", "running footer", "class", "lecture"] 11 | categories = ["book", "report"] 12 | 13 | [template] 14 | path = "template" 15 | entrypoint = "main.typ" 16 | thumbnail = "thumbnail.png" 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 10 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 11 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 12 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 13 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 14 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to 'Ilm will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | 16 | 17 | [unreleased]: https://github.com/talal/ilm/compare/v1.2.1...HEAD 18 | 19 | ## [Unreleased] 20 | 21 | ## 1.2.1 - 2024-08-06 22 | 23 | ### Fixed 24 | - Avoid line break between link text and indicator (circle). 25 | 26 | ## 1.2.0 - 2024-08-01 27 | 28 | ### Added 29 | - `external-link-circle` option for disabling circle next to external links. 30 | 31 | ## 1.1.3 - 2024-07-23 32 | 33 | ### Fixed 34 | - Chapter page breaks when using headings inside of a page container. 35 | 36 | ## 1.1.2 - 2024-06-18 37 | 38 | ### Changed 39 | 40 | - Improved template and `example.pdf`. 41 | 42 | ## 1.1.1 - 2024-05-04 43 | 44 | ### Added 45 | 46 | - Language setting definition in template. 47 | 48 | ### Fixed 49 | 50 | - Removed hardcoded heading for table of contents so that the heading is defined as per 51 | Typst's language settings. 52 | 53 | ## 1.1.0 - 2024-04-11 54 | 55 | ### Changed 56 | 57 | - Use _Libertinus Serif_ font, if available, otherwise fall back to _Linux Libertine_. 58 | 59 | ## 1.0.0 - 2024-04-09 60 | 61 | ### Added 62 | 63 | - `date-format` argument for specifying custom date format. 64 | - `table-of-contents` argument for specifying custom `outline` function for the table of 65 | contents. 66 | 67 | ### Changed 68 | 69 | - Use dictionary for `figure-index`, `table-index`, and `listing-index` arguments and add 70 | title field for specifying custom title. 71 | - Create chapter page breaks inside `body` context. 72 | 73 | ## 0.1.3 - 2024-04-07 74 | 75 | ### Fixed 76 | 77 | - Level 1 headings not being displayed on preface page due to page break inside heading 78 | `show` rule. 79 | 80 | ## 0.1.2 - 2024-03-25 81 | 82 | ### Fixed 83 | 84 | - Check if a heading's `body` has a `text` field before using it. 85 | 86 | ## 0.1.1 - 2024-03-23 87 | 88 | ### Added 89 | 90 | - Running footer demo in template and example. 91 | 92 | ### Changed 93 | 94 | - Footer chapter size from `0.65em` to `0.68em`. 95 | - Start bibliography on a new page regardless of whether `chapter-pagebreak` is set to 96 | `true` or not. 97 | 98 | ### Fixed 99 | 100 | - Use kebab-case for variable and function names. 101 | - Unnecessary `here()` parameter in `query()` usage. 102 | 103 | ## 0.1.0 - 2024-03-22 104 | 105 | Initial Release. 106 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ‘Ilm 2 | 3 | > ‘Ilm (Urdu: عِلْم) is the Urdu term for knowledge. It is pronounced as [/ə.ləm/](https://en.wiktionary.org/wiki/%D8%B9%D9%84%D9%85#Urdu). 4 | 5 | A versatile, clean and minimal template for non-fiction writing. The template is ideal for 6 | class notes, reports, and books. 7 | 8 | It contains a title page, a table of contents, and indices for different types of figures; 9 | images, tables, code blocks. 10 | 11 | Dynamic running footer contains the title of the chapter (top-level heading). 12 | 13 | See the [example.pdf](https://github.com/talal/ilm/blob/main/example.pdf) file to see how it looks. 14 | 15 | ## Usage 16 | 17 | You can use this template in the Typst web app by clicking "Start from template" on the 18 | dashboard and searching for `ilm`. 19 | 20 | Alternatively, you can use the CLI to kick this project off using the command 21 | 22 | ```sh 23 | typst init @preview/ilm 24 | ``` 25 | 26 | Typst will create a new directory with all the files needed to get you started. 27 | 28 | This template uses the [Iosevka] font for raw text. In order to use Iosevka, the font must 29 | be installed on your computer. In case Iosevka is not installed, as will be the case for 30 | Typst Web App, then the template will fall back to the default "Fira Mono" font. 31 | 32 | ## Configuration 33 | 34 | This template exports the `ilm` function with the following named arguments: 35 | 36 | | Argument | Default Value | Type | Description | 37 | | --- | --- | --- | --- | 38 | | `title` | `Your Title` | [content] | The title for your work. | 39 | | `author` | `Author` | [content] | A string to specify the author's name | 40 | | `paper-size` | `a4` | [string] | Specify a [paper size string] to change the page size. | 41 | | `date` | `none` | [datetime] | The date that will be displayed on the cover page. | 42 | | `date-format` | `[month repr:long] [day padding:zero], [year repr:full]` | [string] | The format for the date that will be displayed on the cover page. By default, the date will be displayed as `MMMM DD, YYYY`. | 43 | | `abstract` | `none` | [content] | A brief summary/description of your work. This is shown on the cover page. | 44 | | `preface` | `none` | [content] | The preface for your work. The preface content is shown on its own separate page after the cover. | 45 | | `table-of-contents` | `outline()` | [content] | The result of a call to the [outline function][outline] or none. Setting this to `none` will disable the table of contents. | 46 | | `bibliography` | `none` | [content] | The result of a call to the [bibliography function][bibliography] or none. Specifying this will configure numeric, IEEE-style citations. | 47 | | `chapter-pagebreak` | `true` | [bool] | Setting this to `false` will prevent chapters from starting on a new page. | 48 | | `external-link-circle` | `true` | [bool] | Setting this to `false` will disable the maroon circle that is shown next to external links. | 49 | | `figure-index` | `(enabled: false, title: "Index of Figures")` | [dictionary] | Setting this to `true` will display a index of image figures at the end of the document. | 50 | | `table-index` | `(enabled: false, title: "Index of Tables")` | [dictionary] | Setting this to `true` will display a index of table figures at the end of the document. | 51 | | `listing-index` | `(enabled: false, title: "Index of Listings")` | [dictionary] | Setting this to `true` will display a index of listing (code block) figures at the end of the document. | 52 | 53 | > [!NOTE] 54 | > The language setting for text (`lang` parameter of `text` function) should be defined before the `ilm` function so that headings such as table of contents and bibliography will be defined as per the text language. 55 | 56 | The function also accepts a single, positional argument for the body. 57 | 58 | The template will initialize your package with a sample call to the `ilm` function in a 59 | show rule. If you, however, want to change an existing project to use this template, you 60 | can add a show rule like this at the top of your file: 61 | 62 | ```typ 63 | #import "@preview/ilm:1.2.1": * 64 | 65 | #show: ilm.with( 66 | title: [Your Title], 67 | author: "Max Mustermann", 68 | date: datetime(year: 2024, month: 03, day: 19), 69 | abstract: [#lorem(30)], 70 | bibliography: bibliography("refs.bib"), 71 | figure-index: (enabled: true), 72 | table-index: (enabled: true), 73 | listing-index: (enabled: true) 74 | ) 75 | 76 | // Your content goes below. 77 | ``` 78 | 79 | [iosevka]: https://typeof.net/Iosevka/ 80 | [bibliography]: https://typst.app/docs/reference/model/bibliography/ 81 | [outline]: https://typst.app/docs/reference/model/outline/ 82 | [bool]: https://typst.app/docs/reference/foundations/bool/ 83 | [content]: https://typst.app/docs/reference/foundations/content/ 84 | [datetime]: https://typst.app/docs/reference/foundations/datetime/ 85 | [dictionary]: https://typst.app/docs/reference/foundations/dictionary/ 86 | [paper size string]: https://typst.app/docs/reference/layout/page#parameters-paper 87 | [string]: https://typst.app/docs/reference/foundations/str/ 88 | -------------------------------------------------------------------------------- /template/main.typ: -------------------------------------------------------------------------------- 1 | #import "@preview/ilm:1.2.1": * 2 | 3 | #set text(lang: "en") 4 | 5 | #show: ilm.with( 6 | title: [The Beauty of\ Sharing Knowledge], 7 | author: "Max Mustermann", 8 | date: datetime(year: 2024, month: 03, day: 19), 9 | abstract: [ 10 | 'Ilm (Urdu: #text(lang: "ur", font: ("Noto Nastaliq Urdu", "Noto Naskh Arabic"), size: 0.8em)[عِلْم]) is the Urdu term for knowledge. In its general usage, 'ilm may refer to knowledge of any specific thing or any form of "learning". Subsequently, the term came to be used to refer to various categories of "sciences", especially when used in its plural form ('ulum). 11 | ], 12 | preface: [ 13 | #align(center + horizon)[ 14 | This template is made possible by Matthew Butterick's\ excellent #link("https://practicaltypography.com")[_Practical Typography_] book. 15 | 16 | Thank you Mr. Butterick! 17 | ] 18 | ], 19 | bibliography: bibliography("refs.bib"), 20 | figure-index: (enabled: true), 21 | table-index: (enabled: true), 22 | listing-index: (enabled: true) 23 | ) 24 | 25 | = Text 26 | == External links 27 | 'Ilm adds a small maroon circle to external (outgoing) links #link("https://github.com/talal/ilm")[like so]. 28 | 29 | This acts as a hint for the reader so that they know that a specific text is a hyperlink. This is far better than #underline[underlining a hyperlink] or making it a #text(fill: blue)[different color]. Don't you agree? 30 | 31 | If you want to disable this behavior then you can do so by setting the concerning option to `false`: 32 | 33 | ```typst 34 | #show: ilm.with( 35 | external-link-circle: false 36 | ) 37 | ``` 38 | 39 | == Blockquotes 40 | 'Ilm also exports a `blockquote` function which can be used to create blockquotes. The function has one argument: `body` of the type content and can be used like so: 41 | 42 | ```typst 43 | #blockquote[ 44 | A wizard is never late, Frodo Baggins. Nor is he early. He arrives precisely when he means to. 45 | ] 46 | ``` 47 | 48 | The above code will render the following: 49 | 50 | #blockquote[A wizard is never late, Frodo Baggins. Nor is he early. He arrives precisely when he means to. -- Gandalf] 51 | 52 | == Small- and all caps 53 | 'Ilm also exports functions for styling text in small caps and uppercase, namely: `smallcaps` and `upper` respectively. 54 | 55 | These functions will overwrite the standard #link("https://typst.app/docs/reference/text/smallcaps/")[`smallcaps`] and #link("https://typst.app/docs/reference/text/upper/")[`upper`] functions that Typst itself provides. This behavior is intentional as the functions that 'Ilm exports fit in better with the rest of the template's styling. 56 | 57 | Here is how Typst's own #std-smallcaps[smallcaps] and #std-upper[upper] look compared to the 'Ilm's variants:\ 58 | #hide[Here is how Typst's own ] #smallcaps[smallcaps] and #upper[upper] 59 | 60 | They both look similar, the only difference being that 'Ilm uses more spacing between individual characters. 61 | 62 | If you prefer Typst's default spacing then you can still use it by prefixing `std-` to the functions: ```typst #std-smallcaps()``` and ```typst #std-upper()```. 63 | 64 | == Footer 65 | If a page does not begin with a chapter then we display the chapter's name, to which the current section belongs, in the footer. #link()[Click here] to go to @demo down below and see the footer in action. 66 | 67 | = Figures 68 | The template also displays an index of figures (images), tables, and listings (code blocks) at the end of the document, if you set the respective options to `true`: 69 | 70 | ```typst 71 | #show: ilm.with( 72 | figure-index: (enabled: true), 73 | table-index: (enabled: true), 74 | listing-index: (enabled: true) 75 | ) 76 | ``` 77 | 78 | == Tables 79 | In order to increase the focus on table content, we minimize the table's borders by using thin gray lines instead of thick black ones. Additionally, we use small caps for the header row. Take a look at the table below: 80 | 81 | #let unit(u) = math.display(math.upright(u)) 82 | #let si-table = table( 83 | columns: 3, 84 | table.header[Quantity][Symbol][Unit], 85 | [length], [$l$], [#unit("m")], 86 | [mass], [$m$], [#unit("kg")], 87 | [time], [$t$], [#unit("s")], 88 | [electric current], [$I$], [#unit("A")], 89 | [temperature], [$T$], [#unit("K")], 90 | [amount of substance], [$n$], [#unit("mol")], 91 | [luminous intensity], [$I_v$], [#unit("cd")], 92 | ) 93 | 94 | #figure(caption: ['Ilm's styling], si-table) 95 | 96 | For comparison, this is how the same table would look with Typst's default styling: 97 | 98 | #[ 99 | #set table(inset: 5pt, stroke: 1pt + black) 100 | #show table.cell.where(y: 0): it => { 101 | v(0.5em) 102 | h(0.5em) + it.body.text + h(0.5em) 103 | v(0.5em) 104 | } 105 | #figure(caption: [Typst's default styling], si-table) 106 | ] 107 | 108 | = Code 109 | == Custom font 110 | 'Ilm uses the _Iosevka_@wikipedia_iosevka font for raw text instead of the default _Fira Mono_. If Iosevka is not installed then the template will fall back to Fira Mono. 111 | 112 | #let snip(cap) = figure(caption: cap)[ 113 | ```rust 114 | fn main() { 115 | let user = ("Adrian", 38); 116 | println!("User {} is {} years old", user.0, user.1); 117 | 118 | // tuples within tuples 119 | let employee = (("Adrian", 38), "die Mobiliar"); 120 | println!("User {} is {} years old and works for {}", employee.0.1, employee.0.1, employee.1); 121 | } 122 | ``` 123 | ] 124 | 125 | #show raw: set text(font: "Fira Mono") 126 | For comparison, here is what `code` in Fira Mono looks like: 127 | #snip("Code snippet typeset in Fira Mono font") 128 | 129 | #show raw: set text(font: ("Iosevka", "Fira Mono")) 130 | and here is how the same `code` looks in Iosevka: 131 | #snip("Code snippet typeset in Iosevka font") 132 | 133 | In the case that both code snippets look the same then it means that Iosevka is not installed on your computer. 134 | 135 | = Footer Demo 136 | == Subheading 137 | #lorem(120) 138 | 139 | #lorem(55) 140 | 141 | #lorem(120) 142 | 143 | #pagebreak() 144 | == Subheading Two 145 | #lorem(55) 146 | -------------------------------------------------------------------------------- /lib.typ: -------------------------------------------------------------------------------- 1 | // Workaround for the lack of an `std` scope. 2 | #let std-bibliography = bibliography 3 | #let std-smallcaps = smallcaps 4 | #let std-upper = upper 5 | 6 | // Overwrite the default `smallcaps` and `upper` functions with increased spacing between 7 | // characters. Default tracking is 0pt. 8 | #let smallcaps(body) = std-smallcaps(text(tracking: 0.6pt, body)) 9 | #let upper(body) = std-upper(text(tracking: 0.6pt, body)) 10 | 11 | // Colors used across the template. 12 | #let stroke-color = luma(200) 13 | #let fill-color = luma(250) 14 | 15 | // This function gets your whole document as its `body` and formats it as a simple 16 | // non-fiction paper. 17 | #let ilm( 18 | // The title for your work. 19 | title: [Your Title], 20 | 21 | // Author's name. 22 | author: "Author", 23 | 24 | // The paper size to use. 25 | paper-size: "a4", 26 | 27 | // Date that will be displayed on cover page. 28 | // The value needs to be of the 'datetime' type. 29 | // More info: https://typst.app/docs/reference/foundations/datetime/ 30 | // Example: datetime(year: 2024, month: 03, day: 17) 31 | date: none, 32 | 33 | // Format in which the date will be displayed on cover page. 34 | // More info: https://typst.app/docs/reference/foundations/datetime/#format 35 | date-format: "[month repr:long] [day padding:zero], [year repr:full]", 36 | 37 | // An abstract for your work. Can be omitted if you don't have one. 38 | abstract: none, 39 | 40 | // The contents for the preface page. This will be displayed after the cover page. Can 41 | // be omitted if you don't have one. 42 | preface: none, 43 | 44 | // The result of a call to the `outline` function or `none`. 45 | // Set this to `none`, if you want to disable the table of contents. 46 | // More info: https://typst.app/docs/reference/model/outline/ 47 | table-of-contents: outline(), 48 | 49 | // The result of a call to the `bibliography` function or `none`. 50 | // Example: bibliography("refs.bib") 51 | // More info: https://typst.app/docs/reference/model/bibliography/ 52 | bibliography: none, 53 | 54 | // Whether to start a chapter on a new page. 55 | chapter-pagebreak: true, 56 | 57 | // Whether to display a maroon circle next to external links. 58 | external-link-circle: true, 59 | 60 | // Display an index of figures (images). 61 | figure-index: ( 62 | enabled: false, 63 | title: "", 64 | ), 65 | 66 | // Display an index of tables 67 | table-index: ( 68 | enabled: false, 69 | title: "", 70 | ), 71 | 72 | // Display an index of listings (code blocks). 73 | listing-index: ( 74 | enabled: false, 75 | title: "", 76 | ), 77 | 78 | // The content of your work. 79 | body, 80 | ) = { 81 | // Set the document's metadata. 82 | set document(title: title, author: author) 83 | 84 | // Set the body font. 85 | // Default is Linux Libertine at 11pt 86 | set text(font: ("Libertinus Serif", "Linux Libertine"), size: 12pt) 87 | 88 | // Set raw text font. 89 | // Default is Fira Mono at 8.8pt 90 | show raw: set text(font: ("Iosevka", "Fira Mono"), size: 9pt) 91 | 92 | // Configure page size and margins. 93 | set page( 94 | paper: paper-size, 95 | margin: (bottom: 1.75cm, top: 2.25cm), 96 | ) 97 | 98 | // Cover page. 99 | page(align(left + horizon, block(width: 90%)[ 100 | #let v-space = v(2em, weak: true) 101 | #text(3em)[*#title*] 102 | 103 | #v-space 104 | #text(1.6em, author) 105 | 106 | #if abstract != none { 107 | v-space 108 | block(width: 80%)[ 109 | // Default leading is 0.65em. 110 | #par(leading: 0.78em, justify: true, linebreaks: "optimized", abstract) 111 | ] 112 | } 113 | 114 | #if date != none { 115 | v-space 116 | // Display date as MMMM DD, YYYY 117 | text(date.display(date-format)) 118 | } 119 | ])) 120 | 121 | // Configure paragraph properties. 122 | // Default leading is 0.65em. 123 | set par(leading: 0.7em, justify: true, linebreaks: "optimized") 124 | // Default spacing is 1.2em. 125 | show par: set block(spacing: 1.35em) 126 | 127 | // Add vertical space after headings. 128 | show heading: it => { 129 | it 130 | v(2%, weak: true) 131 | } 132 | // Do not hyphenate headings. 133 | show heading: set text(hyphenate: false) 134 | 135 | // Show a small maroon circle next to external links. 136 | show link: it => { 137 | it 138 | // Workaround for ctheorems package so that its labels keep the default link styling. 139 | if external-link-circle and type(it.dest) != label { 140 | sym.wj 141 | h(1.6pt) 142 | sym.wj 143 | super(box(height: 3.8pt, circle(radius: 1.2pt, stroke: 0.7pt + rgb("#993333")))) 144 | } 145 | } 146 | 147 | // Display preface as the second page. 148 | if preface != none { 149 | page(preface) 150 | } 151 | 152 | // Indent nested entires in the outline. 153 | set outline(indent: auto) 154 | 155 | // Display table of contents. 156 | if table-of-contents != none { 157 | table-of-contents 158 | } 159 | 160 | // Configure heading numbering. 161 | set heading(numbering: "1.") 162 | 163 | // Configure page numbering and footer. 164 | set page( 165 | footer: context { 166 | // Get current page number. 167 | let i = counter(page).at(here()).first() 168 | 169 | // Align right for even pages and left for odd. 170 | let is-odd = calc.odd(i) 171 | let aln = if is-odd { right } else { left } 172 | 173 | // Are we on a page that starts a chapter? 174 | let target = heading.where(level: 1) 175 | if query(target).any(it => it.location().page() == i) { 176 | return align(aln)[#i] 177 | } 178 | 179 | // Find the chapter of the section we are currently in. 180 | let before = query(target.before(here())) 181 | if before.len() > 0 { 182 | let current = before.last() 183 | let gap = 1.75em 184 | let chapter = upper(text(size: 0.68em, current.body)) 185 | if current.numbering != none { 186 | if is-odd { 187 | align(aln)[#chapter #h(gap) #i] 188 | } else { 189 | align(aln)[#i #h(gap) #chapter] 190 | } 191 | } 192 | } 193 | }, 194 | ) 195 | 196 | // Configure equation numbering. 197 | set math.equation(numbering: "(1)") 198 | 199 | // Display inline code in a small box that retains the correct baseline. 200 | show raw.where(block: false): box.with( 201 | fill: fill-color.darken(2%), 202 | inset: (x: 3pt, y: 0pt), 203 | outset: (y: 3pt), 204 | radius: 2pt, 205 | ) 206 | 207 | // Display block code with padding. 208 | show raw.where(block: true): block.with( 209 | inset: (x: 5pt), 210 | ) 211 | 212 | // Break large tables across pages. 213 | show figure.where(kind: table): set block(breakable: true) 214 | set table( 215 | // Increase the table cell's padding 216 | inset: 7pt, // default is 5pt 217 | stroke: (0.5pt + stroke-color) 218 | ) 219 | // Use smallcaps for table header row. 220 | show table.cell.where(y: 0): smallcaps 221 | 222 | // Wrap `body` in curly braces so that it has its own context. This way show/set rules will only apply to body. 223 | { 224 | // Start chapters on a new page. 225 | show heading.where(level: 1): it => { 226 | if chapter-pagebreak { colbreak(weak: true) } 227 | it 228 | } 229 | body 230 | } 231 | 232 | // Display bibliography. 233 | if bibliography != none { 234 | pagebreak() 235 | show std-bibliography: set text(0.85em) 236 | // Use default paragraph properties for bibliography. 237 | show std-bibliography: set par(leading: 0.65em, justify: false, linebreaks: auto) 238 | bibliography 239 | } 240 | 241 | // Display indices of figures, tables, and listings. 242 | let fig-t(kind) = figure.where(kind: kind) 243 | let has-fig(kind) = counter(fig-t(kind)).get().at(0) > 0 244 | if figure-index.enabled or table-index.enabled or listing-index.enabled { 245 | show outline: set heading(outlined: true) 246 | context { 247 | let imgs = figure-index.enabled and has-fig(image) 248 | let tbls = table-index.enabled and has-fig(table) 249 | let lsts = listing-index.enabled and has-fig(raw) 250 | if imgs or tbls or lsts { 251 | // Note that we pagebreak only once instead of each each 252 | // individual index. This is because for documents that only have a couple of 253 | // figures, starting each index on new page would result in superfluous 254 | // whitespace. 255 | pagebreak() 256 | } 257 | 258 | if imgs { outline(title: figure-index.at("title", default: "Index of Figures"), target: fig-t(image)) } 259 | if tbls { outline(title: table-index.at("title", default: "Index of Tables"), target: fig-t(table)) } 260 | if lsts { outline(title: listing-index.at("title", default: "Index of Listings"), target: fig-t(raw)) } 261 | } 262 | } 263 | } 264 | 265 | // This function formats its `body` (content) into a blockquote. 266 | #let blockquote(body) = { 267 | block( 268 | width: 100%, 269 | fill: fill-color, 270 | inset: 2em, 271 | stroke: (y: 0.5pt + stroke-color), 272 | body 273 | ) 274 | } 275 | --------------------------------------------------------------------------------