# How is cropping for EPS-files done in XeLaTeX?

When trying to crop an EPS-figure with trim=<left> <bottom> <right> <top>, clip, ... it results in strange behavior. Please find a MWE and a image of the result below.

It seems like the cropping is done only for the top and the right (or twice). In this post you can read the proceeding until now, to get the boundaries of the EPS recognized by xetex.def and dvipdfmx.def.

\documentclass[]{scrreprt}
\usepackage{xltxtra}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{subfigure}[b]{.3\linewidth}
\includegraphics[width=\linewidth]{Beispiel.eps}
\caption{No clipping}
\end{subfigure}
\begin{subfigure}[b]{.3\linewidth}
\includegraphics[trim = 100 0 0 0, clip, width=\linewidth]{Beispiel.eps}
\caption{Trimming left}
\end{subfigure}

\begin{subfigure}[b]{.3\linewidth}
\includegraphics[trim = 0 100 0 0, clip, width=\linewidth]{Beispiel.eps}
\caption{Trimming bottom}
\end{subfigure}
\begin{subfigure}[b]{.3\linewidth}
\includegraphics[trim = 0 0 100 0, clip, width=\linewidth]{Beispiel.eps}
\caption{Trimming right}
\end{subfigure}

\begin{subfigure}[b]{.3\linewidth}
\includegraphics[trim = 0 0 0 100, clip, width=\linewidth]{Beispiel.eps}
\caption{Trimming top}
\end{subfigure}
\begin{subfigure}[b]{.3\linewidth}
\includegraphics[trim = 100 100 100 100, clip, width=\linewidth]{Beispiel.eps}
\caption{Cropping all}
\end{subfigure}
\end{figure}

\end{document}


-

trim for EPS files with xetex.def is broken. As workaround convert the EPS files to PDF:

• epstopdf file.eps
• ps2pdf -dEPSCrop file.eps

Then include the PDF version of the images in the TeX file.

-
Ok, taking a pdf works. Transferring with \usepackage{epstopdf}, \includegraphics{Beispiel} and initexmf --edit-config-file=miktex\config\pdftex.ini => EnableWrite18=t results in xelatex> Package epstopdf Warning: Drivers other than 'pdftex.def' are not supported.. PDF made by ghostview has a lot of margin. Inkscape works perfect. But not a solution for all my figures to transfer them to PDF by hand. –  LaRiFaRi Jun 18 '13 at 13:52

Clipping is broken in xetex.def up to version 0.94, but this is fixed in version 0.95 and following. In the forthcoming TeX Live 2013 the version of xetex.def is 0.97. The most recent version corrects also some glitches in the order the options are processed.

Here's an example.

\documentclass{article}
\usepackage{fontspec}
\usepackage{graphicx}
\begin{document}
\includegraphics[clip,trim=3cm 3cm 3cm 3cm,width=.5\textwidth]{tiger.eps}

\newpage

\includegraphics[trim=3cm 3cm 3cm 3cm,width=.5\textwidth]{tiger.eps}
\end{document}


## TeX Live 2012

-
How did you get TeX Live 2013? –  kiss my armpit Jun 18 '13 at 13:53
He's testing TL 2013 (tug.org/texlive/pretest.html) –  daleif Jun 18 '13 at 13:55
@mozartstraße Test version, but now it's the one that will be released. Just a few days left. Don't run to the servers that provide the test version: they are few and overloading them is not a good idea. Just be patient for a couple of weeks. –  egreg Jun 18 '13 at 13:57
@daleif and egreg: OK. Thank you! –  kiss my armpit Jun 18 '13 at 13:58
trim=3cm 3cm 3cm 3cm should have select the middle of the image, not the lower left part. Thus xetex.def 0.97/TL 2013 is still broken. :-( –  Heiko Oberdiek Jun 18 '13 at 14:01