1

What is the quickest way (minimum number of manual steps) to let some highlighted text appear as say Courier 12 pt regular?

1.) In Mathematica notebooks, I use a different font in explanatory text cells for Mathematica expressions, keywords, and paths to files: I use Courier regular 12 pt for this.

When I do this via Format>Font>Courier... after entering the C of Courier, I have to select the desired font Courier each time with the mouse among all those starting with C, because as soon as I enter the second letter (in this case "o"), the selection box already changes to the fonts starting with o! And when I have selected Courier, Font Style jumps to Italic!

I want to assign Courier Regular 12 pt to the just selected text with the minimum number of keystrokes. How do I do that?

2.) Mathematica has the concept of Style sheets, which has some similarity to templates in Microsoft Word, LibreOffice and the like. In these word processing contexts, one distinguishes between

  • direct formatting,
  • formatting by paragraph styles,
  • formatting by character styles.

Did I get it right, that styles in Mma are like paragraph styles in the wordprocesors and that there is also direct formatting in Mma. What is the precedence-rule between these two in Mma? Is there no equivalent to character styles?

Adalbert Hanßen
  • 2,808
  • 12
  • 26
  • Hi, I might not have understood all of the details but there seems to some options. Option 1, You can directly call the Font Dialog with FrontEndTokenExecute["FontPanel"] as explained in a comment here. Perhaps you can set a keyboard shortcut that evaluates that. If needed you can search for how to make keyboard shortcuts in Mathematica – userrandrand Dec 11 '22 at 02:39
  • Option 2. You can maybe modify some style you never use in your stylesheet according to the configuration you want then select text, right click to open a menu then click on style then the style you want. Perhaps you can also add a new style in the style sheet but I do not know how to do that. – userrandrand Dec 11 '22 at 02:41
  • There are a lot of questions around this for example https://mathematica.stackexchange.com/q/99712/86543 which is marked as a duplicate of https://mathematica.stackexchange.com/q/47474/86543 – userrandrand Dec 11 '22 at 02:54
  • 1
    userrandrand, there is an input field in the Stylesheet, where you can enter a new name. It creates Cell[StyleData["New"], MenuSortingValue->10000] as can be seen after Shift+Ctl+e. You might change it then e.g. to Cell[StyleData["New"], AutoSpacing->False, LineIndent->0, FontFamily->"Courier", FontSize->12, FontWeight->"Bold", FontSlant->"Plain", FontVariations->{"StrikeThrough"->False, "Underline"->False}] and press Shift+Ctl+e again. Then the defined style New exists. Just adding such an Expression into the big white field doesn't work. – Adalbert Hanßen Dec 13 '22 at 12:58
  • Thank you (:. I saved the page in case I will need to make a new style in the future. – userrandrand Dec 13 '22 at 14:39
  • But it looks like you can apply fonts and outlines only to whole cells. Probably Mma has no equivalent to character style (like in LO Writer), which was part 2) of my question. - Do you have a working example what to add to KeyEvent.tr or to joker.m, such that I could assign Font=Courier 12 regular to the current selection? – Adalbert Hanßen Dec 13 '22 at 15:11
  • I did not try adding a new style but as mentioned in option 2 above you can select a part of a text and give it a style from one of your style-sheet styles. Try with the subsection style it does not have to be the whole cell if you select the part of the text that you want then right click and follow the menu as explained in option 2. – userrandrand Dec 13 '22 at 15:28
  • 1
    Now I finally understood your Option 2: Indeed, one can assign predefined styles to single words in text cells. I changed the item Code to the same appearance as Output (which I already had at Courier 12 point regular). In the stylesheet it appears with grey background (although not part of the definition), but there is no grey background when applied to text. That's really what I want and I can assign it with Alt-8 to a marked portion in a text cell. This really solves my problem! – Adalbert Hanßen Dec 13 '22 at 22:32

0 Answers0