Reinserting a section title followed by (continued) after a page break
I'm trying to use ConTeXt for playwriting, and I think it would be best to use sections for dialog. However, if a dialog's text is interrupted by a page break, it is customary to restate the character name followed by (continued) on the following page: --- open --- John My name is John, and I seek help with my --- page break --- John (cont'd) typesetting needs... --- end --- Maybe what I need is instead a mark? Here's a catch though, I will also need this to work for simultaneous dialog as well. This kind of dialog is represented by having dialog sections in columns: --- open --- Alice Bob John, you fool. John, you imbecile. --- page break --- Alice (cont'd) Don't you know that everyone uses Word to typeset their plays? --- end --- How can I do this kind of thing in ConTeXt? At the moment, I've been looking into adding a hook to shipout to prepend a section header with the last custom mark I've set. Even still, I don't know if this would work, or how to go about achieving this. If columns would be too difficult to implement, I'd be fine with living without (continued) support in them since they are pretty rare.
On the off chance anyone seeing this is interested, I have a solution uploaded as part of a module I wrote for screenplay and stageplay writing: https://github.com/cjayross/drama.mkiv/blob/4a9b2576c8630fd03352d95f99456092... The solution ended up being very detailed and tightly coupled to this particular problem. However, the general approach was to use box registers to capture the portions of dialog marked using a command sequence (`\continue` in this case) that designates acceptable locations to insert a page break in the dialog. The markup is then placed into the document in pieces with each placement testing the `\pagetotal` against the `\pagegoal` to measure whether the current piece will fit on the current page. This solution had to up using `\synchronizeoutput` as opposed to `\triggerpagebuilder`. I'm not sure why there's a difference in behavior between the two, but the former seems to fix bugs where the `\pagetotal`s would output the measure of the previous page rather than the current one -- leading to sporadic page breaks.
On 9/4/2023 5:55 AM, Calvin Ross wrote:
On the off chance anyone seeing this is interested, I have a solution uploaded as part of a module I wrote for screenplay and stageplay writing: https://github.com/cjayross/drama.mkiv/blob/4a9b2576c8630fd03352d95f99456092...
A few remarks: - you can best name modules like t-drama and then t-drame-screenplay and so in order to avoid clashes with files in the tex tree - you really have to be careful with defining additional intercace constants; as you don't define them for other interface languages there is no real reason for them - be aware that when you add key sto existign commands, future clashes can occur - best define new commands CamelCase so that ther ei sno clash with existing or future commands - as you basically define in mkii style, you can use \setevalue {xxx} {\getvalue{yyy}} which is a bit more readable If you load the module in lmtx you get an error on \checkparameters which is not available in lmtx (here \ifparameters is a primitive) because \doifelseassignment is the real tester (checkparameters is more an mkii thing). However, when you \enabledirectives[overloadmode=error] loading will be aborted earlier on because you overload existing macros. It sounds worse than it is because if you use mkiv/lmtx there are easier ways to define an enviroment, think: \unprotect \installnamespace {Slug} \installcommandhandler \????Slug {Slug} \????Slug \protect \setupSlug[this=that] \Slugparameter{this} etc Which would reduce the amount of code. Anyway, I advise users of LMTX to testtheir local definitions with \enabledirectives[overloadmode=error] or at least \enabledirectives[overloadmode=warning]
The solution ended up being very detailed and tightly coupled to this particular problem. However, the general approach was to use box registers to capture the portions of dialog marked using a command sequence (`\continue` in this case) that designates acceptable locations to insert a page break in the dialog. The markup is then placed into the document in pieces with each placement testing the `\pagetotal` against the `\pagegoal` to measure whether the current piece will fit on the current page.
This solution had to up using `\synchronizeoutput` as opposed to `\triggerpagebuilder`. I'm not sure why there's a difference in behavior between the two, but the former seems to fix bugs where the `\pagetotal`s would output the measure of the previous page rather than the current one -- leading to sporadic page breaks.
This is indeed a problem. Forcing the page builder is not always the solution, but neither is synchronize output. The first one triggers a check for pending contributions while the second forces it using a penalty which can have side effects. One problem is that pagegoal and pagetotal are not always reliable. There is a wrap up about this which isnot yet in the disibution because it is part of a larger experiment. In luametatex we have a few more ways to influence the page builder and also get more reliable info about the state so far. It is something Mikael and I are experimenting with (using large complex mixed text/math documents) in the perspective of par and page building. We will come back to this later this year but some already trickled into context lmtx. So, keep an eye on what shows 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 -----------------------------------------------------------------
participants (2)
-
Calvin Ross
-
Hans Hagen