24

Contexts have backticks, which conflict with the normal way to enter inline code. How do I enter an inline context, since the initial approach:

`System``

doesn't work ( `System`` ).

0

4 Answers 4

26

This is so common in Mathematica that I suggest this should be specially included in the editor help or the FAQ on this site. Let me list the most common usages:

  • Contexts, for example, Global`.

    Markdown: ``Global` `` (note the space before the closing ``)

  • Precision of numbers, for example, 2.3`40.

    Markdown: ``2.3`40``

  • Accuracy of numbers, for example, 2.3``3.

    Markdown: ```2.3``3```

  • StringForm expressions, for example, StringForm["x = ``", x]

    Markdown: ```StringForm["x = ``", x]```

    And here the question comes up, how to include a double backtick (``) in inline code? Generally, if you want to include n consecutive backticks, surround the inline code span with n+1 backticks. For this reason, if the inline code has a backtick at the very end, you need to put a space after it. Don't worry, this space will be stripped when the MarkDown is rendered.

0
12

You can also use the HTML markup <code>...</code>. This has the advantage that you can bold and italicise inside it, like so:

<code>f[x_*Pattern*]:= 50.`**watch out**</code>

Results in

f[x_Pattern]:= 50.` watch out

And as you can see, you don't need to count backticks.

8

According to this MSO question, you can use double backticks set off by spaces to surround a code snippet:

`` System` ``

produces System`.

0
3

Backslashes before backticks seem to work too. For example,

`?Global\`*`

in the comment below:

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .