3
$\begingroup$

In this post I pasted some R code:

> r <- eigen(A)
> V <- r$vectors
> lam <- r$values
> Lmbd <- diag(lam)

This was entered as

entry form

but at the time of this writing gets rendered as

rendering

The third line was indented no more than the others, but it gets rendered with four space indentation which the other lines don't have, both in the preview and the saved version.

Could this be some aspect of math rendering involved here, something confused by the dollar signs in there?

$\endgroup$
1
  • 1
    $\begingroup$ Here is another useful hack. $\endgroup$
    – cardinal
    Nov 27, 2013 at 17:33

2 Answers 2

4
$\begingroup$

It definitely has to do with the MathJax combination.

The same code block causes a problem in preview on Physics.SE, which also uses has MathJax enabled.

But the code block does not cause a problem on TeX.SE, which does not have MathJax enabled.

$\endgroup$
2
$\begingroup$

This is the same issue as occurred in a previous meta question.

It would be annoying to implement in general, but one approach to overcoming this is to use the <pre> tag and replace the dollar signs with their HTML entities:

<pre>
&gt; r &lt;- eigen(A)  
&gt; V &lt;- r&#36;vectors  
&gt; lam &lt;- r&#36;values  
&gt; Lmbd &lt;- diag(lam)
</pre>

produces

> r <- eigen(A)  
> V <- r$vectors  
> lam <- r$values  
> Lmbd <- diag(lam)

In this particular case, I also had to replace < and > with their HTML entities because each group (e.g., <- eigen(A) >) was being seen as an invalid HTML tag, and not rendered.

In my answer to the question that I linked to at the start of my post, I didn't have to mess around with HTML entities at all - it seems like the <'s and >'s really put a wrinkle in things.

$\endgroup$

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