a way to implement \testcolumn in mixedcolumns
Hello, On this list I've been advised that mixedcolumns is the latest and greatest implementation of columns; the one to use. We have switched over from columnsets to mixedcolumns, and have been very pleased with the column balancing (for some reason we couldn't get column balancing to work in columnsets). However one thing we do miss from columnsets is the control over widows & orphans in two ways: \testcolumn, and \setupcolumnsetlines. \testcolumn[n] allowed us to do a conditional column break, so when we were about to start a new subsection heading, we could prevent it being an orphan at the bottom of the column; and when starting a paragraph with a hangaround graphic framed flushright and bottom, we could similarly use \testcolumn to prevent the graphic from hanging down into the footer (which is what sometimes happened otherwise). So I'm wondering, is there some way to achieve the equivalent of \testcolumn in mixedcolumns? Is it theoretically impossible to implement this in mixedcolumns because the required information (how many lines are left in the current column) is not yet known? Or could that information be gleaned from somewhere? I see in page-brk.mkiv the following definition for \testcolumn: \def\testcolumn {\dodoubleempty\page_tests_columns_test} \def\page_tests_columns_test[#1][#2]% {\endgraf \ifdim\pagegoal<\maxdimen \ifdim\pagetotal<\pagegoal \d_page_tests_test\dimexpr \pagegoal -\pagetotal \ifdim\lastskip<\parskip+\parskip\fi \ifsecondargument+#2\fi \relax \getrawnoflines\d_page_tests_test % (raw) \ifnum#1>\noflines \column \fi \else \penalty-\plustenthousand % (untested) \fi \fi} I'm not a low-level TeX programmer, and I don't understand a lot of this, but it looks like \getrawnoflines\d_page_tests_test puts the number of remaining lines into \noflines Any suggestions are appreciated. (And I should have a MWE soon.) Lars
On 11/20/2013 4:47 PM, Lars Huttar wrote:
However one thing we do miss from columnsets is the control over widows & orphans in two ways: \testcolumn, and \setupcolumnsetlines. \testcolumn[n] allowed us to do a conditional column break, so when we were about to start a new subsection heading, we could prevent it being an orphan at the bottom of the column; and when starting a paragraph with a hangaround graphic framed flushright and bottom, we could similarly use \testcolumn to prevent the graphic from hanging down into the footer (which is what sometimes happened otherwise).
So I'm wondering, is there some way to achieve the equivalent of \testcolumn in mixedcolumns?
Here is a MWE: \starttext \startmixedcolumns[distance=5mm, balance=yes] \dorecurse {20} { \testcolumn[8] \subsection{Subsection Heading} \input knuth \endgraf } \stopmixedcolumns \stoptext You can see that the heading for subsection 6 is an orphan at the bottom of a column (at least, with the paper size settings I have; otherwise, I'm sure it happens somewhere else). If \testcolumn worked, the \testcolumn[8] would have shoved the subsection heading to the next column, because there was not space for 8 lines left in the column at that point. Any thoughts on how to fix this kind of occurrence? Thanks, Lars
On 11/20/2013 11:12 PM, Lars Huttar wrote:
On 11/20/2013 4:47 PM, Lars Huttar wrote:
However one thing we do miss from columnsets is the control over widows & orphans in two ways: \testcolumn, and \setupcolumnsetlines. \testcolumn[n] allowed us to do a conditional column break, so when we were about to start a new subsection heading, we could prevent it being an orphan at the bottom of the column; and when starting a paragraph with a hangaround graphic framed flushright and bottom, we could similarly use \testcolumn to prevent the graphic from hanging down into the footer (which is what sometimes happened otherwise).
So I'm wondering, is there some way to achieve the equivalent of \testcolumn in mixedcolumns?
for the moment add \penalty10000
Here is a MWE:
\starttext
\startmixedcolumns[distance=5mm, balance=yes]
\dorecurse {20} {
\testcolumn[8]
\subsection{Subsection Heading} \input knuth \endgraf
}
\stopmixedcolumns
\stoptext
You can see that the heading for subsection 6 is an orphan at the bottom of a column (at least, with the paper size settings I have; otherwise, I'm sure it happens somewhere else). If \testcolumn worked, the \testcolumn[8] would have shoved the subsection heading to the next column, because there was not space for 8 lines left in the column at that point.
Any thoughts on how to fix this kind of occurrence?
Thanks, Lars
___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 11/22/2013 4:59 PM, Hans Hagen wrote:
On 11/20/2013 11:12 PM, Lars Huttar wrote:
On 11/20/2013 4:47 PM, Lars Huttar wrote:
However one thing we do miss from columnsets is the control over widows & orphans in two ways: \testcolumn, and \setupcolumnsetlines. \testcolumn[n] allowed us to do a conditional column break, so when we were about to start a new subsection heading, we could prevent it being an orphan at the bottom of the column; and when starting a paragraph with a hangaround graphic framed flushright and bottom, we could similarly use \testcolumn to prevent the graphic from hanging down into the footer (which is what sometimes happened otherwise).
So I'm wondering, is there some way to achieve the equivalent of \testcolumn in mixedcolumns?
for the moment add \penalty10000
OK... where? In the same place we used to use \testcolumn? According to http://www.tug.org/utilities/plain/cseq.html#penalty-rp, "If <number> is 10,000 or larger, TeX will never break a line or a page there. Also, if <number> is -10,000 or less, it will always break a line or a page there [97 and 110]. ... Plain TeX has \break and \nobreak macros which are defined to be: \penalty-10000 and \penalty10000." So it sounds like you're recommending the equivalent of a \nobreak. That wouldn't make sense in the place where we want to conditionally break the column. So I guess you're talking about using it e.g. right after the subsection heading, since we don't want it to break right there? If so, that sounds like it will be helpful for preventing that particular case. I don't think it will work for preventing external figures from hanging down below the bottom of the column though, will it? Because for that to work, we'd have to prevent breaks anywhere in the flowing-around paragraph. And I don't see a way to do that. Thanks, Lars
On 11/22/2013 11:37 PM, Lars Huttar wrote:
On 11/22/2013 4:59 PM, Hans Hagen wrote:
On 11/20/2013 11:12 PM, Lars Huttar wrote:
On 11/20/2013 4:47 PM, Lars Huttar wrote:
However one thing we do miss from columnsets is the control over widows & orphans in two ways: \testcolumn, and \setupcolumnsetlines. \testcolumn[n] allowed us to do a conditional column break, so when we were about to start a new subsection heading, we could prevent it being an orphan at the bottom of the column; and when starting a paragraph with a hangaround graphic framed flushright and bottom, we could similarly use \testcolumn to prevent the graphic from hanging down into the footer (which is what sometimes happened otherwise).
So I'm wondering, is there some way to achieve the equivalent of \testcolumn in mixedcolumns?
for the moment add \penalty10000
OK... where? In the same place we used to use \testcolumn?
just after the (sub)section title i need time to figure out this kind of things in the balancer ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 11/23/2013 6:49 AM, Hans Hagen wrote:
On 11/22/2013 11:37 PM, Lars Huttar wrote:
On 11/22/2013 4:59 PM, Hans Hagen wrote:
On 11/20/2013 11:12 PM, Lars Huttar wrote:
On 11/20/2013 4:47 PM, Lars Huttar wrote:
However one thing we do miss from columnsets is the control over widows & orphans in two ways: \testcolumn, and \setupcolumnsetlines. \testcolumn[n] allowed us to do a conditional column break, so when we were about to start a new subsection heading, we could prevent it being an orphan at the bottom of the column; and when starting a paragraph with a hangaround graphic framed flushright and bottom, we could similarly use \testcolumn to prevent the graphic from hanging down into the footer (which is what sometimes happened otherwise).
So I'm wondering, is there some way to achieve the equivalent of \testcolumn in mixedcolumns?
for the moment add \penalty10000
OK... where? In the same place we used to use \testcolumn?
just after the (sub)section title
i need time to figure out this kind of things in the balancer
Hans, here is what I tried (MWE): \setuppapersize[A4] \starttext \section{Introduction} \startmixedcolumns[distance=5mm, balance=yes] \dorecurse {25} { \subsection{Subsection Heading} \penalty10000 If I had not participated fully in all these activities, literally hundreds of improvements would never have been made, because I would never have thought of them or perceived their importance. \endgraf } \stopmixedcolumns \stoptext As you see, I tried \penalty10000 after the subsection heading. But in the resulting PDF, on page 3, in the left column, we see a subsection heading at the bottom of the column with nothing below it. So something didn't work. Am I not doing it the way you meant? Thanks for your help, Lars
On 11/20/2013 10:47 PM, Lars Huttar wrote:
Hello,
On this list I've been advised that mixedcolumns is the latest and greatest implementation of columns; the one to use. We have switched over from columnsets to mixedcolumns, and have been very pleased with the column balancing (for some reason we couldn't get column balancing to work in columnsets).
However one thing we do miss from columnsets is the control over widows & orphans in two ways: \testcolumn, and \setupcolumnsetlines. \testcolumn[n] allowed us to do a conditional column break, so when we were about to start a new subsection heading, we could prevent it being an orphan at the bottom of the column; and when starting a paragraph with a hangaround graphic framed flushright and bottom, we could similarly use \testcolumn to prevent the graphic from hanging down into the footer (which is what sometimes happened otherwise).
So I'm wondering, is there some way to achieve the equivalent of \testcolumn in mixedcolumns?
Is it theoretically impossible to implement this in mixedcolumns because the required information (how many lines are left in the current column) is not yet known? Or could that information be gleaned from somewhere?
I see in page-brk.mkiv the following definition for \testcolumn:
\def\testcolumn {\dodoubleempty\page_tests_columns_test}
\def\page_tests_columns_test[#1][#2]% {\endgraf \ifdim\pagegoal<\maxdimen \ifdim\pagetotal<\pagegoal \d_page_tests_test\dimexpr \pagegoal -\pagetotal \ifdim\lastskip<\parskip+\parskip\fi \ifsecondargument+#2\fi \relax \getrawnoflines\d_page_tests_test % (raw) \ifnum#1>\noflines \column \fi \else \penalty-\plustenthousand % (untested) \fi \fi}
I'm not a low-level TeX programmer, and I don't understand a lot of this, but it looks like \getrawnoflines\d_page_tests_test puts the number of remaining lines into \noflines
Any suggestions are appreciated. (And I should have a MWE soon.)
That macro was never meant for mixed columns. I made a variant that works ok in mixed columns which will be in the next beta. \setuptolerance[verytolerant] \starttext \startmixedcolumns \dorecurse{4}{\input ward \par} \testcolumn[10][-1pt] % 10 lines - 1pt slack \dorecurse{2}{\input ward \par} \stopmixedcolumns \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 11/28/2013 1:34 PM, Hans Hagen wrote:
That macro was never meant for mixed columns. I made a variant that works ok in mixed columns which will be in the next beta.
Excellent. I will give it a try. I see a context-setup-win64 dated 2013-11-28 19:45. Is that beta? I may wait for the next one anyway just to be sure... today is a holiday for us. Lars
On 11/29/2013 12:26 PM, Lars Huttar (SIL gmail) wrote:
On 11/28/2013 1:34 PM, Hans Hagen wrote:
That macro was never meant for mixed columns. I made a variant that works ok in mixed columns which will be in the next beta.
Excellent. I will give it a try. I see a context-setup-win64 dated 2013-11-28 19:45. Is that beta? I may wait for the next one anyway just to be sure... today is a holiday for us.
you can just update with the already installed first-setup script (no need to do a new install) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 11/28/2013 1:34 PM, Hans Hagen wrote:
That macro was never meant for mixed columns. I made a variant that works ok in mixed columns which will be in the next beta.
\setuptolerance[verytolerant]
\starttext
\startmixedcolumns
\dorecurse{4}{\input ward \par}
\testcolumn[10][-1pt] % 10 lines - 1pt slack
\dorecurse{2}{\input ward \par}
\stopmixedcolumns
\stoptext
Ok. It looks like the second parameter to \testcolumn is now required (it didn't used to be). What does this slack value do? Does it mean that the minimum amount of space left in the column is 10 lines minus 1pt? Also, in the Dec. 2 beta (current version: 2013.12.02 15:22), the \column command now causes an error when we come to the \stopmixedcolumns. I don't know if it's connected with the above change, or something else. MWE: change the \testcolumn command above to \column. I get the following error output: ! LuaTeX error C:/context/tex/texmf-context/tex/context/base/page-mix.lua:474 : attempt to compare number with nil stack traceback: C:/context/tex/texmf-context/tex/context/base/page-mix.lua :474: in function 'process_penalty' C:/context/tex/texmf-context/tex/context/base/page-mix.lua :572: in function 'setsplit' C:/context/tex/texmf-context/tex/context/base/page-mix.lua :687: in function 'setsplit' C:/context/tex/texmf-context/tex/context/base/page-mix.lua :819: in function 'mixsetsplit' [string "\directlua "]:1: in main chunk. system > tex > error on line 14 in file C:/Users/Huttar/Documents/work/tex/test-beta-testcolumn.tex: LuaTeX error ... 4 5 \startmixedcolumns 6 7 \dorecurse{4}{\input ward \par} 8 9 %\testcolumn[10][-1pt] % 10 lines - 1pt slack 10 \column 11 12 \dorecurse{2}{\input ward \par} 13 14 >> \stopmixedcolumns 15 16 \stoptext 17 \ctxcommand #1 -\directlua {commands.#1} \page_mix_routine_construct ...\else false\fi , }} \deadcycles \zerocount \page_mix_routine_continue ...ine_construct \v!no \page_mix_routine_package ... \page_otr_command_routine ...mix_routine_continue \or \page_mix_routine_bala... \page_otr_triggered_output_routine ...and_routine \fi <output> ...eforeoutput \page_otr_triggered_output_routine \relax \the \everyafterout... ... l.14 \stopmixedcolumns ? X Thanks again for your work on this. We're continually reevaluating whether we can use the beta or need to stick with the stable version. At the moment, it looks like we'll be sticking with the stable version. But we'd like to use the beta, if the problems can be ironed out. Lars
On 12/3/2013 3:10 PM, Lars Huttar wrote:
On 11/28/2013 1:34 PM, Hans Hagen wrote:
That macro was never meant for mixed columns. I made a variant that works ok in mixed columns which will be in the next beta.
\setuptolerance[verytolerant]
\starttext
\startmixedcolumns
\dorecurse{4}{\input ward \par}
\testcolumn[10][-1pt] % 10 lines - 1pt slack
\dorecurse{2}{\input ward \par}
\stopmixedcolumns
\stoptext
Ok. It looks like the second parameter to \testcolumn is now required (it didn't used to be).
i'll fix that
What does this slack value do? Does it mean that the minimum amount of space left in the column is 10 lines minus 1pt?
indeed
Also, in the Dec. 2 beta (current version: 2013.12.02 15:22), the \column command now causes an error when we come to the \stopmixedcolumns. I don't know if it's connected with the above change, or something else.
no, more to making section breaks working better in columns (i forgot to rename a variable)
MWE: change the \testcolumn command above to \column. I get the following error output:
! LuaTeX error C:/context/tex/texmf-context/tex/context/base/page-mix.lua:474 : attempt to compare number with nil stack traceback:
C:/context/tex/texmf-context/tex/context/base/page-mix.lua :474: in function 'process_penalty'
C:/context/tex/texmf-context/tex/context/base/page-mix.lua :572: in function 'setsplit'
C:/context/tex/texmf-context/tex/context/base/page-mix.lua :687: in function 'setsplit'
C:/context/tex/texmf-context/tex/context/base/page-mix.lua :819: in function 'mixsetsplit' [string "\directlua "]:1: in main chunk.
system > tex > error on line 14 in file C:/Users/Huttar/Documents/work/tex/test-beta-testcolumn.tex: LuaTeX error ...
4 5 \startmixedcolumns 6 7 \dorecurse{4}{\input ward \par} 8 9 %\testcolumn[10][-1pt] % 10 lines - 1pt slack 10 \column 11 12 \dorecurse{2}{\input ward \par} 13 14 >> \stopmixedcolumns 15 16 \stoptext 17
\ctxcommand #1 -\directlua {commands.#1}
\page_mix_routine_construct ...\else false\fi , }} \deadcycles \zerocount \page_mix_routine_continue ...ine_construct \v!no
\page_mix_routine_package ... \page_otr_command_routine ...mix_routine_continue \or \page_mix_routine_bala... \page_otr_triggered_output_routine ...and_routine \fi <output> ...eforeoutput \page_otr_triggered_output_routine \relax \the \everyafterout... .... l.14 \stopmixedcolumns
? X
Thanks again for your work on this. We're continually reevaluating whether we can use the beta or need to stick with the stable version. At the moment, it looks like we'll be sticking with the stable version. But we'd like to use the beta, if the problems can be ironed out.
fyi: i'll not patch the stable version new beta
Lars
___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 12/3/2013 4:40 PM, Hans Hagen wrote:
On 12/3/2013 3:10 PM, Lars Huttar wrote:
... Thanks again for your work on this. We're continually reevaluating whether we can use the beta or need to stick with the stable version. At the moment, it looks like we'll be sticking with the stable version. But we'd like to use the beta, if the problems can be ironed out.
fyi: i'll not patch the stable version
new beta
Thanks for the fixes. When I said "the stable version", I wasn't very specific, but I was referring to the one on the TeX Live 2013 CD. But after you said the above I realized you were talking about this (http://wiki.contextgarden.net/ConTeXt_Standalone#Single_user_installation):
By default, the suite installs ConTeXt beta. If you want the stable version of ConTeXt, you can use
sh ./first-setup.sh --context=current
I'm making a note of it here in hope that it will help me remember next time what the "stable" version refers to. Regards, Lars
participants (3)
-
Hans Hagen
-
Lars Huttar
-
Lars Huttar (SIL gmail)