10

This question is quite related to Penalty-enhanced approach to float placement, but here I am focusing on the situation for LaTeX3.

The LaTeX2e float placement algorithm does not look backward because of performance/complexity constraints at the time it was originally written.

Is a backward-looking approach planned for LaTeX3, and if so, will penalties be used to encourage a float's placement near adjacent text in the source file?

Paul Gessler
  • 29,607

1 Answers1

11

The current best idea of what a float placement algorithm could look like is the xor (extended output routine) package. That's been worked on off or on since before I joined the project in 1992, although it's not really compatible with LaTeX2e (or LaTeX2.09), It only really makes sense to introduce a new output routine as part of a new format since it is an pervasive change affecting all processing of every page of the document however you can read its surrounding documentation for the basic ideas

http://latex-project.org/svnroot/experimental/trunk/xpackages/xor/

Note that the xpackages versions of the code are designed to be run as packages in latex2e, but in the case of xor you can only really do this for test documents it is not likely to be compatible (or stable enough) to be used with real documents and so we don't encourage its general use, unlike stable packages like xparse.

David Carlisle
  • 757,742
  • Not sure this directly addresses the question! BTW, when you say 'not really compatible with LaTeX2e' perhaps you should explain you mean 'not usable with real documents without change_ rather than 'cannot be loaded on top of LaTeX2e'. – Joseph Wright Jan 31 '15 at 08:58
  • I might also link to the more 'user friendly' GitHub interface to the code: https://github.com/latex3/svn-mirror/tree/master/xpackages/xor – Joseph Wright Jan 31 '15 at 09:00
  • 1
    @JosephWright People should beware the friendly exterior: the code will still bite the unwary:-) – David Carlisle Jan 31 '15 at 09:02
  • Thanks David, but as Joseph hinted: can you address if a backward-looking approach is planned/being considered for LaTeX3 and if penalties will interact with the float placement algorithm? I think this would be an interesting feature if it could be done: users could for example set the penalties based on their preferences/requirements (with sensible defaults set, of course); such as: a float deferred more than 4 pages is "more bad" than a widow or orphan line at that spot, and other variations. – Paul Gessler Jan 31 '15 at 12:38
  • 1
    @PaulGessler I don't think penalties are related really. As for looking back you can't really do that in tex however as with cross references you can use an auxiliary file to pass information from a previous run. One thing we experimented with was a simple external text file that recorded which page each float went to, and if you wanted to change the outcome just edit the file to say float x must end up on page 26 rather than 28 and then the output routine would force that to happen (or give an error if it couldn't) – David Carlisle Jan 31 '15 at 12:42
  • @DavidCarlisle they're not currently (now I know that from my other question) but they could be in the future. You can't look back in TeX, but it could be done in the LaTeX output routine, no? Store the last n pages to allow potential float placements and ship pages to TeX only after the "lookback window" has passed over them? – Paul Gessler Jan 31 '15 at 20:51
  • @PaulGessler yes and no, you could certainly hold more, but really that's looking further ahead than looking back. that is when you reach a float you can't go back and revisit page break decisions, but you could (perhaps) store say a chapters worth of material and so not make any decisions. Perhaps. As for penalties (as in tex primitive penalty nodes) I can't immediately think how they can be used to control floats choices, but tex being tex there is always a way:-0 – David Carlisle Jan 31 '15 at 21:14