2

I plan to write a short statistics textbook using Org-mode. Even if some textbooks have been written using equivalent systems (e.g., the R package bookdown), I have no examples in mind of books directly written in Org-mode.

The LaTeX guidelines of all major editors (e.g., CRC, Springer, Wiley) do not seem to facilitate the use of Org-mode, or at least, they require to build an appropriate workflow I cannot figure out on my own. (I am still a beginner in Org-mode.)

Indeed, they require any part, chapter, appendix, acknowledgments, etc., to be submitted in a separate .tex file, with some precise requirements for each file. A master .tex file then gathers all those files and produce the final output. (Example: Springer class here.)

Has someone already managed to set up an appropriate workflow for this kind of "constraint"? I can imagine two options:

  1. Should I export a series of separate foreword.tex, chapterXX.tex files, partXX.tex files and so on, from one single book.org file? And how to do so automatically each time book.org is exported? (Is it even possible to respect the Springer guidelines by doing so?)

  2. Should I create a series of separate foreword.org, chapterXX.org files, part.org files and so on, export them separately (and manually?) in LaTeX, and finally use the master TeX file from Springer to generate the whole book?

Unfortunately, in both cases, I do not see how to preview easily the whole book when exporting my org file(s), like any other org document. Getting/previewing the final book seem to require several manual operations each time, which would make this workflow really difficult to use.

Sorry for this rather vague question, but I cannot figure out how to proceed to respect those guidelines.

  • 2
    Please edit your post to make it a more discrete question. It looks like you want to know how to have org export the document into a series of well-defined separate tex files. Maybe revise the post to focus on that part. – Dan Dec 17 '19 at 9:42
  • 1
    Two points: 1) you might want to post your question to the Org mode mailing list: I'm pretty sure there are several people who have done books of some sort or another and might be able to help you; 2) depending on your platform, there are tools that might help with aspects of these, e.g. if you use separate Org files, you might be able to use a Makefile and the make program (or some equivalent) to pull everything together in a single PDF for preview. Org mode is great but it is one tool among many. – NickD Dec 17 '19 at 14:54
  • 1
    I suspect the effort involved in bending orgmode to work for this workflow will be greater than the effort involved in writing the book in LaTeX via AucTeX from the beginning. You can use .Rnw format to include R code (or code from other languages) in your LaTeX source. But configuring orgmode to produce a document that conforms to specific LaTeX requirement imposed by a third party is going to be tricky. – Tyler Dec 17 '19 at 16:51
  • 1
    alternatively, you could draft your manuscript in orgmode but keep all formatting and layout to an absolute minimum. Then when you're done, export the org source to the simplest LaTeX output you can, and apply the final editing by hand. – Tyler Dec 17 '19 at 16:52
  • 1
    You should read the section on publishing in the Org manual. – Tobias Dec 17 '19 at 18:33
4

I think you are actually looking for publishing of projects.

This does not only work for HTML but also for LaTeX. Projects are managed in org-publish-project-alist. Each entry of that list is one project. There you specify things like project path, publishing path, whether to create latex files that can be translated separately or body only files that can be included into some main LaTeX file.

Example for a project with Org source files in the project directory ~/Book and publishing directory ~/Book/Publish:

(add-to-list 'org-publish-project-alist
         '("My First Project"
        :base-directory "~/Book"
        :publishing-directory "~/Book/Publish"
        :publishing-function org-latex-publish-to-latex
        :body-only t
        :makeindex t
        ))

In this case you must manage yourself the main latex file which just includes the exported LaTeX files.

You can also create a project with two subprojects where one subproject manages the main file (with setting :body-only nil) and the other is for the org files with the contents of the chapters (with setting :body-only t). This way you let Orgmode generate the LaTeX header. Then use a LaTeX block with the \include commands for the chapters.

EDIT: 1. Do not use :auto-sitemap t but let LaTeX generate the table of contents.

  • "This does not only work for HTML but also for LaTeX": I must admit I skipped this part of the manual because I thought it was only for HTML, blogging and so on. This is really interesting, thanks @Tobias! – Philopolis Dec 18 '19 at 13:43
  • 1
    I finally tested your solution, and using it (+ the Org manual), I managed to set up a perfectly automated workflow. I had to add another publishing project to move all the .png files created by my scripts to the "~/Book/Publish" directory, so they can be found by the final tex files. Everything works nice with C-c C-e P a! That's really amazing, thank you ;) – Philopolis Dec 19 '19 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.