1

Background

When text reaches the end of a column, it triggers inserting a blank page. This does not happen when text reaches the end of a page outside of a columnar environment.

Problem

In the sample code, \dorecurse{3} causes a blank page to appear but \dorecurse{2} does not. The only difference is that when set to 3, additional text is written on the last line of the last column. This scenario results in a blank page.

Minimum Working Example

Code showing the problem:

\showgrid
\setuplayout[grid=yes]

\starttext
  \startcolumnset[n=2]
    \input knuth \input lorem \input lorem \input knuth
    \dorecurse{3}{No TV and no beer make Homer something something.}
  \stopcolumnset
\stoptext

Output

Output before text reaches the last line:

Text Before Last Line

Output after text reaches the last line:

Text At Last Line

Question

Any ideas how the blank page can be suppressed?

Ideas

Suggestions from the mailing list do not appear to suppress the page:

\setuppagenumbering[page=no]
\installpagebreakhandler{last}{}

Suppress Eject Page

The columnset commands are aliased to pagegrid commands, so the following should be equivalent. The output in the following example has some displeasing overlaps, but it nonetheless shows how to eliminate the blank pages. By \unprotecting the \page_grd_stop macro, it is possible to redefine the macro to suppress page breaking.

However, this comes with a few side-effects in that some pages may not be written to the final document (i.e., the pages are not exported).

\showgrid
\setuppagenumbering[alternative=doublesided,page=no]
\setuplayout[grid=yes]

\definepagegrid[example][n=3,distance=.05\makeupwidth,page=no]

\setuppagegrid[example:1][width=.4\makeupwidth]
\setuppagegrid[example:2][width=.2\makeupwidth]
\setuppagegrid[example:3][width=.2\makeupwidth]

\setuppagegrid[example:4][width=.40\makeupwidth]
\setuppagegrid[example:5][width=.2\makeupwidth]
\setuppagegrid[example:6][width=.2\makeupwidth]

\unprotect
\def\page_grd_stop{%
  \endgraf % needed, else wrong vsize in one par case
  \vfill % otherwise weird \placenotes[endnotes]
  \page_grd_command_set_vsize % needed
  \penalty\c_page_otr_eject_penalty
  %\page_grd_command_flush_page
  \page_otr_fill_and_eject_page
  \page_grd_command_set_vsize % why here
  \egroup
  \page_otr_command_set_vsize
  \page_otr_command_set_hsize
}
\protect

\starttext
  \startpagegrid[example]
    \input knuth \input lorem \input lorem \input knuth \input lorem
    \dorecurse{3}{No TV and no beer make Homer something something.}
  \stoppagegrid
\stoptext

Version

$ context --version
mtx-context     | ConTeXt Process Management 1.03
mtx-context     |
mtx-context     | main context file: /opt/context/tex/texmf-context/tex/context/base/mkiv/context.mkiv
mtx-context     | current version: 2019.12.06 19:45
mtx-context     | main context file: /opt/context/tex/texmf-context/tex/context/base/mkiv/context.mkxl
mtx-context     | current version: 2019.12.06 19:45
1
1

Partial Solution

The following code will suppress page breaks when text in a multicolumn environment reaches the end of the last column:

\unprotect
\def\page_grd_stop{%
   \endgraf % needed, else wrong vsize in one par case
   \vfill % otherwise weird \placenotes[endnotes]
   \page_grd_command_set_vsize % needed
   \penalty\c_page_otr_eject_penalty
   %\page_grd_command_flush_page
   \page_otr_fill_and_eject_page
   \page_grd_command_set_vsize % why here
   \egroup
   \page_otr_command_set_vsize
   \page_otr_command_set_hsize}
\protect

However, the solution comes at a cost. First, this will suppress flushing pages of text that do not extend to the last line of the last column of multicolumn text. Second, the following scenario breaks:

\setuplayout[grid=yes]

\starttext
   \startcolumnset[n=2]
     \dorecurse{100}{Line #1\par}
   \stopcolumnset
\stoptext

Problems

The columnset commands are aliased to pagegrid commands, so the following should be equivalent. The output in the following example has some displeasing overlaps, but it nonetheless shows how to eliminate the blank pages. By \unprotecting the \page_grd_stop macro, it is possible to redefine the macro to suppress page breaking.

\showgrid
\setuppagenumbering[alternative=doublesided,page=no]
\setuplayout[grid=yes]

\definepagegrid[example][n=3,distance=.05\makeupwidth,page=no]

\setuppagegrid[example:1][width=.4\makeupwidth]
\setuppagegrid[example:2][width=.2\makeupwidth]
\setuppagegrid[example:3][width=.2\makeupwidth]

\setuppagegrid[example:4][width=.4\makeupwidth]
\setuppagegrid[example:5][width=.2\makeupwidth]
\setuppagegrid[example:6][width=.2\makeupwidth]

\unprotect
\def\page_grd_stop{%
  \endgraf % needed, else wrong vsize in one par case
  \vfill % otherwise weird \placenotes[endnotes]
  \page_grd_command_set_vsize % needed
  \penalty\c_page_otr_eject_penalty
  %\page_grd_command_flush_page
  \page_otr_fill_and_eject_page
  \page_grd_command_set_vsize % why here
  \egroup
  \page_otr_command_set_vsize
  \page_otr_command_set_hsize
}
\protect

\starttext
  \startpagegrid[example]
    \input knuth \input lorem \input lorem \input knuth \input lorem
    \dorecurse{3}{No TV and no beer make Homer something something.}
  \stoppagegrid
\stoptext

Additional Details

Fixing this problem so that multicolumns (i.e., page grids) behave like regular pages and other columnar environments will likely require patching ConTeXt itself.

4
  • Thank you for addressing this issue. I have been having the same problem with the pagecolumns environment: whenever the last column on the last page is partially complete, a blank page is added afterward. Your partial solution of redefining the macro does not seem to work in my case, so I imagine that pagecolumns may not be aliased to pagegrid commands as columnsets are. If this issue is distinct enough to warrant a separate question, I would be happy to open a separate question for it and offer an MWE and some further background. May 4 '20 at 15:43
  • Joey, consider posting your question to the users mailing list. Be sure to provide a minimum working example that illustrates the problem and behaviour. It may be worth noting in the message that there's an implicit page break in \stopcolumnset. Having an option to override that behaviour seems reasonable, but will require changing ConTeXt. May 4 '20 at 16:15
  • 1
    Thanks, Dave! I should have mentioned that I already did post my question (complete with a MWE and some background) to the mailing list about a week ago, and since I hadn't heard anything back since then, I was thinking of asking about it on here, too. That was when I noticed that your question had already covered a very similar issue with columnsets. It may be worthwhile for me to mention your discussion of this issue on the thread I've started on mailing list, though. May 4 '20 at 17:29
  • Absolutely, Joey, bump your thread on the mailing list. May 4 '20 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.