5
$\begingroup$

Like this screenshoot

How to draw such line with Mathematica code?

$\endgroup$
  • $\begingroup$ Graphics[{Gray, Thickness[0.002], Line[{{0, 0}, {1, 0}}]}, AspectRatio -> .1]. Just for curiosity - why did you put memory tag here? $\endgroup$ – Sumit Nov 13 '16 at 9:42
  • $\begingroup$ @Sumit It is not a simple line.It is seem some magic in it. :) $\endgroup$ – yode Nov 13 '16 at 10:45
11
$\begingroup$

In general when you have an element in a notebook that you want to reproduce you can right click on the bracket to the right of it, and choose "Copy as" and then "Cell expression".

Copy cell expression

The cell expression of the line in the documentation looks like this:

Cell[BoxData[
 InterpretationBox[Cell["\t", "ExampleDelimiter"],
  $Line = 0; Null]], "ExampleDelimiter",
 CellID->72220119]

Normally you can reproduce this element, whatever it is, by applying CellPrint to the cell expression. However, this particular cell expression to render in a normal notebook. I suppose this is because the documentation uses a custom stylesheet with styling that's not available to standard notebook.

To get something similar, you can go to the Insert menu, and choose "Horizontal line".

Menu

You can to type something in to the cell before the line appears. Now you can right click on the bracket to the right to find the resulting cell expression, which turns out to be:

 Cell[BoxData[""], "Input", CellFrame -> {{0, 0}, {0, 0.5}}, 
  CellChangeTimes -> {}]

CellPrint will print this as a line. You can change BoxData[""] to BoxData["arbitrary content"] to fill the cell with content. In this case it's an input cell but it could be a text cell or something else.

Making it gray etc. I'll leave to someone else.

$\endgroup$
  • $\begingroup$ If set the CellStyle to be "Section",It will be gray. CellPrint[ Cell[BoxData[InterpretationBox[Cell[""], $Line = 0; Null]], "Section", CellFrame -> {{0, 0}, {0, 0.5}}]] $\endgroup$ – yode Nov 13 '16 at 11:54
4
$\begingroup$

You can determine the "ExampleDelimiter" style by setting your notebook style sheet to the one used by function pages:

SetOptions[EvaluationNotebook[], StyleDefinitions -> "Wolfram/Reference.nb"]

and then using CurrentValue to obtain the styles:

CurrentValue[EvaluationNotebook[], {StyleDefinitions, "ExampleDelimiter"}]

{Editable -> False, ShowCellBracket -> Automatic, CellMargins -> {{48, 14}, {-5, 0}}, Evaluatable -> False, CellGroupingRules -> {"SectionGrouping", 58}, ShowCellLabel -> False, CellLabelAutoDelete -> True, TabFilling -> "[LongDash][NegativeThickSpace]", TabSpacings -> {76}, StyleMenuListing -> None, FontFamily -> "Verdana", FontSize -> 9, FontWeight -> "Plain", FontSlant -> "Plain", FontColor -> GrayLevel[0.905882]}

The key styles are the ShowCellBracket, TabFilling, TabSpacings and FontColor options. So, to obtain an "ExampleDelimiter" style horizontal line, you can do:

CellPrint @ Cell[
    "\t", 
    ShowCellBracket -> Automatic,
    TabFilling->"\[LongDash]\[NegativeThickSpace]",
    TabSpacings->Scaled[1],
    FontColor->GrayLevel[.9]
]
$\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.