如何在LaTeX中将列表分页?

8
我正在尝试将我的列表分成几页,但不幸的是,它没有起作用。
我已经阅读过,如果你设置breaklines=true,它应该自动工作。但我做不到。是否有其他选项而不创建多个列表?
    \lstset{numbers=left,
    columns=fullflexible,
    stepnumber=1,
    basicstyle=\footnotesize\ttfamily,
    numberstyle=\color{lineNumberColor}\tiny,
    inputencoding=utf8,
    showtabs=false,
    extendedchars=true,
    showstringspaces=false,
    showspaces=false,
    tabsize=4,
    postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{pred}\hookrightarrow\space}},
    commentstyle=\slshape\color{commentColor},
    keywordstyle=\color{keywordColor}\bfseries,
    stringstyle=\color{stringColor}\ttfamily,
    breaklines=true,
    breakatwhitespace=true,
}

example


已经设置好了,但页面没有分页。 - N33D
1个回答

10

假设您想要指定在清单中新页面的起始位置,可以使用escapeinside选项进行设置。当breaklines选项设置为true时,该选项确保换行以适应页面宽度。

通过指定escapeinside=`` ,您可以在两个重音符号(`)之间转义清单上下文。要换行,您可以在重音符号之间插入\newpage,就像这样:

\begin{lstlisting}[escapeinside=``]
    page 1

    `\newpage`

    page 2
\end{lstlisting}

该清单应分为两页,第一页上写有“page 1”,下一页上写有“page 2”。

如果你不知道页面应该在哪里分页,而且希望LaTeX能够自动计算,该怎么办呢? - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接