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

rft_encode() doesn't add footnote and source to all pages for doc_type = "figure" #90

Closed
Raylight07 opened this issue Mar 4, 2022 · 1 comment

Comments

@Raylight07
Copy link

Hi @elong0527,

I ran the following code. But footnote and source doesn't appear in each pages.

`
library(dplyr) # version '1.0.8'
library(ggplot2) # version ‘3.3.5’
library(r2rtf) # version ‘0.3.2’

for(i in sort(unique(iris$Species))) {
fil_data <- iris %>% filter(Species == i)

p <- ggplot2::ggplot(fil_data, aes(x = Sepal.Length, y = Sepal.Width))+
geom_point(size = 3)+
theme_minimal()

plot_file <- paste0("figure_", i, ".png")

ggplot2::ggsave(filename = plot_file, plot = p,
path=file.path(tempdir()), device="png", width=8.9, height=4.5, units = "in")
}

filename <- file.path(tempdir(), purrr::map_chr(unique(iris$Species),
~ paste0("figure_", .x, ".png")))

ttl1 <- "Plot of iris Sepal.Width by Sepal.Length"
ttl2 <- paste(\b0\fs20,"Page \pagenumber of \totalpage")

Create RTF file

fig_rtf <- filename %>%
rtf_read_png() %>% # read PNG files from the file path
rtf_title(ttl1, ttl2) %>% # add title or subtitle
rtf_figure() %>%
rtf_footnote("footnote", text_justification = "l" ) %>% # add footnote
rtf_source("[source: IRIS data]", text_justification = "l") # add data source

fig_rtf %>%
rtf_encode(page_footnote = "all",
page_source = "all",
doc_type = "figure") %>%
write_rtf(file = file.path(getwd(),"/","iris_3specices.rtf"))
iris_3specices.pdf
`

@elong0527
Copy link
Collaborator

Thanks! The bug is fixed in c41fd4b

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