Talk:Document layout and layers/Floating objects

From Wiki
Jump to navigation Jump to search

From [1] Alan Braslau, ntg-context, 01 Mar 2023

A few (important) observations on floats:

   \startplacefloat
   \stopplacefloat

triggers a paragraph break.

I therefore locate them always at the beginning or at the end of a paragraph of text. (A trick is to enclose them in a named buffer within a paragraph, typically where a figure call - \in{figure}[figureReference] - is to be located. Then to place the \getbuffer at the beginning or end of a paragraph. See example below.)

The keys location=top/bottom will place the float at the top or bottom of the page IF IT FITS, otherwise it is pushed to the following page. Thus, a bottom can become a top.

The key location=force will place the figure there, perhaps generating a page break if it does not fit.

The key location=page will put the figure on a following page. This situation can sometimes push figures to appear "out of order", if another figure can somehow fit before the figure pushed to the following page. This happens if another floating figure "comes too soon".

The keys location=left/right will also generate a page break if the figure does not fit.

In the end, one needs to tweak a document in final form especially if it contains many figures, unfortunately. This is done by moving the \startfigure...\stopfigure. Here, the use of buffers:

   Paragraph text ...
   (see \in{figure}[myfigure]).
   \startbuffer[myfigure]
     \startfigure[reference=myfigure,
                  location=top,
                  title=Title]
       \externalfigure[myfigure][width=\textwidth]
     \stopfigure
   \stopbuffer
   More text ...\par
   \getbuffer[myfigure]

can make life easier, moving the \getbuffer[myfigure] to an optimal paragraph beginning or end.

Alan

P.S. It might be nice to be able to anchor a figure not to text but to a page location, like location=nexttop or location=nextbottom, or even location={nexttop,right} etc. This gets really complicated (but anything is do-able).

P.P.S. I'm certain to learn some neat trickery from Mikael's tutorial!