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

rtf_subline text indent default doesn't match documentation #12

Closed
Robert-Krajcik opened this issue Feb 2, 2021 · 3 comments
Closed

Comments

@Robert-Krajcik
Copy link

Hi folks,

I noticed the documentation for rtf_subline indicates the default for text_indent_left = 0,
but when I run a small listing using iris data (below), it shows the text_index_left = 360 twips.
and it doesn't change when I specify text_indent_left = 0, in the code

I can post-process it to get what I want, but can you look into this please?

> attr(attr(l_iris, "rtf_subline"),"text_indent_left")
[1] 360

attr(attr(l_iris, "rtf_subline"),"text_indent_left") <- 0

Thanks,
Robert

library(r2rtf)
library(dplyr)

data("iris")

l_iris <- iris %>% 
  slice_sample(prop = 0.15) %>% # take 15% sample

  rtf_page(orientation = "landscape", 
           nrow = 26,
           border_first = "single", border_last = "single",
           # The value set left, right, top, bottom, header and footer margin in order.
           margin = c(1.0, 1.0, 1.0, 1.0, 0.5, 0.5) ) %>% 

  rtf_title( title=paste("\\b\\fs24","Iris data by Species","\\b0"), 
             subtitle = paste("\\fs20","Page \\pagenumber of \\totalpage"),
             text_justification = "l",
             text_convert = TRUE
             ) %>%
  
  rtf_subline(text = "xxyyzz", text_indent_left = 0,
              text_font_size = 10, text_font = 9, text_format = "b") %>%
  
  rtf_colheader(colheader = c(" Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | "), 
                text_font_size = 9, text_format = "b", 
                col_rel_width = c(2.4,2.4,2.4,2.4,0.4),
                cell_justification = "l",
                text_justification = c(rep("d",4),"l"),
                border_left = "", border_right = ""
                ) %>%
  
  rtf_body(col_rel_width = c(2.4,2.4,2.4,2.4,0),
           cell_justification = "l",
           text_justification = c(rep("d",4),"l"),
           text_font_size = 9, text_font = 1,
           page_by = "Species",
           pageby_header = TRUE,
           new_page = TRUE,
           border_first = "single", border_last = "single",
           border_left = "", border_right = "") 

l_iris %>% 
  rtf_encode() %>%
  write_rtf("output/l-iris.rtf") 

image

@elong0527
Copy link
Collaborator

Hi Robert:

It follows the same principal as we discussed in #8. The definition of indent is relative to table instead of page in r2rtf.

I will think twice to add an option to allow user to change to behavior between the two.

Best,

Yilong

@elong0527
Copy link
Collaborator

elong0527 commented Mar 20, 2021

Please test in https://github.com/Merck/r2rtf/tree/0.2.0.9001

We add text_indent_reference argument to control the reference of text indent calculation. You would need to set text_indent_reference="page_margin" for your case.

Example code:

iris %>% rtf_page(col_width = 5) %>% 
             rtf_body() %>% 
             rtf_footnote(footnote = "test", text_indent_reference = "page_margin",as_table = FALSE) %>%
             rtf_encode() %>%
             write_rtf("tmp.rtf")

@Robert-Krajcik
Copy link
Author

retested this one using v02.0.9000 beta

  rtf_subline(text = "subline text", text_indent_left = 0,
              text_indent_reference = "page_margin",
              text_font_size = 10, text_font = 9, text_format = "b")

and it works! The subline text is left-aligned. Thanks @elong0527

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