I have example listings for a book.
I'd like a horizontal rule the width of the tcolorbox between the caption and the listing.
The code used to produce it:
\documentclass[letterpaper,oneside,12pt]{book}
\usepackage{listings}
\usepackage[most]{tcolorbox}
\usepackage{caption}
\usepackage{xcolor}
\definecolor{shadecolor}{gray}{0.95}
\definecolor{captionbox}{cmyk}{0.43, 0.35, 0.35,0.01}
\tcbset{colback=captionbox!5!white,colframe=captionbox!75!black}
\BeforeBeginEnvironment{lstlisting}{\begin{tcolorbox}[toprule=3mm]\vskip-.5\baselineskip}
\AfterEndEnvironment{lstlisting}{\end{tcolorbox}}
\DeclareCaptionFormat{listing}{\parbox{\textwidth}{#1#2#3}}
\captionsetup[lstlisting]{format=listing,skip=10pt}
\lstset{numbers=none}
\begin{document}
\begin{lstlisting}[caption=Sample code block]
This is a code block
\end{lstlisting}
\end{document}
My only constraint is that I need to use the listings package and lstlisting because Pandoc requires that for listings. I am happy to replace anything else to produce the same effect of a box around the caption and listing with the rule between the caption and listing and a similar style feel.
Sample code block
) defined?