[R] How can I use a script "l" (LaTeX \ell) in mathematical annotation of plots?
Eik Vettorazzi
E.Vettorazzi at uke.de
Fri Oct 25 12:40:57 CEST 2013
Hi Byron,
You may have a look at the tikzDevice package, it solves the aesthetic
issue of font mixing.
You can sweave the following example
\documentclass{article}
\usepackage{tikz}
\begin{document}
\SweaveOpts{concordance=TRUE}
\begin{figure}[!h]
\centering
<<fig1, echo=FALSE, fig=FALSE, results=hide>>=
library(tikzDevice)
plotfile<-"simpleEx.tex"
tikz(plotfile, width =3.5 , height =3.5)
plot(1, ,type="n")
text(1,1,"$\\ell$ within ordinary \\LaTeX text")
dev.off()
@
\input{\Sexpr{plotfile}}
\caption{Test TeX annotation}
\end{figure}
\end{document}
cheers
Am 24.10.2013 18:44, schrieb Byron Dom:
>
>
>
> Thanks. That works for me too.
>
> I had worked that out based on Brian's response to my original post.
>
> If you read thru my response to him in detail, you'll see:
>
>> Here are a couple of examples using it that worked:
>> > plot(1:10,xlab="\u2113")
>> >
>> plot(1:10,xlab="\u2113(\u2113 + 1)")
>
>
>
>
> ________________________________
> From: Eik Vettorazzi <E.Vettorazzi at uke.de>
> To: Byron Dom <byron_dom at yahoo.com>; r help <r-help at r-project.org>
> Cc: "ripley at stats.ox.ac.uk" <ripley at stats.ox.ac.uk>
> Sent: Thursday, October 24, 2013 2:50 AM
> Subject: Re: [R] How can I use a script "l" (LaTeX \ell) in mathematical annotation of plots?
>
>
> this works for me:
>
> plot(1,main="\u2113")
>
> cheers
>
>
> Am 24.10.2013 01:39, schrieb Byron Dom:
>>
>>
>> Original post: On 13/10/2013 18:53, Byron Dom wrote:
>>
>>>> Due to convention a script "l" - $$\ell$$ (LaTeX \ell) is used to
>>>> represent a certain quantity in something I'm working on. I'm
>>>> unable to figure out how to use it in R. It's not included in the
>>>> list on ?plotmath.
>>>>
>>>> Can anyone tell me how to use it? Its unicode is U+2113. This
>>>> page has a list of various encodings of it:
>>>>
>> http://www.fileformat.info/info/unicode/char/2113/encoding.htm.
>>>> Is there a way to include it by using one of these encodings somehow?
>>
>> -------------------------------------------------
>>
>> On 13/10/2013 22:06 Prof Brian Ripley responded:
>>
>>> What do you want to do with it? plotmath is about plotting, but you
>>> have not otherwise mentioned that, let alone the device on which you
>>> want to plot.
>>>
>>> Read the help for plotmath: on some plot devices, just use "\u2113". It
>>> is not AFAICS in the Adobe symbol encoding.
>>>
>>> --
>>> 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
>>
>> -------------------------------------------------
>>
>> My response:
>>
>> Thanks I worked out how to do it based on your mention of "u2113".
>> See below.
>>
>> I'm sorry if my information wasn't complete enough. I assumed that
>> what I said, combined with the subject ("How can I use a script "l"
>> (LaTeX \ell) in
>> mathematical annotation of plots?") would have been
>> enough.
>>
>> I just wanted to be able to do this on the default device, which
>> displays plots within the R session window. I have a simple path
>> to go from there to .png form, which I include in LaTeX documents
>> and for other purposes. I am using R version 3.0.1 in Windows 7,
>> for which I believe the default plot device is "windows".
>>
>> An example of the kind of thing I wanted to do is to include
>> "ylab = expression(hat(gamma))" (which is equivalent to the LaTex
>> "\hat{\gamma}}") among the base-graphics plot() arguments. That
>> works. In LaTeX a script "l" is produced with "\ell", but
>> something like "ylab = expression(ell)" doesn't work in R.
>> I wanted to be able to do the equivalent of that, but to obtain "ℓ".
>>
>> Here are a couple of examples using it that worked:
>> > plot(1:10,xlab="\u2113")
>> >
>> plot(1:10,xlab="\u2113(\u2113 + 1)")
>> The only (slight) problem with this is the minor aesthetic issue
>>
>> that the "ℓ" one gets this way is in an obviously different font
>>
>> from what one gets using the LaTeX "\lambda" command/symbol.
>>
>> Strangely, earlier, when I tried
>> > plot(1:10,xlab=expression(symbol("\u2113")))
>> it did the same thing as
>> > plot(1:10,xlab=expression(lambda))
>> So I got a lower-case greek lambda - "λ", rather than "ℓ"
>> (script "l").
>>
>> When I used the unicode representation for lowercase
>> lambda - "λ" - as follows
>> >
>> plot(1:10,xlab=expression(symbol("\u03bb")))
>> I got this for an x-axis label: "<Y+03BB>". On the other hand,
>> the following did work
>> > plot(1:10,xlab="\u03bb"),
>> giving me an x-axis label of lambda - "λ".
>> [[alternative HTML version deleted]]
>>
>>
>>
>> ______________________________________________
>> 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.
>>
>
--
Eik Vettorazzi
Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf
Martinistr. 52
20246 Hamburg
T ++49/40/7410-58243
F ++49/40/7410-57790
--
Besuchen Sie uns auf: www.uke.de
_____________________________________________________________________
Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg
Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Rainer Schoppik
_____________________________________________________________________
SAVE PAPER - THINK BEFORE PRINTING
More information about the R-help
mailing list