[Tex/LaTex] Package listings, set caption position, option top works fine, but bottom does not

listings

I would like that caption position is at the center of the page, like the one at the top in my example.

Here my code:

\documentclass{article}

\usepackage{color}

\usepackage{listings}
\usepackage[justification=centering]{caption}

\lstdefinestyle{SC}{
    language=erlang,
    xleftmargin=.2\textwidth,
    xrightmargin=.2\textwidth
}

\lstset{ 
    numbers=left,
    numberstyle=\tiny,
    basicstyle=\scriptsize,
    showstringspaces=false,
    showspaces=false,
    commentstyle=\color{blue},
    keywordstyle=\bfseries\color{purple},
    captionpos=t,
    frame=lines
}

\begin{document}

\begin{lstlisting}[style=SC, caption={test}]
% Stop all containers
docker stop $(docker ps -a -q)
% Delete all containers
docker rm $(docker ps -a -q)
% Delete all images
docker rmi $(docker images -q)
\end{lstlisting}

\end{document}

The image shows the problem.

enter image description here

How can I set the caption to be centered? I have not found a solution in the package documentation.

Best Answer

The bug has been fixed in the caption package (https://gitlab.com/axelsommerfeldt/caption/commit/0a32b2b8d4f814c58da1969ac7f38c7f9ec8f183) and is included in current texlive for about half a year now.

Related Question