防止 LyX 中枚举的 \item 内出现分页符,无需重新定义 \item

防止 LyX 中枚举的 \item 内出现分页符,无需重新定义 \item

(有关该问题的背景和当前目的,请参见此处:防止枚举的 \item 内出现分页符)。

我有一系列问题。每个问题都有一些开头文字,然后是嵌套的枚举。下面我给出了一个示例,该示例导致 PDF 输出中第二个问题的中间出现分页符。我用 标记了\newpage我希望(自动)插入分页符的位置。在这个特定的例子中,我希望第一个问题在第 1 页,第二个和第三个问题在第 2 页(因为它们恰好都合适)。

有些答案可以在防止枚举的 \item 内出现分页符,但我想要一个 LyX 特定的解决方案,我不想重新定义,\item因为除了环境\item之外还使用enumerate。我想要一个可以在 LyX 布局级别上运行的东西,这样我就可以将其用作模块或本地布局,而无需更改主体的任何内容。

这是一个 LyX 最小示例:

#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\begin_preamble



%% my attempt:
%\let\OldItem\item
%\renewcommand{\item}{\OldItem \ifnum \@listdepth=1 \begin{samepage}\fi}
%\AfterEndEnvironment{enumerate}{\ifnum \@listdepth=1 \end{samepage}\fi}
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\language english
\language_package none
\inputencoding auto
\fontencoding default
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 0
\use_package cancel 0
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 0
\use_package mhchem 0
\use_package stackrel 0
\use_package stmaryrd 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Enumerate
2 + 2 = ? 
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler 
\end_layout

\begin_deeper
\begin_layout Enumerate
1 
\end_layout

\begin_layout Enumerate
2 
\end_layout

\begin_layout Enumerate
3 
\end_layout

\begin_layout Enumerate
4 
\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Plain Layout

% I do not want to put this page break in manually:
\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\begin_inset ERT
status collapsed

\begin_layout Plain Layout

% 
\backslash
newpage
\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\end_deeper
\begin_layout Enumerate
Consider the joint probability distribution below: filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler 
\end_layout

\begin_deeper
\begin_layout Standard
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="3">
<features tabularvalignment="middle">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $X_{2}=0$
\end_inset

 
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $X_{2}=1$
\end_inset


\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $X_{1}=0$
\end_inset

 
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\frac{1}{10}$
\end_inset

 
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\frac{3}{10}$
\end_inset


\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $X_{1}=1$
\end_inset

 
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\frac{2}{10}$
\end_inset

 
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\frac{4}{10}$
\end_inset


\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\begin_layout Standard
What is 
\begin_inset Formula $P(X_{1}=1)$
\end_inset

? 
\end_layout

\begin_layout Enumerate
I do not know.
 
\end_layout

\begin_layout Enumerate
4 
\end_layout

\begin_layout Enumerate
17 
\end_layout

\begin_layout Enumerate
88 
\end_layout

\end_deeper
\begin_layout Enumerate
2 - 2 + 5 = filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler
\begin_inset Newline newline
\end_inset

 filler 
\end_layout

\begin_deeper
\begin_layout Enumerate
1 
\end_layout

\begin_layout Enumerate
2 
\end_layout

\begin_layout Enumerate
3 
\end_layout

\begin_layout Enumerate
4 
\end_layout

\end_deeper
\end_body
\end_document

相关内容