Neural Sketch

Mark Path

Annotating paths with precision and clarity using Neural Sketch.

Sometimes, just connecting things isn’t enough. You might want to draw something that lives on the path itself.

The \nskMarkPath command lets you place custom visuals or annotations directly along a path — with precision. Think of it as a way to narrate your connections: weights, distances, transitions, or any visual punctuation you need.

Overview

\nskMarkPath enables precise placement of annotations along paths defined by other commands, such as \nskConnect. It provides a robust yet intuitive interface for marking intermediate points along any drawn path, ideal for labeling distances, weights, points of interest, or other notable markers in your diagrams.


Basic Usage

The core syntax of \nskMarkPath is:

\nskMarkPath[<options>]{<path id or definition>}{<content>}

You provide:

  • A set of <options>: like where to place marks (at=0.25), whether to skip the ends, or how far apart the marks should go.
  • A <path id or definition>: either a reference like acn, or an explicit coordinate-based path.
  • <content>: your annotation — nodes, lines, arrows, whatever you want rendered at each point.

Marking Specific Points

Use fractional values to mark exact spots along a path (at):

\nskMarkPath[
  at=.25,
]{<path-id>}{
  \node[above=.5] {$w_0$};
  \draw[black, thick] (0,0) -- (0,.5);
}

The position at accepts a fractional value (e.g., 0.25 means 25% of the way along the path).

Fractional ValuePosition on Path
.0Start of path
.5Middle of path
1.0End of path

Complete Example

Illustrating markers placed at multiple intervals along connections:

examples-doc/mark-path-a.tex
\nskContainer[fill=nskSecondaryAccent!30!nskBg, border-color=nskSecondaryAccent,]{
  \nskBlock[
    type=circle, text-center=A, importance=1.2,
    outer-border-type=solid, outer-border-color=nskSecondaryAccent, outer-border-size=3mm,
  ]
  \nskBlock[last-pos={right=3cm}, text-center=B,]
  \nskConnect[id=acn, from=\nskID{2}, to=\nskID{1},]
  \nskMarkPath[at=.25,]{acn}{\nskMark[id=p25]}
  \nskAnnotate[
    connect-to=p25, anchor-from=south, pos={above=of p25},
    text=$w_0$~, disable-tag=true, rounded-box=true, fill=nskYellow,
  ]
}
 
\nskContainer[fill=nskMainAccent!30!nskBg, border-color=nskMainAccent, last-pos={right=}]{
  \nskBlock[
    type=circle, text-center=A, importance=1.2,
    outer-border-type=solid, outer-border-color=nskMainAccent, outer-border-size=3mm,
  ]
  \nskBlock[last-pos={right=3cm}, text-center=B,]
  \nskConnect[id=acn, from=\nskID{2}, to=\nskID{1},]
  \nskMarkPath[at=.5,]{acn}{\nskMark[id=p50]}
  \nskAnnotate[
    connect-to=p50, anchor-from=south, pos={above=of p50},
    text=$w_1$~, disable-tag=true, rounded-box=true, fill=nskOrange,
  ]
}
 
\nskContainer[fill=nskPink!30!nskBg, border-color=nskPink, last-pos={right=}]{
  \nskBlock[
    type=circle, text-center=A, importance=1.2,
    outer-border-type=solid, outer-border-color=nskPink, outer-border-size=3mm,
  ]
  \nskBlock[last-pos={right=3cm}, text-center=B,]
  \nskConnect[id=acn, from=\nskID{2}, to=\nskID{1},]
  \nskMarkPath[at=.75,]{acn}{\nskMark[id=p75]}
  \nskAnnotate[
    connect-to=p75, anchor-from=south, pos={above=of p75},
    text=$w_2$~, disable-tag=true, rounded-box=true, fill=nskRed,
  ]
}

Composability Tip

Pair \nskMarkPath with \nskMark to capture exact coordinates along a path. From there, you can attach labels, arrows, or new geometry using \nskConnect, \nskAnnotate, or any other primitive.

Marking Blocks

Sometimes you want to connect to arbitrary location of a block that are not just the standard north, south, east, or west anchors.

By default, every primitive automatically registers a soft path using its id. This soft path lets you precisely target points along the block’s boundary using \nskMarkPath[...].

Suppose you have:

\nskBlock[id=x, ...]

You can then reference a specific point along the x block’s edge:

\nskMarkPath[at=<n>]{<x>}{<...>}

where <n> selects the nthn^{\text{th}} point along the block’s boundary path.

examples-doc/mark-path-b.tex
\begin{nskFigure}[]
  \foreach \s/\l in {rectangle/1cm, circle/1.5cm, diamond/1.5cm} {
    \nskContainer![last-pos-s={right=1.5cm}]{
      \nskBlock*[\x, type=\s, id=ref, size=2cm]
      \foreach \p[count=\i] in {0,.1,...,1} {
          \nskMarkPath[at=\p]{ref}{\nskMark[ marker=x]}
        }
 
      \nskMarkPath[at=0]{ref}{\nskMark[id=p0]}
      \nskMarkPath[at=.3]{ref}{\nskMark[id=p3]}
      \nskMarkPath[at=.5]{ref}{\nskMark[id=p05]}
      \nskMarkPath[at=.8]{ref}{\nskMark[id=p8]}
      \nskMarkPath[at=1]{ref}{\nskMark[id=p1]}
 
      \nskAnnotate[
        connect-to=p0, anchor-from=south, pos={above=\l of p0},
        text={$p=0$~},
        width=0cm, disable-tag=true, border-color=nskRed, fill=nskRed!70!nskBg,
      ]
 
      \nskAnnotate[
        connect-to=p05, anchor-from=north, pos={below=\l of p05},
        text={$p=0.5$~},
        width=0cm, disable-tag=true, border-color=nskRed, fill=nskRed!70!nskBg,
      ]
 
      \nskAnnotate[
        connect-to=p3, anchor-from=east, pos={left=\l of p3},
        text={$p=0.30$~},
        width=0cm, disable-tag=true, border-color=nskRed, fill=nskRed!70!nskBg,
      ]
 
      \nskAnnotate[
        connect-to=p8, anchor-from=west, pos={right=\l of p8},
        text={$p=0.80$~},
        width=0cm, disable-tag=true, border-color=nskRed, fill=nskRed!70!nskBg,
      ]
    }
  }
\end{nskFigure}

This allows you to draw connections or place elements with fine-grained precision, far beyond simple edge anchors.

Advanced Path Routing

Freeform Paths

Sometimes you want more control. \nskMarkPath lets you annotate any path — even a custom one you draw inline:

\nskMarkPath[at=.5]{(0,0) -- (3,1) -- (4,4)}{
  <content>
}

You can directly specify custom paths using coordinates — and inject any drawing logic you need (any LaTeX\LaTeX-supported, TikZ or pgf). This gives maximum flexibility for complex routing scenarios:

\nskMarkPath[at=.5]{(0,0) -- (3,1) -- (4,4)}{
  \node[above=.5cm, rotate=45] {Midway};
  \draw[black, thick] (0,0) -- (0,.5);
}

\nskMarkPath also seamlessly integrates with complex paths involving bends and custom routes:

\nskContainer[]{
  \tikzmath{ \df = 65; \a = -(180-\df);}
 
  \nskBlock[id=a, text-center=A,]
  \nskBlock[id=b, text-center=B, last-pos={right=3cm}]
  \nskBlock[
    type=rounded rectangle, pos={below right=1cm and .8cm of \nskID!{1}},
    fill=nskMainAccent, width=2cm, border-radius=0mm,
    id=op, text-center=node, outer-border-type=solid,
  ]
  \nskConnect[from=a.south, to=op.west, bend-type=single, bend-direction=up,]
  \nskConnect[id=bTo, from=b.south, to=op.east, route={to[in=0, out=\a]}]
  \nskMarkPath[at=.5,]{bTo}{
    \node[below right=.5cm] {Text};
    \draw[nskFg, thick] (0,0) -- (0,.5); % you can use nskFg
    }
}

Tip

Combine \nskMarkPath with anchors and markers to create informative visual annotations. Markers can include labels, connectors, and custom drawn indicators, greatly enhancing clarity in complex diagrams.


Step-based Marking

Use evenly spaced markers along an arbitrary path by specifying an interval step (step):

\nskContainer[border-type=dashed, padding=3mm]{
  \nskBlock[id=ba, width=8cm, height=1cm]
  \nskMarkPath[
    path-width=8cm,
    skip-first=true,
    skip-last=true,
    step=10mm
  ]{(ba.south west) -- (ba.south east)}{
    \draw[black] (0,0) -- (0,1cm);
  }
}

How It Works

  • step: Defines the interval at which markers are placed along the path.
  • skip-first, skip-last: Allows skipping markers at endpoints for cleaner aesthetics.

No hardcoding

You don’t need to calculate the path length manually. Use \nskMeasure to measure any distance, then reuse it in \nskMarkPath:

\nskBlock[id=ba, width=8cm, height=1cm,]
\nskMeasure[from=ba.east, to=ba.west]
\nskMarkPath[
  path-width=\nskDistance,
  skip-first=true, skip-last=true, step=10mm
]{(ba.south west) -- (ba.south east)}{ \draw[nskFg] (0,0) -- (0,1cm); }

Need more control?

You can combine \nskMeasure with complex paths and programmatic spacing. Learn more in Measure.


Key Takeaway

\nskMarkPath empowers you to annotate paths precisely, clearly communicating detailed information without sacrificing visual appeal.


Reference Table

PropTypeDefault
at?token list{}
color?token listc__nsk_principal
end?number1
path-width?dimension0pt
skip-first?booleanfalse
skip-last?booleanfalse
start?number0
step?dimension10mm

On this page