
Я использую пакеты multicol
и listings
. Я хотел бы, чтобы заголовок был распределен по всему списку для списков с несколькими столбцами.
Вот пример того, что я пытаюсь сделать, однако результат нежелателен, поскольку подпись помещается только в первый столбец.
\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}
решение1
Вот одна из возможностей, явно использующая окружение multicols
(вместо multicols
ключа); заголовок набирается с использованием \captionof
из caption
пакета, с использованием необязательного аргумента 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}