Breitere Überschrift für Auflistung mit Multicol

Breitere Überschrift für Auflistung mit Multicol

Ich verwende die Pakete multicolund listings. Bei mehrspaltigen Auflistungen möchte ich, dass die Überschrift über die gesamte Auflistung verteilt wird.

Hier ist ein MWE meines Versuchs. Die Ausgabe ist jedoch nicht wünschenswert, da die Überschrift nur in der ersten Spalte steht.

\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}

Antwort1

Hier ist eine Möglichkeit, bei der explizit die multicolsUmgebung (anstelle des multicolsSchlüssels) verwendet wird. Die Überschrift wird mithilfe \captionofdes captionPakets gesetzt, wobei das optionale Argument verwendet wird 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}

Bildbeschreibung hier eingeben

verwandte Informationen