[R] latex \subfloat{} incompatible with sweave/knitr code

Liviu Andronic landronimirc at gmail.com
Fri Aug 31 16:40:59 CEST 2012


On Thu, Aug 30, 2012 at 12:50 AM, Yihui Xie <xie at yihui.name> wrote:
> Do you know what environments are allowed inside \subfloat{}? The
>
No, not really. From what I can tell, \subfloat{} is provided by the
`subfig' package. Here's what their docs have to say about
compatibility with verbatim and fancyvrb packages:
"You cannot place a verbatim environment inside of the \subfloat command because
the verbatim environment needs to change the character classes before
the text in the environment is read by TEX. Therefore, if you really
want to include verbatim text inside a sub-float, you will need to
place the verbatim text into a box and then feed the box to the
\subfloat command."

And this is what CTAN says about the 'subfig' package:
"The package 'subfigure' is now considered obsolete: it was superseded
by 'subfig', but users may find the more recent 'subcaption' package
more satisfactory."


> graphics example works because it is nothing but a simple
> \includegraphics{} command. The table example you gave is much more
> complicated than that.
>
I played around with the 'subcaption' package and, although it has
some side effects  on the figures, it accepts verbatim in its
'subtable' environment. See knitr LyX file and PDF:
http://s000.tinyupload.com/index.php?file_id=00455858466446731442
http://s000.tinyupload.com/index.php?file_id=07968719976440864387

Maybe it's high time to ask the LyX devels to implement support for
the 'subcaption' package.

Liviu




More information about the R-help mailing list