Feature SuggestionsEnable Sweave

Suggestions and discussions for new TeXnicCenter features
Post Reply
Bob
Posts: 2
Joined: Mon Sep 03, 2007 3:08 pm

Enable Sweave

Post by Bob »

Hi,

TexnicCenter is my favorite Latex editor. However, as I started using a utility called "Sweave" which allows direct integration of statistical output from the statistics package R into Latex, TexnicCenter becomes less usable.

It would be great to see an add-on or the like which enables the Sweave syntax in TexnicCenter and also allows to automate the process of converting the extended Latex code through Sweave and the processing it further via Latex. That would be awesome!

Many thanks and best regards,
Bob

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
RichardMitten
Posts: 1
Joined: Fri Jul 18, 2008 11:05 am

Re: Enable Sweave

Post by RichardMitten »

Hi Bob,

I have managed to integrate sweave and TexnicCenter under normal build buttons.
It is a little cumbersome to configure but here are the steps:

Oh.... I have the following installed under windows:
-----------------------------------------------------------------------------------------------
unixutils:- A proper port of all the unix command line tools under windows. (Added this to the path)
Mitex:- Which runs smoothly because of unixutils (I think!)(Added this to the path)
R-Project (default install)(Added this to the path)
GSView (Default install)
TexNicCentre (Default install)
-----------------------------------------------------------------------------------------------
So once these are installed run TexNicCentre and configure it using the wizard for a normal project.

When you happy a normal build works do the following:

1) Create a new project lets say demo.tcp
2) There is a default demo.tex file created. Paste in something that will compile, compile it and save the project.

3) Create a MakeDemo.bat batch file with the following contents in the same directory as you project:

copy "C:\Program Files\R\R-2.7.1\share\texmf\*.*" .
R.exe -e "setwd('C:/Documents and Settings/Administrator/Desktop/sweaveDemo/mytestwithsweave'); q();"
r.exe -e "Sweave('demo.Rnw')"
latex demo.tex

This does the following:
Copies all the R-Project + Sweave .sty files to the current directory.
Run's R project and sets the current working directory... (You will need to edit this)
Sweaves hard coded (It needs to be because of the way TexNicCentre Passes quoted args)
Latex's hard coded (It needs to be because of the way TexNicCentre Passes quoted args)

Once that is all done you now need to reconfigure Texniccentre so.....

1) Under menu->Project->Properties Change the demo.tex to demo.Rnw

2) Under menu->Build->Define Output Profiles

Copy and existing output profile (I chose Latex->Ps->PDF)
Give it a new name 'Sweave'

Now simply edit the path to latex compiler to point to you batch file.
For me I change
C:\Program Files\MiKTeX 2.7\miktex\bin\latex.exe
to
C:\Documents and Settings\Administrator\Desktop\sweaveDemo\mytestwithsweave\MakeDemo.bat

Click OK and your done.

You should now have a sweave build option which works.

I am only working on a single latex project at the moment and the sweave option is really hardcoded for a single project... but it's working for me...

Hopefully this will still be of use to you, even (nearly) a year later.


Rgds,

Richard
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

Enable Sweave

Post by T3. »

Hi Richard,

Just a small suggestion about your batch script - you don't have to copy all the .sty files every time your batch is run. You can set the path to .sty files in TEXINPUTS variable:

Code: Select all

set TEXINPUTS=C:/Program Files/R/R-2.7.1/share/texmf;%TEXINPUTS%
Alternatively, you can specify extra include directory as a command line option to latex:

Code: Select all

latex --include-directory="C:/Program Files/R/R-2.7.1/share/texmf" file.tex
You can also avoid hardcoding file paths - let me know what problems you have with that and I can try to help you.

Cheers,

Tomek
Bob
Posts: 2
Joined: Mon Sep 03, 2007 3:08 pm

Re: Enable Sweave

Post by Bob »

Thanks for the replies, guys! Now I see how the build process can be integrated.

But my question was actually referring to the syntax highlighting since the R / Sweave code is messing that totally up.

As has found a new home and is actively developed again, I try to revive my question: Is there some way to get the syntax highlighting to recognize R / Sweave code?

Many thanks,
Bob
Post Reply