In diagrams, I need to include images, such as symbolic icons or photos of actual hardware. I defined a generic TikZ style with two arguments: the name of the image, and the desired width. The height comes automatically with the same aspect ratio.
1 2 3 4 |
image/.style 2 args = {path picture = { \node at (path picture bounding box.center) { \includegraphics[width=#1cm] {#2}};}}, |
For the final node style, I apply this style plus adjustments such as actual node width and x or y separation:
1 2 3 4 5 6 |
Core/.style = { image = {2.4}{nexus7k}, minimum width = 2cm, inner ysep = 1.5cm }, FEX/.style = { image = {2}{nexus2k}, minimum width = 2cm, inner ysep = 0.5cm}, |
All style definitions above go into a \tikzset command, separated by comma, plus many more global styles I need:
1 2 3 4 5 6 7 8 9 10 |
\tikzset{% ... Core/.style = { ... }, ... Label/.style = {black, font= \scriptsize, rounded corners = 2pt, fill=green!50, draw, thin, inner sep = 3pt}, TextLabel/.style = {rounded corners = 8pt, fill=blue!15, draw}, … } |
This way I get photos with annotations for larger physical diagrams: