[R] Sweave produces gibberish instead of apostrophe in pdf
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed Feb 27 22:15:09 CET 2008
On Wed, 2008-02-27 at 20:33 +0000, Prof Brian Ripley wrote:
> On Wed, 27 Feb 2008, Gavin Simpson wrote:
>
> > On Wed, 2008-02-27 at 11:35 +0100, Paul Hiemstra wrote:
<snip />
> > Stick this in your preamble and see if it works (you might need to
> > install a TexLive package from your usual Debian repository to get this
> > [LaTeX] package installed):
> >
> > \usepackage[utf8x]{inputenc}
> >
> > it did for me on my Fedora box when I first came across this issue.
>
> The standard 'spell' is \usepackage[utf8]{inputenc}: that is what R itself
> uses when making a package manual if the encoding is UTF-8. That should
> come with any reasonably recent LaTeX (dates in the LaTeX world are
> imaginary, but I think it is from the '2003' release).
Thank you for the correction/clarification Prof. Ripley.
If you'll permit some further 'guesswork' on my part, IIRC, I had a
problem \usepackage[utf8]{inputenc} on an early Fedora Core but
\usepackage[utf8x]{inputenc} worked and I am a creature of habit at
times. Hence \usepackage[utf8x]{inputenc} was in the Rnw file I looked
at to check I'd got this 'correct'.
Interestingly, the CTAN page for the unicode package:
http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/
contains the instruction
\usepackage[utf8x]{inputenc}
Having checked on my Fedora 8 machines, both incantations produce the
desired result.
All the best,
Gavin
>
> >
> > HTH
> >
> > G
> >
> >>
> >> This is a sample, the problem is in the lm output in the "Signif. codes"
> >> line:
> >>
> >> \documentclass[a4paper,10pt]{article}
> >> \title{Spam}
> >> \author{F. Bar}
> >>
> >> \begin{document}
> >> <<reg>>=
> >> n <- 50
> >> x <- seq(1, n)
> >> a.true <- 3
> >> b.true <- 1.5
> >> y.true <- a.true + b.true * x
> >> s.true <- 17.3
> >> y <- y.true + s.true * rnorm(n)
> >> out1 <- lm(y ~ x)
> >> summary(out1)
> >> @
> >> \end{document}
> >>
> >> And the resulting .tex file:
> >>
> >> \documentclass[a4paper,10pt]{article}
> >> \title{Spam}
> >> \author{F. Bar}
> >>
> >> \usepackage{Sweave}
> >> \begin{document}
> >> \begin{Schunk}
> >> \begin{Sinput}
> >> > n <- 50
> >> > x <- seq(1, n)
> >> > a.true <- 3
> >> > b.true <- 1.5
> >> > y.true <- a.true + b.true * x
> >> > s.true <- 17.3
> >> > y <- y.true + s.true * rnorm(n)
> >> > out1 <- lm(y ~ x)
> >> > summary(out1)
> >> \end{Sinput}
> >> \begin{Soutput}
> >> Call:
> >> lm(formula = y ~ x)
> >>
> >> Residuals:
> >> Min 1Q Median 3Q Max
> >> -31.9565 -9.4745 -0.1708 7.3759 44.6538
> >>
> >> Coefficients:
> >> Estimate Std. Error t value Pr(>|t|)
> >> (Intercept) -0.07386 4.64712 -0.016 0.987
> >> x 1.57405 0.15860 9.924 3.25e-13 ***
> >> ---
> >> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 .’ 0.1 ‘ ’ 1
> >>
> >> Residual standard error: 16.18 on 48 degrees of freedom
> >> Multiple R-Squared: 0.6723, Adjusted R-squared: 0.6655
> >> F-statistic: 98.49 on 1 and 48 DF, p-value: 3.245e-13
> >> \end{Soutput}
> >> \end{Schunk}
> >> \end{document}
> >>
> >> cheers and thanks for any help,
> >> Paul
> >>
> > --
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> > Dr. Gavin Simpson [t] +44 (0)20 7679 0522
> > ECRC, UCL Geography, [f] +44 (0)20 7679 0565
> > Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
> > Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
> > UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> >
> > ______________________________________________
> > R-help at r-project.org 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.
> >
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list