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.

I am creating a TeX document to be distributed to a class and it must use a style file, es150.sty, provided by the professor. For reasons too verbose to get into here, let's assume that es150.sty is a black box which I cannot have access into in order to change the various spacing settings. I've created a document with this style file and everything compiles just fine. However, all of the text, headers, etc., that I need appear only on pages 1 and 2 (as desired), but TeX is generating a totally extraneous, blank page 3 at the end of the document.

I have read many message board posts about tinkering with the book class, the chapter class, and using things like the \part environment in order to remove blank pages and spaces that appear between chapters, or at the end of these types of documents. However, my question is specifically how to remove a single extraneous blank page from a document that's not of any of these types.

What I can say about es150.sty: It defines an environment called "handout" and another called "exercise" for creating homework exercises on a handout to give to students. This style file derives from some others and has been used for dozens of courses. It's a cut-and-dry template file with nothing fancy in it and it's been used consistently without problems like this in the past.

So, to summarize: is there a sane, practical, short way (preferably just by issuing some kind of \ignorepage{} command or something) to chop off the extraneous whitespace at the end of my document without tinkering with the .sty file?

share|improve this question

migrated from stackoverflow.com Feb 22 '11 at 15:23

This question came from our site for professional and enthusiast programmers.

    
Perhaps you could take a look at one of the earlier documents prepared with this style file and find out what you are doing differently. –  Svante Feb 21 '11 at 18:38
    
What Tex engine are you using? Pdftex/Xetex/Luatex? –  Charles Stewart Feb 22 '11 at 9:08
    
Presumably you have access to this style file so it's not actually a black box, but a transparent one. To continue the analogy into absurdity, although you cannot get inside it to change what it does, you can see which gears get messed up and carefully build a surrounding box that un-messes them. (This is basically what Konrad is suggesting). Unfortunately, without being allowed to look in the transparent box, it's hard for us to know which gears are getting mashed. –  Loop Space Feb 22 '11 at 15:33

3 Answers 3

There is a very practical way that doesn't mess with the style file, nor even your tex document: remove the blank page afterwards. If you are on a Unix system with TeXLive installed (debian package texlive-pictures) then you can use the utility pdftk to create a new PDF from an old one by selecting certain pages. If you are doubly fortunate and are using zsh, then here's a command that will strip off the last page of a PDF:

pdftk essay.pdf cat 1-$(pdfinfo !#:1 | perl -ne '/^Pages: *(\d+)/ && print ($1-1)') output !#:1:r.trunc.pdf
share|improve this answer

is there a … way … to chop off the extraneous whitespace at the end of my document without tinkering with the .sty file?

You can always just override the macros of the .sty file by redefining them in your actual document. This may not always be pretty but it’s absolutely possible. In the simplest case, if we assume that some command \foo is responsible for the blank page by issuing a command \clearpage, you can just copy that out of the .sty file and redefine it in your main document.

Given:

\newcommand\foo{…something…\clearpage…something else…}

Just put this into your document:

\renewcommand\foo{…somethign……something else…}

Of course, this needs to be adjusted for parameters etc. and it’s probably not as simple as removing a redundant \clearpage but the principle still applies.

share|improve this answer

It's certainly possible, since what Tex does with the page is controllable by redefining a token list, \output. I'm not sure how to determine whether a page is empty in vanilla Latex, because the contents of \output vary over document classes. With Luatex, you can look at the contents of a page after it is typeset and "rewind" if the page is blank, which allows you to write more robust code.

The following code might or might not work for you:

%%Put this at the point after which you want no blank pages
\makeatletter
\edef\@@output{\the\output}
\output={\ifdim\ht255<\hsize % \ht255 is the height of \box255, 
                             %  which contains the text to be output
            \relax
         \else \@@output \fi}
\makeatother

I haven't tested it.

share|improve this answer

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.