MathGroup Archive 1999

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

Search the Archive

Re: cell question

  • To: mathgroup at
  • Subject: [mg19458] Re: cell question
  • From: paulh at (P.J. Hinton)
  • Date: Wed, 25 Aug 1999 01:25:23 -0400
  • Organization: "Wolfram Research, Inc."
  • References: <7ptav3$>
  • Sender: owner-wri-mathgroup at

In article <7ptav3$lja at>, psalzman at writes:

>when i try to select a cell (say to cut or copy), i position the cursor on
>one of the brakets to the right, but i can't seem to select a single cell;
>a whole bunch of them get selected at the same time, for instance
>epsilon = 1                        ]
>blah blah blah                     ]
>if i try to click on the upper cell, both get selected.  this is contrary
>to what i'm used to with Mathematica for windows.
>is there a way select one cell only?

You were probably running into this problem at the same time as you were
with the hand cursor problem.  What you are observing is the global
selection mechanism that selects all cells of a given style when you
select one cell of that style.  It is activated when the Mod2 key is
depressed.  Under XFree86, the Mod2 key is often mapped to the NumLock
key, so many users stumble onto this feature by surprise.

>also, in the preference browser, what is the meaning of a little black dot
>next to the option?

The dot means simply that the value of that option is set explicitly
at the scope that is displayed on the drop-down listbox at the top
of the dialog window.

Preferences for the front end, cell styles, notebooks, cells, and
local selections are all expressed as optional arguments to Mathematica

scope                        corresponding expression
global                       SetOptions[$FrontEnd, <options>]
style sheet                  Cell[StyleData["stylename"], <options>]
notebook                     Notebook[{<sequence of cells>}, <options>]
cell                         Cell[<contents>, <options>]
local selection              StyleBox[<contents>, <options>]

Any option that does not appear as an explicit rule in a given expression
inherits the value of the option from the next higer-up category.  When 
you display options in the Option Inspector by category, the values you
see for the options are displayed for one of the following scopes:


As mentioned above, the scope is specified in a drop-down list box at
the top of the Option Inspector dialog window.

Here is a little exercise in playing with the Option Inspector.  
Suppose we have the following simple notebook expression.

    Cell["inherited option", "Text"],
    Cell["explicit option",  "Text", 
      FontFamily -> "Helvetica",
      FontColor -> RGBColor[0,0,1]
  FontFamily -> "Courier"

Paste this expression into a notebook and click on "Yes" when
a dialog box asks you whether the expression should be interpreted.

Note that the first Text style cell is set in black-colored Courier,
and that the second cell is set in blue Helvetica.

Select the bracket of the first cell, and then click on Format -> 
Option Inspector.

Make sure that the scope indicator is set to "selection" and 
enter the following text in the lookup line.


You will notice that the inspector expands out Formatting Options
and Font options to expose the FontFamily option entry.  Note
that it is set as 

	FontFamily -> "Courier"

however no bullet appears next to the option.  That's because
the option value is _inherited_ from the option in the parent notebook

Set the scope indicator to "notebook."  The option value does not 
change, but now you have a bullet next to FontFamily.  This means 
that the option is set explicitly at the notebook level because this
option appears explicity in the Notebook expression.

If you click on the bullet, the option will be removed at the notebook
level.  The appearance of the first cell will now inherit from the
global preference set for FontFamily that appears in your front end's
init.m file.  If no explicit setting is there, the front end will supply
a hard-coded value of Times.  This is why the value changed to

	FontFamily -> "Times"

when you clicked on the bullet.  You could evaluate the expression

	SetOptions[$FrontEnd, FontFamily -> "New Century Schoolbook"]

(or some other font on your system).  You will now see that the first
cell inherits the value of the option set at the global scope.

Now click on the second cell bracket and set the scope back to 
"selection".  Note that the option setting changes 

	FontFamily -> "Helvetica"

and the bullet is back.  This reflects that the cell expression
contains an explicit setting for FontFamily.  

Now drag select the word "explicit" in the cell's contents.  
Locate the FontColor option a few lines down in the Option Inspector.
Change its value to read:

	FontColor -> RGBColor[1,0,0]

and deselect the text.  You now see that the word "explicit" is red, 
but the word "option" is still blue.  If you were to unformat the cell
expression, you would find it looks like this.

    FontColor->RGBColor[1, 0, 0]],
  " option"
}], "Text",
  FontColor->RGBColor[0, 0, 1]]

This shows that the "selection" scope will posit its options in the
parent cell expression if you've selected the cell's bracket, but
if you've selected a portion of the the contents, the options appear
in a StyleBox[].

Now for some real fun.  Click on the following menu command sequence

	Format -> Edit Style Sheet...

On the resulting dialog, click on the button which has a label with
the word "Import".

On the resulting style sheet notebook, double-click open the cell 
group with section heading Styles for Body Text.  Locate the cell 
that is labeled 

	Prototype for style: "Text"

Click on its cell bracket and then summon the Option Inspector 
dialog.  Change the drop down list box from "by category" to 
"as text".  You now see all of the options that are set explicitly
for this cell style.  After the final option listed, insert a 
comma and then type in the following text

	FontFamily -> "Helvetica"

and then hit the "Apply" button.  Now the first cell will use 
Helvetica, not because the option has been added to the cell,
but because the prototype for that cell has the option 
specified explicitly.  Because the style sheet is a finer scope
than the global level, it overrides our global setting of 
"New Century Schoolbook".

There is one option inheritance mechanism that acts as an
override at the style sheet level.  Beware of cells style 
definitions that have this option set:


If this is set, whatever settings that apply at the cell's
style or broader scopes will be overriddedn by the format
type which is referenced by this option.  Rather than having
an explicit format type name like StandardForm, indirect
references are used like DefaultInputFormatType.  This value
is determined by the appropriate suboption to the setting 
CommonDefaultFormatTypes.  In the case of DefaultInputFormatType, 
the option resolves to StandardForm.

Options[$FrontEnd, CommonDefaultFormatTypes]

{CommonDefaultFormatTypes -> {"Text" -> TextForm, "Input" -> StandardForm, 
      "Output" -> StandardForm, "TextInline" -> TraditionalForm, 
      "InputInline" -> StandardForm, "OutputInline" -> StandardForm}}

Many beginning users encounter initial frustrations because they
are unable to change the font family used in Input cells.  They
keep trying to modify option values in the Input cell prototype.
The problem is that the StandardForm format type has the option
FontFamily -> "Courier" set.  To escape this problem, the FontFamily
setting for the StandardForm prototype needs to be modified.

Hopefully, this has illuminated some of the ways you can use to
Option Inspector to manipulate settings at various levels.  This
is probably not the way that you would manipulate options in
practice, but it does shed a lot of light on how the inhertance
mechanism plays itself out.

In general, good document design practices should be followed
in setting options.  Rather than applying a font setting at the
cell level for every cell of a given style, it is better to have
the option value inherited from the style sheet or higher scope.

P.J. Hinton
Mathematica Programming Group           paulh at
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.

  • Prev by Date: Re: Up-Values with GroebnerBasis
  • Next by Date: Re: AxesLabel with greek letter
  • Previous by thread: cell question
  • Next by thread: Re: Evaluation with UpValues