7.5 Key value approaches for floats and subfloats

In most examples that we have seen so far, the

s manually placed at the appropriate point in the float body,1 so it is largely up to the user where that happens. The two packages described in this section take a different approach: here a free style float body has vanished, and instead you specify a float object as one argument and a caption object as another (or as a key value).

The placement and formatting are then under the control of the package and can be influenced by set of key/value pairs. On the plus side this gives a consistent and easy-to-use interface, but one downside is that not all of the customization possibilities offered by the packages in the previous sections are exposed. What outweighs the other is probably a matter of taste.

However, both packages also offer one or the other feature not available anywhere else; e.g., hvfloat provides special caption placement possibilities, as well as the ability to deal with floats that are large so that the caption (or even part of the float) needs to go onto a separate page. keyfloat combines most packages from this chapter under a common syntax and offers margin and wrapped floats and the ability to add auxiliary text including artist/author names in consistent ways. Both packages support the concept of subfloats including their appropriate numbering.

7.5.1 hvfloat - Sophisticated caption placement control and more

The hvfloat package, named after its author Herbert Voß, probably started as a weekend activity to “provide a concise and consistent method for specifying simple floats”. However, over time it has grown considerably and incorporated ideas from several other packages (e.g., sidecap or fltpage) that were developed a long time ago, but stopped being fully usable, because of missing maintenance and updates.

The main idea of the package is that instead of a free style float body with one or more captions inside, you have the float body and the caption as two separate objects. The placement of them in relation to each other is then determined by a set of key/value pairs, which gives a high degree of flexibility in manipulating the relationship.

7.5.2 keyfloat - Bringing most packages under one roof

Most of the core packages discussed in this chapter that manipulate floats were written a long time ago. They are still state of the art, but each of them solves only a subset of the existing problems in this space.

The keyfloat package by Brian Dunn is a more recent addition in this space. Its task is not so much to provide new functionality, but to bring existing functionality together in a concise interface. It automatically loads and uses graphicx, rotating, caption, subcaption, placeins, wrapfig, and calc. From this list you can probably guess that it is strongly interested in figure floats, but it supports table and other floats equally well. The main idea is to provide a concise set of commands and environments offering a key/value syntax that delivers the typical sequence of a float environment, loading a graphic or other content, placing caption and graphic, and setting up a label, list entry, etc., behind the scenes.