[texhax] List of Examples (page break?)

bnb at ams.org bnb at ams.org
Sat Sep 26 19:05:16 CEST 2015


On Sat, 26 Sep 2015, Uwe Lueck wrote:

    BB> all very well, but is there a way to
    BB> avoid a page break when the next bit
    BB> after the *heading* is \begin{enumerate}
    BB> or one of its kin?

    Later:

    BB> usually, the text of a theorem is
    BB> expected to start on the same line as
    BB> the *header*, but some authors insist
    BB> on starting with a list.  and that
    BB> can leave the header by itself at the
    BB> bottom of a page.

    Somewhat unfair, my conviction has become that 
    sections have *headings*, theorems have *headers*
    (all stars mine). I violated this rule myself late 
    at night in 

        http://tug.org/pipermail/texhax/2015-September/021933.html

    but the topic was headings, as in \@afterheading.

point taken.  but it's still a problem
for the environment i work in.

    Anyway, the theorem example modified:


    \ProvidesFile{thmhdbrk.tex}[2015/09/26
                                texhax pbrk. thm. env.s (bb/ul)]
    \documentclass{article}
    %\usepackage{amsthm} %% either ...
    \newtheorem{theorem}{Theorem}
    \makeatletter
    \newcommand{\firstthmenvlineemptyintentionally}{%
        \leavevmode\newline
        \clubpenalty\@M     %% TODO restored properly?
    %% choose from:
    %   \@afterheading
        \@nobreaktrue
    %% ... without both, bad spacing (only!)
    }
    \makeatother
    \begin{document}
      \tracingonline=1 \showboxdepth=0 \showboxbreadth=10 
      \iftrue         %% see real-life pagebreak or don't
    text at top of page\par
    \vspace{30\baselineskip}
    some more text\par
    \vspace{12\baselineskip}
      \fi
    \begin{theorem}\firstthmenvlineemptyintentionally
    \begin{itemize}
    \item xxxx
      \par \showlists
    \item yyyy
    \end{itemize}
    \end{theorem}
    \end{document}

doesn't solve the problem, *with
or without* amsthm.  if you change
the second \vspace to

  \vspace{11\baselineskip}

you will find a lonely "Theorem 1"
at the bottom of the first page.
    
    \@item is very complex, I won't understand all of it soon,
    but at some place it uses \clubpenalty \@M too, and at some
    other, it restores the normal value by 

        \clubpenalty \@clubpenalty

    I can't tell soon whether this happens in time with my trick, 
    but something like that is necessary, because \clubpenalty
    and \widowpenalty create a possible breakpoint after the 
    first line in the example, namely a penalty of their sum
    (even with a two-line first item, strangely).

if i were coding this in plain tex,
i would set a switch to indicate that
a heading had just occurred.  (of
course, the switch has to be unset
automatically if any real text follows;
tricky, but not impossible.)  then i
would test when entering the list to
determine whether the switch is set,
if so, prevent the page break, and in
any case, turn the switch off.  but the
latex definitions are so interconnected,
and \everypar so overloaded, that it's
next to impossible to figure out what
will "do the right thing".  and in any
event, using amsthm is an absolute
requirement, because it's build into
all ams document classes.  that is what
i live with.

the present practice with ams production
is to do a final visual sweep of a book
or article, and insert explicit page
breaks *before* "orphaned" headers
(whether section headings or theorem
or proof headers), or in some extreme
cases, make \enlargethispage adjustments
when necessary to keep within a page
limit.  we'd really love to have a
practical solution to the problem;
trying to retrain authors isn't working.
					-- bb


More information about the texhax mailing list