Georg Baum <[EMAIL PROTECTED]> writes:
Sorry, I did not know about this mail. I just find it out now.
> > There is no difference in syntax between noweb and Sweave. There is only
> > difference in what layout should provide - for example Sweave does not
> > need \usepackage{noweb} - it needs \usepackage{Sweave}, but this is
> > inserted by Sweave intself.
>
> Then I don't understand your problem with importing. It should be as easy as
> defining a sweave->lyx converter that calls tex2lyx in noweb mode. Why do
> you want a new option in tex2lyx as you wrote above?
The point is that literate format has special meaning. If format is literate
then tex2lyx does translation in a bit special way:
- parsing of code chunks to scrap style
- choice of literate-* layouts
Additionally, view/export is done as:
1. export to noweb format, which is LaTeX with
<<chunk>>=
...
@
parts and of course \usepackage{noweb} in preamble
2. weaving with defined weaver to get LaTeX
3. further on
I "want/think" that additional option would be the easiest way since it is
easier to hack in another set of layouts say sweave-* as based on literate-*.
I have been working on this styles for last month and there are some additions
that I would like to see in sweave-* layouts. This could also be done as a copy
step between literate and sweave, but would this cause also change of layout
i.e. say from literate-article to sweave-article? If yes OK, but note that the
other way around i.e. sweave --> literate is not what I want as literate will
put \usepackage{noweb}, while I want \usepackage{Sweave} + some other nifty
stuff. Having another format, say sweave instead of literate, would ease the
converters part.
> > This is again a problem, as I have to use literate in output definition in
> > layout files. Then I would need sweave --> literate converter, but then I
> > again have problem with noweb specific things.
>
> I don't get it. Why would you need a sweave->literate converter? If we don't
> have a sweave backend, export would go like this:
>
> lyx->literate->sweave->{dvisweave,pssweave,pdfsweave}
>
> where the step sweave->{dvisweave,pssweave,pdfsweave} would probably be
> composed of several steps.
The point is that literate behaves differently than latex format as noted above.
After one month of thinking and tweaking the layout files I think that direct
support of Sweave in LyX would really be great and I am realising that probably
only minor changes/additions are needed. The needed structure is already in LyX.
What is needed is option to use this structure just a bit differently - to use
literate-* layouts or sweave-* layouts. I would suggest -l option to tex2lyx
instead of -n as -n is specific to noweb. -l option would also accept literate
paradigm, default would be noweb, but with possibility for sweave i.e.
tex2lyx -l file.nw
tex2lyx -l sweave file.Rnw
I already have sweave-*.layout file, working preferences (configure.py could
be easily enriched with this) and additions to syntax.default (already in).
Thanks and happy new year!
Gregor
# What: LyX (1.4.4) preferences file with Sweave tweaks
# $Id: preferences 57 2007-01-02 00:39:57Z ggorjan $
#
# FORMATS SECTION #############################
#
\format "literate" "Rnw" "Sweave" "" "editor" "editor"
\format "r" "R" "R/S code" "" "editor" "editor"
#
# CONVERTERS SECTION ##########################
#
\converter "literate" "r" "R CMD Stangle $$i" ""
\converter "literate" "latex" "R CMD Sweave $$i" ""
\converter "literate" "pdflatex" "R CMD Sweave $$i" ""
------------------------------------------------------------------
#% Do not delete the line below; configure depends on this
# \DeclareLaTeXClass[article, Sweave.sty]{article (Sweave noweb)}
#
# What: literate-article textclass definition file.
# Author: Gregor Gorjanc <[EMAIL PROTECTED]>
# $Id: literate-article.layout 58 2007-01-02 00:41:59Z ggorjan $
#
# This is a copy of literate-article.layout from LyX, but changed for
# Sweave - NoWeb syntax:
# - changed noweb.sty to Sweave.sty
# - moved preamble to literate-scrap.inc
Format 2
Input article.layout
Input literate-scrap.inc
------------------------------------------------------------------
# What: Style definition for R/S code chunks (scraps)
# Author: Gregor Gorjanc <[EMAIL PROTECTED]>
# $Id: literate-scrap.inc 67 2007-01-02 04:24:10Z ggorjan $
#
# This file is a copy of literate-scrap.inc from LyX, but changed for
# Sweave - NoWeb syntax:
# - added preamble where Sweave is used instead of noweb
# - simplified style for scrap
# - added all align possibilities
# - added subtitle style
# - added character styles for R code
#
# Within scrap, lines are separated by newlines (Ctrl-Return).
Format 2
Preamble
\usepackage{Sweave}
\newcommand{\Rcode}[1]{{\texttt{#1}}}
\newcommand{\Robject}[1]{{\texttt{#1}}}
\newcommand{\Rfunction}[1]{{\texttt{#1}}}
\newcommand{\Rfunction}[1]{{\texttt{#1}}}
\newcommand{\Rfunarg}[1]{{\textit{#1}}}
\newcommand{\Rpackage}[1]{{\textit{#1}}}
\newcommand{\Rmethod}[1]{{\textit{#1}}}
\newcommand{\Rclass}[1]{{\textit{#1}}}
EndPreamble
OutputType literate
Style Subtitle
CopyStyle Title
LaTeXName subtitle
LaTeXType Command
Font
Size Larger
EndFont
End
Style Scrap
LatexType paragraph
LatexName dummy
Margin static
TopSep 0.4
BottomSep 0.4
ParSep 0.4
LabelType static
Align left
# We need all of them, due to figures - works from LyX 1.4.4
AlignPossible block, left, right, center
NewLine 0
PassThru 1
FreeSpacing 1
TextFont
Color latex
Family typewriter
EndFont
End
CharStyle Sexpr
LaTeXName Sexpr
LaTeXType Command
Font
Family typewriter
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle SweaveOpts
LaTeXName SweaveOpts
LaTeXType Command
Font
Family typewriter
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle SweaveInput
LaTeXName SweaveInput
LaTeXType Command
Font
Family typewriter
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Rcode
LaTeXName Rcode
LaTeXType Command
Font
Family typewriter
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Robject
LaTeXName Robject
LaTeXType Command
Font
Family typewriter
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Rcommand
LaTeXName Rcommand
LaTeXType Command
Font
Family typewriter
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Rfunction
LaTeXName Rfunction
LaTeXType Command
Font
Family typewriter
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Rfunarg
LaTeXName Rfunarg
LaTeXType Command
Font
Shape italic
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Rpackage
LaTeXName Rpackage
LaTeXType Command
Font
Shape italic
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Rclass
LaTeXName Rclass
LaTeXType Command
Font
Shape italic
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End
CharStyle Rmethod
LaTeXName Rmethod
LaTeXType Command
Font
Shape italic
Color latex
EndFont
LabelFont
Color blue
Size small
EndFont
End