在多個頁面上橫向並排輸入列表

在多個頁面上橫向並排輸入列表

我對 (la)tex 還很陌生,現在正在處理一個文檔,我希望在橫向模式下並排放置兩個輸入列表。現在的問題是這段程式碼:

\documentclass{scrreprt}
\usepackage{lscape}
\usepackage{listings}

\lstdefinestyle{code}{
    basicstyle=\footnotesize\ttfamily,
    stringstyle=\ttfamily, 
    frame=single,
    tabsize=2,
    breaklines=true,
    belowcaptionskip=1\baselineskip,
    showstringspaces=false,
}

\begin{document}

    \begin{landscape}
        \begin{minipage}{.48\textheight}
            \lstinputlisting[escapeinside={(*}{*)},style=code,captionpos=b,caption=file1]{file1.cpp}
        \end{minipage}\hspace{20pt}
        \begin{minipage}{.48\textheight}
            \lstinputlisting[escapeinside={(*}{*)},style=code,captionpos=b,caption=file2]{file2.cpp}
        \end{minipage}
    \end{landscape}

\end{document}

我在清單之前得到一個空白頁面,我的程式碼從第二個頁面開始,如果它比頁面長,就會被切斷。除此之外,是否可以在每個頁面上顯示標題?

我已經搜尋了可能的解決方案,但我還沒有找到任何針對這個明確用例的解決方案,其中大多數都在解釋如何使用表來做到這一點。

對此有一些有用的見解值得讚賞。

相關內容