Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When I tried to include an R plot with the following code into article(Noweb) in LyX 2.0.0


I got the following error message:

! Missing $ inserted.
<inserted text> 
l.146 ...ir.Hp5960/lyx_tmpbuf2/sweave_example-007}

I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! LaTeX Error: File `C:/Users/MYaseen208/AppData/Local/Temp/lyx_tmpdir.Hp5
960/lyx_tmpbuf2/sweave_example-007' not found.

Any idea to fix this problem. Thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The contents of the chunk label (<<fig=TRUE>>=) get typeset, and the equals sign in it wants math mode. Tex is detecting that and assuming you made an error. The easiest thing to do would be to rename the chunk so that it does not contain the equals sign; something like <<figure is true>>.

(The second equal sign tells noweb that it is looking at a chunk definition. It's ok, and stays. It's the sign in the chunk name that's a problem. Nor is there a problem with equals in a chunk definition, because that gets treated as verbatim text. But the chunk label is different, because it is not treated as verbatim text.)

I daresay that you could put math mode symbols in the chunk name (<<fig$=$TRUE>>), but I worry (probably unnecessarily) this might confuse things at the tangling stage, and prefer to keep chunk labels to pure alphabetics. That's probably good practice anyway, because a chunk name should be a brief and understandable summary of what code in the chunk does, not code itself. So it's better to name your chunk in a way that clearly indicates what it does.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.