Here is my listing caption format:

enter image description here

Here is my figure caption format:

enter image description here

How can I format the listing captions to be the same as figure captions? here is the relevant bit from the style file:

% Revised formatting for figure captions and table titles. 

 \vskip 10pt 
        \baselineskip 11pt
        \setbox\@tempboxa\hbox{#1. #2}
        \ifdim \wd\@tempboxa >\hsize
        \sbox{\newcaptionbox}{\small\sl #1.~}
        \usebox\newcaptionbox {\footnotesize #2}
          \centerline{{\small\sl #1.} {\small #2}} 

\def\fnum@figure{Figure \thefigure}
\def\fnum@table{Table \thetable}
% \def\fnum@lstlisting{Listing \thelstlisting}  %% this didn't work
  • 1
    It would be helpful if you composed a fully compilable minimal working example (MWE) including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. Commented Jan 8, 2019 at 17:17
  • It matters which listing package you use. Commented Jan 9, 2019 at 17:12

1 Answer 1


Use package caption and match the formatting in the main style file my_base_style.sty:

\captionsetup[lstlisting]{justification=justified, labelfont=it, font= 
{footnotesize}, labelsep=period, skip=10pt}

Be sure to do this after \usepackage{my_base_style}.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .