Comment 2 for bug 633661

Revision history for this message
Andy Pascall (apascall) wrote :

After digging through rubber's code, I found that this was more of a feature request for a "subfiles" module than a bug.

I spend a few hours trying to hack one together (with my limited python skills). I got it to work with my real use case, but not the test case I provided.

Here is how it works:
Subfiles is both a latex package and a latex class. It works a lot like the combine package which already has a rubber module, so I based the module on that one.

The main difference between combine and subfiles, is that the subfile document inherits its preamble from the master document. This means that when I compile the subfile, I can call "\includegraphics" as long as I have "\usepackage{graphics}" in the preamble of the master. However, rubber doesn't know that the graphics package was declared, so it doesn't load the graphics module.

To get around this, when the subfiles module detects that it is being called from within a subfile, it adds a dependency on the master document. This seems to work, but it will also process all of the other graphics in other subfiles, which might be a problem for master documents with a lot of subfiles.

It seems the solution would be to just look at the master's preamble (and not read the rest of the document) and load the relevant modules from this. However, I don't know how to implement this.

Attached is the start of my module. It works fine for my use case, but for the example I provided it crashes on the "del self.doc.hooks["end{document}"]" statement. If I remove that statement, then in my real use case, it will only process my first subfile statement. I can't figure out the difference between the real case and the test case.

Any help would be appreciated!