Adjusting column width dynamically to get rid of orphans and widows
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
Hello, I recently started experimenting with using ConTeXt (mkiv) for dictionary typesetting. It's a much more attractive option than plain TeX or LaTeX because of the support for typesetting on a grid. However, grid typesetting can easily result in a large number of orphans and widows, which really doesn't look good in a dictionary. In an ideal world, I'd want to alter the column width slightly to prevent them (because most dictionaries aren't justified, this wouldn't be very noticeable). Would it be possible to use LuaTeX to achieve this? I.e., could one write some code that gets triggered by orphans and widows and then alters the current column width slightly until the problem disappears? Has somebody already done this? Or have the relevant TeX internals not been Luafied yet? I'd also be interested in other ways to solve this issue – for instance changing the looseness dynamically instead of the column width. Thanks a lot, Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/60f3cc97f94fa3690ba406f8c1a7fc4f.jpg?s=120&d=mm&r=g)
On Tue, 2017-06-20 at 09:22 +0100, Thomas Widmann wrote:
Hello,
I recently started experimenting with using ConTeXt (mkiv) for dictionary typesetting. It's a much more attractive option than plain TeX or LaTeX because of the support for typesetting on a grid.
However, grid typesetting can easily result in a large number of orphans and widows, which really doesn't look good in a dictionary.
In an ideal world, I'd want to alter the column width slightly to prevent them (because most dictionaries aren't justified, this wouldn't be very noticeable).
Would it be possible to use LuaTeX to achieve this? I.e., could one write some code that gets triggered by orphans and widows and then alters the current column width slightly until the problem disappears? Has somebody already done this? Or have the relevant TeX internals not been Luafied yet?
I'd also be interested in other ways to solve this issue – for instance changing the looseness dynamically instead of the column width.
Have a look at \widowpenalty and \clubpenalty. Also use margin kerning and font expansion.
Thanks a lot,
Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009 ___________________________________________________________________________________ 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 ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 20 June 2017 at 10:41, Henri Menke
On Tue, 2017-06-20 at 09:22 +0100, Thomas Widmann wrote:
I recently started experimenting with using ConTeXt (mkiv) for dictionary typesetting. It's a much more attractive option than plain TeX or LaTeX because of the support for typesetting on a grid.
However, grid typesetting can easily result in a large number of orphans and widows, which really doesn't look good in a dictionary.
In an ideal world, I'd want to alter the column width slightly to prevent them (because most dictionaries aren't justified, this wouldn't be very noticeable).
Would it be possible to use LuaTeX to achieve this? I.e., could one write some code that gets triggered by orphans and widows and then alters the current column width slightly until the problem disappears? Has somebody already done this? Or have the relevant TeX internals not been Luafied yet?
I'd also be interested in other ways to solve this issue – for instance changing the looseness dynamically instead of the column width.
Have a look at \widowpenalty and \clubpenalty. Also use margin kerning and font expansion.
\widowpenalty and \clubpenalty are almost useless in this context – believe me, I've tried! (I'm typesetting on a grid, with a fixed number of lines per page.) Which is why I'm looking for alternatives. Margin kerning and font expansion are definitely options, but again, my real query would be how to trigger them dynamically to avoid a widow or an orphan. Cheers, Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 6/20/2017 11:53 AM, Thomas Widmann wrote:
On 20 June 2017 at 10:41, Henri Menke
wrote: On Tue, 2017-06-20 at 09:22 +0100, Thomas Widmann wrote:
I recently started experimenting with using ConTeXt (mkiv) for dictionary typesetting. It's a much more attractive option than plain TeX or LaTeX because of the support for typesetting on a grid.
However, grid typesetting can easily result in a large number of orphans and widows, which really doesn't look good in a dictionary.
In an ideal world, I'd want to alter the column width slightly to prevent them (because most dictionaries aren't justified, this wouldn't be very noticeable).
Would it be possible to use LuaTeX to achieve this? I.e., could one write some code that gets triggered by orphans and widows and then alters the current column width slightly until the problem disappears? Has somebody already done this? Or have the relevant TeX internals not been Luafied yet?
I'd also be interested in other ways to solve this issue – for instance changing the looseness dynamically instead of the column width.
Have a look at \widowpenalty and \clubpenalty. Also use margin kerning and font expansion.
\widowpenalty and \clubpenalty are almost useless in this context – believe me, I've tried! (I'm typesetting on a grid, with a fixed number of lines per page.) Which is why I'm looking for alternatives.
Margin kerning and font expansion are definitely options, but again, my real query would be how to trigger them dynamically to avoid a widow or an orphan. can you make a small example showing the problem
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 20 June 2017 at 20:33, Hans Hagen
On 6/20/2017 11:53 AM, Thomas Widmann wrote:
On 20 June 2017 at 10:41, Henri Menke
wrote: On Tue, 2017-06-20 at 09:22 +0100, Thomas Widmann wrote:
I recently started experimenting with using ConTeXt (mkiv) for dictionary typesetting. It's a much more attractive option than plain TeX or LaTeX because of the support for typesetting on a grid.
However, grid typesetting can easily result in a large number of orphans and widows, which really doesn't look good in a dictionary.
In an ideal world, I'd want to alter the column width slightly to prevent them (because most dictionaries aren't justified, this wouldn't be very noticeable).
Would it be possible to use LuaTeX to achieve this? I.e., could one write some code that gets triggered by orphans and widows and then alters the current column width slightly until the problem disappears? Has somebody already done this? Or have the relevant TeX internals not been Luafied yet?
I'd also be interested in other ways to solve this issue – for instance changing the looseness dynamically instead of the column width.
Have a look at \widowpenalty and \clubpenalty. Also use margin kerning and font expansion.
\widowpenalty and \clubpenalty are almost useless in this context – believe me, I've tried! (I'm typesetting on a grid, with a fixed number of lines per page.) Which is why I'm looking for alternatives.
Margin kerning and font expansion are definitely options, but again, my real query would be how to trigger them dynamically to avoid a widow or an orphan.
can you make a small example showing the problem
Sorry about the delay – here you go! On my computer, the first column goes on for two lines more than the following column, and it still produces a widow: %%% document starts here \mainlanguage[en] \definefontfeature [default][default] [ protrusion=quality, expansion=quality, onum=yes, ] \definestartstop [negindent] [ before={% \startnarrower[left]% \setupindenting[-.5em,yes,first]% \setuphead[subject][indentnext=yes]% }, after=\stopnarrower, ] \setupbodyfont[palatino] \setupalign[hz,hanging,tolerant] \startsetups[grid][mypenalties] \setdefaultpenalties \setpenalties\widowpenalties{2}{10000} \setpenalties\clubpenalties {2}{10000} \stopsetups \setuplayout[grid=yes, setups=mypenalties] \righthyphenmin=60 \lefthyphenmin=60 \def\Sblackbold#1{{\bf #1}} \def\Sdef#1{{#1}} \def\Sdefrf#1{{\bf #1}} \def\ShwJNR#1{{\blue\bf #1}} \def\Spospsmallcaps#1{{\sc #1}} \def\Spunctuation#1{{#1}} \def\Sxrefxrhw#1{{\bf #1}} \def\Sgroupintro#1{{\it #1}} \def\threeentries{\ShwJNR{headphones}\page[no]\par\-\hskip .5em\Spospsmallcaps{noun}\Spunctuation{ }\Sdef{a pair of small speakers that you wear over your ears}\par\ShwJNR{heard}\page[no]\par\-\hskip .5em\Spospsmallcaps{verb}\Spunctuation{ }\Sgroupintro{the past tense and past participle of}\Spunctuation{ }\Sxrefxrhw{hear}\par\ShwJNR{hearing}\page[no]\par\-\hskip .5em\Spospsmallcaps{noun}\Spunctuation{ }\Sblackbold{2}\Spunctuation{ }\Sdef{If someone gives you a }\Sdefrf{hearing}\Sdef{, they let you give your point of view and listen to you.\par}} \def\thirtyentries{\threeentries\threeentries\threeentries\threeentries\threeentries\threeentries\threeentries\threeentries\threeentries\threeentries} \startdocument \startmixedcolumns[balance=yes] \raggedright \startnegindent \thirtyentries \stopnegindent \stopmixedcolumns \placefloats \stopdocument %%% document ends here The thing is that there simply isn't a good way to break up a three-line dictionary entry, and it would be much better to play around with the column width, the looseness, margin kerning or other tools rather than having to do so. Doing it manually is easy enough, but it would be much nicer if the one or more of these tools could get triggered automatically. Regards, Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 23 June 2017 at 14:21, Thomas Widmann
On 20 June 2017 at 20:33, Hans Hagen
wrote: On 6/20/2017 11:53 AM, Thomas Widmann wrote:
On 20 June 2017 at 10:41, Henri Menke
wrote: On Tue, 2017-06-20 at 09:22 +0100, Thomas Widmann wrote:
I recently started experimenting with using ConTeXt (mkiv) for dictionary typesetting. It's a much more attractive option than plain TeX or LaTeX because of the support for typesetting on a grid.
However, grid typesetting can easily result in a large number of orphans and widows, which really doesn't look good in a dictionary.
In an ideal world, I'd want to alter the column width slightly to prevent them (because most dictionaries aren't justified, this wouldn't be very noticeable).
Would it be possible to use LuaTeX to achieve this? I.e., could one write some code that gets triggered by orphans and widows and then alters the current column width slightly until the problem disappears? Has somebody already done this? Or have the relevant TeX internals not been Luafied yet?
I'd also be interested in other ways to solve this issue – for instance changing the looseness dynamically instead of the column width.
Have a look at \widowpenalty and \clubpenalty. Also use margin kerning and font expansion.
\widowpenalty and \clubpenalty are almost useless in this context – believe me, I've tried! (I'm typesetting on a grid, with a fixed number of lines per page.) Which is why I'm looking for alternatives.
Margin kerning and font expansion are definitely options, but again, my real query would be how to trigger them dynamically to avoid a widow or an orphan.
can you make a small example showing the problem
Sorry about the delay – here you go!
On my computer, the first column goes on for two lines more than the following column, and it still produces a widow:
%%% document starts here [...] %%% document ends here
The thing is that there simply isn't a good way to break up a three-line dictionary entry, and it would be much better to play around with the column width, the looseness, margin kerning or other tools rather than having to do so. Doing it manually is easy enough, but it would be much nicer if the one or more of these tools could get triggered automatically.
Oops, those lines didn't get wrapped very neatly. Here's a better version: \mainlanguage[en] \definefontfeature [default][default] [ protrusion=quality, expansion=quality, onum=yes, ] \definestartstop [negindent] [ before={% \startnarrower[left]% \setupindenting[-.5em,yes,first]% \setuphead[subject][indentnext=yes]% }, after=\stopnarrower, ] \setupbodyfont[palatino] \setupalign[hz,hanging,tolerant] \startsetups[grid][mypenalties] \setdefaultpenalties \setpenalties\widowpenalties{2}{10000} \setpenalties\clubpenalties {2}{10000} \stopsetups \setuplayout[grid=yes, setups=mypenalties] \righthyphenmin=60 \lefthyphenmin=60 \def\Sblackbold#1{{\bf #1}} \def\Sdef#1{{#1}} \def\Sdefrf#1{{\bf #1}} \def\ShwJNR#1{{\blue\bf #1}} \def\Spospsmallcaps#1{{\sc #1}} \def\Spunctuation#1{{#1}} \def\Sxrefxrhw#1{{\bf #1}} \def\Sgroupintro#1{{\it #1}} \def\threeentries{\ShwJNR{headphones}\page[no]\par\-\hskip .5em% \Spospsmallcaps{noun}\Spunctuation{ }\Sdef{a pair of small speakers that you wear over your ears}\par\ShwJNR{heard}\page[no]\par\-\hskip.5em% \Spospsmallcaps{verb}\Spunctuation{ }\Sgroupintro{the past tense and past part.\ of}\Spunctuation{ }\Sxrefxrhw{hear}\par\ShwJNR{hearing}\page[no]% \par\-\hskip .5em\Spospsmallcaps{noun}\Spunctuation{ }\Sblackbold{2} \Spunctuation{ }\Sdef{If someone gives you a }\Sdefrf{hearing}\Sdef{, they let you give your point of view and listen to you\par}} \def\thirtyentries{\threeentries\threeentries\threeentries\threeentries\threeentries% \threeentries\threeentries\threeentries\threeentries\threeentries} \startdocument \startmixedcolumns[balance=yes] \raggedright \startnegindent \thirtyentries \stopnegindent \stopmixedcolumns \placefloats \stopdocument Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/60f3cc97f94fa3690ba406f8c1a7fc4f.jpg?s=120&d=mm&r=g)
On Fri, 2017-06-23 at 17:52 +0100, Thomas Widmann wrote:
On 23 June 2017 at 14:21, Thomas Widmann
wrote: On 20 June 2017 at 20:33, Hans Hagen
wrote: On 6/20/2017 11:53 AM, Thomas Widmann wrote:
On 20 June 2017 at 10:41, Henri Menke
wrote: On Tue, 2017-06-20 at 09:22 +0100, Thomas Widmann wrote:
I recently started experimenting with using ConTeXt (mkiv) for dictionary typesetting. It's a much more attractive option than plain TeX or LaTeX because of the support for typesetting on a grid.
However, grid typesetting can easily result in a large number of orphans and widows, which really doesn't look good in a dictionary.
In an ideal world, I'd want to alter the column width slightly to prevent them (because most dictionaries aren't justified, this wouldn't be very noticeable).
Would it be possible to use LuaTeX to achieve this? I.e., could one write some code that gets triggered by orphans and widows and then alters the current column width slightly until the problem disappears? Has somebody already done this? Or have the relevant TeX internals not been Luafied yet?
I'd also be interested in other ways to solve this issue – for instance changing the looseness dynamically instead of the column width.
Have a look at \widowpenalty and \clubpenalty. Also use margin kerning and font expansion.
\widowpenalty and \clubpenalty are almost useless in this context – believe me, I've tried! (I'm typesetting on a grid, with a fixed number of lines per page.) Which is why I'm looking for alternatives.
Margin kerning and font expansion are definitely options, but again, my real query would be how to trigger them dynamically to avoid a widow or an orphan.
can you make a small example showing the problem
Sorry about the delay – here you go!
On my computer, the first column goes on for two lines more than the following column, and it still produces a widow:
%%% document starts here [...] %%% document ends here
The thing is that there simply isn't a good way to break up a three-line dictionary entry, and it would be much better to play around with the column width, the looseness, margin kerning or other tools rather than having to do so. Doing it manually is easy enough, but it would be much nicer if the one or more of these tools could get triggered automatically.
Oops, those lines didn't get wrapped very neatly. Here's a better version:
How about putting every entry into a box, making it unbreakable? Of course, you get unbalanced columns this way, but I think keeping the entries together is easier for the reader. \mainlanguage[en] \definefontfeature [default][default] [ protrusion=quality, expansion=quality, onum=yes, ] \definestartstop [negindent] [ before={% \startnarrower[left]% \setupindenting[-.5em,yes,first]% \setuphead[subject][indentnext=yes]% }, after=\stopnarrower, ] \setupbodyfont[palatino] \setupalign[hz,hanging,tolerant] \startsetups[grid][mypenalties] \setdefaultpenalties \setpenalties\widowpenalties{2}{10000} \setpenalties\clubpenalties {2}{10000} \stopsetups \setuplayout[grid=yes, setups=mypenalties] \righthyphenmin=60 \lefthyphenmin=60 \def\Sblackbold#1{{\bf #1}} \def\Sdef#1{{#1}} \def\Sdefrf#1{{\bf #1}} \def\ShwJNR#1{{\blue\bf #1}} \def\Spospsmallcaps#1{{\sc #1}} \def\Spunctuation#1{{#1}} \def\Sxrefxrhw#1{{\bf #1}} \def\Sgroupintro#1{{\it #1}} \def\threeentries{ \vbox{\hsize=\textwidth \ShwJNR{headphones}\page[no]\par\-\hskip .5em \Spospsmallcaps{noun}% \Spunctuation{ }% \Sdef{a pair of small speakers that you wear over your ears}% } \vbox{\hsize=\textwidth \ShwJNR{heard}\page[no]\par\-\hskip.5em \Spospsmallcaps{verb}% \Spunctuation{ }% \Sgroupintro{the past tense and past part.\ of}% \Spunctuation{ }% \Sxrefxrhw{hear}% } \vbox{\hsize=\textwidth \ShwJNR{hearing}\page[no]\par\-\hskip .5em \Spospsmallcaps{noun}% \Spunctuation{ }% \Sblackbold{2}% \Spunctuation{ }% \Sdef{If someone gives you a }% \Sdefrf{hearing}% \Sdef{,they let you give your point of view and listen to you}% } } \def\thirtyentries{\threeentries\threeentries\threeentries\threeentries\threeentries% \threeentries\threeentries\threeentries\threeentries\threeentries} \startdocument \startmixedcolumns[balance=yes] \raggedright \startnegindent \thirtyentries \stopnegindent \stopmixedcolumns \placefloats \stopdocument
\mainlanguage[en]
\definefontfeature [default][default] [ protrusion=quality, expansion=quality, onum=yes, ]
\definestartstop [negindent] [ before={% \startnarrower[left]% \setupindenting[-.5em,yes,first]% \setuphead[subject][indentnext=yes]% }, after=\stopnarrower, ]
\setupbodyfont[palatino]
\setupalign[hz,hanging,tolerant]
\startsetups[grid][mypenalties] \setdefaultpenalties \setpenalties\widowpenalties{2}{10000} \setpenalties\clubpenalties {2}{10000} \stopsetups
\setuplayout[grid=yes, setups=mypenalties]
\righthyphenmin=60 \lefthyphenmin=60
\def\Sblackbold#1{{\bf #1}} \def\Sdef#1{{#1}} \def\Sdefrf#1{{\bf #1}} \def\ShwJNR#1{{\blue\bf #1}} \def\Spospsmallcaps#1{{\sc #1}} \def\Spunctuation#1{{#1}} \def\Sxrefxrhw#1{{\bf #1}} \def\Sgroupintro#1{{\it #1}}
\def\threeentries{\ShwJNR{headphones}\page[no]\par\-\hskip .5em% \Spospsmallcaps{noun}\Spunctuation{ }\Sdef{a pair of small speakers that you wear over your ears}\par\ShwJNR{heard}\page[no]\par\-\hskip.5em% \Spospsmallcaps{verb}\Spunctuation{ }\Sgroupintro{the past tense and past part.\ of}\Spunctuation{ }\Sxrefxrhw{hear}\par\ShwJNR{hearing}\page[no]% \par\-\hskip .5em\Spospsmallcaps{noun}\Spunctuation{ }\Sblackbold{2} \Spunctuation{ }\Sdef{If someone gives you a }\Sdefrf{hearing}\Sdef{, they let you give your point of view and listen to you\par}}
\def\thirtyentries{\threeentries\threeentries\threeentries\threeentries\threeentries% \threeentries\threeentries\threeentries\threeentries\threeentries}
\startdocument
\startmixedcolumns[balance=yes] \raggedright \startnegindent
\thirtyentries
\stopnegindent \stopmixedcolumns \placefloats \stopdocument
Thomas
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 24 June 2017 at 01:19, Henri Menke
How about putting every entry into a box, making it unbreakable? Of course, you get unbalanced columns this way, but I think keeping the entries together is easier for the reader.
Thanks for your suggestion, but I don't think that'd work. Firstly, it'd require you to figure out whether an entry is longer than three lines (and thus breakable) before putting it into a box. Secondly, unbalanced columns really aren't the done thing in dictionary publishing. Lots of published dictionaries are full of orphans and widows because they're so hard to avoid without a lot of manual intervention, which is why I'm keen to explore and novel ways to avoid them. However, all ways I can think of requires typesetting the entries in the last column multiple times, i.e.: repeat adjust parameters (column width, looseness, ...) typeset column until the column doesn't generate orphan/widow Is this possible with ConTeXt/LuaTeX? Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 6/24/2017 4:48 PM, Thomas Widmann wrote:
On 24 June 2017 at 01:19, Henri Menke
wrote: How about putting every entry into a box, making it unbreakable? Of course, you get unbalanced columns this way, but I think keeping the entries together is easier for the reader.
Thanks for your suggestion, but I don't think that'd work. Firstly, it'd require you to figure out whether an entry is longer than three lines (and thus breakable) before putting it into a box. Secondly, unbalanced columns really aren't the done thing in dictionary publishing.
Lots of published dictionaries are full of orphans and widows because they're so hard to avoid without a lot of manual intervention, which is why I'm keen to explore and novel ways to avoid them.
However, all ways I can think of requires typesetting the entries in the last column multiple times, i.e.:
repeat adjust parameters (column width, looseness, ...) typeset column until the column doesn't generate orphan/widow
Is this possible with ConTeXt/LuaTeX? maybe be more explicit with very large penalties helps
\startdocument \showmakeup[penalty] \startbuffer \dorecurse{30}{ \widowpenalty\maxdimen \clubpenalty \maxdimen {\tf test #1.1}\crlf {\bi test #1.2}\crlf {\tf test #1.3}\crlf {\bf test #1.4}\relax \par } \stopbuffer \dorecurse{20}{ \dontcomplain \startmixedcolumns[balance=yes] \dorecurse{#1}{line #1\crlf} \getbuffer \stopmixedcolumns \page } \stopdocument ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 25 June 2017 at 12:16, Hans Hagen
On 6/24/2017 4:48 PM, Thomas Widmann wrote:
Lots of published dictionaries are full of orphans and widows because they're so hard to avoid without a lot of manual intervention, which is why I'm keen to explore any novel ways to avoid them.
However, all ways I can think of requires typesetting the entries in the last column multiple times, i.e.:
repeat adjust parameters (column width, looseness, ...) typeset column until the column doesn't generate orphan/widow
Is this possible with ConTeXt/LuaTeX?
maybe be more explicit with very large penalties helps
\startdocument
\showmakeup[penalty]
[...]
\stopdocument
Thanks, Hans, that's a very instructive bit of code, and I'm sure it will be useful from time to time. However, it doesn't really answer my question: Is there a way in ConTeXt/LuaTeX to typeset a column repeatedly until it fulfils certain criteria (such as not generating an orphan or a widow)? Perhaps it would be easier if I didn't think of it as a column, but simply as a box? The only problem I can see with that is that it makes it awkward to handle the fact that long entries will often need to run into the next column. Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 26 June 2017 at 10:31, Thomas Widmann
[...] Is there a way in ConTeXt/LuaTeX to typeset a column repeatedly until it fulfils certain criteria (such as not generating an orphan or a widow)?
Perhaps it would be easier if I didn't think of it as a column, but simply as a box? The only problem I can see with that is that it makes it awkward to handle the fact that long entries will often need to run into the next column.
If the answer is 'no', that's OK. I reckon it might be, given that TeX builds the paragraphs first and then split them to create pages, and I basically want the page builder to be able to rebuild certain paragraphs to make them fit, which goes against TeX's basic design. However, if were is somehow possible with LuaTeX, it would open up a lot of possibilities, and not just for dictionary typesetting. Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 6/28/2017 11:16 AM, Thomas Widmann wrote:
On 26 June 2017 at 10:31, Thomas Widmann
wrote: [...] Is there a way in ConTeXt/LuaTeX to typeset a column repeatedly until it fulfils certain criteria (such as not generating an orphan or a widow)?
Perhaps it would be easier if I didn't think of it as a column, but simply as a box? The only problem I can see with that is that it makes it awkward to handle the fact that long entries will often need to run into the next column.
If the answer is 'no', that's OK. I reckon it might be, given that TeX builds the paragraphs first and then split them to create pages, and I basically want the page builder to be able to rebuild certain paragraphs to make them fit, which goes against TeX's basic design.
However, if were is somehow possible with LuaTeX, it would open up a lot of possibilities, and not just for dictionary typesetting. one can of course make it work somehow, but it's not something standard and takes some coding and testing ... a rather specialized sub mechanism
(basically most of what one wants can be done, but that doesn't mean that all gets implemented; normally i only do such more complex things if i need it in a project, unless it is some rainy day fun project) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 28 June 2017 at 12:04, Hans Hagen
On 6/28/2017 11:16 AM, Thomas Widmann wrote:
If the answer is 'no', that's OK. I reckon it might be, given that TeX builds the paragraphs first and then split them to create pages, and I basically want the page builder to be able to rebuild certain paragraphs to make them fit, which goes against TeX's basic design.
However, if were is somehow possible with LuaTeX, it would open up a lot of possibilities, and not just for dictionary typesetting.
one can of course make it work somehow, but it's not something standard and takes some coding and testing ... a rather specialized sub mechanism
(basically most of what one wants can be done, but that doesn't mean that all gets implemented; normally i only do such more complex things if i need it in a project, unless it is some rainy day fun project)
Thanks, Hans! I never expected it to work out of the box, and I'm quite happy to do a lot of programming to make it work. What I'd really like to know is whether the relevant parts of TeX have been Luafied already (in which case I might do it soon), or whether doing this would require making changes to LuaTeX itself (in which I might not want to touch this yet)… Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 6/28/2017 1:20 PM, Thomas Widmann wrote:
Thanks, Hans! I never expected it to work out of the box, and I'm quite happy to do a lot of programming to make it work.
What I'd really like to know is whether the relevant parts of TeX have been Luafied already (in which case I might do it soon), or whether doing this would require making changes to LuaTeX itself (in which I might not want to touch this yet)… al relevant parts are opened up
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 28 June 2017 at 12:57, Hans Hagen
On 6/28/2017 1:20 PM, Thomas Widmann wrote:
What I'd really like to know is whether the relevant parts of TeX have been Luafied already (in which case I might do it soon), or whether doing this would require making changes to LuaTeX itself (in which case I might not want to touch this yet)…
al relevant parts are opened up
Excellent, thanks! Do you happen to know whether anybody has ever done anything vaguely similar that I can base this on, or would I be better off starting from scratch? Thanks! Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
![](https://secure.gravatar.com/avatar/7e5bde782363ab067ccbdb4e0f008265.jpg?s=120&d=mm&r=g)
On 28 June 2017 at 13:49, Thomas Widmann
On 28 June 2017 at 12:57, Hans Hagen
wrote: On 6/28/2017 1:20 PM, Thomas Widmann wrote:
What I'd really like to know is whether the relevant parts of TeX have been Luafied already (in which case I might do it soon), or whether doing this would require making changes to LuaTeX itself (in which case I might not want to touch this yet)…
al relevant parts are opened up
Do you happen to know whether anybody has ever done anything vaguely similar that I can base this on, or would I be better off starting from scratch?
I must admit I'm struggling a bit with how to do this. I was looking at using buildpage_filter to add some code, but that gets called when "LuaTeX is ready to move stuff to the main vertical list" according to the manual, so I would only be able to affect where the page break happens, not how the paragraphs get typeset. Or am I wrong? Is there any way to re-typeset a paragraph in the current vertical list once you've got as far as buildpage_filter? (Of course, half the paragraph might already have output to the preceding page, so the re-typesetting might have to start mid-paragraph.) Would it be easier to re-typeset the entire document? I.e., whenever a widow or orphan gets generated, mark the entries on the current page in some way (in the aux file?), and then typeset the whole thing again, typesetting the entries marked slightly differently. Any help would be much appreciated! Thomas -- Thomas Widmann Director Complexli Limited +44 789 444 3009
participants (3)
-
Hans Hagen
-
Henri Menke
-
Thomas Widmann