6
votes

Hi LaTeX enthusiasts and TeX programmers!

I'm currently developing a single-page document class for some kind of flyers which should be generated automatically. Unfortunately the limited amount of space doesn't make it possible to display everything on the page, so I need to skip some articles completely (I don't want only one half of a article printed on the flyer).

In pseudo code, thats the command I am looking for:

\if_sufficient_vspace_left
    {<big block/minipage with an article>}
    {<otherwise do nothing or something else>}

And the use cases are:

  • If there is enough vertical space for the following article left on the page, print the article completely. Otherwise add only the headline to an »Other Articles« list.
  • If there is enough vertical space left, add a big advertisement, otherwise add a smaller one or do nothing.

I am quite sure that there will be a way to obtain this. For example, the TeX command \leaders, which works in vertical and horizontal mode, only inserts the leader if there is enough space left. Unfortunately I don't want to repeat anything, and an else action might be great too.

Any keywords and tips to useful commands will be appreciated. You don't have to post complete solutions (but you can of course).

Many thanks,
Christoph

1

1 Answers

2
votes

The 'needspace' package may give you what you're looking for, although if there is not enough space it inserts a pagebreak:

http://ctan.org/pkg/needspace

You would use it something like this:

\needspace{5\BaseLineSkip}    %  assume you need 5 lines for minipage
    {<big block/minipage with an article>}

If you don't want a page break when there isn't enough space, instead want more content but with the minipage saved until next page, then you will need to investigate how LaTeX handles "floats":

http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions