add full(er) knitr support reopens #165

The earlier fix for #165 does not work, as @mikheyev and others noted.
On an `*.Rnw*, especially with beamer class, this still doesn't work; needs more (above) additional scopes.

@dpmccabe suggested the fix for this, and I extended it to also cover the beamer class, which appears to need its own additional scope.