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.

2 commentaires:

Anonymous said...

Hi, thanks much for sharing this. I was trying to get TexLive 2008 working with LEd v0.52 on WinXP however the LEd DVI viewer only showed little blue dots. Apparently this was because tl90kpse.dll was not included in the latest TexLive distro. Simply copying the .dll files from your chkTexFiles.zip into the TexLive\2008\bin\ folder fixed the issue. Hallelujah!

Jeff said...

I had the exact same blue dot problem as the earlier comment. Copying the dll's to ...\texlive\2008\bin\win32\, with "TeX distribution" set to TeXLive2005 in the LEd "DVI Viewer" options worked for me too. Thanks a lot!