rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.79k stars 1.27k forks source link

[FR] pdf_book compilation: for easier refactoring LaTeX chunks please remove _main.Rmd file #1460

Open Mathemilda opened 8 months ago

Mathemilda commented 8 months ago

Hello Bookdown team! Thanks for your work, it is much easier to create PDF files with Bookdown than with LaTeX! However, sometimes I need to fix only LaTeX chunks. Unfortunately I did not find Bookdown error messages useful for this. I know that omitting a $ symbol is one of most typical mistakes, but such advise could be wrong. (I personally never misplaced $ signs working with Rmarkdown. But this could be just me because I have 30 years of LaTeX experience.) I'm recommended to check _main.Rmd file, which at this moment is a copy of my .Rmd file with YAML header from my index.Rmd file. At the point my .log file contains more information. So, to continue on my refactoring I need to remove _main.Rmd manually, because otherwise I cannot knit again. As result I accumulate a bunch of _main.Rmd files in my Recycle Bin, and I should remove them manually, too. Once I had 40 files there! In the same time I noted that messing up Rmarkdown does not produce this file, and I can work without interruptions. So, I have a couple of suggestions:

  1. Please remove _main.Rmd file automatically after LaTeX errors.
  2. I believe that LaTeX error message would be better reformulated as "You are likely to have an error in your LaTeX chunk on the quoted line or above it. Check your .log file for more information, look at its ending for the provided error".

I appreciate the huge amount of work you do here! Best regards, Mya

cderv commented 8 months ago

Thanks for the suggestion.

So, to continue on my refactoring I need to remove _main.Rmd manually, because otherwise I cannot knit again.

About _main.Rmd removal, did you set the configuration delete_merged_file ?

When setting in your _bookdown.yaml configuration

delete_merged_file: true

there should not be any blocking about re-rendering as the _main.Rmd will be overwritten automatically.

Is setting this configuration is helping for your workflow ?

Mathemilda commented 7 months ago

Hello, thanks for your reply! I do not have _bookdown.yaml file for this book because I chose a minimal bookdown template for PDF version of it. Nevertheless I put the line you suggested in YAML header of my index.Rmd file, and unfortunately did not get the desired effect. The thing is, I would like to keep a number of files as few as possible, because I already have many files and folders. Can you please tell me how it could be done without _bookdown.yaml?

cderv commented 7 months ago

Nevertheless I put the line you suggested in YAML header of my index.Rmd file, and unfortunately did not get the desired effect

This is a config only valid when set in _bookdown.yaml. This config file is not the same as index.Rmd YAML header.

The thing is, I would like to keep a number of files as few as possible, because I already have many files and folders. Can you please tell me how it could be done without _bookdown.yaml?

_bookdown.yaml

_bookdown.yml is a configuration file to the tool you are using which is bookdown. So in this type of case it is hard to not use such file as this is the way to configure. _bookdown.yml is entirely part of a bookdown project if you don't want to use default config.

If you don't want to store it, you could create one on the file before calling bookdown::render_book(). But this is dependant on your workflow and how you render your book.

Hope this helps and you understand the limitation here.