I would like to construct a figure using a collection of images/icons as nodes.
I'd like to be able to use matrix
, relative positioning and draw arrows between them.
I'm a bit stumped as to why my current solution (see below) displays the images centered at the lower left corner of node boxes, rather than at the center.
I've found that img./style={align=center}
solves the problem of centering them horizontally.
Any ideas as on how to align them vertically as well?
Use of pgfdeclareimage
and pgfbox
are not required, but just a part of my attempt to get it to work.
Code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\begin{document}
% a bunch of images at 64pxx64px
\pgfdeclareimage{observer}{figures/engineer.png}
\pgfdeclareimage{home}{figures/home.png}
\pgfdeclareimage{user}{figures/user.png}
\pgfdeclareimage{framework}{figures/user.png}
\tikzset{
% style for inserting images as nodes
img/.style={
text width=2cm,
text height=2cm,
rectangle,
align=center,
draw} % only for debugging..
}
\begin{tikzpicture}
\matrix[nodes=img, column sep=0.2cm]{
\node[] (user) {\pgfbox[center,center]{\pgfuseimage{user}}}; &
\node[ right=of user] (home) {\pgfbox[center,center]{\pgfuseimage{home}}}; &
\node[ right=of home] (obse) {\pgfbox[center,center]{\pgfuseimage{observer}}}; \\
};
\end{tikzpicture}
\end{document}
Result:
Best Answer
This is one possibility as suggested by Zarko.
Notes:
text height
as it will spoil the show.width
value in\ing
andtext width
as you wish.inner
andouter sep
with zero value give better look.