Neural Sketch
Commands

nsk@Block

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

The \nskBlock command is the foundational element in Neural Sketch, providing a highly customizable primitive shape used extensively for constructing diagrams.

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

Overview

The \nskBlock command generates fundamental geometric primitives, such as rectangles, circles, diamonds, trapezoids, and more, leveraging the TikZ shapes.geometric library. It is designed for simplicity while offering extensive customization via a concise key-value interface.

By default, a block appears as a rectangle filled with a neutral color (nskLightGray), bordered by a slightly darker outline (nskDarkGray), and optionally labeled using integrated text anchors.

Basic Usage

Here’s a minimal example demonstrating the simplest usage:

\nskBlock[]

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
border-color?token list{}
border-radius?dimension{}
border-size?dimension{}
border-type?token listsolid
embed?token list{}
embed-border-radius?dimension{}
embed-gfx?token list{}
embed-padding?dimension{}
fill?token list{}
height?dimension{}
id?token list{}
importance?number1.0
last-pos?token list{}
last-pos-s?token list{}
outer-border-color?token listnskMainAccent
outer-border-radius?dimension{}
outer-border-size?dimension7mm
outer-border-type?token listnone
pattern?token list{}
pattern-color?token list{}
pos?token list{}
shadow?booleantrue
text-center?token list{}
text-center-loc?token list{}
text-center-style?token list{}
text-east?token list{}
text-east-loc?token list{}
text-east-style?token list{}
text-north?token list{}
text-north-loc?token list{}
text-north-style?token list{}
text-south?token list{}
text-south-loc?token list{}
text-south-style?token list{}
text-west?token list{}
text-west-loc?token list{}
text-west-style?token list{}
tikz-opts?token list{}
type?token listrectangle
width?dimension{}
x?number0
y?number0

On this page