help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ampersand in graphics text?


From: Vic Norton
Subject: Re: Ampersand in graphics text?
Date: Thu, 20 Oct 2016 11:18:42 -0400

> On Oct 20, 2016, at 9:52 AM, Ben Abbott <address@hidden> wrote:
> 
> 
> On Oct 20, 2016, at 08:58, Vic Norton <address@hidden> wrote:
> 
>>> On Oct 20, 2016, at 8:26 AM, Ben Abbott <address@hidden> wrote:
>>> 
>>>> On Oct 20, 2016, at 08:19, Vic Norton <address@hidden> wrote:
>>>> 
>>>> 
>>>>>> On Oct 20, 2016, at 7:51 AM, Vic Norton <address@hidden> wrote:
>>>>>> 
>>>>>> On Oct 20, 2016, at 6:45 AM, Vic Norton <address@hidden> wrote:
>>>>>> 
>>>>>> I would like to write bold faced
>>>>>> RWR & SCHH
>>>>>> text in a figure, but it comes out as
>>>>>> RWRSCHH
>>>>>> with the instruction
>>>>>> text(25, 18, "RWR & SCHH”, “fontsize”, 12, “fontweight”, “bold”);
>>>>>> 
>>>>>> How can I write an ampersand in an Octave figure?
>>>>> 
>>>>> 
>>>>>> On Oct 20, 2016, at 7:07 AM, Nir Krakauer <address@hidden> wrote:
>>>>>> 
>>>>>> The & shows up for me (with Octave 4.0.3). ​Maybe you can try to add a 
>>>>>> backslash: \&
>>>>> 
>>>>> I was running Homebrew’s Octave 4.2.0-rc2 on a Mac. Now I have upgraded 
>>>>> to Octave 4.2.0-rc2_1. There is a slightly improvement in the upgrade:
>>>>> text(25, 18, "RWR & SCHH”, “fontsize”, 12, “fontweight”, “bold”);
>>>>> now shows up as
>>>>> RWR SCHH
>>>>> The " & “ is now interpreted as a single space. Backslash ampersand 
>>>>> produces the same result.
>>>> 
>>>> Problem solved. I am using "graphics_toolkit gnuplot”. The gnuplot advice
>>>> To use the ampersand (&) symbol in labels in the
>>>> postscript terminal you need to escape it twice: \\&
>>>> works for my version of octave. The line
>>>> text(25, 18, "RWR \\& SCHH”, “fontsize”, 12, “fontweight”, “bold”);
>>>> reads the way I want it to.
>>> 
>>> Hmmm, any chance the "interpreter" is set to "tex". If so, does "none" 
>>> resolve the behavior.
>>> 
>>> Ben
>> 
>> I don’t know what “interpreter” even means, Ben, so I don’t know how it is 
>> set.
>> 
>> However I did do a perl test that means something to me. The perl code
>>  my $str1 = "this is a double-backslash-ampersand: \\&";
>>  print $str1, "\n";
>>  my $str2 = "this is a backslash-ampersand: \&";
>>  print $str2, "\n";
>> produces
>>  this is a double-backslash-ampersand: \&
>>  this is a backslash-ampersand: &
>> Apparently to get a backslash-ampersand in a gnuplot command you have to 
>> start with a double-backslash-ampersand.
>> 
>> Vic
> 
> "Interpreter" is a property of text objects. Permitted values are "tex", 
> "latex", and "none".
> 
> Try ...
> 
> text(25, 18, 'RWR & SCHH', “fontsize”, 12, “fontweight”, “bold”, 
> "interpreter", "none");
> 
> Btw, the double backslash was needed because you were using double quotes.
> 
> Ben

Your “interpreter”, “none” suggestion prints the “&” but kills “bold”. No good.

Yes, I know that double-backslash was needed in perl because of the double 
quotes, but now I see that single quotes in octave eliminates the need for the 
double-backslash in front of the ampersand. The lines
  text(25, 18, "RWR \\& SCHH”, “fontsize”, 12, “fontweight”, “bold”);
and
  text(25, 18, 'RWR \& SCHH', “fontsize”, 12, “fontweight”, “bold”);
produce exactly the same results in my octave script.

Thanks for your input, Ben. Your use of single quotes was the idea I needed.

Vic




reply via email to

[Prev in Thread] Current Thread [Next in Thread]