## Wednesday, February 25, 2009

### ChkTex with LyX and Miktex 2.7 under Windows XP

ChkTeX is a LaTeX utility for... checking your Latex syntax. It is maintained by Baruch Even.
LyX can use ChkTex utility. But Miktex does not come with this utility.

I propose here a way to activate this functionality using the chktex binary that is distributed in the TeXLive LaTeX system. This is quite simple indeed.

I assume that you have installed Miktex in the "C:\MiKTeX2.7" folder.

First download the chkTexFiles.zip archive from my web server. It contains the necessary files for the installation of chktex under Miktex.
This archive contains the following files:
• .chktexrc
• ChkTeX.exe
• tl90geturl.dll
• tl90gnu.dll
• tl90kpse.dll
The first file (.chktexrc) is the chktex configuration file. You must put it under in the following folder: "C:\MiKTeX2.7\tex\chktex"
The other four files are the executable for chktex and the necessary libraries. You must put them in the folder C:\MiKTeX2.7\miktex\bin.

You must now tell LyX how to find these files.

You activate "Tools/Preferences" menu item in LyX, and in the Output/Latex item in the left menu, you must give the following command for ChkTex:
ChkTeX.exe -l "C:\MiKTeX 2.7\tex\chktex\.chktexrc" -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38
I must admit that I have not dug all the options for ChkTeX, you can probably finetune them using the ChkTeX documentation but these default options work on my installation. If you execute chktex -h in a Dos box, you will get an output that will indicate the role of different options.

Once you save the configuration (do not forget to click on the Save button in the preferences box ;-) ), you can execute "Tools/Check Tex" menu item and it will indicate the potential problems with your LaTeX file. Don't be afraid by the results! :-)

ChkTeX source files are also available from CTAN.

## Sunday, February 15, 2009

### Lyx and Sweave under Windows XP

These instructions propose a solution for making Sweave work under Windows XP, using Lyx 1.6.1 and R-project 2.8.x.

Adapted from the instructions provided by Paul Johnson and Cheng-shan (Frank) Liu:
(see http://n2.nabble.com/Converter-failure-with-Sweave-td479669.html)

These instructions correct some small problems that were impeding the original instructions from working under the recent version of R that I use. I also take into account the fact that the default installation folders of R and Lyx are under Program Files, a path that contains a space, and can cause problems.

We will suppose that Lyx 1.6.1 is installed in C:\Program Files\LyX16 and R in C:\Program Files\R\R-2.8.1 (their default folders under Windows).
1. Place noweb.sty and sweave.sty (part of the R installation - see the share\texmf subfolder of R, see the next instruction) in a folder that can be find by your Latex installation (under texmf-local for example).
2. Copy the content of the C:\Program Files\R\R-2.8.1\share\texmf folder in the previous folder or in another folder under your texmf tree.
3. Refresh the file catalogue of Latex (execute mktexlsr for TexLive in a Dos command box, for example). You can now check the placement of these files by executing kpsewhich noweb.sty in a Dos command box.
4. Reconfigure Lyx (go to Edit-> Reconfigure). Check if you have document class "article(noweb)" or "article(Sweave noweb)" (in Document-> Settings->Document class). If not, you will need to reinstall Lyx.
5. Create a batch script called Rweave.bat and put it in the folder C:\Program Files\Lyx16\bin\. You can create this file using notepad or any other text editor (PSPad is a very nice and free one). The file should contain a one line instruction:
"C:\Program Files\R\R-2.8.1\bin\Rterm" --no-save --args "%1" < "C:/Program Files/LyX16/bin/MakeSweave.R" > "%1.log"
6. Create a R file MakeSweave.R with the following lines and put it in C:\Program Files\Lyx16\bin\:

library(tools)

args <- commandArgs() filename <- args[length(args)] Sweave(filename) basename <- sub("\\.(Rnw|Rtex|nw)\$", "",filename) texi2dvi(paste(basename, ".tex",sep=""), pdf=TRUE)

7. You must now configure in Lyx the converter for noweb files. Go to Edit->Preferences->File Handlers->Converters. In the "From" pulldown, choose Noweb. In the "To" pulldown, choose PDF (pdflatex).In the box called "Converter" type "Rweave \$\$i" without the quotation marks. If necessary, click the “Modify” button and save the new command.
8. You can now test your installation by opening an example file that contains R scraps. For example Paul Johnson's Gamma distribution lyx document.
You can typeset this document using the pdf icon and the resulting file should open in the acrobat viewer you have configured in Lyx.
You should be able to read the results of computations and see the plots.

## Saturday, February 14, 2009

### A free and powerful text processor : LyX

LyX is a nearly WSYWIG front end for Latex. It constitutes a very credible open source alternative to my other preferred (commercial and quite expensive) Latex editor (Scientific Word).

I have been following LyX's development for some years, without being fully convinced by its facilities. I consider that it now constitutes a very useful front-end to Latex: it is very stable and it fully interfaces with all the facilities characterizing Latex (typesetting mathematics, bibliography management, cross references, graphics, integrating results of statistical computations using R-Project - thanks to the Sweave interface, etc). It definitely offers today more functionality than Scientific Word (see below).
As a consequence, I do not have any reserve in advising you to test LyX, I think you will love it. Binary versions are available for all plateforms (Windows, Linux, Mac OS X).

Web site

Wiki