Please let me know the purpose of the 'code sample' button in the menu while writing/editing questions/answers .

  • $\begingroup$ Not everybody remembers markdown syntax (e.g. me). Anyway, it's intended to be used for displaying source code/code snippets... $\endgroup$ – J. M. is a poor mathematician Apr 17 '11 at 5:42
  • $\begingroup$ On another note, reading the first two entries here ought to have been enough to answer your question. $\endgroup$ – J. M. is a poor mathematician Apr 17 '11 at 5:46
  • $\begingroup$ @JM : can i use it to upload tex/latex code ? $\endgroup$ – Rajesh Dachiraju Apr 17 '11 at 5:56
  • $\begingroup$ Not the intended use for that; I would recommend you upload your $\TeX$ file to a proper filehost and link to it instead. $\endgroup$ – J. M. is a poor mathematician Apr 17 '11 at 6:13

The "code sample button" is for, well, including code samples.

On different StackExchange sites, the typically included code are different. On sites like StackOverflow or TeX.SE, the questions and answers are generally about the code, and those code are marked in the presentation that way. On Math.SE, the most common use for including code samples is to show MatLAB or Mathematica code, either in the question or in the answers.

It is common practice to visually distinguish code samples from the surrounding text. This is especially important when you deal with programming languages such as Python where spaces and tabs are contextual. Without marking the code as such, typical browsers will chomp up the spaces, making the code unparseable.

So: use the code sample button if your question is actually about the code itself (or you are answering a question about certain code implementation). On Meta this certainly also applies to asking about TeX constructions for use with MathJax.

  • 1
    $\begingroup$ right, the main feature of a code block is that it is a monospace font where every character is the same width -- from I to W $\endgroup$ – Jeff Atwood Apr 19 '11 at 17:31

You must log in to answer this question.

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