Search code examples
rr-markdownpapaja

Automatic addition of slash prevents customization of the latex code with apa_table()


I'm rendering a table using apa_table() function of papaja package with success. When I used this function in the past (months ago) I was able to use latex special characters to custom the rendering.

However, it seems that the function now overwrite the initial character strings to render its exact content in latex format.

table <- data.frame(c(1,1),c(2,2))
colnames(table)<-c("$Var1$","Var2")

library(papaja)

cat(apa_table(table))

I got this output :

\begin{table}[tbp]

\begin{center}
\begin{threeparttable}

\begin{tabular}{ll}
\toprule
\$Var1\$ & \multicolumn{1}{c}{Var2}\\
\midrule
1.00 & 2.00\\
1.00 & 2.00\\
\bottomrule
\end{tabular}

\end{threeparttable}
\end{center}

\end{table}

I would like to get $Var1$ instead of \$Var1\$ for it will be rendered by markdown as Var1 instead of $Var1$

Is there a way to escape this and to make full use of the latex language with apa_table ?

Thank you very much =)


Solution

  • You just need to add escape = FALSE to the arguments to apa_table(table), i.e. use

    cat(apa_table(table, escape = FALSE))
    

    This means that no escapes will be added, so if you really want to include something like a dollar sign, you'll need to escape it yourself.

    By the way, the papaja package isn't on CRAN: this isn't a good sign about its reliability. Currently you need this to install it:

    remotes::install_github("crsh/papaja")