{"id":20092349,"url":"https://github.com/rubixdev/typst-i-figured","last_synced_at":"2026-02-05T15:32:31.999Z","repository":{"id":198723367,"uuid":"701404923","full_name":"RubixDev/typst-i-figured","owner":"RubixDev","description":"Configurable figure numbering per section in Typst.","archived":false,"fork":false,"pushed_at":"2025-05-26T16:41:44.000Z","size":642,"stargazers_count":26,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-04T07:06:00.606Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://typst.app/universe/package/i-figured","language":"Typst","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubixDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-06T15:02:58.000Z","updated_at":"2025-06-30T06:45:51.000Z","dependencies_parsed_at":"2025-07-04T07:06:01.935Z","dependency_job_id":"08f38c7e-4032-4d2b-b713-beb33dac7028","html_url":"https://github.com/RubixDev/typst-i-figured","commit_stats":null,"previous_names":["rubixdev/typst-i-figured"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RubixDev/typst-i-figured","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubixDev%2Ftypst-i-figured","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubixDev%2Ftypst-i-figured/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubixDev%2Ftypst-i-figured/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubixDev%2Ftypst-i-figured/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubixDev","download_url":"https://codeload.github.com/RubixDev/typst-i-figured/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubixDev%2Ftypst-i-figured/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29124801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T14:05:12.718Z","status":"ssl_error","status_checked_at":"2026-02-05T14:03:53.078Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T16:36:44.148Z","updated_at":"2026-02-05T15:32:31.983Z","avatar_url":"https://github.com/RubixDev.png","language":"Typst","readme":"# I figured\n\nConfigurable figure numbering per section.\n\n## Examples\n\n### Basic\n\nHave a look at the source [here](./examples/basic.typ).\n\n![Example: basic](./examples/basic.png)\n\n### Two levels deep\n\nHave a look at the source [here](./examples/level-two.typ).\n\n![Example: two levels deep](./examples/level-two.png)\n\n## Usage\n\nThe package mainly consists of two customizable show rules, which set up all the\nnumbering. There is also an additional function to make showing an outline of\nfigures easier.\n\nBecause the [`show-figure()`](#show-figure) function must internally create\nanother figure element, attached labels cannot directly be used for references.\nTo circumvent this, a new label is attached to the internal figure, with the\nsame name but prefixed with `fig:`, `tbl:`, or `lst:` for images (and all other\ntypes of generic figures), tables, and raw code figures (aka listings)\nrespectively. These new labels can be used for referencing without problems.\n\n\u003e [!NOTE]\n\u003e\n\u003e When using this package with math equations, make sure you don't already have\n\u003e a numbering set for equations and instead specify it in the\n\u003e [`show-equation()`](#show-equation) call. Also see\n\u003e [#14](https://github.com/RubixDev/typst-i-figured/issues/14).\n\n```typ\n// import the package\n#import \"@preview/i-figured:0.2.4\"\n\n// make sure you have some heading numbering set\n#set heading(numbering: \"1.\")\n\n// apply the show rules (these can be customized)\n#show heading: i-figured.reset-counters\n#show figure: i-figured.show-figure\n\n// show an outline\n#i-figured.outline()\n\n= Hello World\n\n#figure([hi], caption: [Bye World.]) \u003cbye\u003e\n\n// when referencing, the label names must be prefixed with `fig:`, `tbl:`,\n// or `lst:` depending on the figure kind.\n@fig:bye displays the text \"hi\".\n```\n\n## Reference\n\n### `reset-counters`\n\nReset all figure counters. To be used in a heading show rule like\n`#show heading: i-figured.reset-counters`.\n\n```typ\n#let reset-counters(\n  it,\n  level: 1,\n  extra-kinds: (),\n  equations: true,\n  return-orig-heading: true,\n) = { .. }\n```\n\n**Arguments:**\n\n- `it`: [`content`] \u0026mdash; The heading element from the show rule.\n- `level`: [`int`] \u0026mdash; At which heading level to reset the counters. A value\n  of `2` will cause the counters to be reset at level two _and_ level one\n  headings.\n- `extra-kinds`: [`array`] of ([`str`] or [`function`]) \u0026mdash; Additional\n  custom figure kinds. If you have any figures with a `kind` other than `image`,\n  `table`, or `raw`, you must add the `kind` here for its counter to be reset.\n- `equations`: [`bool`] \u0026mdash; Whether the counter for math equations should be\n  reset.\n- `return-orig-heading`: [`bool`] \u0026mdash; Whether the original heading element\n  should be included in the returned content. Set this to false if you manually\n  want to construct a heading instead of using the default.\n\n**Returns:** [`content`] \u0026mdash; The unmodified heading.\n\n### `show-figure`\n\nShow a figure with per-section numbering. To be used in a figure show rule like\n`#show figure: i-figured.show-figure`.\n\n```typ\n#let show-figure(\n  it,\n  level: 1,\n  zero-fill: true,\n  leading-zero: true,\n  numbering: \"1.1\",\n  extra-prefixes: (:),\n  fallback-prefix: \"fig:\",\n) = { .. }\n```\n\n**Arguments:**\n\n- `it`: [`content`] \u0026mdash; The figure element from the show rule.\n- `level`: [`int`] \u0026mdash; How many levels of the current heading counter should\n  be added in front. Note that you can control this individually from the\n  `level` parameter on [`reset-counters()`](#reset-counters).\n- `zero-fill`: [`bool`] \u0026mdash; If `true` and assuming a `level` of `2`, a\n  figure after a `1.` heading but before a `1.1.` heading will show `1.0.1` as\n  numbering, else the middle zero is excluded. Note that if set to `false`, not\n  all figure numberings are guaranteed to have the same length.\n- `leading-zero`: [`bool`] \u0026mdash; Whether figures before the first top-level\n  heading should have a leading `0`. Note that if set to `false`, not all figure\n  numberings are guaranteed to have the same length.\n- `numbering`: [`str`] or [`function`] \u0026mdash; The actual numbering pattern to\n  use for the figures.\n- `extra-prefixes`: [`dictionary`] of [`str`] to [`str`] pairs \u0026mdash;\n  Additional label prefixes. This can optionally be used to specify prefixes for\n  custom figure kinds, otherwise they will also use the fallback prefix.\n- `fallback-prefix`: [`str`] \u0026mdash; The label prefix to use for figure kinds\n  which don't have another prefix set.\n\n**Returns:** [`content`] \u0026mdash; The modified figure.\n\n### `show-equation`\n\nShow a math equation with per-section numbering. To be used in a show rule like\n`#show math.equation: i-figured.show-equation`.\n\n```typ\n#let show-equation(\n  it,\n  level: 1,\n  zero-fill: true,\n  leading-zero: true,\n  numbering: \"(1.1)\",\n  prefix: \"eqt:\",\n  only-labeled: false,\n  unnumbered-label: \"-\",\n) = { .. }\n```\n\n**Arguments:**\n\nFor the arguments `level`, `zero-fill`, `leading-zero`, and `numbering` refer to\n[`show-figure()`](#show-figure).\n\n- `it`: [`content`] \u0026mdash; The equation element from the show rule.\n- `prefix`: [`str`] \u0026mdash; The label prefix to use for all equations.\n- `only-labeled`: [`bool`] \u0026mdash; Whether only equations with labels should be\n  numbered.\n- `unnumbered-label`: [`str`] \u0026mdash; A label to explicitly disable numbering\n  for an equation.\n\n**Returns:** [`content`] \u0026mdash; The modified equation.\n\n### `outline`\n\nShow the outline for a kind of figure. This is just the same as calling\n`outline(target: figure.where(kind: i-figured._prefix + repr(target-kind)), ..)`,\nthe function just exists for convenience and clarity.\n\n```typ\n#let outline(target-kind: image, title: [List of Figures], ..args) = { .. }\n```\n\n**Arguments:**\n\n- `target-kind`: [`str`] or [`function`] \u0026mdash; Which kind of figure to list.\n- `title`: [`content`] or `none` \u0026mdash; The title of the outline.\n- `..args` \u0026mdash; Other arguments to pass to the underlying\n  [`outline()`](https://typst.app/docs/reference/meta/outline/) call.\n\n**Returns:** [`content`] \u0026mdash; The outline element.\n\n[`str`]: https://typst.app/docs/reference/foundations/str/\n[`int`]: https://typst.app/docs/reference/foundations/int/\n[`bool`]: https://typst.app/docs/reference/foundations/bool/\n[`content`]: https://typst.app/docs/reference/foundations/content/\n[`function`]: https://typst.app/docs/reference/foundations/function/\n[`array`]: https://typst.app/docs/reference/foundations/array/\n[`dictionary`]: https://typst.app/docs/reference/foundations/dictionary/\n\n## Acknowledgements\n\nThe core code is based off code from [@PgBiel](https://github.com/PgBiel)\n(`@PgSuper` on Discord) and [@aagolovanov](https://github.com/aagolovanov)\n(`@aag.` on Discord). Specifically from\n[this message](https://discord.com/channels/1054443721975922748/1088371919725793360/1158534418760224809)\nand the conversation around\n[here](https://discord.com/channels/1054443721975922748/1088371919725793360/1159172567282749561).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubixdev%2Ftypst-i-figured","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubixdev%2Ftypst-i-figured","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubixdev%2Ftypst-i-figured/lists"}