[R] there are fontencoding problem in Sweave

Duncan Murdoch murdoch at stats.uwo.ca
Thu Apr 16 17:56:27 CEST 2009


On 4/16/2009 10:29 AM, Угодай n/a wrote:
> I want  write article by russian language using Sweave. For cyrillic text
> LaTeX use T2A encoding
> 
> \usepackage[T2A]{fontenc}
> 
> But in Sweave.sty we find:
> 
> \RequirePackage[T1]{fontenc}
> 
> It is source of critical problem.
> 
> For example Rnw file
> 
> $ cat estimation.Rnw
> 
> \documentclass[A4paper]{article}
> 
> \usepackage[T2A]{fontenc}
> \usepackage[utf8]{inputenc}
> \usepackage[russian,english]{babel}
> 
> \begin{document}
> 
> Для начала попытаемся апроксимировать результаты нормативной зависимости.
> 
> $$
> \Delta T_k = 800(C_p + 0.07C_{Cu})F^{1/3}
> $$
> 
> \end{document}
> 
> will be translate to this estimate.tex
> 
> $ R CMD Sweave estimation.Rnw
> $ cat estimate.tex
> \documentclass[A4paper]{article}
> 
> \usepackage[T2A]{fontenc}
> \usepackage[utf8]{inputenc}
> \usepackage[russian,english]{babel}
> 
> \usepackage{Sweave}
> \begin{document}
> 
> Для начала попытаемся апроксимировать результаты нормативной зависимости.
> 
> $$
> \Delta T_k = 800(C_p + 0.07C_{Cu})F^{1/3}
> $$
> 
> \end{document}
> 
> and if I try to compile to pdf, LaTeX don't do it by reason
> 
> $ pdflatex estimation.tex
> This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
>  %&-line parsing enabled.
> entering extended mode
> (./estimation.tex
> LaTeX2e <2005/12/01>
> Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang,
> noh
> yphenation, croatian, ukrainian, russian, bulgarian, czech, slovak, danish,
> dut
> ch, finnish, basque, french, german, ngerman, ibycus, greek, monogreek,
> ancient
> greek, hungarian, italian, latin, mongolian, norsk, icelandic, interlingua,
> tur
> kish, coptic, romanian, welsh, serbian, slovenian, estonian, esperanto,
> upperso
> rbian, indonesian, polish, portuguese, spanish, catalan, galician, swedish,
> loa
> ded.
> (/usr/share/texmf-texlive/tex/latex/base/article.cls
> Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
> (/usr/share/texmf-texlive/tex/latex/base/size10.clo))
> (/usr/share/texmf-texlive/tex/latex/base/fontenc.sty
> (/usr/share/texmf-texlive/tex/latex/cyrillic/t2aenc.def)
> (/usr/share/texmf-texlive/tex/latex/cyrillic/t2acmr.fd))
> (/usr/share/texmf-texlive/tex/latex/base/inputenc.sty
> (/usr/share/texmf-texlive/tex/latex/base/utf8.def
> (/usr/share/texmf-texlive/tex/latex/base/t1enc.dfu)
> (/usr/share/texmf-texlive/tex/latex/base/ot1enc.dfu)
> (/usr/share/texmf-texlive/tex/latex/base/omsenc.dfu)
> (/usr/share/texmf-texlive/tex/latex/base/t2aenc.dfu)))
> (/usr/share/texmf-texlive/tex/generic/babel/babel.sty
> (/usr/share/texmf-texlive/tex/generic/babel/russianb.ldf
> (/usr/share/texmf-texlive/tex/generic/babel/babel.def))
> (/usr/share/texmf-texlive/tex/generic/babel/english.ldf))
> (/usr/share/texmf/tex/latex/R/Sweave.sty
> (/usr/share/texmf-texlive/tex/latex/base/ifthen.sty)
> (/usr/share/texmf-texlive/tex/latex/graphics/graphicx.sty
> (/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty)
> (/usr/share/texmf-texlive/tex/latex/graphics/graphics.sty
> (/usr/share/texmf-texlive/tex/latex/graphics/trig.sty)
> (/etc/texmf/tex/latex/config/graphics.cfg)
> (/usr/share/texmf-texlive/tex/latex/pdftex-def/pdftex.def)))
> (/usr/share/texmf-texlive/tex/latex/fancyvrb/fancyvrb.sty
> Style option: `fancyvrb' v2.6, with DG/SPQR fixes <1998/07/17> (tvz)
> No file fancyvrb.cfg.
> ) (/usr/share/texmf/tex/latex/R/upquote.sty
> (/usr/share/texmf-texlive/tex/latex/base/textcomp.sty
> (/usr/share/texmf-texlive/tex/latex/base/ts1enc.def
> (/usr/share/texmf-texlive/tex/latex/base/ts1enc.dfu))))
> (/usr/share/texmf-texlive/tex/latex/base/fontenc.sty
> (/usr/share/texmf-texlive/tex/latex/cyrillic/t2aenc.def))
> (/usr/share/texmf-texlive/tex/latex/ae/ae.sty
> (/usr/share/texmf-texlive/tex/latex/base/fontenc.sty
> (/usr/share/texmf-texlive/tex/latex/base/t1enc.def)
> (/usr/share/texmf-texlive/tex/latex/ae/t1aer.fd))))
> 
> LaTeX Warning: Unused global option(s):
>     [A4paper].
> 
> (./estimation.aux) (/usr/share/texmf-texlive/tex/latex/base/ts1cmr.fd)
> 
> ! LaTeX Error: Command \CYRD unavailable in encoding T1.
> 
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...
> 
> l.10 Д
>        ля начала попытаемся апроксимировать...
> 
> ?
> 
> ! LaTeX Error: Command \CYRD unavailable in encoding T1. --- this is the
> error message
> 
> I know how to win this situation. For this I must edit Sweave.sty, change T1
> to T2A, and move usepakage{Sweave} operator in estimate.tex file to top of
> declaration usepakage block, thus
> 
> \usepackage{Sweave}
> \usepackage[T2A]{fontenc}
> \usepackage[utf8]{inputenc}
> \usepackage[russian,english]{babel}
> 
> But this method similar to the rape. Which is the correct, regular method of
> declaration of necessary fontecoding in Sweave?

R is open source.  Changing the source to handle an unforeseen situation 
is normal and expected, it's not an assault.

I don't know LaTeX well enough to know if there's a way to override the 
Sweave.sty fontenc declaration.  (I do know there are well documented 
ways to change the formatting of code chunks, for example.)  You could 
ask on a LaTeX list if you want, but I'd suggest the solution you 
already have is easier.

Duncan Murdoch




More information about the R-help mailing list