9

I very much believe that Rmarkdown and bookdown are the future of content publishing, however some publishers use specific LaTeX templates, and in order to submit the manuscript they need it in that precise template.

For example, see this Springer manuscript template:

http://resource-cms.springer.com/springer-cms/rest/v1/content/20566/data/v3/monographs

Is it possible to make bookdown use this template in order to produce a PDF file?

EDIT: in this book (https://bookdown.org/yihui/bookdown/) on section 4.2 Theming I read it is indeed possible, but I might end up designing a "custom Pandoc LaTeX template".

I guess the question is now about how to design this Pandoc template, and section 4.3 provides some details about it.

Adrian
  • 744
  • 7
  • 17
  • 1
    I very much believe you are wrong. :-) – Konrad Rudolph Jul 26 '16 at 20:38
  • :-) Any arguments as to why my opinion is wrong? – Adrian Jul 26 '16 at 21:09
  • I just so happen to have this written up already: https://www.reddit.com/r/programming/comments/32bepp/word_or_latex_typesetting_which_one_is_more/cq9t7xt – Konrad Rudolph Jul 26 '16 at 21:12
  • 2
    OK, I see your point. But I didn't say "markdown"... but "Rmarkdown". And "bookdown" is even better, supporting equations, tables, and most importantly reference handling. – Adrian Jul 26 '16 at 21:22
  • The criticism is fundamentally the same though, even exemplifying it: sure, Bookdown supports feature X. But if I need feature Y, I cannot implement it within Bookdown. I have to write my own processor, breaking compatibility. It’s strictly a devolution from a more advanced format (TeX). “More features” isn’t the answer, “extensibility” is. – Konrad Rudolph Jul 26 '16 at 22:34
  • I am probably not the best person to bring arguments, as I am in the process of learning how to use bookdown. But as far as I can read from that book, it supports everything that LaTeX does (it actually uses it behind the scenes), and brings more features on top of that. The code is not static (as in the classic .tex documents) but dynamic: it uses R to produce figures on the fly, or to output some results. Books can be published not only in PDF, but also Kindle, HTML, Tufte and many other formats. In my honest opinion, this is an evolution (opposed to a devolution) over LaTeX. – Adrian Jul 27 '16 at 08:21
  • 3
    The point of (R) Markdown/bookdown is never to replace LaTeX, but achieve most (perhaps 80%?) of what can be done in LaTeX using much simpler syntax, and do not limit the output format to PDF only. With some small sacrifice, you can enjoy multiple output formats (HTML output is important, useful, beautiful, and fun) and a more human-readable source document (I guess I have expressed enough times that I hate reading source documents that are full of backslashes; I understand this is totally subjective). – Yihui Xie Jul 28 '16 at 21:24

1 Answers1

4

You don't really have to use a custom Pandoc LaTeX template (of course you can if you want). Tweaking a few options and you will be done. I just put an example in the bookdown-demo repository. See this commit for what I changed, and see here for a PDF example.

You almost surely still have to tweak other things, one of which might be the index page. I also made an example for that.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • I managed to follow all your changes (I think), and the .pdf file got produced... still with a few missing things: (a) the table of contents is empty; (b) the index is missing completely (I believe even in your PDF example). In addition, for the gitbook (HTML) version, instead of the "References" (unnumbered) chapter, I get a numbered "7. Placeholder" title, and this happens only for the "1. Prerequisites" page (for all the other chapters, the placeholder is replaced by "References"). – Adrian Jul 29 '16 at 11:07
  • In addition to your modifications, I added the svmono.cls file in the directory, but I am left out of clues what to do next. Perhaps unimportant (until we get to see the Index page), the Springer template also provides a style for the index, in the file svind.ist (is there a way to feed that to bookdown?) – Adrian Jul 29 '16 at 11:09
  • Forgot to add, since for some reason I am missing the "Build" button in RStudio (the preview version), I have compiled the PDF file using this command: ```bookdown::render_book("index.Rmd", "bookdown::pdf_book")``` – Adrian Jul 29 '16 at 11:19
  • For the Build button, go to `Tools -> Project Options -> Build Tools`, change it to `Website`. Yes, you will need svind.ist if you want the index page, but rmarkdown does not currently support custom ist files, so you have to pass the ist to makeindex from other approaches, e.g. http://tex.stackexchange.com/a/31965/9128. For the `7. Placeholder` problem, that is because `Knit` is only for previewing the current chapter. You have to build the whole book using the Build button. – Yihui Xie Jul 29 '16 at 15:47
  • Oh, that solved both the Build button and the placeholder things. So only one thing left in the question queue: what else should be done to obtain the table of contents in the pdf file? It is now produced via the Build button, and it opens in the RStudio's PDF viewer (but the Contents page is still empty). – Adrian Jul 29 '16 at 18:47
  • Do you have a reproducible example? I do have the TOC in my example output. – Yihui Xie Jul 29 '16 at 19:34
  • I've only downloaded your example commit (23ba576aa59b84b0e2b3b07be7fcf60e655985b8) and made sure all your modifications are there. Then I've copied the svmono.cls file in the same directory, double-clicked the bookdown-demo.Rproj file to open RStudio, opened the index.Rmd file and build it using the Build button. For some reason, the TOC is missing in my pdf file... – Adrian Jul 29 '16 at 20:23
  • Oh, got it: I had forgotten to add the spbasic.bst file in the root directory. Awesome stuff. – Adrian Jul 29 '16 at 20:31
  • Hmm, that is interesting. I don't understand why .bst can affect TOC... Anyway, glad you have made the first step. – Yihui Xie Jul 29 '16 at 21:15