views:

23

answers:

1

I have defined a new LaTeX environment for excursions in a book chapter I am writing. The environment is multipage and often includes inline images. Moreover, I am using the shaded environment to give the environment a background colour to make it stand out a bit.

However, the environment, as shown below, is split up by floating tables and images, which makes the flow of the environment visually more difficult to follow. For example, it is now difficult to see if that floating image or table is part (the missing background colour does not help). So, I like to extend my environment to disallow it to be interrupted by floating elements, but do not know how to get that done.

\newcounter{bioclipse}
\def\thebioclipse{\thechapter-\arabic{bioclipse}}
\newenvironment{bioclipse}[2][]{\begin{small}\begin{shaded}\refstepcounter{bioclipse} \par\medskip\noindent%
   \textbf{Bioclipse Excursion~\thebioclipse #1: #2
   \vspace{0.1cm} \hrule \vspace{0.1cm}}
   \rmfamily}{\medskip \end{shaded}\end{small}}

Any solution to disallow interruption is fine, even if the background colour is done differently.

+1  A: 

The algorithm for insertion is rather complex. Basically you want that any pending insertion must not be put into the page where the env bioclipse apply. As first fast solution you could flush all the insertion first, and then start the new chapter. If you want to put figures or whatever into the environment, and you want them to be "flushed" only after the last page where the env is at work... second fast solution is: put them after the environment directly!! So they won't "annoy" the page/s at all (of course, avoid using of footnotes).

The other solution (making it someway automatic) is a little bit tricky. Insertion places for "pending" materials are chosen while constructing the vertical list that is the page ("candidate"), in the output routine. This means you have to play with the output routine at worst; but maybe it is too much, unless you're planning your own TeX format, and maybe LaTeX gives easier choices...

Digging a bit in LaTeX codes, I see there's a conditional you can try to use, it is \@insert* i.e. \@insertfalse and \@inserttrue. If you're lucky they "drive" the possibility of putting insertions, so that at the beginning of your env you can say \@insertfalse and at the end \@inserttrue. Try, I am not saying it works.

As maybe you know to use @ as letter catcode so that it can be part of a "command" name, you have to use \makeatletter and \makeatother when you finished (likely default class/style preamble does it for you).

You could also be iterested in having a look at placeins style (it could be already in your installation, otherwise, see here ) which apparently could solve (part of) your problem.

ShinTakezou