Ampersand in graphics text?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Ampersand in graphics text?

vicnorton
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?

-
Vic



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Ampersand in graphics text?

Nir Krakauer-3
The & shows up for me (with Octave 4.0.3). ​Maybe you can try to add a backslash: \&

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Ampersand in graphics text?

vicnorton
> On Oct 20, 2016, at 6:45 AM, Vic Norton <[hidden email]> 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 <[hidden email]> 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.
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Ampersand in graphics text?

vicnorton

> On Oct 20, 2016, at 7:51 AM, Vic Norton <[hidden email]> wrote:
>
>> On Oct 20, 2016, at 6:45 AM, Vic Norton <[hidden email]> 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 <[hidden email]> 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.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Ampersand in graphics text?

bpabbott
Administrator
> On Oct 20, 2016, at 08:19, Vic Norton <[hidden email]> wrote:
>
>
>>> On Oct 20, 2016, at 7:51 AM, Vic Norton <[hidden email]> wrote:
>>>
>>> On Oct 20, 2016, at 6:45 AM, Vic Norton <[hidden email]> 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 <[hidden email]> 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
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Ampersand in graphics text?

vicnorton

> On Oct 20, 2016, at 9:52 AM, Ben Abbott <[hidden email]> wrote:
>
>
> On Oct 20, 2016, at 08:58, Vic Norton <[hidden email]> wrote:
>
>>> On Oct 20, 2016, at 8:26 AM, Ben Abbott <[hidden email]> wrote:
>>>
>>>> On Oct 20, 2016, at 08:19, Vic Norton <[hidden email]> wrote:
>>>>
>>>>
>>>>>> On Oct 20, 2016, at 7:51 AM, Vic Norton <[hidden email]> wrote:
>>>>>>
>>>>>> On Oct 20, 2016, at 6:45 AM, Vic Norton <[hidden email]> 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 <[hidden email]> 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


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Ampersand in graphics text?

Dmitri A. Sergatskov
In reply to this post by vicnorton
On Thu, Oct 20, 2016 at 5:45 AM, Vic Norton <[hidden email]> wrote:

  text(25, 18, "RWR & SCHH”, “fontsize”, 12, “fontweight”, “bold”);

​This string taken verbatim gives me a syntax error. The reason is that it uses
UTF-8 double quotation marks ( ​342 200 235 and 342 200 234) instead of ascii.

 cat tstr.txt
text(25, 18, "RWR & SCHH”, “fontsize”, 12, “fontweight”, “bold”);
od -c tstr.txt
0000000   t   e   x   t   (   2   5   ,       1   8   ,       "   R   W
0000020   R       &       S   C   H   H 342 200 235   ,     342 200 234
0000040   f   o   n   t   s   i   z   e 342 200 235   ,       1   2   ,
0000060     342 200 234   f   o   n   t   w   e   i   g   h   t 342 200
0000100 235   ,     342 200 234   b   o   l   d 342 200 235   )   ;  \n
0000120  \n
0000121

Replacing them with an ASCII (") or single quote (') , gives me the expected
result.

Dmitri.




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave