Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
Since you are running MiKTeX 2.8, it may be that some packages are outdated. Compile your minimal working example (MWE) and add \listfiles in your document preamble. Then, include all the file versions by editing your post. –  Werner Sep 26 '11 at 3:18
    
have you considered updating to latest miktex 2.9 or texlive 2011? It is very likly that you will stumble over more problems related to outdated packages. –  Matthias Pospiech Sep 26 '11 at 10:54
    
I can replicate the error on a fresh installation of TeXlive 2011. I changed trim=0 0 {\width} to trim=0 0 {\mywidth} and trim={\width} to trim={\mywidth}. It produced (what I think) was the intended results. @MartinScharrer will know if this was appropriate or not. –  cmhughes Sep 26 '11 at 21:53
    
@cmhughes, Stephen: This is a bug in the current version of adjustbox. Apparently the \width (and \height etc.) macros are no longer provided. The code in my answer is actually correct and compiles fine with v0.3 but not with the current one. I will fix this ASAP. –  Martin Scharrer Sep 27 '11 at 6:47
1  
@Stephen: Please always post a complete minimal working example (MWE) and double-check if the issue also appears with it. Your code e.g. has a typo in the class option (twoside not twosided) and misses the required filler text (e.g. a \lipsum) in order to have normal figure placement. Without that text both parts will be placed on one float page. It is always difficult to discuss issues if we don't have the exact same code. Anyway, here it is was a package issue. –  Martin Scharrer Sep 27 '11 at 8:26
show 1 more comment

1 Answer

This is caused by a bug in the current version of adjustbox. The trim 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:

\adjustbox{trim=0 0 {.5\width} 0,clip}{\includegraphics[width=2\mywidth]{#3}}
%...
\adjustbox{trim={.5\width} 0 0 0,clip}{\includegraphics[width=2\mywidth]{#3}}

you can write:

\adjustbox{trim=0 0 {\mywidth} 0,clip}{\includegraphics[width=2\mywidth]{#3}}
%...
\adjustbox{trim={\mywidth} 0 0 0,clip}{\includegraphics[width=2\mywidth]{#3}}

which will work with the current buggy version as well.

I used \adjustbox (which is somewhat based on the graphicx 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 the adjustbox package is loaded with the export option:

\includegraphics[width=2\mywidth,Clip=0 0 {.5\width} 0]{#3}}%
%...
\includegraphics[width=2\mywidth,Clip={.5\width} 0 0 0]{#3}}%

which works because Clip is handled differently than clip,trim=..., or:

\includegraphics[width=2\mywidth,Clip=0 0 {\mywidth} 0]{#3}}%
%...
\includegraphics[width=2\mywidth,Clip={\mywidth} 0 0 0]{#3}}%
share|improve this answer
    
I (also) was hunting the last two days the "! Illegal unit of measure (pt inserted)" error. Finally, found the above mentioned solution -- thank you so much! Note for LyX users: However, the above does not work when inserting the picture itself in LyX (without modifying the picture's properties at all, like size scaling, rotation, et.c.). It worked only when typing the complete command in an ERT box (i.e. \twopagepicture{b}{p}{photo.jpg}{Test}). –  Nikos Alexandris Sep 30 '11 at 14:18
    
When in a two-sided document, how to ensure that a two-page wide picture starts always from the "left" page? –  Nikos Alexandris Nov 18 '11 at 10:08
    
@NikosAlexandris: Have a look at the code in my original answer tex.stackexchange.com/questions/23860/…. I use \ifoddpage to check if the page is odd and then use \afterpage either once or twice to place it accordantly. –  Martin Scharrer Nov 18 '11 at 10:32
    
I did already! Me thinks that something I use in the Preable overrides this check!? Will investigate as far as I understand and report back. –  Nikos Alexandris Nov 19 '11 at 15:33
    
I did not investigate this in detail--no time. However, I guess the multiple changes between empty and other pagestyle(s) within the document, or the various \clearpages I use, could be the reason? –  Nikos Alexandris Feb 9 '12 at 15:20
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.