I am trying to put some code in an alltt environment, in a subfigure in LLNCS documentclass.

I was previously using another documentclass which supported the subcaption package just fine, but when changing it to llncs, the subcaption package outputs

The `subcaption' package does not work correctly in compatibility mode.

So I think I am bound to use a \subfloat in the subfig package. Unfortunately, I could not get it working, and the answer at the similar question \begin{alltt} inside \subfloat is not quite satisfactory for me: would I have to use n saveboxes, one for each subfig in the figure?

Also, I think the main problem here is the next error that happens if I replace subcaption with subfig as per the previously linked question:

Something's wrong--perhaps a missing \item
  • The problem is that alltt cannot go in the argument to another command.
    – egreg
    Commented Jul 8, 2016 at 11:27

1 Answer 1


It seems [1] that the altt environment uses an internal list, and that floats do not place nice with it.

So, it seems that the walkaround is to embed the alltt text inside a minipage, like so:

  \subfloat[Subcaption here]{\label{fig:example:mwe}%
      your altt text goes here
\caption{The whole figure's caption. Can refer to \ref{fig:example:mwe}.}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .