Neural Sketch
Commands

nsk@Coord

Define and manage precise named coordinates for robust positioning in Neural Sketch diagrams.

Introduction

The \nskCoord macro in Neural Sketch introduces a concise and intuitive system for defining named coordinates, significantly enhancing the precision and readability of complex diagrams. By creating labeled anchor points, you gain the capability to position elements reliably, reducing redundancy and minimizing manual calculations.


Basic Usage

A minimal invocation of \nskCoord defines a simple named coordinate at the origin (0,0):

\nskCoord[id=myCoord]

Advanced Example

For precise control, specify explicit coordinates, relative positioning, or custom markers:

\nskCoord[
  id=refPoint,
  x=2,
  y=3,
  marker=o,
  marker-color=nskBlue,
  marker-size=1.5mm
]

Available Options

Identity

  • id (string, default=auto-generated): Assigns a unique identifier to the coordinate.
\nskCoord[id=centerPoint]

If an explicit id is not provided, Neural Sketch automatically assigns a sequential identifier such as coord1, coord2, etc, See the Auto-Incremental IDs page for a comprehensive guide.

Positioning

  • x, y (number, default=0): Directly specify coordinates.
\nskCoord[x=1.5, y=-2.0]
  • at (coordinate, default={}): Places the coordinate precisely at another node or explicit TikZ coordinate.
\nskCoord[at={(nodeA.north east)}]
  • pos (string, default={}): Specifies relative positioning similar to TikZ's syntax.
\nskCoord[pos={below right=1cm and 2cm of nodeB}]

Shifting

Apply small manual shifts to coordinates:

  • shift-x, shift-y (dimension, default=0pt): Adjust coordinate placement horizontally or vertically.
\nskCoord[shift-x=5mm, shift-y=-3mm]

Visual Markers

Add visual markers for debugging or enhancing diagram readability:

  • marker (choice: none, o, x, default=none): Specifies the type of visual marker.
  • marker-color (color, default=red): Defines the marker color.
  • marker-size (dimension, default=1mm): Sets the marker's size.
\nskCoord[
  marker=x,
  marker-color=nskRed,
  marker-size=2mm
]

Marker Types

MarkerVisualDescription
noneNo marker displayed.
oCircle marker centered at coordinate
xCross marker centered at coordinate

Markers are excellent for visually verifying coordinate placement during development or presentations.

Usage Examples

Precise Element Placement

Use named coordinates to position elements precisely:

\nskCoord[id=centralAnchor, x=0, y=0]
\nskBlock[pos={above=2cm of centralAnchor}]
\nskBlock[pos={below=2cm of centralAnchor}]

Debugging Complex Layouts

Visually verify positions with markers:

\nskCoord[
  id=debugPoint,
  pos={right=1cm of nodeA},
  marker=o,
  marker-color=nskGreen,
  marker-size=1.5mm
]

Internal Mechanics

Internally, \nskCoord:

  • Generates a phantom (invisible) TikZ node that serves as a named anchor.
  • Automatically assigns sequential IDs if explicit names are omitted.
  • Handles precise shifts and markers robustly.
  • Integrates seamlessly with Neural Sketch’s positioning system.

Reference Table

PropTypeDefault
id?stringauto-generated
x?number0
y?number0
at?coordinate{}
pos?string{}
shift-x?dimension0pt
shift-y?dimension0pt
marker?choicenone
marker-color?colorred
marker-size?dimension1mm

On this page