Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize the bookdown output filename #737

Closed
2 tasks done
tchevri opened this issue Jun 28, 2019 · 5 comments
Closed
2 tasks done

Customize the bookdown output filename #737

tchevri opened this issue Jun 28, 2019 · 5 comments
Labels
question general questions - not an issue

Comments

@tchevri
Copy link

tchevri commented Jun 28, 2019

我特别非常不好意思问问您,but i tried to ask my questions over a year ago, and i think you might have missed it - so a couple of weeks ago, i went to ask on Stack Overflow HERE but nobody picked it up yet and i am quite keen, if possible - and it seems like at least one other person would be keen too!
i feel bad to take up your time again: this is a follow to a question i already asked - you answered "impossible", but i tried some more and asked you again - i don't think you saw what i tried after you gave your negative answer.

Many thanks
thomas


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
  • [x ] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

:-)

@tchevri
Copy link
Author

tchevri commented Jun 28, 2019

ok... looks like my question number (link: 737) is not very auspicious!! hopefully does not crash me :-(

@yihui
Copy link
Member

yihui commented Jun 29, 2019

The only way at the moment is to render (bookdown::render_book()) to the default output filename, rename it (file.rename()), then render the next output format, and also rename the output file to your desired filename. This process could be automated via an R script. I don't have time for a more detailed answer. Sorry.

@timjore
Copy link

timjore commented Jun 5, 2020

@tchevri Have you found a solution yet?

@yihui Would it be possible to add a configuration parameter to bookdown that uses a custom filename or automatically renames the output files? For example, the notes in section 4.4 explain that the book_filename parameter can be used to set the filename of the main Rmd file, i.e., the Rmd file that is merged from all chapters; by default, it is named _main.Rmd.

That parameter apparently triggers a file rename operation on _main.Rmd (or perhaps uses the custom name directly). It would be really helpful if the same process could be run on the filenames for the EPUB and PDF formats that are made available for download automatically from the gitbook toolbar. The filename could be set by the same book_filename parameter or perhaps default to the title parameter. As it is, the default download is _main.pdf which is not as helpful to the user.

@cderv
Copy link
Collaborator

cderv commented Mar 24, 2021

@timjore I think book_filename already change the filename for the pdf or epub associated. Using bookdown-demo, pdf and epub are named as the book_filename parameter.

is that not working for you ? Is what you mean different ?

@tchevri case is different because it is about two output format for pdf but different files are needed. The best way is to indeed create a main R script (like _render.R) or a Makefile that would coordinate the different render_book() calls and rename output file as necessary. That way you would have filename as you want.
This is quite easy as bookdown::render_book() will return the path of the resulting file name.

I don't think we will support support in bookdown::render_book() directly because it feels something what should do part of an outside workflow and usually you won't build two files with the same extension from a bookdown project. it will be multiple formarts but 1 epub, 1 pdf, 1 docx, 1 HTML folder all named the same - which is already happening with book_filename (unless I am missing something).

@cderv cderv added the question general questions - not an issue label Mar 24, 2021
@yihui yihui closed this as completed Apr 14, 2022
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question general questions - not an issue
Projects
None yet
Development

No branches or pull requests

4 participants