Hi Bruce,

I had an analogous problem a while ago, but with 7 chapter files, which I treated manually…
Your solution is a very nice one, thank you for sharing ! 

For the archives, if one wishes to have the correct chapter number in each separate PDF file, one could change the content of « test.tex » file as follows:

\starttext
\setupheadnumber[chapter][\cldcontext{\env{ChapNo}-1}]
\input chapter-\env{ChapNo}.tex
\stoptext

Best regards: Otared


On 20 Sep 2024, at 19:04, Bruce Horrocks <ntg@scorecrow.com> wrote:



On 20 Sep 2024, at 03:57, Joel via ntg-context <ntg-context@ntg.nl> wrote:

I have a document that's quite long. It uses a recurse function, a bit like this:

\starttext

   \dostepwiserecurse{1}{180}{1}{%

      \input chapter\recurselevel

}

\stoptext

That produces 180  chapters of content.

Anyway, my boss is upset she has to use a table of contents to navigate to the page she wants, and so wants me to split the file into 180  separate files, which somehow is going to be easier to look at. Honestly, she probably still won't ever actually look at it, but that's her requirement.

Since you’ve already got the chapter content split into separate \input files ...

At the Unix level, use the following script to run Context 180 times specifying a different output file each time:

#! /bin/bash
for i in {1..180}
do
 context \
   --arguments="ChapNo=$i" test.tex \
   --result="chapter_$i.pdf”
done

And at the Context level, test.tex is simply:

\starttext
 \input chapter\env{ChapNo}
\stoptext


Regards,

Bruce Horrocks
Hampshire, UK

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Otared Kavian
e-mail: otared@gmail.com
Phone: +33 6 88 26 70 95