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

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Aug 29 13:34:36 CEST 2012


Hi,

On Wed, Aug 29, 2012 at 6:56 AM, Liviu Andronic <landronimirc at gmail.com> wrote:
> Dear all
> Are LaTeX \subfloat{} commands incompatible with Sweave code? I cannot
> get the following code to compile properly:
> \begin{table}
> \subfloat[asdfa]{<<>>=
> 2+2
> @
>
> }
>
> \caption{asdf}
>
> \end{table}
>
>
> If I replace the Sweave chunk with a random string or a table, the
> compilation works fine. Any ideas what happens? I hit the same trouble
> when running the code chunks through knitr.

This isn't exactly what you want, but I'm using kintr and building and
saving my figures in the their own "chunks" then just inlining the
path to the generated figure in the \subloat{..}. Things are working
fine, eg. my default settings are to suppress chunk echo/output,
generate pdf figures, and fig.path='figs/gen-' so:

<<someFig>>
plot(1:10, 1:10, ...)
@

\begin{figure}[...]
...
  \sublfoat[some][caption]{
    \includegraphics[...]{figs/gen-someFig.pdf}
  }
...
\end{figure}

does the trick for me.

HTH,
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list