Blog

Signals Blog

Chemical Structure Kerning

Kerning often comes up in the context of typography, in which it refers to adjustments made to the horizontal space between characters. Balanced whitespace can have an enormous effect on both readability and visual perception of quality, which explains why kerning has been important in typography for many years.

Chemical Structure Layout

Although rarely discussed, chemical structure layout shares many similarities to the arrangement of characters in typography. For example, the horizontal positioning of three or more structures in a row forces the author to decide how to space each structure. This is essentially the same faced when laying out a line of text and solved with kerning.

A recent question by Renée Webster on Twitter suggests that this topic might be more than an abstract mathematical puzzle.

Monospaced Structures

All of the structure drawing tools I'm aware of use monospacing, which is easy to understand and explain. Draw an imaginary box around each structure. Then make the gap between each structure equal to the amount of free horizontal space divided by one less than the number of structures.

monospaced structures
Monospaced structures. The first two structures appear closer together than the others.

The limitations of monospacing become pronounced with substituent crowding.

monospaced structures with crowding
Monospaced structures with crowding. The first two structures now appear much closer than the others.

Alternative: Center Spacing

We can partially solve the problems of structure monospacing by enforcing equal spacing between the center of each structure.

center spaced open
Center spaced structures. Better, but now there's too much space between the first two structures.

But this approach breaks down once again on adding more substituents.

center space crowded
Center spaced structures with crowding.

Solution: Structure Kerning

Fonts can aid text layout algorithms by providing kerning metrics. Unfortunately, the dynamic nature of chemical structures means that no such pre-configuration is possible. Nevertheless, structure kerning can be achieved by manual layout.

Manual structure kerning. The distance between the first two structures was chosen by inspection. The remaining three structures were monospaced.

In the majority of cases, manual layout will simply be too time consuming to be practical. In fact, this is exactly the kind of thing that sofware should be doing, isn't it? Still, the simplicity of the result hides a potentially complex algorithm that would be needed for the general case:

Conclusions

Typography and chemical structure layout share many qualities, one of which being the desirability of kerning. Although automatic structure kerning would appear to be an eminently achievable feature, it would not be a simple task. Has a drawing tool ever implemented it?