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

Side-by-side images with knitr::include_graphics #52

Open
mikelove opened this issue Jun 25, 2018 · 6 comments
Open

Side-by-side images with knitr::include_graphics #52

mikelove opened this issue Jun 25, 2018 · 6 comments
Assignees

Comments

@mikelove
Copy link

mikelove commented Jun 25, 2018

I'm trying to include some images side by side in a figure, but can't seem to see how to use the bookdown recommended code with BiocStyle. It becomes rendered as multiple separate figures, e.g. try the following

---
title: "Test"
author: "Mike"
output: BiocStyle::html_document
---

# Testing side-by-side images

```{r pacman, echo=FALSE, fig.cap="test"}
knitr::include_graphics(rep("pacman.png",3))
```

```{r pacman-solo, echo=FALSE, fig.cap="test"}
knitr::include_graphics("pacman.png")
```
@aoles
Copy link
Collaborator

aoles commented Jun 25, 2018

Interesting, as swapping BiocStyle::html_document to bookdown::html_document2 doesn't seem to produce side-by-side figures either. If you experience this too, you might consider checking with the bookdown guys what their thoughts on this are.

@mikelove
Copy link
Author

Good point! I also tried rmarkdown::html_document and I do get side-by-side images.

Any pointers on how one should go about putting side-by-side images into a BiocStyle doc with html output, even outside of the figure environment?

With rmarkdown::html_document, I can get them with:

<img width="30%" src="pacman.png"/>
<img width="30%" src="pacman.png"/>
<img width="30%" src="pacman.png"/>

But if I switch to BiocStyle::html_document these are no longer side by side.

@aoles
Copy link
Collaborator

aoles commented Jun 25, 2018

Thanks Mike for investigating further! I don't get side-by-side figures no matter what output format I use. BiocStyle::html_document is build on top of bookdown::html_document2 (which itself extends rmarkdown::html_document), so if things fail upstream I wouldn't expect them to work in BiocStyle either...

Output of rmarkdown::html_document:
image

Output of bookdown::html_document2:
image

@mikelove
Copy link
Author

Here is how I get side by side (w/ rmarkdown 1.9):

---
title: "Test"
author: "Mike"
output: rmarkdown::html_document
---

# Testing side-by-side images:

<img width="30%" src="pacman.png"/>
<img width="30%" src="pacman.png"/>
<img width="30%" src="pacman.png"/>

screen shot 2018-06-25 at 10 33 41 am

@aoles
Copy link
Collaborator

aoles commented Jun 25, 2018

This approach won't work with BiocStyle because of the way the CSS is defined for positioning the <img> elements. You can override this through the following customization. I will need to investigate this further, though, in order to decide whether a general fix is possible.

---
output:
  BiocStyle::html_document:
    css: custom.css
---

custom.css

img {
  display: inline;
}

@aoles aoles self-assigned this Jun 25, 2018
@mikelove
Copy link
Author

Thanks @aoles no rush from my side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants