0

TikZ noob here: The following is a simplified and equivalentdescription of my problem.

The following TikZ code

\begin{tikzpicture}
       \node[inner sep=0pt] (stony1) at (0,0){\includegraphics[width=.04\textwidth]{example-image-a}};
\end{tikzpicture}

produces the following a picture inline with my latex text as expected . However, I would like to add some tikz code that produces a blue rectangle above that same included image of the same (horizontal) width. I should be able to customize the height of that rectangle.

What code should I add for this?

In a nutshell, I want to go from the following picture to

enter image description here

the following picture

enter image description here

1 Answers1

4

You can draw a rectangle on top of the node containing the image. The yshift=1ex adjusts the height of the blue box.

\documentclass{article}
\usepackage{tikz}

\begin{document} \begin{tikzpicture} \node[inner sep=0pt,outer sep=0pt] (stony1) at (0,0) {\includegraphics[width=.04\textwidth]{example-image-a}}; \fill[blue] (stony1.north west) rectangle ([yshift=1ex]stony1.north east); \end{tikzpicture} \end{document}

enter image description here