On Tue, Mar 3, 2009 at 3:23 AM, Rainer M Krug <[email protected]> wrote: > On Mon, Mar 2, 2009 at 10:30 PM, Paul Johnson <[email protected]> wrote: >> Hello, I don't have any answers, but I have some questions for you.. I >> have an interest because I have been using LyX with Sweave a long >> time, but have not yet needed a beamer Sweave. > > I wanted to use it for lectures, where it would be very nice to have > the code and the result. > >
Wow, this is frustrating. I've hammered on this all night and I've
only succeeded in re-producing the problem as you originally stated
it.
I believe I've gotten down the base of the problem by repeatedly
exporting documents to noweb format and then running them through R.
Recall the transformation from LyX first creates a noweb file *.Rnw
and then it runs "R CMD Sweave whatever.Rnw" to create the tex file,
which is then processed through latex. It is possible to monitor each
step and see where it goes wrong.
Using ERT in the lyx document can generate a working document. From
the attached example "beamerERTSweave.lyx", you should be able to
compile the document even if echo=T. Processing that into Rnw and
then tex, the working LaTeX is like this:
\begin{frame}[containsverbatim]
\frametitle{Here's a title}
\begin{Schunk}
\begin{Sinput}
> plot(gl(5, 20))
\end{Sinput}
\end{Schunk}
\includegraphics{beamerERTSweave-001}
LaTeX can process that.
All we need to do is create a new Frame environment based on
beamer.layout that will add the right code. I tried to take the
BeginPlainFrame environment and revise it to create
BeginVerbatimEnvironment. Like you, I thought this should be a simple
change.
But it fails. A file you can test is "beamertest-1.lyx".
I'm attaching the layout files I was using.
Maybe somebody who writes lots of layout files will take mercy and
tell us how we can modify a frame environment from beamer.layout so
that it creates the proper preamble to create the tex we need. If we
start with this, which changes are needed?
Style BeginPlainFrame
Category Frames
TocLevel 4
KeepEmpty 1
LatexType Command
LatexName lyxframeend{}\lyxplainframe
Margin First_Dynamic
NextNoIndent 1
ParSkip 0
TopSep 2.5
BottomSep 0.5
ParSep 0
Align Center
LabelType Static
LabelBottomSep 0
LeftMargin M
LabelSep xx
LabelString "Frame (no head/foot/sidebars)"
Font
Series Bold
Size Largest
Color Blue
EndFont
LabelFont
Family Roman
Color latex
EndFont
Preamble
\makeatletter
\long\def\lyxplainframe#...@lyxplainframe#1\@lyxframestop}%
\d...@lyxplainframe{\@ifnextchar<{\@@lyxplainframe}{\@@lyxplainframe<*>}}%
\long\def\@@lyxplainframe<#1>#...@lyxframestop#3\lyxframeend{%
\frame<#1>[plain]{\frametitle{#2}#3}}
\makeatother
EndPreamble
End
I tried to change "lyxplainframe" to "lyxverbatimframe" everywhere and
then simply replace [plain] with [containsverbatim] but it didn't get
the job done.
Oh, well.
I'm wondering if this will be useful in the end because it appears to
me that the R output does not want to fit itself very nicely onto the
tight pages of the beamer layout. But, then again, we might find
enthusiasm to fix margins if we could make documents compile when they
have Schunk in them.
--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas
beamertest-1.lyx
Description: application/lyx
beamerERTSweave.lyx
Description: application/lyx
pjbeamer.layout
Description: Binary data
literate-beamer.layout
Description: Binary data
