3
$\begingroup$

Today, while giving a lecture on preparation of a custom StyleSheet, I noticed an unexpected problem that I did not see a year ago.

Namely, I create a new type of a cell, entitled "EmphasisCell", and require that this cell be aligned to the left. In the StyleSheet the underlying expression has the form:

Cell[StyleData["EmphasisText"],"Text",
 CellFrame->True,
 MenuSortingsValue->1420,
 FontFamily->"Helvetica",
 TextAlignment->Left,
 FontSize->14]

In the StyleSheet it indeed looks to be aligned left. This is, however, not the case, if I open a new notebook with the style of this new StyleSheet. In this notebook the cell with the style EmphasisCell is aligned to center, rather than left. And it cannot be overridden by going to Menu/Format/Text Alignment/Aligne Left. This simply does not work.

More than that.

I want to modify the simple Text cell as follows:

Cell[StyleData["Text"],
 TextAlignment->AutomaticLeftCenterRight,
 LineSpacing->{2, 3},
 FontFamily->"TimesNewRoman",
 FontSize->14,
 FontWeight->"Plain",
 FontSlant->"Plain",
 FontVariations->{"StrikeThrough"->False,
 "Underline"->False}]

However, the modified cell appears to be aligned to center, and as well cannot be overridden.

I kill this cell and start from the beginning. This time I do the modifications not by changing the underlying code, but through the OptionInspector. This time I only change the font size and line spacing, but do not even touch the alignment. However, the effect is the same: the text in the document created on the basis of such a StyleSheet is aligned to center.

So, it seems me that any modification of a cell style through the StyleSheet forces this cell to be aligned to center.

I have Mma 11.2.0, Win7 and started modification of the StyleSheet starting from the JournalArticle one.

Have you seen this kind of problems? Workaround?

Edit: @Kuba reports that he could not reproduce my observation. Please find here the StyleSheet and here the whole lecture (to see, what steps have been done). By the way, I would be grateful for any comments and criticisms on the lecture itself.

$\endgroup$
3
$\begingroup$

The problem is caused by your All/DockedCells spec:

Cell[StyleData[All], DockedCells -> { ...}, TextAlignment -> Center ]

All is fetched again when FormatTypes are resolved so effectively it will take precedence over specific style options.

Read more in [...] Why does setting a font on the "All" style affect the style resolution...

The fix is to use "Notebook" instead of All.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.