0

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
1
  • The problem is that alltt cannot go in the argument to another command. – egreg Jul 8 '16 at 11:27
0

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:

\begin{figure}[t]
  \subfloat[Subcaption here]{\label{fig:example:mwe}%
    \begin{minipage}{0.4\textwidth}
      \begin{alltt}\scriptsize
      your altt text goes here
      \end{alltt}
    \end{minipage}
  }
\caption{The whole figure's caption. Can refer to \ref{fig:example:mwe}.}
\end{figure}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.