Hugo Story Theme
Archives Slides Talks

Story’s Figures, Captions, and Tables

Published Aug 22, 2018 by Baron SCHWARTZ in Demo at https://story-customized.tchinchow.net/figures/

Story can automatically transform images into figures with captions. It can also add captions to tables. And it adds features and styling to both images and tables. This article is a demo of Story’s features for figures, tables, and captions.

Image Captions and Figures

If the feature-figcaption flag is set (and not negated), Story will transform your images into figures, and add a caption. There are several ways this can be done. Story tries each method, in the following order.

First, if an image is followed immediately by an <em> in the same paragraph, Story treats the content of the <em> as the image caption. To enable this, the image and the text must not have a blank line between them. Example:

![Water Lily](/img/unsplash-photos-vHnVtLK8rCc.jpg)
_Water lily photo by Zoltan Tasi on Unsplash_

This markup results in a <p><img...><em...></p> markup that Story converts into a captioned figure. Hover your mouse over the picture to see the caption:

Water Lily Water lily photo by Zoltan Tasi on Unsplash

If there’s no <em> to use, Story uses the image’s title attribute as a fallback:

![Water Lily](/img/unsplash-photos-vHnVtLK8rCc.jpg "A water lily")

Water Lily

Finally, Story falls back to the alt attribute:

![Water Lily](/img/unsplash-photos-vHnVtLK8rCc.jpg)

Water Lily

Table Styling

Story has multiple built-in table styles that you can apply with feature flags. The default is similar to GitHub’s table styling:

CommandDescription
git statusList all new or modified files
git diffShow file differences that haven’t been staged
git commitRecord changes to the repository
git branchList, create, or delete branches

There is also a style designed for tables that are part of an article with figures, resembling scientific papers or other more formal use cases. This is enabled with feature-tablefig. Click here to toggle.

ItemEstimatedPositive and SignificantNegative and Significant
Demographic Variables for Head
Male857411
Age85850
Age Squared85085
Head’s Education
Completed primary or incomplete secondary76760
Completed secondary or higher60600
Completed secondary19190
Higher20200
Unknown12120

Tables with columns of right-aligned numbers are more readable with fixed-width numerals; click to toggle feature-tablefw. Observe the table below and see how its columns are easier to read with fixed-width numerals. This is noticeable with Github-style table formatting, but not with academic-style.

DateInclination, deg.Longitude, Asc. Node, deg.Mean Distance, auEccentricityMean Longitude, deg.
Jan. 287.005248.4860.3870970.205644355.3943
Mar. 97.005248.4870.3870980.205646159.0899
Apr. 187.005248.4890.3870970.205649322.7854
May 287.005248.4900.3870970.205650126.4812
July 77.005248.4920.3870980.205645290.1771
Aug. 167.005248.4930.3870980.20564593.8725
Sept. 257.005248.4940.3870980.205642257.5683
Nov. 47.005248.4950.3870990.20563561.2628
Dec. 147.005248.4970.3870990.205635224.9579
Dec. 547.005248.4980.3870980.20563328.6524

Mercury’s Heliocentric Osculating Orbital Elements Referred to the Mean Equinox and Ecliptic of Date for 2013

Caption Styling And Linking

Story uses JavaScript and CSS to make figures and tables more beautiful and functional.

  • Figures and tables get sequentially numbered ID attributes of #fig-1 and so on, so you can link to them.
  • The feature-figlink feature flag searches the article for text such as Figure 1 and automatically links it to the appropriate figure.
  • If the feature-fignum feature is enabled, the text of the caption is prepended with the figure number. Click here to toggle this feature, then inspect the captions again to see the effect.
  • The feature-figcaption-hidden feature makes the captions hidden until you move the mouse over them. The feature-figcaption-visible feature flag overrides this and makes the captions visible immediately below the image. Click here to toggle this feature.

Table Captions

Story doesn’t convert tables to figures, but it can add captions to tables. See Table 3, which is followed by a paragraph whose entire content is inside an <em> tag. If the feature-tablecaption feature is enabled, Story will use unobtrusive JavaScript to move that paragraph’s text into the table’s <caption> element.

Tables can be autolinked and table captions can be numbered, similar to images. These features are controlled by the same feature-figlink and feature-fignum flags that control image captioning and linking, so they’ll be consistently applied.

Read next: Story’s Image Slideshows.

Baron Schwartz

Baron Schwartz is the creator of Hugo’s Story theme.

Find out more about Baron on his web site.

Story logo

© 2025 Baron Schwartz / Lionel VICTOR