How can I write inline code (e.g. in a comment) ending in a backtick, without adding an extra space at the end?

I know that backticks can be included if the code is surrounded by double backticks, like so:


But what if we want the last character of the code to be a backtick?

``context```  <-- this doesn't work because "```" doesn't close the code segment

``context` `` <-- this adds an extra space at the end

Use case: in Mathematica, context names always end in a backtick.

Of course this is not a big deal, and we can live with that space at the end. I was curious if there was a way to do this. If this is not possible, I'll accept that as an answer.

  • 1
    Try using a backslash to escape the backtick: \` It will then appear as a literal backtick. Dec 29, 2011 at 14:06
  • @JasonPlank that does not work....
    – Naftali
    Dec 29, 2011 at 14:06
  • 1
    @amanaPlanaCAnalPAnaMA works for me: context` Dec 29, 2011 at 14:08
  • @JasonPlank hehe idk what computer you are looking at :-P
    – Naftali
    Dec 29, 2011 at 14:09
  • @amanaPlanaCAnalPAnaMA viewed source because I don't always trust the highlighting. I see <code>context`</code>. What do you see? Dec 29, 2011 at 14:10
  • @JasonPlank oy... none of that works in the comments....
    – Naftali
    Dec 29, 2011 at 14:11
  • @amanaPlanaCAnalPAnaMA not sure what you mean by that Dec 29, 2011 at 14:13

2 Answers 2

``context` `` <-- this adds an extra space at the end

Actually, it doesn't. All characters have the same width inside <code>. It's just that the backtick is smaller than most characters, so it seems like there is a space at the end.

The following two have the same length:



  • You might be right. I realize the space might be an illusion because of the tiny size of `. It's common to even move small glyphs like punctuation out towards the margin in professional typesetting to compensate for this illusion, isn't it?
    – Szabolcs
    Dec 29, 2011 at 14:17
  • You lost me at professional typesetting.
    – Dennis
    Dec 29, 2011 at 14:20
  • 1
    I just remembered this: en.wikipedia.org/wiki/Optical_Margin_Alignment
    – Szabolcs
    Dec 29, 2011 at 14:27

You have to cheat it:


This was achieved by doing this:


I got the idea from this answer

You can even do:


Which was achieved by doing:


(thanks to Arjan in the comments)

  • Thanks for pointing out that we can use <code> instead of backticks! It turns out I was wrong about the space at the end though ... it is stripped. It is only an illusion that it appears.
    – Szabolcs
    Dec 29, 2011 at 14:19

You must log in to answer this question.

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