I've recently seen this the following image in this question:

enter image description here

As I was looking for a way to create nice captions (without the "Figure:") for a beamer presentation, I wondered if it was possible to create this effect within LaTeX.

I got so far with GIMP:

enter image description here enter image description here

I did it like this:

  1. add a white layer where the caption will go and set it's transparancy to 50%
  2. gaussian blur on the image where the caption will go 3 add the caption

Can I do this within LaTeX, too?

I have a couple of images which I would like to include in a beamer presentation like this, so it would be great if this worked.

(I've tried a google image search for this, but "latex caption" seems not to be good ... even when I filter explicit results)

My try:



        \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=\linewidth]{foto-martin.jpg}};
        \begin{scope}[x={(image.south east)},y={(image.north west)}]
            \draw[white, fill=white!50!transparent] (0,0.05) rectangle (1,0.1);
            \node at (0.5, 0.075) {\Huge Martin};

But I don't know how to get the transparency / positioning working.

As somebody suggested imagemagick, I tried this:

width=`identify -format %w foto-martin.jpg`;     convert         -background '#0008'         -fill white         -gravity center         -size ${width}x40             caption:"Martin"             foto-martin.jpg +swap         -gravity south         -geometry +0+10        -composite  out.jpg

But I can't get some padding for the text in the caption and the box arround.

  • 6
    Drawing on an image with TikZ – cmhughes Mar 6 '13 at 18:53
  • 1
    @cmhughes: Thank you very much! The positioning-problem is now almost fixed :-) – Martin Thoma Mar 6 '13 at 19:00
  • 2
    @moose Writing your name on your forehead is the equivalent of putting a caption inside a picture:-) I wouldn't recommend it. – user10274 Mar 6 '13 at 19:13
  • 2
    @MarcvanDongen: OTOH, you might want to put some text on a (blurred) part of the picture and make it semi-transparent, so I find the question more general-purpose and very good indeed. One application that comes to mind is a calendar on a photograph. (I did something like that in Gimp, with pictures of my daughter for my parents, and it was an instant hit;).) – mbork Mar 6 '13 at 19:21
  • 3
    @MarcvanDongen I have to do a presentation about a project. This includes showing five team members. I would like to do it on one slide. This means, I don't have much space for captions below. Additionally, I think this looks very good. – Martin Thoma Mar 6 '13 at 20:00

Assuming that this question isn't a duplicate of Drawing on an image with TikZ you can achieve what you want by using the opacity=<value> key, where value can be anything between 0 (invisible) and 1 (completely visible).


Complete MWE



        \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=\linewidth]{mushroom}};
        \begin{scope}[x={(image.south east)},y={(image.north west)}]
            \draw[white, fill=gray,opacity=0.5] (0,0) rectangle (1,0.15);
            \node[opacity=0.5] at (0.5, 0.075) {\Huge Mushroom};
  • Arrgh.... I wait a little the delete mine eheh. That mushroom is magic! – percusse Mar 6 '13 at 22:18
  • There is no blurred effect! – Paul Gaborit Mar 6 '13 at 22:22
  • @cmhughes: I didn't know opacity=0.5. Thank you! – Martin Thoma Mar 6 '13 at 22:53
  • I've adjusted some values a little bit. May I edit your solution? As I applied your solution to my presentation, I noticed that I have to choose the adjust the font size manually. Not that was a big problem ... Here is the result – Martin Thoma Mar 6 '13 at 22:56
  • I'd like to give +2 because from all the captions in this thread so far, this one looks the most beautiful, blur effect or not. – Christian Mar 7 '13 at 1:29

Here's an approach that uses ImageMagick to blur the image and place a clipped version on top of the unblurred image (which requires -shell-escape or -enable-write18 to call the external program). The whole thing is wrapped in a macro called \labelimage{<file name>}{<image width>}{<label text>}. The background rectangle style can be set using image label background/.style, the label node uses image label text/.style:



    image label text/.style={
        white, font=\sffamily
    image label background/.style={
        white, opacity=0.35
        \immediate\write18{convert #1 -blur 0x3 blurred#1}
        \node [inner sep=0pt] (original) {\includegraphics[#2]{#1}};
            shift=(original.south west),
            x=(original.south east),
            y=(original.north west)
        \fill [clip] (0,0.05) rectangle (1,0.25);
            \node [inner sep=0pt, anchor=south west] {\includegraphics[#2]{blurred#1}};
            \fill [image label background] (0,0.05) rectangle (1,0.25)
                node [text opacity=1, pos=0.5, image label text] {#3};

  • 1
    +1. Your solution requires -shell-escape or -enable-write18... – Paul Gaborit Mar 6 '13 at 22:50
  • Could you adjust your solution so that I can resize the image? I would like to call it like \labelimage[width=0.3\textwidth,height=0.4\textheight,keepaspectratio]{foto-martin.jpg}{Martin}. I've also noticed that relative paths like ../images/foto-peter.jpg seem not to work. – Martin Thoma Mar 6 '13 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.