Neural Sketch

Measure

Precisely measure distances and align blocks effortlessly with Neural Sketch.

The \nskMeasure command provides a powerful yet intuitive mechanism to accurately measure distances and align diagram components within your Neural Sketch diagrams. Whether you need blocks of precisely matching sizes, exact spacing between elements, or consistent alignment, this command simplifies your workflow.

Basic Usage

To measure distances between two points or anchor coordinates, use the \nskMeasure macro as follows:

\nskMeasure[
  axis=horizontal, % Axis along which to measure (horizontal or vertical)
  from={a.south west}, % Starting anchor
  to={b.south east}, % Ending anchor
]

Once you've performed the measurement, you can immediately reuse the resulting length via the built-in macro \nskDistance.

Example: Matching Block Widths

Here's how you can measure the width between two blocks and then set a new block to precisely match that measured width:

% Measure distance horizontally from block 'a' to block 'b'
\nskMeasure[
  axis=horizontal,
  from={a.south west},
  to={b.south east},
]
 
% Create a new block 'c' with exactly the measured width
\nskBlock[
  id=c,
  width={\nskDistance},
  text-center={Width: \nskDistance}
]

This ensures c matches precisely the combined width of a and b, providing visual consistency and exact alignment across your diagram elements.

Using nskMeasure to align block sizes

Available Options

OptionTypeDescriptionDefault
axisEnum (horizontal, vertical)Axis along which the measurement is taken.horizontal
fromAnchorStarting anchor coordinate for measurement.required
toAnchorEnding anchor coordinate for measurement.required

Practical Use Cases

  • Consistent Spacing: Maintain equal spacing between elements across your figures.
  • Dynamic Sizing: Create adaptive blocks or containers that adjust sizes based on other elements.
  • Perfect Alignment: Ensure elements line up precisely, essential for professional-quality diagrams.

Best Practices

  • Always explicitly state the axis to ensure clarity.
  • Use descriptive block IDs for from and to anchors to maintain readability.
  • Consider adding descriptive labels or annotations to measured elements to facilitate reviewing and editing.

Reference

PropTypeDefault
axis?choicehorizontal
from?token list{}
to?token list{}

On this page