Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

05 Stylesheets

0 (0 Likes / 0 Dislikes)
This section of introduction to Wolfram Notebooks is about customizing the style of a notebook by editing stylesheets. The stylesheet is where all of the cell styles and things like indentation and font sizes and background colors and so on are specified for cells and for the notebook. Every notebook has a stylesheet. The stylesheet can be chosen from the Stylesheet submenu under the Format menu. This notebook was created by just selecting new notebook from the File menu without specifying a stylesheet, so the notebook was assigned a stylesheet called Default, which is the item that is checked in this menu, but there are lots of other stylesheets to choose from. For example, this chooses the Sky stylesheet from the PresenterTools submenu. PresenterTools styles are used for showing the notebook as a slideshow, as will be discussed in a later section. You can also select Stylesheet Chooser from the Style menu, which opens this palette for selecting a stylesheet. The lower part of each item in this display is used to apply that style to an existing notebook and the upper part creates a new notebook. For example, here I will click the upper part of the entry for a StandardReport style, which gives a notebook that uses the StandardReport stylesheet and in addition, that notebook is already filled in with examples of all of the cell styles that are defined within that stylesheet, which is a nice way of getting an overview of what the available cell styles look like. Even with lots of possible stylesheets and cell styles to choose from, there are still situations where it is useful to customize things, which you can do by editing the stylesheet. To show an example of how that can work, I will return this notebook to the default stylesheet and choose Edit Stylesheet from the Format menu. The stylesheet that comes up is not the default stylesheet, but rather a private stylesheet that is specific to this notebook. This private stylesheet can be used to specify option settings to apply in preference to the settings, in the actual default stylesheet. For example, to change the styles for all of the text cells in the notebook, I will start by choosing Text from the Choose a style menu, which generates here a special type of cell that is mostly only used in stylesheets. The other items at the top of this window are the Enter a style name box, which can be used to introduce a new cell style and the Install Stylesheet button, which is used to add a whole new stylesheet that can be used by other notebooks. Any option settings that I add for this new cell in the stylesheet will apply to all of the text cells in the notebook. For example, here I will select this cell and use items under the Format menu to set the background color to light orange and set an italic font. Choosing Show Expression from the cell menu shows the underlying cell expression, with the new settings for the background option and the font slant option. What makes this cell special is that the content of the cell is this style data expression. The stylesheet itself is a notebook and in general a stylesheet is just a notebook where all of the cells are these special style data cells. Returning to the original notebook shows that this change in the stylesheet had the effect of changing the background color and the font slant for all of the text cells in the notebook. It is still possible to override the styles in the stylesheet by making changes directly to selections in a notebook. For example, if I don't want the italic font for some part of the text, I can select that text and specify a different font. When a style is specified in several different places, like the italic font in this text cell, the general principle is that styles that are set for a specific selection take precedence over settings in a stylesheet. That general principle is also sometimes described using the notion of inheritance. We could say, for example, that any style not explicitly specified in the notebook is inherited from the stylesheet. There is also a principle of inheritance for the stylesheets, since most notebooks actually use a sequence of stylesheets. For example, returning to the private stylesheet, at the top of the stylesheet is a cell that says that styles here are inherited from the default stylesheet. Clicking on the hyperlink in that cell brings up the actual default stylesheet, which includes specifications not just for text cells, but for all of the cell styles within this stylesheet. The default stylesheet also includes a cell at the top, noting that this stylesheet inherits styles from another stylesheet called Core, which is the end of the sequence. Any style not specified in one of these stylesheets just uses a global value. Inheritance for this set of stylesheets means that each stylesheet inherits styles from the stylesheet above it. Usually the only stylesheet to edit is the private stylesheet for the notebook, but it is often useful to see what is in one of the other stylesheets. For example, one of the styles in this stylesheet is Item style, which can be used for creating bullet lists like this one, but suppose that I want to add a new style that works just like Item style except that the marker, the cell dingbat for each cell, is a checkmark rather than a filled square and the text is shown in bold letters. If I do that by going to the private stylesheet and choosing Item style, I will be modifying the default Item style, but here I want to leave the default Item style alone and instead create a new cell style, which I will do by going through the default stylesheet and navigating to the cell in this stylesheet that describes Item cells, where I will select the cell bracket for that cell, to select the entire cell, then copy the cell and return to the private stylesheet for this notebook and paste that cell into the private stylesheet. The difference between this cell and the one above it can be seen by showing the cell expressions. The second cell here, which is the one that I just copied from the default stylesheet, includes all of the option settings for Item cells. So even when I change the name of the cell, which will have the effect of creating a new cell style, the new cell style will still behave exactly like an Item cell. The default CellDingbat is the FilledSmallSquare, which I will change now to the Checkmark character. I will also change the value of the MenuSortingValue option to a smaller number. This isn't a critical change, but it will have the effect of moving the new cell style to the top of the style menu, where it will be easier to find. There are several other options here, which won't be explored here, except to note that one good way to learn about options is to find a cell style and then look in the stylesheet to see the options that were used to set up that style. I could change the font to a bold font by typing in the option here, but I will instead do that by reformatting the cell and choosing Bold from the Face item under the Format menu. Now return to the original notebook and add a cell by choosing the new CheckmarkItem style from the Style menu, which adds a new cell that behaves like an item cell except for the checkmark cell dingbat and the bold font. Before concluding the subject of stylesheets, many stylesheets support variations that can be selected by specifying an option called Environment. For example, the current environment for displaying this notebook on the computer screen is called Working environment, which we can see because Working is checked in the Screen Environment submenu under the Format menu. If the screen environment is changed to Printout, the styles used in the notebook change to styles that are more appropriate for printing. In this example, switching to Printout environment changes the magnification and the cell margins and limits the page width to the width of printing paper. The different environments could, in principle, give cells with completely different sets of options and completely different styles, but environments are more typically used to introduce small variations on a general theme, like optimizing a notebook for printing or optimizing a notebook for a slide presentation. There is really an enormous range of other things that can be done like this to customize notebook styles. You can find more information about stylesheets in the Wolfram Documentation by navigating to this tutorial on working with stylesheets and a good reference on the general structure of Wolfram notebooks, is this section on notebooks as Wolfram Language expressions.

Video Details

Duration: 7 minutes and 58 seconds
Country:
Language: English
License: Dotsub - Standard License
Genre: None
Views: 0
Posted by: wolfram on Jan 14, 2020

05 Stylesheets

Caption and Translate

    Sign In/Register for Dotsub above to caption this video.