Neural Sketch
Commands/preloaded

nsk@Block

Comprehensive reference for the `\nskBlock` command in Neural Sketch

Overview

The \nskBlock command is the foundational drawing primitive in Neural Sketch, providing a rich set of customization options for geometric shapes, styling, positioning, and embedded content. It leverages TikZ’s shapes.geometric library to render rectangles, circles, diamonds, trapezoids, and more, with fine-grained control via a concise key-value interface.

If no id is provided, an auto-incremental identifier is generated, allowing seamless chaining and referencing of blocks.

Basic Usage

\nskBlock[<key=value, ...>]

This will draw a block (defaulting to a rectangle) with any combination of the supported keys to customize its appearance, position, and content.

Customized Example

For advanced use cases, you can specify options to adjust styling, positioning, and labeling:

\nskBlock[
  id=myBlock,
  fill=nskBlue!50,
  border-color=nskDarkGray,
  text-north={Block A},
  last-pos={right=2cm}
]

Available Keys

Identity

  • id (string): Assigns a unique identifier to the block, useful for referencing positions later.
\nskBlock[id=blockA]

ID-Generation

IDs are internally managed and allow efficient shape tracking. If no ID is explicitly provided, an automatic ID is generated, which you can also reference. See the Auto-Incremental IDs page for a comprehensive guide.

Shape and Dimensions

  • shape (string, default=rectangle): Sets the geometric shape of the block (rectangle, circle, diamond, trapezium, etc.).
\nskBlock[shape=circle]
  • width, height (dimension, default=1cm): Specifies the minimum width and height of the block.
\nskBlock[width=2cm, height=1.5cm]
  • border-radius (dimension, default=2.5mm): Sets the corner radius for rectangular shapes.
\nskBlock[border-radius=4mm]

Supported Primitives

For a list of all Supported Primitives check out Supported Primitives.

Colors and Styling

  • fill (color, default=nskLightGray): Defines the fill color.
\nskBlock[fill=nskOrange!40]
  • border-color (color, default=nskDarkGray): Sets the border color.
\nskBlock[border-color=nskRed]
  • border-size (dimension, default=0.4mm): Adjusts the thickness of the block border.
\nskBlock[border-size=0.6mm]

Basic Styles

For a list of all the styles provided out-of-the-box, check out Basic Styles.

Positioning

  • last-pos (coordinate, default={}): Positions the current block relative to the previous block.
\nskBlock[last-pos={below=1cm}]
  • last-pos-s (coordinate, default={}): Similar to last-pos but allows silent overrides without warnings.
\nskBlock[last-pos-s={right=0.5cm}]

Advanced Positioning

For detailed guidance on advanced positioning techniques, refer to the Positioning Mechanism page.

Text Anchors

These keys define text labels attached to specific block anchor points:

  • text-north, text-south, text-east, text-west, text-center (string, default={}): Adds text anchored to the specified side or center.
\nskBlock[text-north={Layer 1}]

Text Positioning

For detailed information on placing and positioning text, see Text Positioning.

Technical Details

Internally, \nskBlock:

  • Sets user-defined keys and processes any position overrides (last-pos, last-pos-s).
  • Auto-generates a unique ID if none is provided.
  • Maintains a history of block positions and IDs for subsequent referencing.
  • Provides debugging information when needed.

Example: Position Chaining

\nskBlock allows intuitive chaining of positions:

\nskBlock[id=A, text-center={A}]
\nskBlock[last-pos={right=of A}, text-center={B}]
\nskBlock[last-pos={below=of B}, text-center={C}]

Advanced Tips

  • Leverage Neural Sketch’s curated palette and color mixing syntax for visual clarity:
\nskBlock[fill=nskBlue!30!nskGreen]
  • Combine custom shapes with annotations for detailed diagrams:
\nskBlock[
  shape=diamond,
  fill=nskMagenta!20,
  text-center={Decision},
  last-pos={below=2cm}
]

See Also

Reference

PropTypeDefault
type?choicerectangle
padding-x?dimensionstyle default
padding-y?dimensionstyle default
id?token listauto-generated
x?numberstyle default
y?numberstyle default
shift-x?number0
shift-y?number0
anchor?token liststyle default
rotate?numberstyle default
opacity?numberstyle default
pos?token listnone
last-pos?token listnone
last-pos-s?token listnone
align?choicenone
width?dimensionstyle default
height?dimensionstyle default
size?dimensionnone
border-type?token listsolid
border-color?colorstyle default
border-radius?dimensionstyle default
border-size?dimensionstyle default
outer-border-type?token liststyle default
outer-border-color?colorstyle default
outer-border-radius?dimensionstyle default
outer-border-size?dimensionstyle default
fill?colorstyle default
shadow?booleantrue
importance?number1.0
tikz-opts?token list{}
text-size?token liststyle default
text-north?token listnone
text-north-loc?token liststyle default
text-north-style?token liststyle default
text-south?token listnone
text-south-loc?token liststyle default
text-south-style?token liststyle default
text-east?token listnone
text-east-loc?token liststyle default
text-east-style?token liststyle default
text-west?token listnone
text-west-loc?token liststyle default
text-west-style?token liststyle default
text-center?token listnone
text-center-loc?token liststyle default
text-center-style?token liststyle default
embed?token list{}
embed-gfx?token list{}
embed-padding?dimensionstyle default
embed-border-radius?dimensionstyle default
embed-border-size?dimensionstyle default
embed-border-color?colorstyle default
pattern?token listnone
pattern-color?colornskFg
pattern-opacity?number0.2
fade?choicenone
stack?booleanfalse
stack-opts?token liststyle default
stack-xoffset?dimensionstyle default
stack-yoffset?dimensionstyle default
stack-count?choicesingle

On this page