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:


%...twosidepicture code copy/pasted from above by M. Scharrer>


\chapter{testing code}

This is a test for the code.

\twosidedpicture{t}{p}{image.jpg}{Caption test}


This is processed via pdfLaTeX through MikTeX 2.8.

LaTeX spits out two errors, both the same:

! Illegal unit of measure (pt inserted).


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.

  • 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
    Commented Sep 26, 2011 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. Commented Sep 26, 2011 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
    Commented Sep 26, 2011 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. Commented Sep 27, 2011 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. Commented Sep 27, 2011 at 8:26

1 Answer 1


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}}%
  • 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}). Commented Sep 30, 2011 at 14:18
  • When in a two-sided document, how to ensure that a two-page wide picture starts always from the "left" page? Commented Nov 18, 2011 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. Commented Nov 18, 2011 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. Commented Nov 19, 2011 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? Commented Feb 9, 2012 at 15:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .