The simplest way is to use the onimage
package from the From Answers to Packages
project, which implements the answer given in Drawing on an image with TikZ.
To use the package: Download the file onimage.dtx
from bazaar.launchpad.net/~tex-sx/tex-sx/development/files, run pdflatex
on it, and move the resulting .sty
file to your working directory.
Then you can load the onimage
package and use the tikzonimage
environment, which has the form
\begin{tikzonimage}[<options for includegraphics>]{<image name>}[<options for TikZ>]
...
\end{tikzonimage}`
The coordinate system will be scaled in such a way that (0,0)
is the bottom left corner of the image, and (1,1)
is the top right. You can disable this scaling, if you wish, by setting the key tsx/scale cs=none
in the optional TikZ arguments.
Here's a simple example:
\documentclass{article}
\usepackage{onimage}
\begin{document}
\begin{tikzonimage}{bottle.jpg}
\draw [orange, line width=5pt] (0.5,0.92) circle [radius=0.75cm];
\end{tikzonimage}
\end{document}
![](https://i.stack.imgur.com/NML6R.png)
You can switch on a grid to help you position your TikZ objects by setting the key tsx/show help lines
.
\documentclass{article}
\usepackage{onimage}
\begin{document}
\begin{tikzonimage}{bottle.jpg}[tsx/show help lines]
\draw [orange, line width=5pt] (0.5,0.92) circle [radius=0.75cm];
\end{tikzonimage}
\end{document}
![](https://i.stack.imgur.com/HaVqc.png)
In order to get the labels to look like you described them, you can use the font=<font commands>
option to set the font options, fill=<color>
for the background and text=<color>
for the text color. To keep things neat, you can define a new style for this using
\tikzset{
<new style name>/.style={
fill=black,
text=white,
font=\fontfamily{phv}\selectfont\Large\bfseries
}
}
Here's an example in which I've also added the label position (0.2 cm from the bottom right edge of the images) as part of the style definition, and made the style alter the every node/.style
, which is applied to all nodes in a TikZ picture. This allows us to apply this newly defined style to the whole TikZ picture in the tikzonimage
optional argument, instead of applying it to the node itself using \node [<style>] {};
:
![](https://i.stack.imgur.com/veLnJ.png)
\begin{document}
\tikzset{
image label/.style={
every node/.style={
fill=black,
text=white,
font=\fontfamily{phv}\selectfont\Large\bfseries,
anchor=south east,
xshift=-0.2cm,
yshift=0.2cm,
at={(1,0)}
}
}
}
\begin{tikzonimage}[width=0.5\textwidth]{bottle}[image label]
\node{A};
\end{tikzonimage}
\begin{tikzonimage}[width=0.25\textwidth]{bottle}[image label]
\node{B};
\end{tikzonimage}
\end{document}
This is possible by hooking in to the footline
template. Fortunately, beamer
provides the \addtobeamertemplate
command so once the theme has been loaded it is straightforward to add some extra code there. With the mechanics sorted, the next question is as to how to make it easy to use. What I decided to do (though there may well be other methods) was to use the \addtobeamertemplate
to place an overlaid tikzpicture
as the last thing on the page. Then I provide a macro which can place things in this picture. This is cleared every slide, so using overlay specifications it is to control what appears on each slide. Here's an example (hopefully it's clear from the pictures that the overlay really does cover everything. Setting the fill colour to something like pink
makes it even clearer):
\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/45420/86}
\usepackage{tikz}
\usetheme{Copenhagen}
\makeatletter
\def\ft@overlay{}
\addtobeamertemplate{footline}{}%
{%
\lineskiplimit0pt
\begin{tikzpicture}[remember picture,overlay]%
\ft@overlay
\end{tikzpicture}%
\gdef\ft@overlay{}%
}
\newcommand<>{\addtooverlay}[1]{%
\only#2{%
\expandafter\gdef\expandafter\ft@overlay\expandafter{\ft@overlay #1}%
}%
}
\makeatother
\begin{document}
\section{Beamer}
\begin{frame}{Beamer}
Some text
\pause
\addtooverlay<.(1)>{%
\draw[fill=black,opacity=0.70]
(current page.north east) rectangle (current page.south west);
\node[text=white,font=\Huge] at (current page.center) {Overlaid};
}
\pause
And yet more text
\end{frame}
\end{document}
![Slide three, no overlay](https://i.stack.imgur.com/qQzjJ.png)
Best Answer
You can include the picture into a TikZ node and then draw some rectangles over it. For example,
with a picture from Wikipedia as
some_image.jpg
gives the two slidesNote the
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics{...}};
line. This adds the picture so that the lower left corner is at the origin of the TikZ coordinate system. Section 14.6 “Rounding Corners” of the TikZ manual (v2.10) tells you how you can change the corner rounding.Btw, do you really mean
width=1\textheight
?