TransWikia.com

How to use captions in the style of headings in the appendix of floating environments?

TeX - LaTeX Asked on June 25, 2021

TL;DR: If I have to word it differently, I could also ask: How can I use headings instead of captions for these entries (listings or figures)?

I do have these elements:

  • pictures in figure floats
  • source code listings with minted

I do have these requirements:

  • create a listoffigures for all figures/images
  • create a listoflistings for all source code listings

This is all no problem, and I’ve already listed the commands on how to do that, but now I have one problem:

  • I use the package appendix and I do want to list the long source code entries and some images in there.

This can also easily be done by moving them there (and optionally using h for the float to keep it at it’s position), however, the small caption it inserts there is really small IMHO.
Especially if you have long source code entries that can easily get lost and IMHO is not useful in the appendix, where there is no surrounding text.
The caption there is then smaller than the actual source code and does not fulfill it’s purpose of being a caption/heading for that piece of code anymore.

As a solution, I’d want this:

  • Keep the caption "semantically" (i.e. it should appear in the listoffigures or listoflistings), but show it as a heading (section or so, in any case in a style that is not so tiny as captions usually are).

Now I don’t know how to best approach it: Keep using caption? Hide the caption, and use a heading instead? Fake a caption and use a simple section command before? Or somehow fake the listof… entry?


Here are the important options from minted:

% Make listoflistings appear in TOC and heading-like in the same way as "listoffigures". https://tex.stackexchange.com/a/448329/98645
addtotoclist[float]{lol}
renewcommand*listoflistings{listoftoc[{listoflistingscaption}]{lol}}
makeatletter
newcommandl@listing{l@figure}
makeatother

newenvironment{multipageListing}{
    setstretch{1.0}
    captionsetup{type=listing}
}{}

At the end of the document it e.g. does:

    newpage

    begin{appendices}

        chapter{Source code}
        label{sourceCode}
        
        begin{multipageListing
            caption{Some JS}
            label{lst:someJs}
            
            inputminted{js}{./res/data/some.js}
        end{multipageListing}

        % more listings here

        chapter{Images/Screenshots}
        label{images}
        
        % and some figures here

    end{appendices}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP