[Tex/LaTex] How is cropping for EPS-files done in XeLaTeX

cropepsfloatsgraphicsxetex

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}

Output

Best Answer

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.