Neural Sketch
Commands/preloaded

nsk@BlockIDLast

Retrieve identifiers of previously defined blocks based on their relative creation order.

This is an unstable API, only used internally. Deprecated in favor of \nskID

Overview

The \nskBlockIDLast macro returns the identifier of the nth-last defined block within the current nskFigure, where 1 corresponds to the most recently created block, 2 to the second most recent, and so on. This enables precise referencing and positioning relative to any previously defined element in your diagram.

Usage

\nskBlockIDLast{<n>}
  • n (number, required): Relative index counting backwards from the latest block, with 1 indicating the most recent, 2 the second most recent, etc.

Referencing an index larger than the number of existing blocks triggers a LaTeX compilation error. Always ensure the requested block exists.

Alias: \nskLastBlockID

For convenience, the alias \nskLastBlockID is provided, which returns the ID of the block immediately preceding the latest defined block (equivalent to \nskBlockIDLast{2}).

\nskLastBlockID

Examples

\begin{nskFigure}
  \nskBlock[id=first]{}
  \nskBlock[id=second]{}
  \nskBlock[id=third]{}
 
  % Most recent block ID (n=1):
  Most recent: % returns "third"
  \texttt{\nskBlockIDLast{1}}
 
  % Second most recent (n=2):
  Second last: % returns "second"
  \texttt{\nskBlockIDLast{2}}
 
  % Using the alias:
  Prev block: % returns "second"
  \texttt{\nskLastBlockID}
\end{nskFigure}

Reference Table

PropTypeDefault
nnumber{}

On this page