ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Alan Braslau via ntg-context <ntg-context@ntg.nl>
To: Hans Hagen via ntg-context <ntg-context@ntg.nl>
Cc: Alan Braslau <alan.braslau@icloud.com>
Subject: Re: Float control
Date: Wed, 1 Mar 2023 19:35:01 -0700	[thread overview]
Message-ID: <20230301193501.76e68fd6@boo.my.domain> (raw)
In-Reply-To: <8d147251-030a-0b3e-450b-8693b2041004@freedom.nl>

On Thu, 2 Mar 2023 00:12:53 +0100
Hans Hagen via ntg-context <ntg-context@ntg.nl> wrote:

> On 2/28/2023 11:45 AM, Denis Maier via ntg-context wrote:
> > Hi everyone,
> > 
> > I’ve recently had to typeset a document that gave me some headaches
> > with the floats. The floats where jumping around, appearing in a
> > different order than in the source file, tables ended up split up
> > at weird points, some positioning keys had not the intended effect
> > (e.g. top), «page» moved the float more than seemed necessary for
> > me... I know, TeX’s float positioning algorithm should be rather
> > reliable and stable, and it’s quite possible that I’m messing
> > things up in my setups–especially since my source files are XML.
> > 
> > Anyway, I’d like to learn more about the whole float issue. Is
> > there anything particular I could read to learn more about the
> > whole thing? Maybe I’m missing out on something fundamental...
> Basically floats are output in order when they fit. You can use force
> to really do that. When there is no room they will migrate. Some
> options like top and bottom might also change the order. Normally you
> start with just placing ('here') and see how that works out. Side
> floats are special and anchored to the text.
> 
> The more complex and confliuctign the demands, the harder it gets for 
> ConTeXt to fulfill all requirements. In that case shifting around the 
> text or places where you ask for a float helps. It's one of the areas 
> where 'fully automated and perfect' are complex as everything can 
> interfere.
> 
> Btw, Mikael S is working on a tutorial that explains some neat
> trickery with specific placements (which also triggered some
> additional features).

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 and location=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!
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2023-03-02  2:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 10:45 Denis Maier via ntg-context
2023-03-01 19:34 ` Peter Hopcroft via ntg-context
2023-03-01 23:12 ` Hans Hagen via ntg-context
2023-03-02  2:35   ` Alan Braslau via ntg-context [this message]
2023-03-02 12:24     ` Denis Maier via ntg-context
2023-03-01 23:22 ` Max Chernoff via ntg-context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230301193501.76e68fd6@boo.my.domain \
    --to=ntg-context@ntg.nl \
    --cc=alan.braslau@icloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).