Neural Sketch

Annotations

Clearly label and reference diagram elements with automatically numbered annotations.

Overview

Annotations in Neural Sketch provide an elegant way to insert clear, auto-numbered labels and explanatory notes directly into your diagrams. This streamlines the creation of professional, self-explanatory visuals, crucial for effectively communicating complex ideas such as neural architectures, algorithmic steps, or intricate system diagrams.

Key Features:

  • Automatic numbering or customizable reference tags.
  • Flexible positioning relative to diagram elements.
  • Rich styling options for annotation boxes and connector arrows.
  • Seamless integration with the Neural Sketch ecosystem.
  • Highly extensible reference system that allows overriding default numbering by providing custom reference tags and labels, ensuring complete control and adaptability.
  • Integrated referencing: Easily incorporate citations, equations, and references directly within figures, seamlessly linking your diagrams to other sections of your LaTeX\LaTeX paper.

Basic Usage

To create annotations, use the straightforward command:

\nskAnnotate[<key=value list>]

Minimal Example

Here's how to attach a simple annotation to a block:

\nskBlock[id=myblock, text-center={My Block}]
\nskAnnotate[
  connect-to=myblock.west,
  text={Important},
  pos={left=1cm of myblock},
]

This generates an annotation box positioned neatly to the left of myblock, connected via an arrow, and auto-incremented by default.


Annotation Customization

Annotations offer extensive customization through various keys:

PropertyDefaultDescription
ref-tagAuto-numberedCustom identifier for referencing annotations explicitly.
header(none)Bold-styled header for clear categorization.
title(none)Italicized subheading offering additional context.
text(required)Main annotation content.
text-alignleftAlignment of annotation text (left, right, center, justify).
fillnskLightestGrayBackground color of the annotation box.
border-colornskMidGrayColor of annotation box border.
border-typesolidBorder style (solid, dashed, none).
rounded-boxfalseToggles rounded corners for the annotation box.
padding3ptPadding within the annotation box.
connect-to(none)Element the annotation arrow points to.
anchor-fromeastAnchor point on annotation box from which the arrow emerges.

Detailed Example

This example demonstrates advanced annotations featuring different styles and placements:

% Annotation 1: Simple, no border
\nskAnnotate[
  pos={left=2cm of a},
  anchor-from=east,
  connect-to=a.west,
  header={Explanation},
  title={Key Observations},
  text={This is an important portion.},
  fill=none,
  border-type=none,
]
Annotation Example

Customizing Reference Tags

Annotations are automatically numbered by default, providing convenient referencing. To explicitly define a tag, use ref-tag:

\nskAnnotate[
  ref-tag={Critical},
  text={Essential observation.},
  connect-to=myBlock.west,
]

Disabling Tags

To omit tags entirely, set disable-tag:

\nskAnnotate[
  disable-tag=true,
  text={Tagless annotation.},
  connect-to=myBlock.south,
]

Advanced Arrow Routing

Annotations support intricate arrow routing, beneficial in dense diagrams:

\nskAnnotate[
  connect-to=myBlock.north,
  connect-opts={
    arrow-style={dotted, thick},
    bend-route={single left},
    corner-radius=5mm
  },
  text={Clearly routed arrows improve readability.},
]

You can pass custom options to the connecting segments through the connect-opts key to define more advanced arrow routing behaviors. For more details, refer to the Routing System documentation.


Text Alignment

Ensure readability with the text-align property, ideal for multi-line annotations:

\nskAnnotate[
  text-align=justify,
  text={Justified alignment enhances readability, especially when the annotation spans multiple lines or includes detailed explanations.}
]

Best Practices

Recommendations

  • Keep headers concise for quick recognition.
  • Justify longer texts to maintain structured readability.
  • Match annotation colors and styles consistently with your diagram theme.
  • Arrange annotations logically to maintain visual flow.
  • Utilize distinct borders or fills to visually differentiate annotation types.

Practical Example

The following illustrates how annotations clarify layers in a neural network:

\begin{nskFigure}
  \nskBlock[id=input, text-center={Input Layer}]
  \nskBlock[last-pos={right=1.5cm}, id=hidden, text-center={Hidden Layer}]
  \nskBlock[last-pos={right=1.5cm}, id=output, text-center={Output Layer}]
 
  % Annotation for hidden layer
  \nskAnnotate[
    pos={above=2cm of hidden},
    connect-to=hidden.north,
    header={Hidden Layer},
    title={Feature Extraction},
    text={This layer transforms inputs into meaningful features through nonlinear activations.},
    rounded-box=true,
    border-color=nskBlue,
  ]
\end{nskFigure}

Reference

PropTypeDefault
anchor-from?token listeast
border-color?token listnskMidGray
border-radius?dimension1mm
border-size?dimension{}
border-type?token listsolid
connect-opts?token listarrow-style = {dotted, thick
connect-to?token list{}
disable-tag?booleanfalse
fill?token listnskLightestGray
header?token list{}
header-style?token list\bfseries
padding?dimension3pt
pos?token list{}
ref-tag?token list{}
rounded-box?booleanfalse
text?token list{}
text-align?choiceleft
text-color?token listc__nsk_principal
text-style?token list{}
tikz-opts?token list{}
title?token list{}
title-style?token list\itshape
width?dimension0cm
x?number0
y?number0

Key Takeaway

Annotations in Neural Sketch elegantly combine auto-management of numbering, positioning, and styling, allowing you to create diagrams that communicate ideas with unparalleled clarity and professional finesse.

On this page