MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: StyleForm

  • To: mathgroup at
  • Subject: [mg14258] Re: StyleForm
  • From: "Allan Hayes" <hay at>
  • Date: Mon, 12 Oct 1998 13:51:40 -0400
  • References: <6vf692$>
  • Sender: owner-wri-mathgroup at

David Epstein wrote in message <6vf692$dja at>...
>When working with the kernel (no front-end), I give the following
>text = StyleForm[Text["a",{2,4}]]
>I get a reasonable result.
>When I give the subsequent command
>I get an error message
>Graphics::gprim: Unknown Graphics primitive Text[c, {2, 4}] encountered.
>I thought Text[c,{2,4}] WAS a graphics primitive---very strange.
>Can someone explain to me how I should be handling the second case. The
>reason I want to use StyleForm is in order to increase the font size of
>the text in my picture.
>David Epstein


In the following
 (A) contains  suggestions for doing what you want;
 (B) is an explanation of what you  found.


Alllan Hayes
Mathematica Training and Consulting
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

(A) suggestions for doing what you want

I shall deal only with text size, but other options and lists of options
can be used similarly.
The following techniques are of increasing generality.  Local rules
overide more general ones. However Show , the last technique, has its
own rules.

1) take StyleForm inside and wrap it round "a"

text = Text[StyleForm["a", FontSize->24] ,{3,4}]; Show[Graphics[text]];

2) option in Text

Show[Graphics[Text["a",{3,4}, TextStyle->{FontSize->24}]] ];

3) option in Plot
Plot[x,{x,0,1}, TextStyle-> {FontSize->24}];

4) change default Plot option

SetOptions[Plot,TextStyle:>{FontSize->36}]; Plot[x,{x,0,1}]

5) option in a Graphics object



6) change default Graphics option


Show[Graphics[ {Text["a",{3,4}]}]];

7) Change default TextStyle option value (affects all graphics)

$TextStyle = {FontSize -> 24};


8) Option in Show (supercedes options in Graphics, Graphics3D...but not
options with StyleForm and Text)


  {Text["a",{2,4}], text}, 
 TextStyle -> {FontSize -> 10}

(B) an explanation of what you  found.

Your results arise from the way that $OutputForms evaluate. These forms
are used to alter the way in which expressions are displayed.  In
principal they should not affect value and output but in fact they can
do so. A complet list of them is.


Let's look at MatrixForm, since its effects are evident in ASCII  (to 
help with this I set the Default Output Format Type to OutputForm (see
the Cell menu)) mt = {{1,2},{3,4}};
1   2

3   4

This displays as a 2D matrix structure. But the output is actually the
same as for mt 


MatrixForm has been stripped off at the final stage, when the value of
Output[..] was assigned(the //MatrixForm in the output label indicates

Check  the full form


**** However the stripping off occurs only when MatrixForm is the head
of the expression entered. 

A[ MatrixForm[mt]];

A[1   2]

  3   4

Check the full form


This retention of  interior output formats often gives a surprise:
compare the following two inputs

3+ MatrixForm[mt] (*the retained MatrixForm prevents 3 being taken
inside the matrix*)

3 + 1   2

    3   4

MatrixForm[3+ mt]

4   5

6   7

In  your example

text = StyleForm[Text["a",{3,4}]];
assigns StyleForm[Text["a",{3,4}]] to text in the process of evaluation,
before any ouput is generated; so StyleForm has not been stripped.
Check this:


text = StyleForm[Text["a", {3, 4}]]

But the output from evaluating text has StyleFrom stripped off



So with Show[Graphics[%]] you are getting


Which is fine, since Text is a good Graphics primitive.

However, with Show[Graphics[text]] the evaluation steps are

Show[Graphics[text]] ;

And  StyleForm[Text["a",{3,4}]] is not a graphics primitive. So you
would expect a message to tell you this. But instead you get one
telling  you  that Text[a, {3, 4}] is not a Graphics primitive - which
is false. Thus:


   Unknown Graphics primitive Text[a, {3, 4}]

The reason for this that the displayed form of
StyleForm[Text["a",{3,4}]] seen in the message is Text["a",{3,4}]

We can hint at this with


which displays Text[...] in 24 point font.

  • Prev by Date: RE: 3-D to 2-D slice revisited
  • Next by Date: Asymptotic expansions
  • Previous by thread: Re: Re: Images in Mathematica
  • Next by thread: RE: StyleForm