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... Best, Denis
Yes, me too. I found the best thing is to post on LaTeX stack exchange a short piece of context that shows one problem you are having. Tag it #context. Someone will kindly help. Repeat for your other problems. I use layers a lot to avoid floats. Good luck, Peter
On 28/02/2023, at 11:47 PM, 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...
Best, Denis ___________________________________________________________________________________ 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 ___________________________________________________________________________________
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
On 2/28/2023 11:45 AM, Denis Maier via ntg-context wrote: 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). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Thu, 2 Mar 2023 00:12:53 +0100
Hans Hagen via ntg-context
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
On 2/28/2023 11:45 AM, Denis Maier via ntg-context wrote: 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!
Thanks everyone for your responses. That's quite a bit to digest. I'll have a look, read and play around. Thanks again and all the best, Denis
-----Ursprüngliche Nachricht----- Von: ntg-context
Im Auftrag von Alan Braslau via ntg-context Gesendet: Donnerstag, 2. März 2023 03:35 An: Hans Hagen via ntg-context Cc: Alan Braslau Betreff: Re: [NTG-context] Float control On Thu, 2 Mar 2023 00:12:53 +0100 Hans Hagen 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
On 2/28/2023 11:45 AM, Denis Maier via ntg-context wrote: 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 __________________________________________________________ _________________________
Hi Denis,
The floats where jumping around, appearing in a different order than in the source file
Tables and figures can appear in different orders than each other, and a top float could appear at the top of the page that it is mentioned, but if you ever see Figure 2 before Figure 1 or a float appearing before it is placed in the source (with the exception of the top issue), then you've probably found a bug.
some positioning keys had not the intended effect (e.g. top)
I've had mixed results with some of the positioning keys too, but "top" should generally work okay. If you're using columns, weird stuff can sometimes happen with top/bottom floats, but you should still be able to make them work. You can also try adding \setupfloat[ntop=100] at the start of you're document. I've had that fix an otherwise- unexplainable bug once.
I know, TeX's float positioning algorithm should be rather reliable and stable
Not as much as you would expect. The TeX page breaking algorithm is greedy, single-pass, and dependant on every page prior, so you can get some pretty chaotic results in pathological situations. "Typical" documents don't usually have any issues, but you can (even accidentally) make a document that gives some really weird results.
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?
The only float documentation for ConTeXt that I'm aware of is a short section in It's in the Details https://www.pragma-ade.nl/general/manuals/details.pdf#%5B%7B%22num%22%3A39%2... and another short section in the old Reference Manual http://pmrb.free.fr/contextref.pdf#aut%3A957 There's also the Wiki page https://wiki.contextgarden.net/Floating_Objects and the source code https://source.contextgarden.net/tex/context/base/mkxl/strc-flt.mklx I haven't been able to find anything that really goes into the details though. (If there's something that I'm missing here, please let me know! I've been looking for awhile now)
Maybe I'm missing out on something fundamental...
At the TeX level, floats are known as \insert's/insertions. The end of Chapter 15 in The TeXbook goes into detail here. TeX By Topic also has a good description in Chapter 29 https://texdoc.org/serve/texbytopic/0#chapter.29 Then there's also Low Level TeX which documents the changes in LMTX https://www.pragma-ade.com/general/manuals/lowlevel-inserts.pdf Inserts are (in my opinion) the most complicated part of TeX. Even at an engine level, they aren't that well documented. When writing the footnote code for lua-widow-control, I had to read through "TeX the program" since some of the details weren't documented anywhere else. And as Peter mentioned, if you post a specific example someone will probably come along and help. -- Max
participants (5)
-
Alan Braslau
-
denis.maier@unibe.ch
-
Hans Hagen
-
Max Chernoff
-
Peter Hopcroft