It keeps telling me: \begin{document} ended by \end{figure}, but I do not understand why. I tried to follow the guidelines for the subfigure package. Here is my MWE:
\documentclass[10pt,journal,a4paper]{IEEEtran}
\usepackage{listings}
\usepackage[pdftex]{graphicx}
\usepackage{subfig}
\usepackage{algorithmic}
\begin{document}
\begin{figure}%
\centering
\begin{subfigure}
nothing in it
\end{subfigure}
\qquad
\begin{subfigure}
\begin{lstlisting}
The code
With a line
\end{lstlisting}
\end{subfigure}
\caption{A program and its corresponding trace.\label{figuretrace}}
\end{figure}
\end{document}
I also tried the command \subfigure without success. I just would like to be able to embed a lstlisting environment inside a subfigure.
What is wrong?
EDIT
Another environment, algorithm, does not work either:
\begin{subfigure}
\begin{algorithm}
The code
With a line
\end{algorithm}
\end{subfigure}
Nor does this work with a table, tabular... Why not?


\lstlistingis a verbatim environment. In that case, it can't be stuffed inside another environment. Perhaps theverbatimboxpackage would give an acceptable alternative tolstlistingfor your situation. – Steven B. Segletes May 30 '13 at 13:48subfigureis not recommended; you should usesubfiginstead (pags 9 and 10 of the HOWTO). Also thealgorithmfloating environment shouldn't be used with this class (page 10 of the HOWTO document). – Gonzalo Medina May 30 '13 at 14:10