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

The following TikZ code

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

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 Answer 1


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


    \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);

enter image description here

You must log in to answer this question.

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