我正在使用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}