# How to correctly clip with viewports with includegraphics and beamer columns?

I will happily accept any alternative to beamer's columns and \includegraphics that produces the intended result in a beamer slide.

I'm trying to take the attached eps file and reorganize it so that it fits in to a beamer slide by using viewports and clip to have effectively 3 separately cropped images. PNG version:

Here is the MWE:

\documentclass[compress,red,notes]{beamer}

\begin{document}

\frame{\frametitle{}
\begin{columns}
\begin{column}{0.5\textwidth}
\includegraphics[width=\textwidth, viewport=13 730 671 1146, clip=true]
{SmatExample}
\\
\includegraphics[width=\textwidth, viewport=13 439 722 722, clip=true]
{SmatExample}
\end{column}
\begin{column}{0.5\textwidth}
\includegraphics[width=\textwidth, viewport=13 13 722 435, clip=true]
{SmatExample}
\end{column}

\end{columns}

}

\end{document}


As you can see, it almost works, but the cropping slightly cuts off the letters, and also cuts in to the bottom of Figure B, putting the bottom of Figure B in to the top of Figure C (it is hard to tell in this low resolution version, but there should be no lines above "S Matrix" in Figure C):

When I check the viewport coordinates in gsview, they look correct, both at the original high resolution (100ppi) and the attached 30ppi image.

Note: I have recently asked two questions in an attempt to get at this one, which has helped in some ways, but I feel I am no closer to the answer (thanks for the help so far!):

Multiple commands in declareGraphicsRule - how to do it?

auto-correct bounding box for eps files that simply wrap a bitmap

Additionally, playing with resolution=xxx did not seem to have an effect for \includegraphcis. See

Image from \includegraphics showing in wrong image size

epstopdf takes the bounding box of SmatExample.eps:

%%BoundingBox: 14 14 723 1147


to create the PDF file. The image is moved to (0,0), and a new media size is calculated:

/MediaBox [0 0 709 1133]


The coordinates of gv/gsview/... are based on the EPS version. For the PDF version and viewport, the coordinates needs to be corrected by subtracting the old origin values of the bounding box. Actually the following example subtracts 13 in both cases:

\documentclass[compress,red,notes]{beamer}

\begin{document}

\frame{\frametitle{}
\begin{columns}
\begin{column}{0.5\textwidth}
\includegraphics[width=\textwidth, viewport=0 717 658 1133, clip]{SmatExample}
\\
\includegraphics[width=\textwidth, viewport=0 426 709 709, clip]{SmatExample}
\end{column}
\begin{column}{0.5\textwidth}
\includegraphics[width=\textwidth, viewport=0 0 709 422, clip]{SmatExample}
\end{column}

\end{columns}
}
\end{document}


\fbox is helpful for a visual control of the viewports:

\documentclass[compress,red,notes]{beamer}

\begin{document}

\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.1pt}

\frame{\frametitle{}
\begin{columns}
\begin{column}{0.5\textwidth}
\fbox{\includegraphics[width=\textwidth, viewport=0 717 658 1133, clip]{SmatExa
\\
\fbox{\includegraphics[width=\textwidth, viewport=0 426 709 709, clip]{SmatExam
\end{column}
\begin{column}{0.5\textwidth}
\fbox{\includegraphics[width=\textwidth, viewport=0 0 709 422, clip]{SmatExampl
\end{column}
\end{columns}
}
\end{document}


• To make one's images portable then, it seems the best solution is to adjust all bounding boxes to have the lower left corner at (0, 0)? – bbarker May 27 '14 at 23:54
• @bbarker: For portability with all kind of drivers: yes. – Heiko Oberdiek May 28 '14 at 1:09