I am in the process of writing a Python program that scrapes exam questions in tex files from a website and combines them to create a new paper. The questions are picked by random from a spreadsheet, so that questions from various years (and therefore from different latex files) may be combined. Here is an example of such a paper (1987), and here is an example from a much newer paper (2018).
The preambles are considerably distinct and this makes it difficult to simply include them into the same latex file. How could I, for example, take a particular question from the older paper and another question from the newer paper and produce a single pdf file? I have attempted to use the subfiles
and standalone
packages but I get bombarded with errors. I have also considered compiling each latex file separately and concatenating them using pdfpages
or a similar command line utility but I would like to avoid having only a single question per page. I have thought about programmatically retrieving the "union" of the preambles from the two (or more) files and simply substituting in each \question
in a single latex file, but this is a last resort.