On Mon, Jul 6, 2015 at 11:45 AM, Scott Kostyshak <skost...@lyx.org> wrote: > On Mon, Jul 06, 2015 at 11:25:57AM +0200, Liviu Andronic wrote: >> On Mon, Jul 6, 2015 at 11:08 AM, Jean-Marc Lasgouttes >> <lasgout...@lyx.org> wrote: >> > Le 06/07/2015 00:44, Scott Kostyshak a écrit : >> >> >> >> chktex is enabled as follows: >> >> >> >> enable = params().isLatex() && !lyxrc.chktex_command.empty(); >> >> >> >> This excludes it from running when knitr is in the document. Is there >> >> any easy way to have it run on the .tex file that is ultimately >> >> produced by knitr? >> > >> > >> > Continued: it would be nice if chktex was able to read sweave/knitr files. >> > A >> > possibility could be to create a chktex wrapper that comments out these >> > chunks before calling chktex. >> >
>> But what happens when the chunks are then replaced by valid LaTeX code >> (e.g. xtable(iris))? Shouldn't this be chktex'ed, too? > > Ideally yes. In fact I think all chunks are replaced by valid LaTeX > code. > My point being: I'm not sure if it's ideal to comment out the chunks, as their output can (and often will) cause compilation troubles. The other argument against commenting out is that chunks may output LaTeX elements used elsewhere in the document. For instance, `xtable(iris, label = "asdf")` would contain a label that would be used in non-chunk LaTeX code as a cross-ref, probably generating issues as far as chktex is concerned (if the chunks or their output are commented out). Can't instead LyX run chktex on the .tex file outputted by R (i.e. the sweaved/knitted version)? I can think of a fancy wrapper that would take the Rnw file, spot all chunks and record line numbers before/after each chunk, then chktex on the file output by R, and then adjust reported line numbers given recorded line numbers above... I imagine it would take some will and tinkering to get this right, though. Liviu > Scott -- Do you think you know what math is? http://www.ideasroadshow.com/issues/ian-stewart-2013-08-02 Or what it means to be intelligent? http://www.ideasroadshow.com/issues/john-duncan-2013-08-30 Think again: http://www.ideasroadshow.com/library