-
Notifications
You must be signed in to change notification settings - Fork 77
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
flextable and knitr/markdown/docx #175
Comments
Upon further investigation, I see that when knitted, the flextable is written to the intermediate .md file as an openxml code chunk. When the code chunk is wrapped in |
Well... FWIW, there's #174, which doesn't really care what prefix you're using, so it should work for Apart from that... yes, definitely possible. Whether I'll find time to implement that is up in the air though -- #174 seems like a more promising direction, so it'll likely end up higher on the priority list. |
Thanks for the pointer. I am using pandoc 2.1.3 and pandoc-crossref windows binary v0.3.1.0. The snippet in #84 as below. docx output does not create a reference for neither command document
|
#174 is unreleased as of yet, sorry if it wasn't clear. You could build it though if you wanted. Or I could make a tag from that, and CI would hopefully build it in a couple hours... which I might as well do, why not. Check back with https://github.com/lierdakil/pandoc-crossref/releases/tag/v0.4.0.0-alpha0 in an hour or so, there should be binaries available by then. |
That's Great! v0.4.0.0-alpha0 works as advertised. For completeness, I have included the .Rmd file which demonstrates. One note, the `\n' linefeeds used in catting of the caption appear to be necessary as flextable does not append a linefeed to the end of its output nor does the get picked up.
|
I'm not familiar with RMD myself, but if it's Pandoc Markdown on the top level, I would expect you could simplify the table part to ::: {#tbl:iris}
```{r, results='asis'}
iris.t <-
iris[1:5,] %>%
regulartable() %>%
style(pr_c = officer::fp_cell(vertical.align = "bottom",
border.bottom = officer::fp_border(width = 2)), part = "header") %>%
rotate(j = names(iris)[-c(1:2)],
rotation = "tbrl", part = "header", align = "bottom") %>%
height(height = max(dim_pretty(., part = "header")$widths), part = "header") %>%
width(width = c(dim_pretty(. ,part = "all")$widths[c(1:2)],
dim_pretty(. ,part = "body")$widths[-c(1:2)]))
iris.t
```
Iris table caption.
::: |
Your last suggestion was not successful. Didn't really dig into it as the above solution is good enough for me. |
It has been a while but trying to reuse the code snippet above to reference a div wrapped table but it is currently broken. Any idea why this may be? |
No idea, since you didn't specify what is "broken" exactly. Remember, I don't use R. In case you've updated pandoc recently, the last v0.4.0.0 prerelease (alpha6d) is not compatible with pandoc v2.10.x. In that case, you might try a more recent build https://bintray.com/lierdakil/pandoc-crossref/any-prefix/40a8b12efce01cf46ff385875cf2d49e3cae6a91#files |
Sorry, that was a really poor question... Briefly, R will render a markdown document
Then submit to pandoc with following command: Output
So, crossref is able to process the markdown style table but not the div wrapped table. The produced docx contains properly produced tables but only the markdown style table results in the properly formatted reference. |
Right. So, looking at the previous discussion here, I believe we established that pandoc-crossref 0.3.x doesn't really handle this, it really wants to see a table being referenced as Try getting the latest prerelease build of v0.4.0.0 (find it here), that should (hopefully) work. Or checkout the top of any-prefix branch on this repo if you want to build from source. If you're not keen on using prerelease software, we can return to the idea of referencing arbitrary |
Aha, yes it had been so long I forgot about your comment re v0.4 and missed it this time. I will try again. Thanks! |
flextable is a library for creating docx tables which adds word xml directly to the knitted document. I have been using pandoc-crossref in a Rstudio/rmarkdown/knitr/docx workflow with pandoc.table with great success. With flextable, there isn't the option to add a tag to the caption in a way similar to pandoc.table.
Questions:
Below is a reproducible .Rmd snippet.
The text was updated successfully, but these errors were encountered: