Neural Sketch

Embed Graphics

Learn how to embed graphics and customize their appearance within Neural Sketch blocks.

Introduction

Neural Sketch makes it simple to place images inside blocks—as native parts of your diagrams. You can inject anything from icons to plots, screenshots to schematics—using just one line of code.

There are two modes:

  • GFX embed — quick image injection, auto-scaled to fit
  • Custom embed — full manual control via raw TikZTikZ

Universal Raster Embedding

Neural Sketch offers robust, universal raster embedding features capable of automatically adapting graphics to any block shape. It also supports precise cropping, clipping, and customization to fit your exact diagramming needs.

Quick Usage

Use the embed-gfx key to quickly insert and automatically scale graphics to fit block dimensions:

\nskBlock[
  embed-gfx=<image-path>,
]

For advanced control, the embed key allows you to directly inject custom TikZTikZ commands:

embed={
    <custom-wrapper>
},

For instance a node with includegraphics

\nskBlock[
  embed={
    \node[] {
      \includegraphics[width=4cm, height=2cm]{../assets/in.png};
    };
  }
]

Comparison of Embed Types

Here's a comprehensive example illustrating both raw and gfx embeddings:

\nskBlock[
  embed-gfx={../assets/in.png},
]

Embedding in Custom Shapes

Neural Sketch automatically adapts embedded graphics to various block shapes. Here’s how graphics seamlessly fit into different geometrical primitives:

examples-doc/embed-s.tex
\nskContainer[text-north=Raster Block Embedding, text-north-loc=west]{
  \foreach \shape in
    {rectangle, circle, diamond, trapezium, semicircle}{
      \nskBlock[
        type=\shape,
        text-south=\shape, text-south-style={yshift=-2mm},
        last-pos-s=right,
        embed={ 
            \node[] 
            {\includegraphics[width=4cm, height=2cm]{../assets/in.png};}; 
        }, 
      ]
    }

Explore Available Shapes

Want to see which shapes you can embed into? Head over to the Basic Styles guide—it covers every supported primitive, from rectangles and circles to diamonds and trapezoids.

Fine-Tuning Padding

Control the spacing between your embedded graphics and block boundaries using embed-padding:

\nskBlock[
  embed-gfx={../assets/in.png},
  embed-padding=<padding-size>
]

Here's a practical demonstration:

examples-doc/embed-p.tex
\nskContainer[text-north=Variable Embed Padding, text-north-loc=west]{
  \foreach \p in {1,...,4} {
      \nskBlock[
        last-pos-s=right, text-north=\p mm,
        embed-gfx={../assets/in.png}, embed-padding={\p mm}
      ]
    }
}

Rounding the Embed

You can round the embedded content corners using embed-border-radius. This value mirrors the block’s own corner radius unless set manually.

\nskBlock[
  embed-gfx={../assets/in.png},
  embed-border-radius=<radius-size>
]

A visual example:

examples-doc/embed-b.tex
\nskContainer[text-north=Variable Embed B-Radii, text-north-loc=west]{
  \foreach \r in {0,...,4} {
      \tikzmath{int \oor, \r; \oor = \r+1;}
      \nskBlock[
        last-pos-s=right, text-north=\r mm, text-south=\oor mm,
        embed-gfx={../assets/in.png}, embed-border-radius={\r mm},
        border-radius={\oor mm},
      ]
    }

Design Tip

To maintain visual harmony between the block and its embedded graphic, consider offsetting their radii. For instance, if the inner (embedded) radius is set to 3mm, using 4mm or more for the outer block’s corner radius helps preserve a smooth, nested feel—especially in rounded or layered designs.


Reference Table

PropTypeDefault
embed-gfx?string{}
embed?TikZ code{}
embed-padding?dimension1mm
embed-border-radius?dimension1.3mm
embed-border-size?dimension.4mm

On this page