Icons
A guided tour of Neural Sketch's icon pipeline – from declarative SVG inclusion to automatic fetching, recoloring, and cleanup.
Why an Icon System?
In complex, publication‑grade diagrams, a lone arrow or block label is rarely enough. We often need semantic glyphs – check‑marks for valid, exclamation triangles for warning, tiny CPUs for compute node – to compress entire phrases into a few visual atomic components.
Yet: manually hunting SVGs, juggling \includegraphics
, tweaking dimensions, and recoloring for dark‑mode is drudgery. Neural‑Sketch treats icons as first‑class primitives, governed by the same declarative key–value philosophy that powers blocks, annotations, and containers.
The Big Idea
\nskIcon
is not a passive include command. It is a pipeline – a bridge
between your .tex
file and an ecosystem of reusable vector assets.
Quick Start
On first compilation Neural Sketch will:
- Fetch the raw SVG from the Lucide repo (via pyfetch).
- Recolor its stroke to match your theme (
icon-color
, defaults to your block border color). - Cache the processed file in
./icons/
for future compilations. - Inline it with the correct width/height so it sits snugly beside text.
- Collect unused icons and purge them from the disk—keeping your repo lean.
No extra packages, no manual downloads, no brittle path juggling.
Anatomy of \nskIcon
Parameter Cheatsheet
Key | Purpose | Notes |
---|---|---|
name | Slug of the SVG file | Omit extension; check resolves to check.svg |
type | Provider to pull from | Currently only supported lucide . More to come... |
color | Stroke color | Applied at fetch‑time, so the glyph stays vector‑pure across light and dark themes |
border-size | Stroke width | Applied at fetch‑time, controls the size of the border |
size | Convenience wrapper for both width and height | Any TeX dimension (1em , 8pt , 3mm ). Overrides package defaults |
shift-y | Vertical nudge | Dimensional offset added to the icon’s baseline (ideal for inline text centering) |
style | Raw PGF/tikz tweaks | Icon additional stylings; examples: opacity=.75 , rotate=90 |
Icons as regular text
Icons read like letters—seamless in the line. \nskIcon
is a real node, so place it anywhere accepts text—mid‑sentence, in captions, or via a `\nskBlock` text-*
keys.
Spin it with style={rotate=…}
or nudge the baseline with shift-y
. Below, a compass‑rose demo shows the idea.
You can use and insert an
\nskIcon
wherever text is accepeted. The most common way is to embed it in atext-*
within an\nskBlock
.
Providers
You can easily use an icon from one of the supported providers by just specifying their icon name (slug
).
Search icons on Lucide
Search the icon you wish to use e.g., check
mark
Copy the icon's name (slug) e.g., check
:
Use it by its name!
Supported
Provider Name | Provider Type | Link |
---|---|---|
Lucide | lucide | Lucide |
Alignment
Icons ship baseline‑centred, so they slip into prose without tilting the line. Add breathing room with the usual TeX spacers (\,
, \;
, \quad
, …).
By default icons are vertically aligned, with their baseline aligned with the center of the icon. This allows natural insertion within text. You can easily adjust the horizontal spacing using the usual spacing macros.
Macro | Width (approx.) | Typical use |
---|---|---|
\! | −0.166 em | Negative thin space – tighten symbol pairs |
\, | 0.166 em | Thin space – subtle separation |
\: | 0.222 em | Medium space |
\; | 0.277 em | Thick space |
\quad | 1 em | Quad – paragraph‑level padding |
\qquad | 2 em | Double quad – generous padding |
Customization
To ensure pixel-perfect rendering and broad compatibility across icon libraries, we rely on SVG vector graphics. However, does not support vector graphics directly, so a preprocessing conversion must take place before you can use them.
This means that you cannot directly change icon properties on-the-fly. Neural Sketch allows you to modify both the color and border-size of the icon by altering the SVG
properties before the icon is converted to a format accepted by .
Tip
Every time you change one of these properties,Neural Sketch re-runs the conversion preprocessing stage
Icon Color
You can specify the icon color through the color=
key:
Icon Border size
You can specify the border-size
as:
The border-size
accepts only floating point (fp) values, which are in the
relative svg system.
Behind the Curtain – the pyfetch CLI
The TeX layer delegates all I/O to the Python helper pyfetch.py
, invoked under \write18
(so remember to enable --shell-escape
).
Four micro‑services form the backbone:
CLI sub‑command | Responsibility |
---|---|
fetch-lucide | HTTP‑download an SVG by slug and drop it in icons/ . |
update-color | Parse the SVG , rewrite every stroke="..." to your chosen hex (only if different). |
update-stroke | Parse the SVG and updates the stroke-width="... |
clean-lucide | Garbage‑collect icons that are no longer referenced in the current run – keeping your repo diet‑friendly. |
Limitation
Currently only one color or border-size per icon-name is supported.
Global Style Hooks
Neural‑Sketch exposes a quartet of package‑level keys so you can shape icon behaviour across all icons:
Tweak them once in the preamble, watch every figure adapt automatically.
Garbage Collection – \nskCleanUnusedIcons
Unused icons are automatically purged and deleted. You can modify this behavior by specifying the icon-clean
global options:
If you want to manually clean the unused icons, At the end of each run, issue:
The macro walks the internal property list g__nsk_used_icons_prop
, computes the set difference against files on disk, and delegates removal to pyfetch clean-lucide …
.
Reference Table
Prop | Type | Default |
---|---|---|
type? | choice | lucide |
color? | color | nskFg |
size? | dimension | 5mm |
width? | dimension | 5mm |
height? | dimension | 5mm |
border-size? | floating point | 2.0 |
shift-y? | dimension | 0pt |
shift-y? | dimension | 0pt |
style? | token list | {} |