svmiller/svm-r-markdown-templates

Use templates in bookdown? (align environment definition needed for PDF output)

Opened this issue ยท 2 comments

I'd love to be able to use your templates, e.g. svm-latex-ms.tex, in writing my dissertation and some manuscripts in bookdown.

The trouble is, bookdown supports align-style equation environments for LaTeX-PDF output. This is a very useful thing about bookdown, as it allows more customisable equation layout:

\begin{align}
  \hat{Y}_{i}
    &= \beta_{0} + \beta_{1} X_{i} + \epsilon_{i}
    &= 4.20 + 3.69 X_{i} + \epsilon
\end{align}

For example, I wish to render to PDF from .Rmd source files that contain align-style equations. Using svm-latex-ms.tex as the template, my _output.yml is as follows:

bookdown::pdf_book:
  latex_engine: xelatex
  template: svm-latex-ms.tex

On rendering (with bookdown::render_book("index.Rmd")), I get this error:

! LaTeX Error: Environment align undefined.

Error: Failed to compile manuscript.tex. See manuscript.log for more info.
Execution halted

I think it would be great to include a definition for the align environment in these templates (I'm willing to help!) so that they can be more flexibly applied to outputs from the wider RMarkdown ecosystem, such as bookdown ๐Ÿ˜„.

Here's where I confess I know nothing of bookdown. Could I ask for your help with that? I'm at a point with these templates where I'm happy when they don't break for my narrow purposes. :P

I can sympathise with "narrow purpose" templates. We all want very specific and sometimes different things out of doc prep. Sometimes our own MacGyver-solutions are good enough ๐Ÿ˜‰

I'd be happy to help ๐Ÿ˜ƒ . I don't know much about LaTeX templates, but I imagine adding support for a new environment in a template would be easy enough. Perhaps we can borrow from the pandoc templates bookdowncalls on? https://github.com/jgm/pandoc-templates