# ConTeXt: column breaks (reduce balancing penalty)

I'm trying to prevent ugly breaks of the items inside a \startcolumns...\stopcolumns environment:

\setuppapersize[letter]

\setuplayout
[ topspace=0.5in
, height=10in
, backspace=0.75in
, width=7in
]

\setupcolumns[n=3,separator=rule,balance=yes,distance=0.5in]

\define\eachtestpar{\EveryPar{%
%\clubpenalties  5 10000 10000 10000 100 0%
%\widowpenalties 5 10000 10000 10000 100 0%
\keeplinestogether{20}%
}}

\defineitemgroup[test]
[inner=\eachtestpar]

\starttext

\startcolumns
\startitemize
\item One
\item Two
\item Three
\item Four
\item Five\blank[medium]

Thus, I came to the conclusion that the designer of a new system must not only be the...

\item Six
\item Seven
\stopitemize
\stopcolumns

\blank[5*big]

\startcolumns
\startitemize
\item One
\item Two
\item Three
\item Four
\item Five\blank[medium]

Thus, I came to the conclusion that the designer of a new system must not only be the...
\startitemize
\item One
\item Two
\item Three
\stopitemize

\item Six
\item Seven
\stopitemize
\stopcolumns

\stoptext


I don't want to completely prevent breaks, but I do want my penalties to take precedence over column balancing. Unfortunately \EveryPar with \clubpenalties, \widowpenalties and \keeplinestogether does nothing but reduce the space between the paragraph and nested list (i.e. uglier).

Specifically: a break less than 5 lines or 5 nested items should not happen; instead the columns should be unbalanced.

• You are aware that spaces before commas are not ignored in ConTeXt? \setupwhatever[foo=bar ,hello=world] is not the same as \setupwhatever[foo=bar,hello=world]. You are lucky that things in \setuplayout is parsed as dimensions. – Henri Menke Feb 13 '20 at 20:27
• Ah that's why it sometimes works, sometimes doesn't. – user19087 Feb 13 '20 at 20:39

First of all, there is no need to wrap itemize in columns. The itemize environment supports columns out of the box.

To rigidly keep the lines together you can wrap the item content into \start...\stopitem and pack it into a \vtop.

\setuppapersize[letter]

\setuplayout
[topspace=0.5in,
height=10in,
backspace=0.75in,
width=7in]

\unexpanded\long\def\vtopitem#1\stopitem{%
\vtop{%
\rightskip=\leftskip\relax
\leftskip=0pt\relax
#1%
}%
\stopitem
}

\starttext

\startitemize[columns][n=3,command=\vtopitem]
\startitem One \stopitem
\startitem Two \stopitem
\startitem Three \stopitem
\startitem Four \stopitem
\startitem Five\blank[medium]

Thus, I came to the conclusion that the designer of a new system must not only be the...
\stopitem
\startitem Six \stopitem
\startitem Seven \stopitem
\stopitemize

\blank[5*big]

\startitemize[columns][n=3,command=\vtopitem]
\startitem One \stopitem
\startitem Two \stopitem
\startitem Three \stopitem
\startitem Four \stopitem
\startitem Five\blank[medium]

Thus, I came to the conclusion that the designer of a new system must not only be the...
\startitemize
\item One
\item Two
\item Three
\stopitemize
\stopitem
\startitem Six \stopitem
\startitem Seven \stopitem
\stopitemize

\stoptext


• The main issue is it doesn't allow any breaking whatsoever, unlike '\clubpenalties, \widowpenalties, etc. I guess the vertical rules would have to be added via MetaFun? – user19087 Feb 13 '20 at 21:31
• Why is it that penalties don't affect itemgroup paragraphs, via \clubpenalties, \widowpenalties, \penalty, \keeplinestogether etc? I can force individual items together with inbetween=\penalty... but that only works as an on/off switch. Either 0 or 10000, nothing else matters. Also took me a while to realize that itemgroups have default settings: before and inbetween are \blank[big], so using them even with a no-op will change your formatting. – user19087 Feb 14 '20 at 2:53
• I even tried adding some vertical glue after the itemgroup to allow intermediate penalties to work, but no luck. It is also frustrating that additional top-level items automatically shrink top-level spacing but not nested item spacing. Which makes the list appear lopsided requiring you to change the nested inbetween spacing manually. – user19087 Feb 14 '20 at 3:01
• Anyway the point is that I don't want encase itemized paragraphs and nested itemizations in a vbox. I would rather apply standard widow/orphan penalties. While tinkering with dorecurse` I've seen certain combinations push the last three words of a paragraph to the next column while the current one isn't completely full. Also, I can't live without vertical-rule column separators. – user19087 Feb 14 '20 at 3:05
• The best way to phrase the problem, I think, is to say the column balancing penalty is too high. – user19087 Feb 14 '20 at 4:53