[R] Greek symbols in xtable rows

Andris Jankevics andza at osi.lv
Tue Apr 17 08:48:22 CEST 2007


Thank You for answer. I Tried code that You provided in reply to my question 
on both PC's with Linux and Widows OS.

On linux box output is:

> xtable(diag(c("$\\sigma_1^2$","$\\sigma_2^2$")))
% latex table generated in R 2.4.0 by xtable 1.4-3 package
% Tue Apr 17 09:18:31 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{rll}
  \hline
 & 1 & 2 \\
  \hline
1 & \$$\backslash$sigma\_1\verb|^|2\$ & 0 \\
  2 & 0 & \$$\backslash$sigma\_2\verb|^|2\$ \\
   \hline
\end{tabular}
\end{center}
\end{table}

System information:

> sessionInfo ()
R version 2.4.0 (2006-10-03)
i686-redhat-linux-gnu

locale:
LC_CTYPE=lv_LV.UTF-8;LC_NUMERIC=C;LC_TIME=lv_LV.UTF-8;LC_COLLATE=lv_LV.UTF-8;LC_MONETARY=lv_LV.UTF-8;LC_MESSAGES=lv_LV.UTF-8;LC_PAPER=lv_LV.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=lv_LV.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "tcltk"     "methods"   "stats"     "graphics"  "grDevices" "utils"
[7] "datasets"  "base"

other attached packages:
 xtable     pls ellipse
"1.4-3" "1.2-1" "0.3-2"

> version
platform       i686-redhat-linux-gnu
arch           i686
os             linux-gnu
system         i686, linux-gnu
status
major          2
minor          4.0
year           2006
month          10
day            03
svn rev        39566
language       R
version.string R version 2.4.0 (2006-10-03)


And there is an output form my windows PC:

> mat <- diag (c("$\\sigma_1^2","$\\sigma_2^2$"))
> xtable (mat)

% latex table generated in R 2.4.1 by xtable 1.4-3 package
% Tue Apr 17 09:39:09 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{rll}
  \hline
 & 1 & 2 \\
  \hline
1 & \$$\backslash$sigma\_1\verb|^|2 & 0 \\
  2 & 0 & \$$\backslash$sigma\_2\verb|^|2\$ \\
   \hline
\end{tabular}
\end{center}
\end{table}

> sessionInfo ()
R version 2.4.1 (2006-12-18) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"   
"base"     

other attached packages:
 xtable 
"1.4-3" 
> version
               _                           
platform       i386-pc-mingw32             
arch           i386                        
os             mingw32                     
system         i386, mingw32               
status                                     
major          2                           
minor          4.1                         
year           2006                        
month          12                          
day            18                          
svn rev        40228                       
language       R                           
version.string R version 2.4.1 (2006-12-18)


Thank You,

Andris Jankevics


On Pirmdiena, 16. Aprīlis 2007 22:38, Charles C. Berry wrote:
> On Mon, 16 Apr 2007, Andris Jankevics wrote:
> > Dear R-helpers,
> >
> > I am using xtable package to prepare a Latex code of some R tables.
> > Is this possible to have a greek symbols in xtable cells?
> >
> > How can I get for example a string of : $\Delta$
> >
> >> "$\Delta$"
> >
> > [1] "$Delta$"
> >
> > And string: > "$\\Delta$"
> > 		[1] "$\\Delta$"
> >
> > Gives a latex aoutput like: \$$\backslash$Delta\$
>
> The posting guide says
>
>  	Sometimes it helps to provide a small example that someone can
>  	actually run.
>
> which you did not do.
>
> This makes it hard for us to pinpoint the error.
>
> For me, this works
>
> > mat <- diag(c("$\\sigma_1^2$","$\\sigma_2^2$"))
> > xtable(mat)
>
> % latex table generated in R 2.4.1 by xtable 1.4-2 package
> % Mon Apr 16 12:27:54 2007
> \begin{table}[ht]
> \begin{center}
> \begin{tabular}{rll}
>    \hline
>   & 1 & 2 \\
>    \hline
> 1 & $\sigma_1^2$ & 0 \\
>    2 & 0 & $\sigma_2^2$ \\
>     \hline
> \end{tabular}
> \end{center}
> \end{table}
>
>
>
> and placing the text output in between
>
>  	\documentclass{article}
>
>  	\begin{document}
>
> and
>
>  	\end{document}
>
> saving the file and running latex (or pdflatex) produces nicely set
> output with the Greek letter 'sigma' properly rendered.
>
> > Thank You in advance
> >
> > Andris Jankevics
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html and provide commented,
> > minimal, self-contained, reproducible code.
>
> Charles C. Berry                        (858) 534-2098
>                                           Dept of Family/Preventive
> Medicine E mailto:cberry at tajo.ucsd.edu	         UC San Diego
> http://biostat.ucsd.edu/~cberry/         La Jolla, San Diego 92093-0901



More information about the R-help mailing list