4

I have an enumerate of questions. Each of those questions has some opening text and then a nested enumerate. I give an example below that results in a page-break in the middle of the second question in the PDF output. I mark with \newpage where I would like the page-break to be (automatically) inserted. In this particular example, I want the first question to be on page 1, and the second and third to be on page 2 (just because they both happen to fit).

I also put my attempt commented out in below. I try to start a "samepage" environment right at the beginning of an \item and I try to end it at the end of the (nested) enumerate environment. The code seems to work on a simpler example, but in the current example it fails with the error ! LaTeX Error: \begin{samepage} on input line 56 ended by \end{center}. In any case, my approach seemed fragile anyway so I'm hoping there's a better solution.

I think the reason I find this hard is because of the way \item works. If it were \item{contents} then I think it would be easier to patch. That's why I tried to hack together an approach that hooks into the beginning of \item and end of \enumerate.

I'm looking for a solution that can patch \item and base enumerate (rather than using \newitem or enumitem). i.e., I'm hoping that I can just drop some preamble code in.

There are related questions. For example, Page breaks within enumerated list is related but is not about nested enumerates and also the solution seems to use enumitem.

\documentclass{article}

\makeatletter
%% my attempt:
%\let\OldItem\item
%\renewcommand{\item}{\OldItem \ifnum \@listdepth=1 \begin{samepage}\fi}
%\AfterEndEnvironment{enumerate}{\ifnum \@listdepth=1 \end{samepage}\fi}
\makeatother

\begin{document}

\begin{enumerate}
\item 2 + 2 = ? \\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
  \begin{enumerate}
  \item 1
  \item 2
  \item 3
  \item 4
  \end{enumerate}

% I do not want to put this page break in manually:
% \newpage
\item Consider the joint probability distribution below:
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
\begin{center}
\begin{tabular}{|ccc|}
\hline 
 &
$X_{2}=0$ &
$X_{2}=1$\tabularnewline
\hline 
$X_{1}=0$ &
$\frac{1}{10}$ &
$\frac{3}{10}$\tabularnewline
\hline 
$X_{1}=1$ &
$\frac{2}{10}$ &
$\frac{4}{10}$\tabularnewline
\hline 
\end{tabular}
\par\end{center}

What is $P(X_{1}=1)$?
\begin{enumerate}
\item I do not know.
\item 4
\item 17
\item 88
\end{enumerate}

\item 2 - 2 + 5 =
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
  \begin{enumerate}
  \item 1
  \item 2
  \item 3
  \item 4
  \end{enumerate}
\end{enumerate}

\end{document}
7
  • Lists were specifically designed to allow paage breaks. Not allowing page breaks is easier. Just use \item\parbox{\linewidth}{...}. You might also want to add some glue to \itemsep. Commented Apr 30, 2023 at 0:06
  • I'm looking for something I can drop in a preamble (and not make any changes to the body of the document). Can I redefine \item to do what you suggest?
    – scottkosty
    Commented Apr 30, 2023 at 0:38
  • If this is to be used in a LyX document you can use the ItemCommand attribute to change the command that LyX inserts inside the enumerate environment.
    – Udi Fogiel
    Commented Apr 30, 2023 at 4:47
  • The new item would have a required argument: \item{...}. Commented Apr 30, 2023 at 12:10
  • I see. So I would need to change the body from using \item ... to use \item{...}. That is indeed a minimal change but I'm hoping to avoid making any changes. @UdiFogiel indeed I hope to use it with LyX. That's good to know I can change the ItemCommand. But I don't know if I could change it to wrap the contents of \item in the braces.
    – scottkosty
    Commented Apr 30, 2023 at 15:52

5 Answers 5

3
+100

You could try the following. Don't use \\ at the end of paragraphs. This only give underfull hbox messages.

\documentclass{article}

\makeatletter
\AddToHook{cmd/item/before}{%
 \if@nmbrlist %only for enumerate?
  \ifnum \@listdepth=1
   \penalty-200
   \samepage
  \fi
 \fi}
\makeatother

\begin{document}

\begin{enumerate}
\item 2 + 2 = ? \\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
  \begin{enumerate}
  \item 1
  \item 2
  \item 3
  \item 4
  \end{enumerate}

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

\item Consider the joint probability distribution below:
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler

\begin{center}
\begin{tabular}{|ccc|}
\hline 
 &
$X_{2}=0$ &
$X_{2}=1$\tabularnewline
\hline 
$X_{1}=0$ &
$\frac{1}{10}$ &
$\frac{3}{10}$\tabularnewline
\hline 
$X_{1}=1$ &
$\frac{2}{10}$ &
$\frac{4}{10}$\tabularnewline
\hline 
\end{tabular}
\end{center}

What is $P(X_{1}=1)$?
\begin{enumerate}
\item I do not know.
\item 4
\item 17
\item 88
\end{enumerate}

\item 2 - 2 + 5 =
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler
  \begin{enumerate}
  \item 1
  \item 2
  \item 3
  \item 4
  \end{enumerate}
\end{enumerate}

\end{document}

enter image description here

3
  • Thank you! Using \penalty-200 doesn't work on my non-MWE example. But after increasing the number it does work. I wonder if I can just change it to \penalty-9999? Also, the code seems to slightly change the vertical space (compared to using \newpage manually). The difference is very minor and I don't mind it, but I'm a bit curious if you know why?
    – scottkosty
    Commented May 6, 2023 at 17:11
  • @scottkosty \newpage adds vfil before penalty to fill the page before the break, so TeX will not stretch other vertical glues (such as the ones between paragraphs) and the break will appear "at the point" where \newpage was written. For that reason it should not be used very often, otherwise pages will be uneven. The difference between \newpage and just plain \penalty is somewhat similar to the difference between \newpage and \pagebreak. With \penalty-9999 you might get a very spaced page.
    – Udi Fogiel
    Commented May 6, 2023 at 19:00
  • @UdiFogiel Thank you, that is helpful! Instead of a very spaced page, I would prefer a very short page (and then blank space until the next page). I guess I will try with \penalty-9999 until something bad happens (and I'll accept the responsibility!).
    – scottkosty
    Commented May 6, 2023 at 21:29
3

\def once, \let many times.

\documentclass{article}
\usepackage{blindtext}% MWE only
\usepackage{showframe}% alignment tool

\newcommand{\RepItem}[1]{\OldItem\parbox[t]{\linewidth}{#1}}
\AtBeginEnvironment{enumerate}{\let\OldItem=\item% in case enumerate changes \item first
  \let\item=\RepItem
  \addtolength{\itemsep}{0pt plus 1fil}}
% changes are local to enumerate, but could be passed to nested environments

\begin{document}
\begin{enumerate}
  \item{\blindtext}
  \item{\blindtext}
  \item{\blindtext}
  \item{\blindtext}
  \item{\blindtext}
\end{enumerate}
\end{document}
2
  • +1 nice answer! I'm still hoping for an answer that avoids changing \item ... to \item{...}.
    – scottkosty
    Commented Apr 30, 2023 at 15:53
  • Changing \newcomand{\RepItem}[1]... to \def\RepItem#1... will do the job Commented May 8, 2023 at 5:44
1

Perhaps try this. Hardly tested but appears to do what one hopes.

\documentclass[a4paper]{article}
% \usepackage{geometry}
\AddToHook{env/enumerate/begin}{\AddToHook{env/enumerate/begin}{\samepage}}%

\begin{document}

\begin{enumerate}
\item 2 + 2 = ? \\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
  \begin{enumerate}
  \item 1
  \item 2
  \item 3
  \item 4
  \end{enumerate}

% I do not want to put this page break in manually:
% \newpage
\item Consider the joint probability distribution below:
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
\begin{center}
\begin{tabular}{|ccc|}
\hline 
 &
$X_{2}=0$ &
$X_{2}=1$\tabularnewline
\hline 
$X_{1}=0$ &
$\frac{1}{10}$ &
$\frac{3}{10}$\tabularnewline
\hline 
$X_{1}=1$ &
$\frac{2}{10}$ &
$\frac{4}{10}$\tabularnewline
\hline 
\end{tabular}
\par\end{center}

What is $P(X_{1}=1)$?
\begin{enumerate}
\item I do not know.
\item 4
\item 17
\item 88
\end{enumerate}

\item 2 - 2 + 5 =
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
filler\\
  \begin{enumerate}
  \item 1
  \item 2
  \item 3
  \item 4
  \end{enumerate}
\end{enumerate}

\end{document}

This will create pagebreak moving all text starting with What is $P(X_1=1)$? on next page. Without the hack the pagebreak occurs between (b) 4 and (c) 17.

3
  • I don't think this does what I'm looking for since I need the same page to begin after (or before?) \item and end before the next \item. That is, I want the page break to be where \newpage is in the example. I do not want a page break starting with What is $P(X_1=1)$? because the student needs the table (on the previous page) to answer the question.
    – scottkosty
    Commented May 3, 2023 at 17:46
  • @scottkosty Yes it does not address your question. The natural response to your query is that you should not use top level enumerate at all for this. Perhaps use one file per question and use \include.
    – user691586
    Commented May 3, 2023 at 19:23
  • I should have removed the last \\ 's (the ones before enumerate or center environments), but as this was not the focus, I simply copied-pasted OP example.
    – user691586
    Commented May 8, 2023 at 6:49
1

As John Kormylo suggested, you can use \vtop (the internal command \parbox[t]... use) to prevent from item's to break between pages. Instead of adding the necessary curly braces, with \vtop you can wrap the argument with \bgroup and \egroup, which might be easier if you are using LyX.

Personally, I wouldn't redefine \item, as there are more than several environments that use it internally, even some that might surprise you (such as environments defined with \newtheorem or amsthm's proof environment).

As mentioned in the comments, you can use LyX's ItemCommand to replace \item with the desired code, instead of redefining \item.

So, basically we want to replace \item with \item\leavevmode\vtop{<text>}, but that would be hard, so we can replace it with \item\leavevmode\vtop\bgroup. To close the group, just prepend \egroup to \item, but that would create unbalanced grouping with the first and last use of \egroup\item\leavevmode\vtop\bgroup, luckily we can fix it with some hooks. We also nee to add \hsize\linewidth\@parboxrestore after \bgroup to get the correct width and indentation.

Here is a LyX file that demonstrate the idea:

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

\AddToHook{cmd/enumerate/after}{\bgroup}
\AddToHook{env/enumerate/end}{\egroup}
\newcommand*\myitem{\egroup\item\leavevmode\vtop\bgroup\hsize\linewidth\@parboxrestore}
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\begin_local_layout
Format 66
Style Enumerate
  ItemCommand myitem
End
\end_local_layout
\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

And its LateX output is (for all of you worrying about the fact that LyX adds \usepackage[latin9]{inputenc} to the preamble, it is fixed in LyX 2.4):

%% LyX 2.3.7 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass{article}
\usepackage[latin9]{inputenc}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.



%% my attempt:
%\let\OldItem\item
%\renewcommand{\item}{\OldItem \ifnum \@listdepth=1 \begin{samepage}\fi}
%\AfterEndEnvironment{enumerate}{\ifnum \@listdepth=1 \end{samepage}\fi}

\AddToHook{cmd/enumerate/after}{\bgroup}
\AddToHook{env/enumerate/end}{\egroup}
\newcommand*\myitem{\egroup\item\leavevmode\vtop\bgroup\hsize\linewidth\@parboxrestore}

\makeatother

\begin{document}
\begin{enumerate}
\myitem 2 + 2 = ? \\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler 
\begin{enumerate}
\myitem 1 
\myitem 2 
\myitem 3 
\myitem 4 
\end{enumerate}
% I do not want to put this page break in manually:
% \newpage

\myitem Consider the joint probability distribution below: filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler 
\begin{center}
\begin{tabular}{|ccc|}
\hline 
 & $X_{2}=0$  & $X_{2}=1$\tabularnewline
\hline 
$X_{1}=0$  & $\frac{1}{10}$  & $\frac{3}{10}$\tabularnewline
\hline 
$X_{1}=1$  & $\frac{2}{10}$  & $\frac{4}{10}$\tabularnewline
\hline 
\end{tabular}
\par\end{center}

What is $P(X_{1}=1)$? 
\begin{enumerate}
\myitem I do not know. 
\myitem 4 
\myitem 17 
\myitem 88 
\end{enumerate}
\myitem 2 - 2 + 5 = filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler\\
 filler 
\begin{enumerate}
\myitem 1 
\myitem 2 
\myitem 3 
\myitem 4 
\end{enumerate}
\end{enumerate}

\end{document}
7
  • Interesting. The page breaking indeed looks good. however, the inner enumerates are shifted to the left. i.e., the "(a)", "(b)", etc. are not indented.
    – scottkosty
    Commented May 9, 2023 at 0:47
  • @scottkosty see my edit
    – Udi Fogiel
    Commented May 9, 2023 at 1:27
  • Now they appear overly indented, and text in my non-MWE goes off the page to the right. I can edit my post to put in a new minimal example showing this issue if you don't see the over-indent.
    – scottkosty
    Commented May 9, 2023 at 2:26
  • @scottkosty I think I've fixed it, see the new code.
    – Udi Fogiel
    Commented May 9, 2023 at 3:49
  • Works great, thank you! A couple of questions: 1. Why is it cmd in \AddToHook{cmd/enumerate/after}? I expected env since enumerate is an environment. To be clear, I don't doubt it, I'm just trying to learn. 2. The two hooks will also modify the "outer" enumerate, which I think (?) is unnecessary. Am I correct that this could be prevented by conditioning on \@listdepth but since the unnecessary modification doesn't have a negative consequence it's not worth the code complication?
    – scottkosty
    Commented May 9, 2023 at 13:53
0

Is's a biy old style, but it works:

\def\RepItem#1{\OldItem\parbox[t]{\linewidth}{#1}}
\documentclass{article}
\usepackage{blindtext}% MWE only
\usepackage{showframe}% alignment tool

%\newcommand{\RepItem}[1]{\OldItem\parbox[t]{\linewidth}{#1}}
\AtBeginEnvironment{enumerate}{\let\OldItem=\item% in case enumerate changes \item first
  \let\item=\RepItem
  \addtolength{\itemsep}{0pt plus 1fil}}
% changes are local to enumerate, but could be passed to nested environments

\begin{document}
\begin{enumerate}
  \item\blindtext
  \item\blindtext
  \item\blindtext
  \item\blindtext
  \item\blindtext
\end{enumerate}
\end{document}
1
  • 1
    Replacing in your example the fourth \item by \item a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d \blindtext one sees the problem: your \RepItem fetches an argument which in my example will simply be the token a.
    – user691586
    Commented May 8, 2023 at 6:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .