# [Tex/LaTex] overpic overlap box frame

framedgraphicsoverpic

.Hello tex.se community,
I have a problem when I put a\frame around an overpic environment.
The top border of the frame is overlapped by the picture.

Is it a bug or a wrong use of\frame command ?
I can't find anithing on the Internet or tex.se.

I just want to put a frame around the image.

Here is the mwe :

\documentclass{article}
\usepackage{graphicx}
\usepackage{overpic}

\begin{document}
\begin{figure}
\centering
\frame{\includegraphics[width=0.7\textwidth]{foo}}
\caption{framed figure include with \emph{includegraphics}.}
\end{figure}
\begin{figure}
\centering
\frame{\begin{overpic}[width=0.7\textwidth]{foo}
\put(50,20){foo}
\end{overpic}}
\caption{framed figure include with \emph{overpic}.}
\end{figure}
\end{document}


## Edit 1

The issue doesn't seems to come from the viewer and thin border rendering.
See this screenshot of the pdf rendering with xpdf and evince.
In this case, the image is a grey square an cross the right border of the frame.

# EDIT by cfr

The following image can be used to reproduce the issue:

\documentclass{article}
\usepackage{graphicx}
\usepackage{overpic}

\begin{document}
\begin{figure}
\centering
\frame{\includegraphics[width=0.7\textwidth]{img}}
\caption{framed figure include with \emph{includegraphics}.}
\end{figure}
\begin{figure}
\centering
\frame{\begin{overpic}[width=0.7\textwidth]{img}
\put(50,10){foo}
\end{overpic}}
\caption{framed figure include with \emph{overpic}.}
\end{figure}
\end{document}


Effect:

# Partial Solution

[using overpic package v0.53 2010/09/13]

## Possible explanation

The overpic package makes operations on the dimensions of the image to fit with the local basis used to position overlapping object. It seems that there is some approximations in these operations that lead to a wrong dimension of the image in the local basis. As the image is placed relatively to the bottom-left corner, it goes over the picture box on right or top side.

## Solution

It appear that the approximation of the image dimensions is different when the package is loaded with option percent, permil or abs.
In my case, the permil option seems to not introduce any error, with a correct framed image.

## Bug fix ?

I looked the overpic.sty file but I'm not expert in TeX at all.
If somebody can confirm my thought, we could fix this.
It's only a hundred of line file.