Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need good reference for writing Stylesheets

0 views
Skip to first unread message

TerryH

unread,
Aug 18, 2006, 4:03:12 AM8/18/06
to

Hi All,
I was wondering if there is a good reference for writing/constructing
a new style sheet. Thanks to all who reply.
.....Terry

David Park

unread,
Aug 19, 2006, 12:56:06 AM8/19/06
to
Terry,

The book "The Beginner's Guide To Mathematica" by Jerry Glynn & Theodore
Gray has a short chapter 'What exactly are styles, style sheets, and style
environments?'.

Basically, bring up a new blank notebook. Use Menu -> Format -> Edit Style
Sheet and then 'Edit Shared Style Sheet'. But then immediately use SaveAs to
save under your new style sheet name and not modify the existing Default
style. I think it should be saved in your private
Mathematica\SystemFiles\FrontEnd\StyleSheets folder so Mathematica will find
it and list it in the StyleSheets menu.

Then if you examine the style sheet it will almost be self-explanatory. You
can select the various cell types and either bring up the underlying
expression (Shift-Ctrl-E) and edit them, or use the Format Menu.

If you want to add new cell styles you can copy and paste one of the
existing ones and then change its name and edit it.

The one tricky thing is if you want to add new cell types. You should add
these later in the style sheet, in what might not seem the logical order, so
that they won't change the standard order of the 'hot keys'. Mathematica
automatically adds hot keys (Alt-1, Alt-2, etc.) in the order it encounters
the cells. It is very bad form to change these because if a user is used to
using them he doesn't want to switch to an entirely new set with a new style
sheet.

I put up a style sheet at my web site that adds a number of new cell types,
changes the style of cells, and adds GroupOpenCloseIcons to the various
section headings. It is more to my taste of a useful style sheet. You could
look at that as an example.

David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/

Helen Read

unread,
Aug 21, 2006, 3:51:18 AM8/21/06
to
David Park wrote:
>
> The one tricky thing is if you want to add new cell types. You should add
> these later in the style sheet, in what might not seem the logical order, so
> that they won't change the standard order of the 'hot keys'. Mathematica
> automatically adds hot keys (Alt-1, Alt-2, etc.) in the order it encounters
> the cells. It is very bad form to change these because if a user is used to
> using them he doesn't want to switch to an entirely new set with a new style
> sheet.

Perhaps, but I had to put one of my own styles (GraderText) near the top
of the custom stylesheet that I embed into assignments for my students,
because I couldn't see any other way to give it a hot-key. My students
download these notebooks from the web, do the exercises, and send them
to me via e-mail. I grade them on my computer, then e-mail them back;
it's all completely paperless. It would be extremely tedious to grade
the assignments without a hot-key for GraderText. I gave it Alt-8, which
would be SmallText -- a style I rarely if ever use -- in the default
stylesheet. Hopefully nobody will arrest me for this :-)

--
Helen Read
University of Vermont

AES

unread,
Aug 22, 2006, 5:30:28 AM8/22/06
to
Where do the standard style sheets in the Format >> Style Sheet
hierarchical menu hide?


How can one add a customized style sheet to that menu? (other than
modifying one of the existing ones)


If one has edited a private style sheet for (and within) a Mathematica
notebook, how can one pull that style sheet out of that notebook, assign
it a name, and put it somewhere? (as well as into the Style Sheet menu)


Some of the standard named style sheets in the Format >> Style Sheet
menu seem to have styles associated with the different command keys that
are different not just visually or "format-wise" but functionally. One
time when I stepped through these named style sheets with one of my
notebooks open, just to see what different styles looked like, it seemed
to leave some of the cells in my notebook seriously screwed up (from the
nature of the damage, my guess is one of the styles had made some of the
non-Input cells in my notebook into evaluatable cells, and they didn't
like it). Should there be a warning about this?


More generally, are these standard styles illustrated and discussed in
any documentation anywhere?


Several other applications that I use also have named styles (EndNote 8,
for example, has 1,189 (!!) named styles for formatting journal
citations, which is insane, not to say criminal!). Several of these
have at the bottom of their "Styles" menu a set of more or less blank
style templates named "Custom 1", . . . . "Custom 6" to use for making
your own styles. Wolfram?

David Park

unread,
Aug 22, 2006, 5:39:33 AM8/22/06
to
Dear Helen,

You didn't put the new cell type "near the top" of the style sheet but just
far enough down so that it would catch a hot key and NOT disturb most of the
standard hot keys. So you don't have to worry about the Mathematica Militia
appearing on your doorstep! (Just kidding.)

You could have gone one position lower and only bumped the hot key for
InputCells since they don't really need a hot key. What caused me to include
the comment in my posting is the MiER style sheet for submission of
articles. It completely rearranges most of the hot keys, and specifically
the hot key for Text cells had been changed. Since that is the hot key I use
most often I found it quite annoying.

And I am quite impressed with the work you are doing with Mathematica in
education.

albert

unread,
Aug 23, 2006, 7:24:49 AM8/23/06
to
AES wrote:

> Where do the standard style sheets in the Format >> Style Sheet
> hierarchical menu hide?

I think this is where the standard stylesheets "hide":

ToFileName[{$TopDirectory,"SystemFiles","FrontEnd","StyleSheets"}]

> How can one add a customized style sheet to that menu? (other than
> modifying one of the existing ones)

You could copy your stylesheet into the above directory. Anyway I think a
better choice would be:

ToFileName[{$PreferencesDirectory,"SystemFiles","FrontEnd","StyleSheets"}]

I think that for version >= 5.0 both $TopDirectory and $PreferencesDirectory
are deprecated, but still work. If you don't care for earlier versions,
better use $InstallationDirectory and $UserBaseDirectory instead.

> If one has edited a private style sheet for (and within) a Mathematica
> notebook, how can one pull that style sheet out of that notebook, assign
> it a name, and put it somewhere? (as well as into the Style Sheet menu)

Format -> Edit Stylesheet

will open the Stylesheet as a regular notebook. You can then use File ->
Save As to save a copy of it.

> Some of the standard named style sheets in the Format >> Style Sheet
> menu seem to have styles associated with the different command keys that
> are different not just visually or "format-wise" but functionally.

the shortcut keys are not as standard as one probably would wish. On the
other hand, it might be different styles that are important for different
purposes/stylesheets, so it could be justified with that. I think the
problem here is that with the current setup one is limited to 10 shortcuts
per stylesheet...

> One time when I stepped through these named style sheets with one of my
> notebooks open, just to see what different styles looked like, it seemed
> to leave some of the cells in my notebook seriously screwed up (from the
> nature of the damage, my guess is one of the styles had made some of the
> non-Input cells in my notebook into evaluatable cells, and they didn't
> like it). Should there be a warning about this?

If changing the stylesheet screws up cells that is a bug in my opinion. You
should report that to Wolfram.

> have at the bottom of their "Styles" menu a set of more or less blank
> style templates named "Custom 1", . . . . "Custom 6" to use for making
> your own styles. Wolfram?

If you know where to put them, there is no need for "Custom 1" etc. Maybe it
should be made easier to find the relevant documentation, though. Have you
found FrontEnd -> StyleSheets in the HelpBrowser? It basically tells
everything about stylesheets, but is not very exhaustive...

albert

Helen Read

unread,
Aug 23, 2006, 7:39:04 AM8/23/06
to
David Park wrote:
> Dear Helen,
>
> You didn't put the new cell type "near the top" of the style sheet but just
> far enough down so that it would catch a hot key and NOT disturb most of the
> standard hot keys. So you don't have to worry about the Mathematica Militia
> appearing on your doorstep! (Just kidding.)

Phew, I'll sleep better tonight!

> You could have gone one position lower and only bumped the hot key for
> InputCells since they don't really need a hot key.

Right, but it's too late. I've been using Alt-8 for my GraderText for at
least 6 years, and don't want to have to train myself to use Alt-9 instead.

> What caused me to include
> the comment in my posting is the MiER style sheet for submission of
> articles. It completely rearranges most of the hot keys, and specifically
> the hot key for Text cells had been changed. Since that is the hot key I use
> most often I found it quite annoying.
>
> And I am quite impressed with the work you are doing with Mathematica in
> education.

Thanks.

0 new messages