我正在使用multicol
和listings
包。我想让标题分布在整个多列列表中。
这是我正在尝试的 MWE,但是输出不理想,因为标题仅放在第一列。
\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}