latex \subfloat{} incompatible with sweave/knitr code
Yes that is one possible solution, but the filename is hard-coded somehow. The key to this problem is a missing new line before <<>>=, which was addressed in https://github.com/downloads/yihui/knitr/knitr-subfloats.pdf The LyX and Rnw source files can be checked out with GIT under https://github.com/yihui/knitr/tree/master/inst/examples If you open knitr-subfloats.lyx, you will see an intentional new line in the ERT, and that is to break \subfloat[asdfa]{<<>>= into \subfloat[asdfa]{ <<>>= Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Wed, Aug 29, 2012 at 6:34 AM, Steve Lianoglou
<mailinglist.honeypot at gmail.com> wrote:
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