Título más amplio para listados usando multicol

Título más amplio para listados usando multicol

Estoy usando los paquetes multicoland listings. Me gustaría que el título se extendiera por todo el listado en el caso de listados de varias columnas.

Aquí hay un MWE de lo que estoy intentando, sin embargo, el resultado no es deseable porque el título se coloca solo en la primera columna.

\documentclass{article}
\usepackage{listings}
\usepackage{multicol}

\begin{document}

\begin{lstlisting}[caption={A longer caption that ideally spans all the columns in the listing, otherwise it just does not look right if you get what I mean}, multicols=3]

text not important
text not important
text not important
text not important
text not important
text not important

text not important
text not important
text not important
text not important
text not important
text not important

\end{lstlisting}

\end{document}

Respuesta1

Aquí hay una posibilidad, usando explícitamente el multicolsentorno (en lugar de la multicolsclave); el título está escrito usando \captionofel captionpaquete, usando el argumento opcional de multicols:

\documentclass{article}
\usepackage{caption}
\usepackage{listings}
\usepackage{multicol}

\begin{document}

\begin{multicols}{3}[\captionof{lstlisting}{A longer caption that ideally spans all the columns in the listing, otherwise it just does not look right if you get what I mean}]
\begin{lstlisting}

text not important
text not important
text not important
text not important
text not important
text not important

text not important
text not important
text not important
text not important
text not important
text not important

\end{lstlisting}
\end{multicols}

\end{document}

ingrese la descripción de la imagen aquí

información relacionada