다중 열을 사용한 목록의 더 넓은 캡션

다중 열을 사용한 목록의 더 넓은 캡션

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에서 조판됩니다 .captionmulticols

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

여기에 이미지 설명을 입력하세요

관련 정보