1

I am trying to insert small icons (figures.jpg/png) in a triangle. I have this code:

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage{pgf}
\usepackage[english]{babel}
\usepackage{graphicx}
\definecolor{bluedeep}{RGB}{0, 13, 51}
\begin{document}

\begin{tikzpicture}
\draw[color=bluedeep,line width=0.5mm] (0,6) -- (7,6) -- (7,8) -- (0,8) -- (0,6);
\draw[color=bluedeep,line width=0.5mm] (0,4) -- (7,4) -- (7,6) -- (0,6) -- (0,4);
\draw[color=bluedeep,line width=0.5mm] (0,2) -- (7,2) -- (7,4) -- (0,4) -- (0,2);
\draw[color=bluedeep,line width=0.5mm] (0,0) -- (7,0) -- (7,2) -- (0,2) -- (0,0);

\end{tikzpicture}

\end{document}

which gives the following result: enter image description here

I want to have a figure like this: enter image description here

The small icon encircled with black pen is a figure on the hard disk that I have to add using \includegraphics. For your sake just pick any icon you want but it has to be added using \includegraphics because in my case I have specific icons to add to these boxes. Additionally all small rectangles should have a label just as I have shown in the figure by encircling using red pen.

Thank you in anticipation.

2

1 Answer 1

3

You can use \includegraphics in a \node, e.g. \node at (x,y) {\includegraphics{filename}};, and knowing that it's just a matter of picking the right coordinates.

I used some loops to add text and images, if all icons are different, and the positions are not meant to be regular, use separate \node commands, with appropriate coordinates.

output of code

\documentclass[a4paper,12pt]{article}
\usepackage{tikz} % loads pgf and graphicx
\usepackage[english]{babel}
\definecolor{bluedeep}{RGB}{0, 13, 51}
\begin{document}

\begin{tikzpicture}
\draw [bluedeep, line width=0.5mm] (0,0) rectangle (7,8);
\foreach \y in {2,4,6}
   \draw (0,\y) -- (7,\y);

\foreach [count=\i] \txt in {
  Text A,
  Text B,
  Text C,
  Text D}
  \node[below] at (3.5,\i*2) {\txt};

\foreach \y in {1,3,5,7}
  {
   \node at (1.5,\y) {\includegraphics[width=1cm]{example-image-a}};
   \node at (3.5,\y) {\includegraphics[width=1cm]{example-image-b}};
   \node at (5.5,\y) {\includegraphics[width=1cm]{example-image-c}};
  }

\end{tikzpicture}
\end{document}
1
  • Cheers. Just what I needed.
    – Saad
    Commented Jan 3, 2018 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .