jlreq icon indicating copy to clipboard operation
jlreq copied to clipboard

\color after headings allow page break

Open minamotorin opened this issue 3 years ago • 1 comments

If there are \color immediately after headings, page breaks are not prohibited.

This happens with both (u)pLaTeX and LuaLaTeX. I couldn't find version of jlreq which doesn't cause this problem.

% This program is in the public domain.
%<jlreq>\documentclass{jlreq}
%<classes>\documentclass{article}
\usepackage{color}
\begin{document}
\makeatletter
\@tempcnta\z@
%<jlreq>\@whilenum\@tempcnta<34\do{
%<classes>\@whilenum\@tempcnta<42\do{
  aaaaa\par
  \advance\@tempcnta\@ne
}
\makeatother

\section{bbbbb}

\color{black}

ccccc

\end{document}
  • jlreq

    color_jlreq

  • classes

    color classes

The cause seems to be that \special (same for \write) allows page break there. In classes or jclasses, inserting \addpenalty{-300} solves this and \color immediately after headings are no problem. However, in jsclasses or jlreq, \addpenalty doesn't solve this. I don't know why.

% This program is in the public domain.
%<jsclasses>\documentclass{jsarticle}
%<jclasses>\documentclass{jarticle}
%<classes>\documentclass{article}
\begin{document}
\makeatletter
\@tempcnta\z@
%<jsclasses>\@whilenum\@tempcnta<39\do{
%<jclasses>\@whilenum\@tempcnta<38\do{
%<classes>\@whilenum\@tempcnta<45\do{
  aaaaa\par
  \advance\@tempcnta\@ne
}
\makeatother

\addpenalty{-300}

bbbbb

\nopagebreak

\write16{ccccc}

ddddd

\end{document}
  • jsclasses

    jsclasses

  • jclasses

    jclasses

  • classes

    classes

Thanks.

minamotorin avatar Dec 20 '21 17:12 minamotorin

As one can see the following example, it is possible to have a break after \section with article class.

%#!uplatex
\documentclass[dvipdfmx]{article}
\usepackage[vmargin=0pt,hmargin=0pt,paperwidth=50pt,paperheight=55pt]{geometry}
\usepackage{color}
\begin{document}
aaaaa
\section{bbbbb}
\color{black}
ccccc
\end{document}

Above results is a consequence of the TeX's (complicated) calculation to determine the position of page break. I'll try to use the same penalties as article class around \section etc.

abenori avatar Dec 21 '21 14:12 abenori