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.

7 comments:

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!

AlanJ said...
This comment has been removed by the author.
AlanJ said...

This is brilliant Murat, and exactly what I would like to do under the latest ChkTeX-LyX-Miktex-Win7 combination, however your chkTexFiles.zip link is dead and the only chktex.exe I found (from http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2013-12/msg00251.html) doesn't work as you explain :-(. It is a recent version, so perhaps LyX have changed the piping to chktex.

Does it still work for you? Any suggestions? Is there an alternate link to your executatble and .dlls (which are different)? ANy way forward you can suggest.

TIA,
Jethro Belle

yildi said...

Hi Alan,
I do not use Windows anymore and have not followed the development of chktex under this platform.
Sorry for not being able to be more helpful. Please post back here for other users, if you find a solution to this problem.
All the best,
Murat

AlanJ said...

Thanks to your effort years ago Murat, I pursued this line and the developers have all gotten together to make it happen for everyone without all the effort you had to go through!
http://www.lyx.org/trac/ticket/9989
http://www.ctan.org/tex-archive/support/chktex/
I will be off-line, but anyone needing the releases indicated, please support its pursuance. The developers are keen to get this to you: just overstretched.

krgds,
Jethro Belle

AlanJ said...

Per https://sourceforge.net/p/miktex/feature-requests/226/ the wonderful developers have finally incorporated it within MikTeX so all the workarounds are no longer required. This is confirmed by http://miktex.org/kb/roadmap-2-9 It should appear the LyX menu |Tools>Check TeX> after you have used MikTeX Package Manager to install both miktex-chktex-base and miktex-chktex-bin-2.9 and run the LyX reconfigure.