# IEEE Latex Listing

Here is a minimal version of my code:

\documentclass[10pt, conference, compsocconf]{IEEEtran}
\usepackage{listings}
\lstset{frame=single,language=C}

\begin{document}
\begin{lstlisting}[caption=matrix multiplication pseudo
code,linewidth=8.7cm,label=lst1:mxm]

#include <stdlib.h>
#include <stdio.h>
void main(int argc, char **argv)
{
printf("hello! ");
}
\end{lstlisting}

\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,IEEEexample}

\end{document}


My questions:

• How can i add a space after the caption ?

• How can reduce the size of the police of the pseudo code ?

Thanks a lot. Best Regards.

• Can you please add the \documentclass line? Jun 5, 2015 at 16:57
• ok :) it's done :) Jun 5, 2015 at 17:00
• What do you mean with "size of police"? Jun 5, 2015 at 17:23

Class IEEEtran only distinguishes between table and figure captions. When the caption is made (\@makecaption), it checks for table and sets the space \abovecaptionskip below, otherwise \abovecaptionskip is set above the caption. \belowcaptionskip is not used. Table captions should be set above the table and figure captions below. Since the listings caption is set above, the following redefinition of \lst@makecaption tricks IEEEtran to think a listings is a table to put the space below the caption.

The empty space above the first source line with contents is removed by removing the empty line.

The font size of the listings can be changed by using option basicstyle.

\documentclass[10pt, conference, compsoc]{IEEEtran}

\usepackage{listings}
\lstset{
frame=single,
language=C,
basicstyle=\small,
}

\makeatletter
\def\lst@makecaption{%
\def\@captype{table}%
\@makecaption
}
\makeatother

\begin{document}
\begin{lstlisting}[
caption=Matrix multiplication pseudo code,
label=lst1:mxm,
]
#include <stdlib.h>
#include <stdio.h>
void main(int argc, char **argv)
{
printf("hello! ");
}
\end{lstlisting}
\end{document}