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

Allow images or text or pdf pages above first top level heading in bookdown::gitbook: #864

Closed
3 tasks done
markbneal opened this issue Feb 26, 2020 · 2 comments
Closed
3 tasks done

Comments

@markbneal
Copy link

@markbneal markbneal commented Feb 26, 2020

The example below (i.e. saved as a file index.rmd ) has the same code chunk to display an image above and below the top level heading, but the image doesn't appear above the top level heading. This occurs if there is a file _output.yml with only this entry bookdown::gitbook: in the same directory.

That line seems to enforce a table of contents (which I want) and that appears to strip out anything (image or text) before the first top level heading by default (which I don't want) - so can this behaviour be modified?

---
site: bookdown::bookdown_site
---

```{r echo=FALSE, message=FALSE, warning=FALSE}
library(imager)
im <- load.image(system.file('extdata/Leonardo_Birds.jpg',package='imager'))
plot(im, axes=FALSE)
```

# I'm a top level heading, but please let me have my image above! {-}

```{r echo=FALSE, message=FALSE, warning=FALSE}
library(imager)
im <- load.image(system.file('extdata/Leonardo_Birds.jpg',package='imager'))
plot(im, axes=FALSE)
```

From a post at rstudio community, I received the option of editing the _output.yml with

  includes:
    before_body: assets/big-image.html

includes is an option that will probably work, but it feels unnecessary - how about bookdown::gitbook: doesn't constrain the user to its ideal scenario of "nothing can exist above the top level header, therefore I will ignore anything that is there" :) - unless there is a really good reason I'm not aware of?

Link to stackoverflow post:
Link to rstudio community post:

The index.rmd and _output.yml are in the following zip
testimage2.zip


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/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.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('bookdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/bookdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • 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.

@markbneal
Copy link
Author

@markbneal markbneal commented Mar 7, 2020

I've listed three approaches with their disadvantages as a stackoverflow answer. I'm fairly sure a neat resolution reguires a bookdown adjustment which is beyond my skill set.
EDIT
There is now a workable hack at stackoverflow for html output. For pdf output, there are working examples of an image at the start here or pdf inserted at the start here

I'm going to close this issue unless someone else thinks it is important enough.

@markbneal markbneal changed the title Allow images or text above first top level heading in bookdown::gitbook: Allow images or text or pdf pages above first top level heading in bookdown::gitbook: Mar 17, 2020
@github-actions
Copy link

@github-actions github-actions bot commented Nov 6, 2020

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 Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant