防止清單後分頁

防止清單後分頁

當內部列表後面緊跟著外部列表的末尾時,如何防止內部列表後出現分頁符號?

兩個清單中的其他地方都應該允許分頁。

微量元素

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\newenvironment{lista}{%
  \list{}{}%
    \item\relax
}{%
    Prevent page break before here.
  \endlist
}
\newenvironment{listb}{%
  \list{}{}%
    \item\relax
}{%
  \endlist
}
\begin{document}
\vspace*{7.5cm plus 1cm}
\begin{lista}
  \begin{listb}
    \lipsum[4]
  \end{listb}
  Permit page break before here.
  \begin{listb}
    \lipsum[4]
  \end{listb}
\end{lista}
\end{document}

答案1

若要防止內部清單後面緊接在外部清單末端時出現分頁符,您可以\filbreak在內部清單之後和其後的文字之前使用該指令。該\filbreak命令鼓勵在該點進行分頁,以防止內部列表和外部列表之間的中斷。這是 MWE 的更新版本:

\documentclass[twocolumn]{article}
\usepackage{lipsum}

\newenvironment{lista}{%
  \list{}{}%
    \item\relax
}{%
    Prevent page break before here.
  \endlist
}
\newenvironment{listb}{%
  \list{}{}%
    \item\relax
}{%
  \endlist\filbreak % Use \filbreak to prevent a page break after the inner list
}

\begin{document}
\vspace*{7.5cm plus 1cm}
\begin{lista}
  \begin{listb}
    \lipsum[4]
  \end{listb}
  \lipsum[1-2] % This text follows the inner list
\end{lista}
\end{document}

在這個例子中,我在環境中的命令\filbreak後面添加了。這將有助於防止內部清單後面緊跟著外部清單末尾時出現分頁符號。\endlistlistb

在此輸入影像描述

相關內容