5
$\begingroup$

How can I make a stylesheet where inline cells are styled like input cells? By "similar", I mean the same font and syntax highlighting.

I have even tried copying all settings from Input cell of Core.nb to a private style definition for InlineCell, but had no luck.

$\endgroup$

3 Answers 3

3
$\begingroup$

It looked like I had misunderstood "syntax highlighting" in this context. What I need turned out to be ShowCodeAssist->True. Combining this and settings on font and others that looked relevant:

Cell[StyleData["InlineCell"],
ShowAutoStyles->True, 
ShowCodeAssist->True,
LanguageCategory->"Mathematica",
FormatType->"InputForm",
FontFamily->"Courier New", 
FontWeight->"Bold"]

I finally achieved what was almost what I was looking for.

$\endgroup$
3
$\begingroup$

You can change the DefaultInlineFormatType for "Text" cells to DefaultInputInlineFormatType (i.e., "StandardForm"), and change the style "InlineCell" to inherit options from "Input":

SetOptions[
    EvaluationNotebook[],
    StyleDefinitions -> Notebook[
        {
        Cell[StyleData[StyleDefinitions -> "Default.nb"]],
        Cell[StyleData["Text"], DefaultInlineFormatType -> System`DefaultInputInlineFormatType],
        Cell[StyleData["InlineCell", StyleDefinitions->StyleData["Input"]]]
        }
    ]
]

Here is screen capture from a notebook, showing a text cell with an inline cell, followed by a normal "Input" cell, so that you can compare them:

enter image description here

$\endgroup$
0
1
$\begingroup$

You can't get syntax highlighting in an inline cell. Syntax highlighting is not a style, but a function of the front end's code editor, which is only active in Input cells. You can put text in a text cell into Input style. Select the text, then type Cmnd+9 (OS X) or Ctrl+9 (Windows).

$\endgroup$
2
  • $\begingroup$ thanks. Can I set upright font shape in stylesheet so that single character will not get automatically slanted? $\endgroup$
    – Naitree
    Commented Apr 18, 2014 at 4:39
  • $\begingroup$ I just noticed that by typing Shift + Ctrl + I, inline cell can be converted to InputForm. Is there a way to automate this process? $\endgroup$
    – Naitree
    Commented Apr 18, 2014 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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