davidgohel / flextable

table farming
https://ardata-fr.github.io/flextable-book/
565 stars 82 forks source link

Super- and subscripts incorrectly rendered in LaTeX #556

Closed phgrosjean closed 1 year ago

phgrosjean commented 1 year ago

In an R Markdown document, I have this chunk:

library(flextable)
flextable(head(iris)) |>
  add_footer_lines(as_paragraph(as_chunk("Super"), as_sup("script"),
    as_chunk(" and sub"), as_sub("script")))

then, I knit to PDF. The super- and subscripts are rendered with same font size as normal text. This is wrong: they should be smaller.

The culprit is (in the .tex file), a call to \fontsize{} after \textsuperscript{}, like: {\textsuperscript{\fontsize{11}{11}\selectfont{script}}}. This should be \fontsize{} first and \textsuperscript{} in second, like: {\fontsize{11}{11}\selectfont{\textsuperscript{script}}}. When I do this change manually in the .tex document generated by knitr, the super- and subscripts are correctly rendered in the PDF.

I use R 4.2.3 and {flextable} 0.9.2.

davidgohel commented 1 year ago

Thank you for that, your solution has been used!

github-actions[bot] commented 9 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.