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

Cross referencing figures with html_letter #234

Closed
NewGraphEnvironment opened this issue Jul 22, 2021 · 3 comments
Closed

Cross referencing figures with html_letter #234

NewGraphEnvironment opened this issue Jul 22, 2021 · 3 comments

Comments

@NewGraphEnvironment
Copy link

NewGraphEnvironment commented Jul 22, 2021

First off - unreal package. Amazing! Game changer. Thank you so much.

For some reason I cannot seem to cross reference figures with html_letter. I can see that the figure caption will be a pop up in the html file but I would prefer it as a caption that I could cross reference in the text.

Interestingly, I have found a situation where it does work and that seems to be when the actual chunk output does not display. Sorry for the use of the DiagrammeR package in the example but it is the exception case I ran into so thought it might be relevant. Thank you!

---
title: "A letter of recommendation for Emi Tanaka"
author: "Yihui Xie"
output:
  pagedown::html_letter:
knit: pagedown::chrome_print
---
Any thoughts on how I might get Figure \@ref(fig:figure-1) to cross-reference like the failed output of Figure \@ref(fig:figure-2) does?

```{r figure-1, fig.cap='my_caption'}
knitr::include_graphics('https://www.rstudio.com/wp-content/uploads/2016/09/RStudio-Logo-Blue-Gray-250.png')
DiagrammeR::grViz("digraph rmarkdown{
graph[layout = dot, rankdir = LR]
d1 [label = 'step 1']
d2 [label = 'Step 2']
d1 -> d2 
}")



@RLesur
Copy link
Collaborator

RLesur commented Aug 11, 2021

Thanks a lot for this bug report.
This behavior comes from the fact that the html_letter output format modifies the defaut value of the fig_caption parameter and cannot be changed:

pagedown/R/paged.R

Lines 60 to 62 in f63b780

html_letter = function(..., css = c('default', 'letter')) {
html_paged(..., css = css, fig_caption = FALSE)
}

This is undocumented, sorry for that.

@RLesur RLesur closed this as completed in 7daf1c0 Aug 11, 2021
@RLesur
Copy link
Collaborator

RLesur commented Aug 11, 2021

This is now fixed in the development version of pagedown. You can install this version with:

remotes::install_github("rstudio/pagedown")

In order to get figure references in html_letter you need to use

output:
  pagedown::html_letter:
    fig_caption: true

@NewGraphEnvironment
Copy link
Author

👑

NewGraphEnvironment added a commit to NewGraphEnvironment/safety_plan that referenced this issue Aug 24, 2021
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