I'm trying to create a table using kable()
with papaja()
that includes IPA transcriptions of words. I've had no issue rendering the symbols in the main text using TIPA.
My table is as follows (with some more complex symbols that I haven't included here):
IPA_table <- tribble(~Gloss, ~IPA, "baby", "beibi",
"ball", "bɑl", "cow", "kaʊ")
And I try to run it in the following chunk:
knitr::kable(IPA_table,
"latex", booktabs=T, longtable=T, align="c") %>%
kable_styling()
Which generates the following error:
! LaTeX Error: Unicode character ɪ (U+026A)
not set up for use with LaTeX.
Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex.
I am using xelatex
and my YAML front matter is as follows:
output:
papaja::apa6_pdf: default
latex_engine: xelatex
How can I generate a table within this script that will render the IPA fonts correctly?
Change a yaml a bit, like:
---
[...]
classoption : "man"
output:
papaja::apa6_pdf:
latex_engine: xelatex
---
The indentation in header is important. Then the log contains xelatex:
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex 2024.10.22) 22 OCT 2024 19:33
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**aaaaa.tex
(./aaaaa.tex
LaTeX2e <2024-06-01> patch level 2
L3 programming layer <2024-09-10>
(/usr/local/texlive/2024/texmf-dist/tex/latex/apa6/apa6.cls
Document Class: apa6 2023/08/07 v2.35 APA formatting (6th edition)
And pdf file is created as well.
Edit:
The missing characters in pdf are caused by lack of proper font definition either in {papaja}
The solution can be to add required package/font in yaml (header-includes:
part):
[...]
output:
papaja::apa6_pdf:
latex_engine: xelatex
header-includes:
- \usepackage{fontspec}
- \setmainfont{FreeSerif}
# - \setsansfont{FreeSans}
# - \setmonofont{FreeMono}
---
It renders the pdf a bit better:
But to be honest, I have two doubts: 1/ redefining main fonts will change the look and feel of the article, so you would better check with journal redactor which font(s) shall be used in this case; 2/ don't know which font you should use to cover the all required letters/glyphs.