5

When using the InlineMathCell one types Ctrl+9 within the text cell, and gets a slot for starting typing the InlineMathCell part. When typing the content of the InlineMathCell is slightly highlighted by a light pink color. As soon as the typing goes outside of the InlineMathCell, the highlighting disappears, and the InlineMathCell background looks white.

My question is: How can I change the highlighting color of an InlineMathCell to make it more visible?

Reaction to the statement that this question already has an asnwer: NO IT HAD NOT BEFORE THE PRESENT ANSWER OF SILVIA. See the discussion below.

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96
  • @Silvia seems, He is not searching for background color, but hilighting color, that's also the op's previous question. – HyperGroups Jun 17 '13 at 10:29
  • @HyperGroups IMO, with the method in the post I linked, there is no difference between adjusting the Background, the FontColor, the FontFamily or any other style things. – Silvia Jun 17 '13 at 10:34
  • @Silvia Hilighting color is something temporary, and its style will disappear after ending the inline cell. Maybe should use CellEventActions in stylesheet. I've tried a little, but still not succesful for only inline cell. – HyperGroups Jun 17 '13 at 10:40
  • 1
    @HyperGroups Ahh... I see your point. Sorry I misundertood OP's question. It can't be un-voted, but other folks would vote to leave it open. – Silvia Jun 17 '13 at 10:43
  • @MichaelE2 I think it's not exactly the same problem. I think what OP wants is a temporary style which applies to a inline cell only when the cursor is in it. And when the cursor is out of it, its style should automatically fall back to "InlineCell". Please see the video in my answer for more precise what I mean. – Silvia Jun 18 '13 at 19:25

2 Answers2

7

Sorry I voted as duplicate because I misunderstood the question.

If you want to tune the style of inline cells, you can adjust the "InlineCell" style.

If you want to tune the style of inline cells that presents when editing the cell, there is a similar style called "InlineCellEditing".

An example used by myself:

Cell[StyleData["InlineCellEditing"],
 FontFamily->"Constantia",
 FontColor->RGBColor[0.5019607843137255, 0., 0.5019607843137255],
 Background->RGBColor[0.964706, 0.929412, 0.839216]]

Edit:

According to OP's comment, I made a video to demonstrate how to setup the style (please choose 720p quality for detail view):

customize stylesheet

Silvia
  • 27,556
  • 3
  • 84
  • 164
  • I think I would upvote if I knew how stylesheets worked :). – Jacob Akkerboom Jun 17 '13 at 11:07
  • @JacobAkkerboom Stylesheets are great tools. Maybe you would be interested in [tag:stylesheet]. :) – Silvia Jun 17 '13 at 11:11
  • I'll keep that in mind, but I suppose I could invest more 5-10 minutes looking at the relevant doc pages also :). I guess I'm not one for style, Raw Inputform appeals to me :P. – Jacob Akkerboom Jun 17 '13 at 11:18
  • 1
    @JacobAkkerboom Yes the official documentations are definitely the best place to start. – Silvia Jun 17 '13 at 11:36
  • @Silvia Thank you. This looks like a very reasonable solution. However, I made a StyleSheet on the basis of the JournalArticle, in which I have inserted the cell from above, and though it should work, it does not. – Alexei Boulbitch Jun 18 '13 at 07:58
  • @AlexeiBoulbitch It works fine here. Did you add the style in the private stylesheet of the very nb you're editing? – Silvia Jun 18 '13 at 11:17
  • @AlexeiBoulbitch Please see my edit. – Silvia Jun 18 '13 at 12:49
  • @Silvia Thank you very much. This of course, makes no doubts of how you did it. In fact I did pretty much the same. When you did the background color change it transformed into a pale-lihgt-red. In my case, however, after I repeated all your operations the background color stays the same as it has been before the change (I would say that it is like a pale-gray-brown). I tried to change it radically. Say, into RGBColor[1,0,0], but with no effect. It may be due to a system (I have PC WinXP/Mma9.01) or whatever else, since I see that in your case the color changes. – Alexei Boulbitch Jun 19 '13 at 08:48
  • @Silvia However, the variation of the fontSize during the editing of the InlineCell is an excellent idea. It alone solves my problem: to be informed during typing, if I already out of the InlineCell, or still in there. Thank you once more. – Alexei Boulbitch Jun 19 '13 at 08:52
  • @AlexeiBoulbitch You're welcome. I'm not sure why the Background option failed on your machine.. Maybe you could try it on other styles and see what happens. – Silvia Jun 19 '13 at 09:09
  • @Silvia, Just to give a fit back. I tried at bureau (PC WinXP,Mma 9.01). It works with the default StyleSheet, but did not with JournalArticle and Monograph StyleSheets. At home, however, (PC Win7, Mma 9.01 Home Edition) it worked everywhere. The hypothesis, thus, is that the problem is in the PC WinXP properties. – Alexei Boulbitch Jun 20 '13 at 07:15
  • @AlexeiBoulbitch Thanks. Good to know. – Silvia Jun 20 '13 at 07:21
0

I came up with this, not so good, hope for someone will develop this.

CellPrint@Cell["This is one InlineFourmula Style Cell", "InlineFormula", CellEventActions -> 
{
"MouseMoved" :> (SelectionMove[InputNotebook[], All, ButtonCell];
 SetOptions[NotebookSelection[InputNotebook[]], Background -> LightGreen, FontColor -> Red]),
"ReturnKeyDown" :> (SelectionMove[InputNotebook[], All, ButtonCell]; 
SetOptions[NotebookSelection[InputNotebook[]], Background -> Inherited, 
FontColor -> Green, FontSize -> 25])}
]

And this StyleData in one stylesheet only take effect for InlineFormula style cell but not InlineFormula style inline cell What a pity.

Cell[StyleData["InlineFormula"],
CellEventActions->{"MouseMoved" :> SetOptions[
 NotebookSelection[
  InputNotebook[]], Background -> Green], "ReturnKeyDown" :> SetOptions[
 NotebookSelection[
  InputNotebook[]], Background -> LightRed]},
 FontSize->24,
Background->RGBColor[0, 1, 0]]

ReturnKey will change the background color temporarily

enter image description here

HyperGroups
  • 8,619
  • 1
  • 26
  • 63