If I have a paragraph of text and have some very short code inline such as a function/symbol names in the sentences, how to format them more like code? Sort of like an analogue of computerCode
in Markdown.
1 Answer
$\begingroup$
$\endgroup$
3
As you are typing, you can toggle between Code
and Text
styles using Alt+8
and Alt+7
(version 9.0.1.0 windows 8 x64)
If the paragraph is already typed, you can highlight the part you want to change and use Alt+8
to change its style to Code
.
Or, you can use Format
menu and select Code
in the Style
sub-menu.
Alternatively, you can use Style[#,"Code"]
to change the style of selected elements. For example:
text = StringTake[ExampleData[{"Text", "LoremIpsum"}], 400];
reStyle = TextCell[Row[List @@ StringReplace[#, p : Alternatives @@ #2 :> Style[p, "Code"]]], 16,
"Panel"] &;
reStyle[text, {"Integer", "condimentum", "porttitor", "vitae", "rutrum", "justo"}]
-
5$\begingroup$ this doesn't seem to work for v11. It generates an all-gray area with the code blocks in bold $\endgroup$– glSCommented Feb 23, 2017 at 16:06
-
$\begingroup$ Thank you @glS. Looks like
"Panel
style definition has been modifed since version 9 to add a gray background. Does adding the optionBackground->None
inTextCell
work in version 11? $\endgroup$– kglrCommented Feb 23, 2017 at 17:37 -
$\begingroup$ nope. It makes the background white, but the code blocks also have a white background. $\endgroup$– glSCommented Feb 23, 2017 at 17:45