Widows and Orphans

Using Gramps on Linux
I suspect that the large majority of Gramps users do not use Text Reports.
However for those that do, it must be a bit off putting to have reports which leave headings beheaded from their content by a page break.
There is a solution within CSS called Widows and Orphans.
Unfortunately although Gramps uses CSS to format Text Reports it only uses a very limited sub set of the commands and Widows and Orphans are not included.

I have managed to hack the ODFDOC.PY file to permanently output the W & O commands to the OFD document.
Does anybody have a better method?

1 Like

My hack is to add the following

        wrtf('fo:orphans="2" ' 'fo:widows="2" '

at line 1257 in the ODFDOC.PY file as shown in the link contents.
I presume the file shown is for Gramps 5v2. Indents should be the same as for the following line of text.

2 Likes

That’s a nice, logical enhancement.

Does the CSS have a “Keep with next” for headers too? Yep. wrtf('fo:keep-with-next="auto" for Header greater than level zero. Twice. Lines 595 and 1245

1 Like

come to think of it I don’t think the widows and orphans is part of CSS either

I’ve often wondered about headers and footers, also not part of CSS but would be jolly useful for printouts.

1 Like

I’ve just tried adding the keep_with_next to the odfdoc.py file but it keeps breaking the odf output.
I’ve probably done something wrong with syntax.
So be careful if attempting this hack, make sure you have a copy of the file you are hacking incase it all goes wrong.

1 Like

It would seem that by “text” you are actually referring to html output? If so, I don’t have any particular suggestion.

But if your utlimate output format is either as a formatted text document (such as odt or doc), or pdf, your simplest strategy is to output in odt format, apply appropriate styles which keep headings with next, then either use that as now formatted, or export to pdf.

I do this all the time to output text reports.

First I generate an odt file in gramps using the appropriate filters and settings, then in LibreOffice I load a template which can do all page, paragraph and text formatting in one pass, including setting margins, headers, footers and anything else you want to format. It takes a little work to set up your intitial template, but gramps text output is beautifully written with virtually every pararaph already tagged with a named paragraph style. You just have to create a template that exploits this scheme and tells LibreOffice what you want those styles to look like.

Then I export to my preferred distribution format, in pdf, with settings that meet archival standards.

As far as I am aware, most of the other text packages out there such as Office have a similar capacity to use the styles written into the gramps output to reformat the document, and to export to pdf.

2 Likes

Yes, adriandavey I thought similar, but would have preferred Gramps using the default document. But I suspect that this would be a bit too WP specific.