abenori / jlreq

Other
125 stars 18 forks source link

Page break between consecutive headings #100

Open minamotorin opened 2 years ago

minamotorin commented 2 years ago

About

Page break is not suppressed between consecutive headings.

Environments

Example

% This program is in the public domain.
\documentclass{jlreq}
\begin{document}

\makeatletter
\@tempcnta\z@
\@whilenum\@tempcnta<32\do{
  aaaaa\par
  \advance\@tempcnta\@ne
}
\makeatother

\section{bbbbb}

\subsection{ccccc}

aaaaa

\end{document}

4b760c7

Cause

Prior to jlreq 2019/05/07 (3fed581), this issue doesn't occur.

This image is the result of compiling the above code with jlreq 2019/05/07 (380c151).

380c151

\noexpand\allowbreak in \csname jlreq@BlockHeading@spaces@current@before@\the\jlreq@BlockHeading@spaces@current@count\endcsname is the cause.

https://github.com/abenori/jlreq/blob/4b760c72c9e144779aa8aa098062bff2749f7755/jlreq.cls#L1901-L1905

In my environment, commenting out \noexpand\allowbreak didn't cause the problem like #54. Maybe this is because of update of hyperref.

Thanks.

minamotorin commented 2 years ago

54 has been fixed in https://github.com/latex3/hyperref/commit/f59667380eef4f9ec2c3344dca6a4472c25ef599.

minamotorin commented 2 years ago

The cause of #54 was that hyperref prevent page break around \refstepcounter.

% This program is in the public domain.
\documentclass{article}
\usepackage[dvipdfmx]{hyperref}% 2020/01/14 v7.00d
\begin{document}

\makeatletter
\@tempcnta\z@
\@whilenum\@tempcnta<46\do{
  aaaaa\par
  \advance\@tempcnta\@ne
}
\makeatother

%\vskip0pt\relax
\refstepcounter{enumi}

ccccc

\end{document}

Adding \vskip before \refstepcounter solves this (I don't know why). This is why #54 didn't occur with classes or jsclasses.

abenori commented 2 years ago

I do not understand what is happening exactly, but I changed \allowbreak to\vskip 0pt and it seems work.

minamotorin commented 2 years ago

5dea7c3 seems work fine for me (hyperref 2021-06-07 v7.00h). Thanks!

minamotorin commented 2 years ago

Maybe, keep open was better?