The simplest way is to indent your code block by 4 spaces: To get the output
\documentclass[paper=a5,pagesize]{scrbook} just type
\documentclass[paper=a5,pagesize]{scrbook} (The first empty line is essential, the last one is recommended.) If you have more than one line, then it's simpler to highlight the code block and hit Ctrl+K (or click the "code" button, with "101010" on it). This auto-indents the highlighted code by 4 spaces (and also adds the empty lines in the beginning and in the end).
Syntax highlighting
By default, your code gets some LaTeX syntax highlighting. (This doesn't work on meta.tex.sx, so unfortunately you can't see it here.) If you don't want this syntax highlighting, you can use a special HTML comment to specify the language. For no highlighting, use
<!-- language: lang-none --> (J:\MiKTeX2.9\tex\latex\elsarticle\elsarticle.cls Document Class: elsarticle 2009/09/17, 1.2.0: Elsevier Ltd (You wouldn't want \MiKTeX to be highlighted as a control sequence, right?) Note that the HTML comment must not be indented, and that the blank line between the <!-- language: ... --> and the indented code block is required. For a list of supported languages have a look here: Manually specify language for syntax highlighting.
Emphasizing pieces of the code
If you want to highlight parts of your code using bold or slanted text, or if you want to strike something out, you have to use the HTML <pre> tag instead of 4 space indentation. For example,
<pre> \documentclass[paper=a5,<i>pagesize</i>]{scrbook} \usepackage<b>[draft]</b>{graphicx} </pre> gives
\documentclass[paper=a5,pagesize]{scrbook} \usepackage[draft]{graphicx} For striking something out, use <s>...</s>. Using just <pre> you don't get syntax highlighting, so you can use this as an alternative to <!-- language: lang-none -->. Be careful, however, to use < and > if you want < and > in <pre> blocks; you may also need & for &.
If you want syntax highlighting and additional emphasis in bold or slanted, use <code> inside the <pre> block:
<pre><code>\documentclass[paper=a5,<i>pagesize</i>]{scrbook} \usepackage<b>[draft]</b>{graphicx} </code></pre> Note that there's no line break after <code>; otherwise the code block would start with an empty line.
Code blocks in lists
If your code appears inside a list, you must indent a further four spaces for every level of nesting. An example:
1. The first point I want to make This is the code 1. The second point I want to make gives
The first point I want to make
This is the codeThe second point I want to make
So you need 8 spaces in the first level, 12 spaces in the second level and so on.
Code blocks in blockquotes
A blockquote is started with > , and a code block with 4 space, so for a code block within a blockquote you need 5 spaces after the >. An example:
> This is (not) a quote from the TeXbook, and here's some code: > \relax gives
This is (not) a quote from the TeXbook, and here's some code:
\relax