Skip to content

Sweave (R?) font encoding problems

3 messages · Friedrich Leisch, Luis Torgo, Brian Ripley

#
> Dear R list,
  > I'm having some problems with font encodings when using R+Sweave+Latex in my 
  > native language: Portuguese.

  > My environment:
  > Kubuntu 5.10 Linux
  > $> uname -a
  > Linux nassa 2.6.12-9-686 #1 Mon Oct 10 13:25:32 BST 2005 i686 GNU/Linux

  R> R.version
  >          _                
  > platform i486-pc-linux-gnu
  > arch     i486             
  > os       linux-gnu        
  > system   i486, linux-gnu  
  > status                    
  > major    2                
  > minor    1.1              
  > year     2005             
  > month    06               
  > day      20               
  > language R  
  R> Sys.getlocale()
  > [1] 
  > "LC_CTYPE=pt_PT.utf-8;LC_NUMERIC=C;LC_TIME=pt_PT.utf-8;LC_COLLATE=pt_PT.utf-8;LC_MONETARY=pt_PT.utf-8;LC_MESSAGES=pt_PT.utf-8;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C"
  R> localeToCharset()
  > [1] "ISO8859-1"


  > Here is a small example trying to replicate my problems:

  > File:exp.Rnw
  > ================================
  > \documentclass[10pt,twoside]{article}
  > \usepackage[dvips]{graphicx}
  > \usepackage[portuges]{babel}
  > \usepackage[latin1]{inputenc}
  > \usepackage[T1]{fontenc}

You use a UTF-8 locale but load latin1 input encoding in latex -> that
cannot work.

Try

\usepackage[utf8]{inputenc}

and no special fontenc setting -> works for me for Austrian German.

HTH,
2 days later
#
Dear R list,

I'm having some problems with font encodings when using R+Sweave+Latex in my 
native language: Portuguese.

My environment:
Kubuntu 5.10 Linux
$> uname -a
Linux nassa 2.6.12-9-686 #1 Mon Oct 10 13:25:32 BST 2005 i686 GNU/Linux

R> R.version
         _                
platform i486-pc-linux-gnu
arch     i486             
os       linux-gnu        
system   i486, linux-gnu  
status                    
major    2                
minor    1.1              
year     2005             
month    06               
day      20               
language R  
R> Sys.getlocale()
[1] 
"LC_CTYPE=pt_PT.utf-8;LC_NUMERIC=C;LC_TIME=pt_PT.utf-8;LC_COLLATE=pt_PT.utf-8;LC_MONETARY=pt_PT.utf-8;LC_MESSAGES=pt_PT.utf-8;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C"
R> localeToCharset()
[1] "ISO8859-1"


Here is a small example trying to replicate my problems:

File:exp.Rnw
================================
\documentclass[10pt,twoside]{article}
\usepackage[dvips]{graphicx}
\usepackage[portuges]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}

\section{Introdu????o}

Isto ?? uma experi??ncia.

\begin{figure}[b]
\centering
<<echo=false,fig=true,width=10,height=10>>=
barras(1)
@
\caption{Distribui????o dos valores percentuais.}
\label{fig:idade}
\end{figure}

\end{document}
=================================

The problem occurs when I Sweave this file using the command:
R> Sweave('exp.Rnw')

The generated exp.tex file gets these contents:
=================================
\documentclass[10pt,twoside]{article}
\usepackage[dvips]{graphicx}
\usepackage[portuges]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{/usr/lib/R/share/texmf/Sweave}
\begin{document}

\section{Introdu????????o}

Isto ???? uma experi????ncia.

\begin{figure}[b]
\centering
\includegraphics{exp-001}
\caption{Distribui????????o dos valores percentuais.}
\label{fig:idade}
\end{figure}

\end{document}
=================================

All Portuguese  characters were "spoiled".  So apparently the Sweave function 
is "translating" my original font encoding

I suspect that this is a problem related to the recent internationalization 
changes in R, as this same file/process was previously (around a year ago I 
think) working correctly for me.

I've read several documentation on these internationalization issues in R and 
browsed the mailing list. As a result, because initially I didn't have R 
working with the pt_PT.utf-8 locale, I've installed the PT language support 
package for my OS, expecting that this would solve the "problem".  Apparently 
I'm missing something else, so I wonder if someone could give me a hint on 
how to solve this.

Thanks,
Luis Torgo
#
You are using UTF-8 and declaring latin1.  It is your use of UTF-8
that will have changed, not R.
On Mon, 31 Oct 2005, Lu?s Torgo wrote: