[R] Symbols in pdf output of flextable() via R markdown
Paul Sherliker
p@u|@@her||ker @end|ng |rom ndph@ox@@c@uk
Wed Oct 7 12:26:15 CEST 2026
>________________________________________
>From: Duncan Murdoch <murdoch.duncan using gmail.com>
>Sent: Tuesday, October 06, 2026 5:20 PM
>To: Paul Sherliker <paul.sherliker using ndph.ox.ac.uk>; r-help using r-project.org <r-help using r-project.org>
>Subject: Re: [R] Symbols in pdf output of flextable() via R markdown
>
>
>On 2026-10-06 7:57 a.m., Paul Sherliker via R-help wrote:
>> I am trying to produce some tables in flextable(), sending the results to .pdf. The target format is not negotiable, >and because I must produce them at volume, I can't have any human intervention after the code is run; flextable() >might be negotiable, but I would be loath to try to learn something else. (both R markdown and flextable() are new >to me)
>>
>> My problem is a difficulty with a single character that my tables must contain - a chi in the footer. (Again, not >negotiable - my bosses are not going to be persuadable.)
>>
>> I have tinytex installed to allow the use of .pdf.
>>
>> Sample R markdown code showing the problem (for me!) follows (the body of the table is irrelevant):
>>
>> ________________________________________
>> title: "Example"
>> author: "Paul Sherliker"
>> date: "2026-10-06"
>> output: pdf_document
>> ________________________________________
>> ```{r setup, include=FALSE}
>> knitr::opts_chunk$set(echo = TRUE)
>> ```
>> R Markdown
>> ```{r cars}
>> require(flextable)
>> ft <- flextable(head(cars))
>> ft <- add_footer_lines(ft, value=as_paragraph(
>> as_chunk(paste0("* The % change in log RR is displayed only if the log ",
>> "RR to be changed differs by >3.3 SE from zero (")),
>> as_chunk("c", props = fp_text_default(font.family = "Symbol")),
>> as_sup("2"),
>> as_chunk(" of 10.89; p<0.001).")))
>> ft
>> ```
>>
>> What I get does not have the chi character that I would expect, but instead a 'c'. Is there some way to get the chi >without adding too much extra complexity, please?
>>
>> Thank you for your time and, I hope, for your help.
>On my Mac, it works to insert the Unicode symbol 1D712 which is
>"MATHEMATICAL ITALIC SMALL CHI". You do that by replacing the
>as_chunk("c", ...) with as_chunk("\U1D712").
>Duncan Murdoch
Thank you for the suggestion!
Sadly, I get an error:
"! LaTeX Error: Unicode character 𝜒 (U+1D712)
not set up for use with LaTeX.
Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex. See https://bookdown.org/yihui/rmarkdown-cookbook/latex-unicode.html
Error: LaTeX failed to compile r-markdown-first-attempt.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See r-markdown-first-attempt.log for more info.
Execution halted"
The referenced web page is not obviously helpful; trying to switch to xelatex for the latex engine:
(by:
output: pdf_document:
latex_engine: xelatex
)
gets me only
"Error in yaml::yaml.load(..., eval.expr = TRUE) :
Scanner error: mapping values are not allowed in this context at line 1, column 22
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load -> <Anonymous>
Execution halted"
More information about the R-help
mailing list