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

column.width issue when using img refs #336

Closed
dcomtois opened this issue Jan 21, 2019 · 4 comments
Closed

column.width issue when using img refs #336

dcomtois opened this issue Jan 21, 2019 · 4 comments

Comments

@dcomtois
Copy link
Contributor

dcomtois commented Jan 21, 2019

The column widths are affected by the length of the path to images, which should not happen... For instance, if a cell contains:

![](C:\\Users\\usr1234\\AppData\\Local\\Temp\\RtmpQhs2I7\\file3a745a6e4f4f.png)

The width will try to accomodate for all these characters.

Here's a .Rmd demo:

---
title: "Untitled"
output: html_document
---

```{r, results='asis'}
devtools::install_github("dcomtois/summarytools", ref="colwidth-issue")
library(summarytools)
dfSummary(tobacco, plain.ascii = FALSE, style = "grid", 
          graph.magnif = 0.82, valid.col = FALSE)
```

Rendered results here

@daroczig
Copy link
Member

I think this is a limitation of pandoc and not a pander issue, so please check with the devs there with a minimal example of a markdown file including a grid table with an image (markup) in a cell. Once we know how to do that properly in markdown, pander will be able to kick in as well.

@dcomtois
Copy link
Contributor Author

dcomtois commented Jan 25, 2019

Just a little update, in case someone encounters the same situation: I asked the question on the pandoc discussion group, and it is indeed a limitation in pandoc. There is an easy workaround when the column containing the images is the last one:

+-------+---------------+
| color |      Img      |
+=======+===============+
| Blue  | ![](tiny-blue-square-with-a-ridiculously-long-file-name.png) |
+-------+---------------+

... but if it's not the last column, it doesn't work.

Otherwise, here are the suggestions I got from the Pandoc discussion board:

  • use reference links (with knitr, I think this is only possible with images what were created in the .Rmd document itself)
  • use pipe tables (not possible since the tables I generate are multi-line)
  • use a filter like pandoc-fignos but it's not supported in knitr (see this feature request
  • encapsulate the table in a <div>, as explained here

Only the last solution seems appropriate, at least for the moment (Edit: as it turns out, it also requires the use of a pandoc filter, so there is no obvious solution AFAIK.)

And it doesn't seem like there's a lot of appetite for change at this point.

@daroczig
Copy link
Member

Thanks, @dcomtois, these points are really useful 👍

@dcomtois
Copy link
Contributor Author

You're welcome! Unfortunately the workaround I was putting my faith in a non-solution since it also requires a pandoc filter. Maybe an advanced Web developer could see a solution (involving Javascript, most probably), but I had to do something far from ideal to make things work: copy the images in a subdirectory and save them using short names. That way I can put in the cells something like this:

![]img/ds001.png

...and it makes the widths perfectly fine. Only (quite annoying) problem is that it leaves garbage behind.

image

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