Package xetex.def Warning: No clipping support in XeTeX yet
However, clipping within TikZ works fine with text and the image as
shown by the example code below.
Can it be that the `xetex.def` driver file is outdated and the support
got actually implemented in the meantime?
I don't see a reason why that driver doesn't use the same technique as
the XeTeX system driver of PGF/TikZ.
Do you see this wrong?
I don't use XeLaTeX myself but wanted to add lower level clipping
support for my `adjustbox` package to avoid the dependency on PGF/
TikZ.
% Compile with xelatex
\documentclass{article}
\usepackage{tikz}
\begin{document}%
\frame{%
\begin{tikzpicture}%
\clip (0,0) rectangle (1em,1ex);
\node {Hello};
\end{tikzpicture}%
}
\frame{\includegraphics[trim=5cm 5cm 5cm 5cm,clip]{tiger.pdf}}% does
not clip
\setbox0\hbox{\includegraphics{tiger.pdf}}
% Clips fine
\frame{%
\begin{tikzpicture}%
\clip (5cm,5cm) rectangle (\wd0-5cm,\ht0-5cm);
\node [above right] {\usebox0};
\end{tikzpicture}%
}
\end{document}
in your adjustbox package, why don't you use \pgfpathqclip ?
Thanks in advance.
Originally I used TikZ code and then translated it to the PGF
equivalent without checking if there is such a better macro.
I'm planning now to replace the use of PGF/TikZ altogether. I already
found out how to do it with pdftex (`\pdfxform`) but still
have to crack `dvips` and other output drivers.
Best,
Martin
No \pdfxform must not be used for clipping, though it clips as a side
effect. If you use \pdfxform each time you clip, your pdf file will
grow up because \pdfxform inserts the box in the catalog each time.
Clipping with pdfTeX can be done with \pdfliteral.
\pdfxform (like \pdfximage) must be used when a same form (box) or
image have to be inserted many time in the document.
Regards.
>
> Best,
> Martin
The `pdftex.def` driver used by `graphics/x` uses:
\expandafter\pdfxform\GPT@temp\@tempboxa
\pdfrefxform\pdflastxform
Where `\GPT@temp` is either empty or an attribute.
I don't mind either way.
Please give me an example how to clip a given TeX box using four
parameters (llx, lly, urx, ury).
Best,
Martin
Just \setbox 0=\hbox{\tikz { \clip ...}}
And then \showbox 0 => look at the \pdfliteral code and you will know
how to proceed. This is what i've done for TabU images (and some leaders)
Each time you use \pdfxform, the form is inserted into the calatog.
I think pdftex.def does not provide clipping but for \includegraphics.
In this case, using \pdfxform or \pdfximage makes sense. It's just
non optimal if the same image is inserted many times in the document.
In TabU for example, the images are stored in a buffer, in order not
to insert the same image more than once (because images can be easily
replicated as backgrounds of cells). The same would apply for a tiled
wallpaper.
However, if you clip 1 squared centimeter of a A1 image, the full A1
image will be inserted in the pdf catalog with \pdfxform... This is not
what "clipping means" and pgf uses appropriately \pdfliteral to clip.
>
> Best,
> Martin
> I think pdftex.def does not provide clipping but for \includegraphics.
>
> In this case, using \pdfxform or \pdfximage makes sense. It's just
> non optimal if the same image is inserted many times in the document.
>
> In TabU for example, the images are stored in a buffer, in order not
> to insert the same image more than once (because images can be easily
> replicated as backgrounds of cells). The same would apply for a tiled
> wallpaper.
I don't see it:
Using:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[clip,trim=1cm 1cm 1cm 1cm]{tiger}
\includegraphics[clip,trim=1cm 1cm 10cm 1cm]{tiger}
\includegraphics[clip,trim=1cm 10cm 1cm 1cm]{tiger}
\includegraphics[clip,trim=1cm 10cm 1cm 10cm]{tiger}
\end{document}
I get:
<tiger.pdf, id=1, 612.2875pt x 644.4075pt> <use tiger.pdf> <use
tiger.pdf>
<use tiger.pdf> <use tiger.pdf>
and a PDF of 42k where the tiger.pdf (comes with PStricks) is 34k.
With only one image I get 40k.
The image isn't stored multiple times.
> However, if you clip 1 squared centimeter of a A1 image, the full A1
> image will be inserted in the pdf catalog with \pdfxform... This is not
> what "clipping means" and pgf uses appropriately \pdfliteral to clip.
Does \pdfliteral then strip all material of the A1 image which isn't
displayed?
It would surprise me.
Martin
Sorry this does not work for me with a .jpg image...
Don't know why.
It works for me with an JPG image as well.
pdfTeX 3.1415926-1.40.11-2.2 (TeX Live 2010)
kpathsea version 6.0.0
Copyright 2010 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh
(pdfTeX).
Compiled with libpng 1.2.40; using libpng 1.2.40
Compiled with zlib 1.2.3; using zlib 1.2.3
Compiled with xpdf version 3.02pl4
Martin
> When using the `clip,trim=..` options of \includegraphics XeLaTeX
> prints the error:
>
> Package xetex.def Warning: No clipping support in XeTeX yet
>
> However, clipping within TikZ works fine with text and the image as
> shown by the example code below.
> Can it be that the `xetex.def` driver file is outdated and the support
> got actually implemented in the meantime?
> I don't see a reason why that driver doesn't use the same technique as
> the XeTeX system driver of PGF/TikZ.
> Do you see this wrong?
I agree with you: it should be technically possible. The problem is
to find someone who can update the code of xetex.def. Jonathan Kew
wrote two or three years ago about it in the xetex mailing list.
Another idea would be the (x)dvipdfmx team. In their mailing list I
saw that Jin-Hwan Cho wrote the driver files for pgf.
--
Ulrike Fischer
> The problem is
> to find someone who can update the code of xetex.def. Jonathan Kew
> wrote two or three years ago about it in the xetex mailing list.
> Another idea would be the (x)dvipdfmx team. In their mailing list I
> saw that Jin-Hwan Cho wrote the driver files for pgf.
I simply would base the xetex.def code on the PGF driver, so that author would be indeed a good choice to contact. Who would be in charge to accept the new version?
--
Best Regards,
Martin Scharrer