1
votes

I would like a co-author to edit a lyx file I created. He doesn't have knitr installed and he is going to edit only text and equations parts of the document where knitr generated content is not present. I would still like him to be able to generate the pdf file from lyx though. Under Documents / settings / modules, I can delete the Rnw (knitr) module. But then there are errors appearing.

I posted a sample lyx file under knitr_iris.lyx. When the knitr module is activated, Pdf generation works fine, but when you deselect the knitr module under Documents / settings / modules, the following errors pop up:

! You can't use `macro parameter character #' in horizontal mode.

! Missing $ inserted.

These are due to the use of $ and # in R. How to tell Lyx that knitr chunks are not latex code but something else that it should ignore?

1

1 Answers

0
votes

You can do what you want to do by using LyX branches. First, highlight an ERT or knitr chunk (there are two ways to insert knitr in LyX) and go to Insert > Branch > Insert New Branch. Call the branch as you like, for example "knitrChunks". Now highlight the rest of the ERT or knitr chunks and go to Insert > Branch > knitrChunks (this branch exists now that you created it). When you see an "X" in front of the branch, that means it's deactivated. So when your co-author edits and wants to compile, he/she can just right-click on the branch inset and go to "deactivate branch" and remove the module. To reverse that, you can right click and go to "activate branch" and add the module back.