Reputation: 545
This is my Rsweave reproducible example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{B5}{$\alpha$}
\DeclareUnicodeCharacter{B5}{$\tau$}
\DeclareUnicodeCharacter{B5}{$\sigma$}
\DeclareUnicodeCharacter{B5}{$\beta$}
\DeclareUnicodeCharacter{B5}{$\gamma$}
\DeclareUnicodeCharacter{B5}{$\mu$}
\DeclareUnicodeCharacter{B5}{$\Delta$}
\begin{document}
This is a table
<<summarymatrix,echo=FALSE>>=
library(knitr)
library(kableExtra)
alpha='\u03b1'; tau='\u03c4'; sigma='\u03c3'; beta='\U03B2'; gamma='\u03b3'; mu='\u03BC'; Delta='\u0394'
dt <- mtcars[1:5, 1:3]
colnames(dt)=c('Sample1','Sample2','Sample3')
rownames(dt)=c(paste0(mu),paste0(tau),paste0(sigma),paste0(beta),paste0(Delta))
dt
@
\end{document}
There are two problems:
First the Delta rowname is placed at the wrong positionin my output table. Should be in the 5-th row. And the first rowname should be mu.
Second, why I can not have repeated symbols as rows? For example, how can I put the second and the thirs rownames as Beta?
How can I solve this?
Upvotes: 0
Views: 187
Reputation: 44977
Your preamble is messed up. You need the inputenc package to get \DeclareUnicodeCharacter
, and you shouldn't be declaring B5 to be 7 different things.
Here is your document with those things fixed:
\documentclass{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{3B1}{$\alpha$}
\DeclareUnicodeCharacter{3C4}{$\tau$}
\DeclareUnicodeCharacter{3C3}{$\sigma$}
\DeclareUnicodeCharacter{3B2}{$\beta$}
\DeclareUnicodeCharacter{3B3}{$\gamma$}
\DeclareUnicodeCharacter{3BC}{$\mu$}
\DeclareUnicodeCharacter{394}{$\Delta$}
\begin{document}
\SweaveOpts{concordance=TRUE}
This is a table
<<summarymatrix,echo=FALSE>>=
library(knitr)
library(kableExtra)
alpha='\u03b1'; tau='\u03c4'; sigma='\u03c3'; beta='\U03B2'; gamma='\u03b3'; mu='\u03BC'; Delta='\u0394'
dt <- mtcars[1:5, 1:3]
colnames(dt)=c('Sample1','Sample2','Sample3')
rownames(dt)=c(paste0(mu),paste0(tau),paste0(sigma),paste0(beta),paste0(Delta))
dt
@
\end{document}
And here is the output:
That looks more or less fine to me (except for the alignment on the last line).
The reason you can't repeat rownames is that they are used to identify rows. If you had two rows named beta, what would dt["beta", ]
give? If you want repeated values, just add an extra column.
Upvotes: 1