Joey McCollum schrieb am 16.05.2020 um 05:45:
All right, I've found a tentative solution that appears to work in all cases, but I'd like to know more about why the code I'm patching was implemented in the first place, because I don't want to break anything else. According to the code in page-pcl.mkiv, the \stoppagecolumns macro has two implementations, \page_col_stop_yes and \page_col_stop_nop. The choice of which implementation is used is determined by which of two implementations of \startpagecolumns (\page_col_start_yes and \page_col_start_nop) is used. That choice, in turn, is made in the \page_col_start macro, in the following lines:

```
\c_page_col_n_of_columns\pagecolumnsparameter\c!n\relax
    \ifnum\c_page_col_n_of_columns>\plusone
      \expandafter\page_col_start_yes
    \else
      \expandafter\page_col_start_nop
    \fi
```

so if the number of columns (i.e., the n option for the pagecolumns environment) is more than one, the "yes" implementation of the start and stop commands is used.

But this seems wrong. The naming convention for the two implementations ("yes" and "nop") suggests that they should be related the parameters "page=yes" and "page=no" (hence, no page, which is what I think "nop" abbreviates), but the choice of which implementation to use is determined not by the page parameter, but by the n parameter. Is this an error in the code, or am I just understanding this incorrectly? Is there some reason why a layout with more than one column would need special instructions to add a blank page after stopping the environment?

Why do you think "yes" and "nop" are related to the page-key?

In any event, I was able to solve the problem by patching the \page_col_start_yes macro to invoke the \page_col_start_nop macro as follows:

```

\unprotect

\def\page_col_stop_yes
{\page_col_stop_nop}

\protect

```

With this fix, the MWE I provided works regardless of which column the text ends in. I'm content to consider the problem solved, but I would certainly appreciate any feedback on my thoughts and questions about page-pcl.mkiv.

You broke now now normal single columns text after the pagecolumns environment. A better fix is to add a check for the \column command at the end of the environment and add it only when we aren't in the last column.

\unexpanded\def\page_col_stop_yes
  {%\column % \page_otr_eject_page
   \ifnum\c_page_col_current<\c_page_col_n_of_columns
     \column
   \fi
   \page
   \endgroup
 % \setupoutputroutine[\s!singlecolumn]%
   \page_otr_command_set_vsize
   \page_otr_command_set_hsize
   \page
   \endgroup}

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to