Here's a compilable example of the listing code I'm currently using to define my code listing :
Code: Select all
\documentclass[12pt,letterpaper]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{here}
\usepackage{array}
\usepackage{booktabs}
\usepackage{subfig}
\captionsetup{margin=1cm,format=hang,font=small,format=plain,labelfont={bf,up},textfont={it}}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\begin{document}
\lstset{tabsize=4,frame=single,language=mathematica,basicstyle=\scriptsize\ttfamily,keywordstyle=\color{black}}
\begin{lstlisting}[title={Some pretty long code title, just to show its lenght over the box. I need it to be of the same size as the box itself. Currently, it is not !}]
Some code here...
\end{lstlisting}
\end{document}
So how can I define a margin of 0 cm for the listing titles, without changing the figures and sub-figures captions ?