Module Loading
Selectively enabling Neural Sketch modules
Overview
By default, Neural Sketch activates only its core module, which provides fundamental features like \nskBlock
and the global styling keys. For more advanced functionality—such as bridging lines, coordinate helpers, or annotations—you can load the corresponding modules manually. This modular setup ensures your document remains concise, while allowing you to incorporate precisely the tools you need.
Why Load Modules Separately?
When creating extensive diagrams, especially ones that may not always require bridging arcs, containers, or specialized annotation features, it can be advantageous to load only the specific modules needed. This approach:
- Minimizes compilation overhead: Each additional module introduces extra code and style definitions; loading unneeded modules may slow compilation.
- Provides clarity of usage: You can see exactly which advanced features your diagram employs by referencing the module list.
- Supports scalability: For simpler sketches, you can rely on the core. For complex diagrams—like neural network architectures with crossing lines or annotated sub-sections—load bridging, annotations, containers, and other relevant modules.
The \nskUseModule
Macro
Neural Sketch offers a macro, \nskUseModule
, that can load one or more modules in a single pass. You specify a comma-separated list of module names, or use an asterisk ({*}
) to load all available modules at once.
Load specific modules:
Or if you want all core features at your disposal, simply issue:
Invoke \nskUseModule{...}
in your document’s preamble (or at least before creating your figures).
Avoid calling \nskUseModule
multiple times with different sets of modules to prevent conflicts or unexpected behavior.
Minimal Working Example
Below is a minimal working example to confirm your environment is set up correctly:
Available Modules
Below are the modules currently available, along with a short summary of their purpose:
Module | Description |
---|---|
block | Geometric primitives: e.g., rectangles, diamonds, circles. |
loader | Controls partial or complete loading of modules. |
styles | Global style definitions for all shapes and lines. |
colors | Curated color palette for consistent, publication-ready diagrams. |
groups | Logical grouping of shapes with transformations (scale/rotate). |
containers | Bounding containers with padding, used to visually group content. |
coords | Defines named coordinates or anchor points for precise positioning. |
bridges | Manages arrow routing and bridging arcs where lines cross. |
annotations | Auto-incrementing annotations, tags, and references. |
decorations | Custom path decorations (markers, repeating shapes, etc.). |
render | Conditional rendering: switch or case-based macros. |
pargs | Dark-mode support and color inversion logic. |
When you pass the name of one or more modules to \nskUseModule
, only those modules are loaded, so your diagrams gain that functionality without pulling in the rest.
Balancing Complexity and Performance
By tailoring your module list, you keep your diagram code and compilation light. If you need bridging arcs and coordinates but have no use for containers or extra text adornments, simply load:
This way, you gain automatic bridging arcs to handle crossing lines and coordinate anchors for precise placement—while skipping unrelated modules. For large or intricate documents, this selective loading can be pivotal for maintaining manageable compile times, especially on cloud-based services like Overleaf.
Note
In many common scenarios, the overhead introduced by extra modules is modest. But if your diagram is extremely large or if your environment imposes strict memory limits, selective loading can preserve efficiency.