Problem with bold letters inside equations Bookdown PDF \boldsymbol


I am using Bookdown to publish my final project in PDF but I do not find the way to print bold letters inside equations. I am using \boldsymbol command. If I use Rmarkdown without Bookdown, \boldsymbol works properly, but not if publishing via Bookdown.

For example, for the equation \boldsymbol y_k = \nabla f(\boldsymbol x_{k+1})-\nabla f(\boldsymbol x_k), which should be printed in PDF like the first equation, is printed like the second one instead:


I have tried by explictly loading amsmath package and does not work either. Also by loading bm package and using \bm but it gives me a compilation error.

Thanks in advance to anyone who can help me.

Putting curly braces around text to be bolded \boldsymbol{y_k}

\boldsymbol{y_k} = \nabla f(\boldsymbol{x_{k+1}})-\nabla f(\boldsymbol{x_k)}


\boldsymbol y_k = \nabla f(\boldsymbol x_{k+1})-\nabla f(\boldsymbol x_k)

(in RMarkdown, but not here, and I haven't tested in Bookdown)

Hi, maybe I was not clear when I published my problem (English is not my first tongue).

The problem I have is that I think that Bookdown ignores \boldsymbol{} command (something that does not happen when using just Rmarkdown). For example, if I write \boldsymbol{x} it displays x instead of \boldsymbol x. I do not think it is something related to using curly braces because I am just trying to bold the first letter.

Thanks for your help.

Not at all, I should have tested in bookdown

title: "A Minimal Book Example"
author: "Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."

# dummy1

No bolding

$y_k = \nabla f(x_{k+1})-\nabla f(x_k)$

With bolding and braces

$\boldsymbol{y}_k = \nabla f(\boldsymbol{x}_{k+1})-\nabla f(\boldsymbol{x}_k)$

With bolding without braces

$\boldsymbol y_k = \nabla f(\boldsymbol x_{k+1})-\nabla f(\boldsymbol x_k)$


I have tried creating a new prject in a different computer using your code and does not work either.

To build the project I use bookdown::pdf_book. Are you using any special configuration or default?

Thanks in advance.

In case someone faces the same problem I have found a solution, which is not a very rigorous method, but works. I think that the problem arises when you build the pdf file using bookdown::pdf_file; if instead pdf_document is used (which I think is the default method for RMarkdown), \boldsymbol works (but you lose features from Bookdown like cross-referencing).

What I did to make it work is building the project with bookdown::pdf_file, going to the _book folder inside the project, copying the .tex file and pasting it inside _bookdown_files folder. Once that is done, just open the .tex file and compile it (you can open it with RStudio and click on "Compile PDF" button).

If anyone knows how to make it work directly from bookdown::pdf_file, let us know.

Can you open an issue in bookdown ?

If something is not working with bookdown::pdf_book or bookdown::pdf_document2() but works with rmarkdown::pdf_document() that it is not expected.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.