Skip to content

[bug] Indentation layout when using padding is in pt but only integers. Hence, layout mm can not be set correctly #652

@Melkiades

Description

@Melkiades

In the example, I am trying to set an indentation of 1 cm. I am using a transformation via a constant, but all numerical precision is discarted in the final output.

library(flextable)
ft <- flextable(cbind(rn = rownames(head(mtcars)), head(mtcars[, seq(3)]))) |> 
  theme_vanilla()
mm_to_pt_conversion <- 2.834
a <- ft |> padding(i = seq(2, 6, 2), j = 1, padding.left = 10 * mm_to_pt_conversion) # 10 mm is the wanted indentation
doc <- officer::read_docx()
doc <- body_add_flextable(doc, a)
file <- "filetocheck.docx"
print(doc, target = file)

When I use the above code, I get 0.99:
image

Thinking it was a fixed artifact or a converter issue I tried with different values like padding.left = 10.01 * mm_to_pt_conversion and to change font etc. Nothing changes the value. To get to have a different value you need to go from 28.xx points to 29.xx points. you can get there by using the above code with padding.left = 10.24 * mm_to_pt_conversion. Nonetheless the mm are again wrong due to the gap between the 28-29.

image

I do not think is a big issue but I was requested exactly 1cm indentation and I am wondering if there is a fix to this like if it is possible to use different units or add more precision to pt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions