pdf_book handling of inline latex ($ x $, \( x \), $$ x $$)

Dear bookdown users,

Keen to write my first chapter, with some mathematical content, but unable to include inline expressions reliably.

My question (as bookdown newbie): please distinguish latex expressions/ environments suitable for inline insertions (within delimiters when using bookdown::pdf_book to render to pdf output.

My steps:

[installed: Ubuntu 18.04, texlive-full, R version 3.5.2 (2018-12-20), bookdown package]

  1. clone Xie's bookdown-demo

  2. append to file 01-intro.Rmd the following:

You can write citations, too. For example, we are using the **bookdown** package [@R-bookdown] in this sample book, which was built on top of R Markdown and **knitr** [@xie2015].

For LaTeX math in pdf output use
\begin{verbatim}
bookdown::render_book('index.Rmd', 'bookdown::pdf_book')
\end{verbatim}

Using ubuntu 18.04 texlive, setting *latex_engine: pdflatex* in output.yml,
we run tests.

Test inline LaTeX, $f(k) = {n \choose k} p^{k} (1-p)^{n-k}$ works.
But failing when placed inline between single dollars is
$$ E \{ \, X |\, X > t \} = t + 1/\lambda . $$
Also failing inline is
\begin{verbatim} 
$\lambda_{m+1}$ and \( \lambda_{m+1} \) 
\end{verbatim} 
whereas:
in step \(m\) is $$ \lambda_{m+1} $$ works but the subscripted expression requires its own line.
  1. bookdown::render_book('index.Rmd', 'bookdown::pdf_book')

Please note the comments about failures to render when $$ $$ pairs are replaced by ( ) or pairs in step 2 above.
How can a user predict when the inline equations will work?

tia

hmh

No spaces after the opening $ or before the closing $ should get you E \{ \, X |\, X > t \} = t + 1/\lambda . inline should fix that

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.