# Strange alignment of rendered text in a code chunk [duplicate]

In an answer of mine on CV I have the following code chunk, indicated via indentation by 4 spaces at the start of the line.

> AIC(gam_example$lme) [1] -2.136317 > AIC(gamm_example$lme)
[1] -1286.448


(Note that to illustrate this I have wrapped the above in HTML <pre> tags - the layout above is how it was entered in the edit window in the Answer.)

The displayed code block is rendered as

> AIC(gam_example$lme) [1] -2.136317 > AIC(gamm_example$lme)
[1] -1286.448


(Again, here this is wrapped in <pre> in the editor, but only to show the problem.)

Clearly the alignment in the code block is wrong. I wonder if this is something to do with MathJax (note the $ in both chunks). Compare these two blocks, both entered without <pre> tags in the editor: > AIC(gam_example$lme)
[1] -2.136317
> AIC(gamm_example$lme) [1] -1286.44  and > AIC(gam_example$lme)
[1] -2.136317
> AIC(gamm_example)
[1] -1286.44


The first chunk of these two is a live example of the problem I report here. Note the lack of a second  in the second code block allows this to render with the correct, intended alignment. Is there anything that can be done about this, or is it an unfortunate clash of R syntax and MathJax? Or something else? • @smillig sigh, I thought I'd done my due diligence and checked related Qs. Thanks for doing that job properly for me and pointing out the original. I've voted to close. (+1) – Reinstate Monica - G. Simpson Sep 20 '13 at 14:57 • ... and I actually answered that duplicate and had forgotten it existed. – whuber Sep 20 '13 at 16:09 ## 1 Answer Yes, it looks like a clash of markup procedures. The only workaround I have found is to add a comment containing an odd number of\ after each offending line. For example,

> AIC(gam_example$lme) [1] -2.136317 > AIC(gamm_example$lme)
[1] -1286.44


becomes

> AIC(gam_example$lme) #$
[1] -2.136317
> AIC(gamm_example$lme) #$
[1] -1286.44

• Thanks; I supposed one could also render using <pre>, as I did above, but that begs the question why this fails for the rendered code blocks and not for code added in <pre> tags. This seems to be something specific to code blocks and how they are rendered from the MD into HTML. – Reinstate Monica - G. Simpson Sep 19 '13 at 19:59
• Thanks for this workaround. I've run into this problem many times and sometimes managed to get it to go away, but this is a better solution than any I managed. – Glen_b -Reinstate Monica Sep 19 '13 at 21:23