[R] backslash in xtable (generate latex code from R)

John m|@ojpm @end|ng |rom gm@||@com
Fri Nov 6 13:39:31 CET 2020


I'd like to have $\alpha_1$ in my table, and the column name is $\beta_0$
####
library(xtable)
mytable <- data.frame(beta_0 = c("aa","bb","cc$\\alpha_1$"))
colnames(mytable) <- "$\\beta_0$"
print(xtable(mytable), include.rownames = F, sanitize.colnames.function =
identity)
####

No problem with \beta_0, but a problem with \alpha_1:

\begin{table}[ht]
\centering
\begin{tabular}{l}
  \hline
$\beta_0$ \\
  \hline
aa \\
  bb \\
  cc\$$\backslash$alpha\_1\$ \\
   \hline
\end{tabular}
\end{table}

How may I fix the $\alpha_1$? Thanks!

	[[alternative HTML version deleted]]



More information about the R-help mailing list