\documentclass{IEEEtran}
\usepackage{lipsum}
\usepackage{listings}
\begin{document}
\lipsum[1]
\begin{lstlisting}[%
caption={``Hello, world!'' program},
frame=single,
language=c,
belowcaptionskip=1cm
]
printf("Hello, world!\n");
\end{lstlisting}
\lipsum[2]
\end{document}
Note how little space appears between the caption and the frame. Now
change "IEEEtran" to "article" and note that the requested 1cm of space
appears as expected.
I'm running the 20070206 version of TeX Live, which provides the following
IEEEtran and listings versions:
IEEEtran.cls 2007/01/11 V1.7 by Michael Shell
listings.sty 2004/10/17 1.3b (Carsten Heinz)
-- Scott
> It seems that lstlisting's belowcaptionskip option is ignored when using
> the IEEE documentclass.
Scott,
IEEE's figure and table captions pose a special problem in that a
nonzero \abovecaptionskip is used for figures, but that the same
spacing is used *below* table captions because the table captions
are *prior* to the tables. Thus, we really need \abovefigcaptionskip,
\abovetabcaptionskip, \belowfigcaptionskip, etc. or something like
\captiontextskip, \captionfloatskip, etc.
For better or worse, my design choice for handling this in IEEEtran
was to use \abovecaptionskip as both caption-to-figure/table-skip
(i.e., in effect a \captionfloatskip) and totally ignore
\belowcaptionskip (i.e., a \captiontextskip), which always defaults to
0pt (well, other than the nominal space provided by a \begin{center})
under IEEEtran. If I were to use both \abovecaptionskip and
\belowcaptionskip, then their roles would have to be reversed for
tables. Either way, there is going to be a lie of sorts.
In your case, you can restore a hook to \belowcaptionskip by using
this patch code after IEEEtran loads:
\makeatletter
\let\@ORGmakecaption\@makecaption
\long\def\@makecaption#1#2{\@ORGmakecaption{#1}{#2}\vskip\belowcaptionskip\relax}
\makeatother
As far as what is the proper thing to do to make everyone play nice,
well that I am not to sure about because the base LaTeX system
does not seem to anticipate the mixed use of above/below captions.
Sigh.
Mike Shell
That works for what I'm doing; thanks!
> As far as what is the proper thing to do to make everyone play nice,
> well that I am not to sure about because the base LaTeX system
> does not seem to anticipate the mixed use of above/below captions.
> Sigh.
topcapt's swapping of \abovecaptionskip and \belowcaptionskip for top
captions seems to work reasonably well. One merely think about the "above"
skip as being the skip between the float contents and the caption and the
"below" skip as being the skip between the caption and the body text,
regardless of which is typeset above the other.
-- Scott