7/28/2023 0 Comments Lyx windows 10I added another environment in LyX named ScrapCenter, which is for the code chunks that produce plots, because plots are usually centered in the page.Gregor’s original definition for breaking a line was Ctrl Enter. I modified the file literate-scrap.inc so that we can hit the Enter key to start a new line in R code, which is more natural for the users, I think.You are still reading… So first you have to read Gregor Gorjanc’s paper in R News and that make most things clear in this blog entry. It will do no harm to your system, but I need to warn you first in the spirit of “open source”. Under Mac and Linux, it tries to download and copy files to your home directory so that LaTeX and LyX will work properly. But I have to confess it is a really nasty script - (for Windows) it calls several system commands to help the configuration, such as initexmf or mpm, or setx to set the system PATH variable this is a dangerous practice and some users may feel extremely uncomfortable with it. I spent several hours on writing an R script trying to cover all these gory details automatically, so the configuration becomes as easy as source('') For example, you may ask “what’s a texmf tree?” “What’s a layout file? Where is it?” “Where is the preference file?” “What’s a converter?”… Where $$i is a variable in LyX denoting the input fileĮach step involves with several novel concepts for beginners. R -e "library(pgfSweave) pgfSweave($$i,compile.tex=FALSE)" (the critical step) create converters to convert Sweave documents to LaTeX (this is done in the preferences file) and the converter is like.define the literate programming environment in LyX (literate-scrap.inc) and corresponding layouts.put the LaTeX style files such as Sweave.sty under the texmf tree.To make LyX work with Sweave, we need to take these steps: Later I’ll explain how to connect LyX and R/pgfSweave in this way. R can accept a string in its -e argument, e.g. Instead, I use this way: R -q -e "library(pgfSweave) pgfSweave('yourfile.Rnw')" I’m not using this approach in LyX, because this requires system admin privilege to install pgfSweave. PgfSweave comes with a command line usage like Sweave: R CMD pgfSweave your-file.Rnw. In pgfSweave, we just set the width and height naturally in the code chunk options like >=. There might be some text editors which can automatically do this tedious task, but the more serious problem is I cannot see the whole picture - in my eyes there are only commands my imagination is limited - it is difficult for me to imagine \section. For example, I hate typing \item in an itemize environment each time I need a new item. In the past, I did not like writing LaTeX documents just because I hate wasting my time on typing the raw commands. (I don’t want to comment more about Microsoft Word here.) LyX is a somewhat WYSIWYG tool based on LaTeX, and on the first time I saw it I decided that Word was completely useless to me from then on. I use command-line tools a lot every day, but I am still “GUI-addicted”. Gregor Gorjanc published an interesting article “Using Sweave with LyX” in R News in 2008, which (I believe) makes it much easier to use Sweave. This works for MikTeX under Windows (Server 2003 / Win7), and TeXLive 2009 under Ubuntu 10.10, MacTeX 2010 under Mac OS R 2.12.0 or 2.11.1 LyX 1.6.x. Take a look at this video if you feel confused. restart LyX as instructed, and you can enjoy pgfSweave in LyX now - either play with my demo (click to download), or DIY: create a new document, change the document class to article (Sweave noweb) from Document –> Settings, switch the environment to Scrap from the top-left drop list, start your Sweave code chunks click the PDF button to compile this document.run source('') in R under Windows or Ubuntu or Mac I tried my best to automatically configure LaTeX, R and LyX.install LyX and R as well as a working LaTeX toolkit such as MikTeX or TeXLive or MacTeX.Take a look at the video in this entry if you don’t understand the title.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |