-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
figure labels for use with pandoc-fignos filter #417
Comments
I think we either wait for the official pandoc support (jgm/pandoc#813), or ask you to DIY by redefining the |
Ok. I think I want to change hook_plot_md_base as in
I don't know where to go from here. If I load the function into the global env it seems to not be called from hook_plot_md. how to get knitr to use the modified function? |
Add this to the first code chunk of your Rmd document: library(knitr)
knit_hooks$set(plot = YOUR_OWN_HOOK_FUNCTION) Note there are a few internal functions in |
I have gotten back to this issue and have tried the following without success. I am sure it is due to lack of fundamental understanding.
This is an R Markdown document to demonstrate the generation of self-contained code chunks in a markdown file. It is particularly useful for situations where multiple plots are generated in a single code chunk allowing for dynamic label and caption support. See Figure @fig:carsPlot This example draws on http://stackoverflow.com/questions/21685885/knitr-plots-labels-and-captions-within-one-chunk in response to Items to note: #. output pdf_document fig_caption option must be set to yes #. plot.knit has been modified to plot.knit.md to account for the different syntax needed. suppressPackageStartupMessages(require(ggplot2))
cars.p<-ggplot(cars,aes(x=speed,y=dist))+
geom_point()
plot(cars.p)
|
Hi @HJAllen. Did this issue get resolved? |
yes thanks |
I know this is a rather old issue, but I just want to share a few observations about this topic, more specifically about the fact that column widths are being calculated from the cell's content, including when this content is a link to something else. (Thus a long path/filename creates huge columns, unrelated to the size of the image). While links are made possible when creating images inside an Rmd document's chunks, when the markdown table itself comes from a package using functions such as See this issue for all the details, but here's the TL;DR version :
The best workaround I could find is to store the images into a subfolder using short names, such as So that's it. I know it's probably not a priority for many R developers, but I thought this should be the place to give a try and maybe revive the discussion. Some unexpected solutions could come up, who knows! |
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. |
Is is possible to get knitr to add labels for figures (and tables) to the markdown files so that the pandoc-fignos filter could be used?
Particulars of the filter at
https://github.com/tomduck/pandoc-fignos
The filter requires the following format to create a reference
I have tried using fig.lp='#fig:' and extra.out='{#fig:description}' for both pdf and html output to no avail. if I knit to html and add the {#fig:description} to the .md file manually, pandoc will compile the pdf as expected.
Thanks!
Joel
The text was updated successfully, but these errors were encountered: