Take the 2-minute tour ×

I have a large collection of notes that currently consists of a large number of individual "chapters" that I manually number and keep track of. E.g. visit http://www.stat.sfu.ca/~cschwarz/CourseNotes with a manually created and maintained HTML index.

I would like to create a "superdocument" that includes all the individual chapters and use this to automatically create both an HTML index structure with "leaves" in PDF.

For example, at the highest level, you would get an HTML document that looks like:

This is my large set of course notes.
1. This is Chapter 1
2. This is Chapter 2
3. This is Chapter 3

where each of the "This is Chapter x" is a pointer to the PDF document for Chapter x.

This looks like a combination of latex2html type of conversions for the chapter/section headers and creation of separate pdf files for each chapter type of problem. Ideally, you would have control on the level of the HTML index created (e.g. shows all level 1 and 2 headings) and the level of leaf where the PDF is created (e.g. at the chapter level, or the section level). Cross references across the leaf boundaries would be nice, but not essential, i.e. a reference in Section 15.3 to Section 13.2 would jump to the "leaf" containing Section 13.2.

Is the a package that will do this? Am I asking too much from LaTeX? Other suggestions on automating the workflow? I've read the suggestions on separate PDF files for each chapter and this is a start, but the creating of main index would still have to be done manually.


Hmmm... I think I can see a potential workflow for this. If I can split the final pdf document in a convenient way (e.g. a chapter boundaries) this gets me part of the way there, and I think that a post-processing of the *.toc file could generate me the html code ?? Not sure how to link the two yet. I think I noticed a question/answer on how to split the final pdf file ... time for more research ...

share|improve this question

1 Answer 1

OK... I've managed to develop a workflow that seems that it will work. I've tested it for proof of concept and it mostly works but I need to do some fine tuning.

  1. Use the hyperref package so that the PDF file has bookmarks associated with each chapter/section.

  2. Use pdflatex to generate the book containing ALL the chapters etc. Do NOT destroy the .toc file as it will be used later.

  3. Use pdfasm to split the book from (2) into individual chapters. You can use the [FILENUMBER###] fragment in the output file names to number the parts appropriately, e.g. MyBook-Part-[FILENUMBER###].pdf generates MyBook-Part-001.pdf, MyBook-Part-002.pdf etc. Note that the book title generates a separate file so Chapter 1 is MyBook-Part-002.pdf etc. [I think in the future, I will not generate the title pages for the book.] I also used the minitoc package to generate a mini table of contents for each chapter.

  4. Process the .toc file from (2) to generate the HTML. I used SAS (just because I know SAS) to generate HTML code for the chapter and section headers. I then used a server side include to automatically embed this generated HTML code fragment in my index.shtml page. The generating the HTML isn't too hard and so can likely done in the language of your choice (e.g. perl). At this stage, you can control to what level in the ToC you want the HTML generated.

I have a few "features" that need tweaking:

  • greek letters in titles are stored in the .toc file as $\alpha$ etc. which needs to be modified for the HTML generated code;
  • some formatting in the chapter/section titles needs tweaking for the HTML, e.g. {\it text};
  • automating the entire flow process.
share|improve this answer

Your Answer


