PreTeXt book to handouts

Skip to first unread message

Aaron Greicius

Sep 9, 2022, 5:36:16 PM9/9/22
to PreTeXt support
I just posed this question at the PreTeXt drop-in today and was encouraged to post here too. 

I am looking for an efficient method of extracting only statements of definitions and theorems (and the like) from specific sections of a PreTeXt book, to be published as a PDF and distributed in class as a short handout or executive summary.  I was planning on just writing some Python code to do so, but imagine there must be a better way using xsl. 

I have in mind something like a another build target for the CLI,  which allows for the selection of  (a) a specific section of the book and (b) the type of elements to be extracted (e.g. definition, theorem, corollary, algorithm, etc.), and then builds a LaTeX file containing just those elements from the selected section, organized by type. (In my executive summaries I have three separate sections: definitions, theory (theorems and corollaries), and procedures (algorithms). 

At the drop-in session some potential starting points were suggested: e.g., creating a modified version of the pretext-latex.xsl file. I thought I'd put it to PreTeXt support group  to see (a) whether anyone has done something similar, and (b) whether this would be a useful feature to the community more generally. 


Oscar Levin

Sep 10, 2022, 2:12:55 PM9/10/22
to PreTeXt support
This is something I have been playing with over the last couple of years, in my case, to make a pdf of just the activities in a book (Project-like), one per page.  The xsl isn't difficult, and I have a good starting point for that, which I would be happy to share (although I probably need to update it a bit before it would be useful to anyone else, or with the most recent updates to PreTeXt). 

Once you have the custom xsl, it is very easy to use it in the CLI: just add a new target and set the <xsl> tag to point to the custom xsl.    With the subset build stuff, you should be able to limit to just a chapter.

Another option that might be worth looking into is the <list-of> mechanism that has recently (within the last two years, I think) been implemented.  You can get a list of all the theorems from a particular scope.  I don't know if this is useful in pdf though.  Search the documentation or maybe sample article?

Another consideration we need to be careful with is numbering.  I assume you would like to refer to the theorems by their proper PreTeXt given numbers.  This would mean processing the whole document.  Would building a pdf of just the theorems (or whatever element you wanted) for the whole book, and then printing just the pages you need for a given chapter, be sufficient?  

All that said, I would really like to develop a "course materials" suite of targets that would be useful for your application and others.  So if you are interested in working on this with me, let me know.

Aaron Greicius

Sep 11, 2022, 9:14:34 AM9/11/22
to PreTeXt support
A course materials suite of targets is just what I had in mind, and I'd be happy to work on this with you. 

Regarding <list-of>: this is indeed a fantastic feature, and I use it extensively in my main html course resource, but as you write it doesn't quite fit the bill for this specific pdf purpose. 

Regarding numbering: when I produce these executive summaries the various elements are unnumbered. The main purpose of this resource is for the students to have easy access to careful, legible statements of the given day's definitions and pieces of theory, and to save me board space and time. As such it is not important to me that they come equipped with the same numbering as it appears in the main course object, or any numbering at all. That said, essentially all of these elements in my resources have titles that I use for cross referencing purposes in my teaching, and which are included in the executive summaries. Processing the whole document as you propose would indeed suffice, though it would obviate the user's selection of a particular section. I think it would be nice to have some more flexibility with numbering: e.g., no numbering, or level-1 style numbering (Theorem 1, Theorem 2, etc.), or level-2 style numbering (Theorem X.1, Theorem X.2, etc.) where user gets to select X.     

Sean Fitzpatrick

Sep 11, 2022, 9:29:25 AM9/11/22
I think you could do this without extra xsl, using versions, but this might require a lot of source modification unless someone can think of a way to omit the "empty component".

1. Create a new top level file and publisher file (you probably want article and not book for this, and you'll need to use different numbering)

2. For anything in your source that you want to include, add component="handout" to the XML tag

But the problem is that anything without a component attribute gets included by default. I don't think you want to put something like component="text" on every single <p>, example, and exercise in the book.

I don't think we have an "exclude" option in the publisher file, only include.

But if there's a way to leave out everything but what you want, you could use the subset target to make handouts.

Rob Beezer

Sep 11, 2022, 11:13:08 AM9/11/22
Some brief thoughts. @Aaron - maybe more discussion at Drop-In on Sep 23 would be useful.

Numbering would be a real sticking point, and as a general feature some would want that.

Sean is right about versions, pro and con. I thought about the problem of "excluding" the untagged component, but can't recall if that is implemented in some way.

First thought is to extend the preprocessor, so that any standard conversion might be applied (without running the preprocessor again!) and all varieties of output format might be possible. Comprehensive extension of something like the latex conversion will be very brittle.

Right now the preprocessor computes division numbers and adds them to division elements as attributes. So building on the output of the preprocessor would allow you to capture the "original" numbers. (Those attributes are in an "internal" namespace right now.) With some dedicated time, I hope to pre-compute all numbers in this way. (And give the latex conversion to use them, rather than using latex's native numbering for most items.)

The starting point, as always, is how a publisher would specify this partition and subset easily, cleanly, and generally.


Aaron Greicius

Dec 12, 2022, 5:10:55 PM12/12/22
to PreTeXt support
Hi Oscar, 

I finally have a little bit of time on my hands and thought I'd try and pick this up again. Would you be willing to briefly meet remotely  to (a) walk me through your xsl approach and (b) discuss your course materials target suite idea?  I am pretty much totally free this week and next. 


On Saturday, September 10, 2022 at 1:12:55 PM UTC-5 wrote:
Reply all
Reply to author
0 new messages