This is question with regards to the previously asked question How to include a picture over two pages
I think this is a great little bit of code, however it doesn't seem to be working for me. I've copied and pasted the \twopagepicture
code from the solution given above into a test file, along with a large picture (.jpg
format) to use.
The test file is:
\documentclass[twosided]{book}
%...twosidepicture code copy/pasted from above by M. Scharrer>
\begin{document}
\chapter{testing code}
This is a test for the code.
\twosidedpicture{t}{p}{image.jpg}{Caption test}
\end{document}
This is processed via pdfLaTeX through MikTeX 2.8.
LaTeX spits out two errors, both the same:
! Illegal unit of measure (pt inserted).
\width
1.105 \end{document}
The output of this file is 3 pages. The first shows the dummy chapter title. The second page shows the oddsided portion of the twopage image correctly with a caption below it. However, page three shows the LHS image again but clipped incorrectly: The image begins from the left (hence clipping off the RHS) and the top of the image is not level with the image on the LHS page.
Not sure exactly what is causing this, but after a search the only point at which there is a call to \width
is within the \twopagepicture
code itself.
Any help would be greatly appreciated.
Best Answer
This is caused by a bug in the current version of
adjustbox
. Thetrim
values are evaluated before the\width
macro is set. I fixed this in the package and the next released version will work fine with the given code.As cmhughes pointed out you can actually use the custom width
\mywidth
here because it is also used to determine the to-be-adjusted content. So instead of:you can write:
which will work with the current buggy version as well.
I used
\adjustbox
(which is somewhat based on thegraphicx
code) around the\includegraphics
macro because we need to resize first and then clip. Unfortunately\includegraphics
doesn't provide a\width
macro to clip relative to the original width.However I added some new features to
adjustbox
since I wrote the original code and so you can write it as well in the following form when theadjustbox
package is loaded with theexport
option:which works because
Clip
is handled differently thanclip,trim=...
, or: