500
500

Reputation: 6619

Coloring "horizontal line" in Mathematica

Is there anyway to have those lines automatically Black in Mathematica ?

enter image description here

enter image description here

Upvotes: 4

Views: 1246

Answers (3)

Simon
Simon

Reputation: 14731

Although it doesn't satisfy the criterion of "automatic", you could just insert the default blue line and then change its color. Since the line is not selectable, you need to click under the line the press shift-up. Then press Ctrl-Shift-E (Show Expression) to see (for a thick line)

Cell[" ", "Text",
 Editable->False,
 Selectable->False,
 CellFrame->{{0, 0}, {0, 3}},
 ShowCellBracket->False,
 CellMargins->{{0, 0}, {1, 1}},
 CellElementSpacings->{"CellMinHeight"->1},
 CellFrameMargins->0,
 CellFrameColor->RGBColor[0, 0, 1],
 CellSize->{Inherited, 5}]

Then the RGBColor is easily changed.

Upvotes: 2

Sjoerd C. de Vries
Sjoerd C. de Vries

Reputation: 16232

Heike has the answer, but in the unlikely case you don't want to mess with those .tr files you could also execute

NotebookPut[
  NotebookGet[
    SelectedNotebook[]] /. {
      Cell[" ", "Text", x___, CellFrameColor -> RGBColor[___], y___] :> 
      Cell[" ", "Text", x, CellFrameColor -> RGBColor[0, 0, 0], y]}, 
  SelectedNotebook[]];

and turn every cell frame (the lines are just cell frames) black.

Upvotes: 4

Heike
Heike

Reputation: 24420

The default style of those lines is defined in the file ContextMenus.tr located in the subdirectory SystemFiles/FrontEnd/TextResources of $InstallationDirectory. If you search for "CellInsertionPoint" in that file then you should find something like

"CellInsertionPoint" -> {
  ....
  Menu["Insert Ho&rizontal Line",
    {
     MenuItem["Thi&n Line", FrontEndExecute[{
       FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], 
        Cell[" ", "Text", 
         ....
         CellFrameColor->RGBColor[0,0,1]], 
       After]
      }]],
     MenuItem["&Medium Line", FrontEndExecute[{
         .....    
         CellFrameColor->RGBColor[0,0,1]], 
       After]
      }]],
     MenuItem["&Thick Line", FrontEndExecute[{   
         .....
         CellFrameColor->RGBColor[0,0,1]], 
       After]
      }]],
  ....
}

To permanently change the default colour of the horizontal lines you could set CellFrameColor of these three MenuItems to whatever colour you want (or you could create extra MenuItems if you want more choice). Note that you need to restart Mathematica for the changes to take effect.

If you don't want to change the original file you can also save a copy of the file to the appropriate subdirectory in either $BaseDirectory or $UserBaseDirectory and edit that.

Upvotes: 7

Related Questions