lgrind for Win32

Philip A. Viton

May 11, 2004


1  Introduction
2  Setting up lgrind
     2.1  Get the files
     2.2  Set up the files
     2.3  Create the style and documentation files
     2.4  Adjust lgrind.exe
3  Using lgrind
     3.1  The simple strategy
     3.2  The more complicated strategy
A  Using CTAN
B  Changing your path
     B.1  WinNT, Win2k, WinXP
     B.2  Win95, Win 98

1 Introduction

This note describes how to set up the lgrind system for Win32, when the underlying TeX system is not Scientific Word or Scientific WorkPlace, collectively, ‘SWP’. I’ll generally assume that the TeX system is MiKTeX. For SWP users, there is a more extensive discussion, which also describes other options for including programming code in your document, available here .  

2 Setting up lgrind

Here’s how to set up the system. Note that the Win32 support contains a number of files aimed specifically at SWP; you’ll just ignore those.

2.1 Get the files

You will need the following files:

2.2 Set up the files

2.3 Create the style and documentation files

2.4 Adjust lgrind.exe

You must now tell lgrind.exe where to find its definitions file, lgrindef, which in this case is in the same place as the executable. The problem is that there’s no user folder guaranteed to be in the path in all versions of Windows (otherwise I could have compiled lgrind.exe with that information embedded, andtold you to place the file in that folder). So we need to produce a customized version of lgrind.exe.

3 Using lgrind

There are two approaches to pre-processing your code files using lgrind.

3.1 The simple strategy

lgrind can usually deduce the language of your source files from the extension (see toward the end of the lgrindef file for a list of known extensions: you can add to this list; of course, the extension must be unique).

3.2 The more complicated strategy

In this case we create a batch file which explicitly names the language that lgrind is to use. This will probably be necessary only (a) when you use an extension unknown to lgrind (but you can fix this by adding the extension in lgrindef); (b) when you have a case of multiple extensions for the same language: for example, Matlab and Maple might both use .m extensions; or (c) when you want to provide a substitution file (see the lgrind manual) which will not apply to all languages. Note that you’ve already installed language-specific batch files for the C (c2tex.bat) and assembly language (asm2tex.bat) languages.

Creating the batch file

Here I’ll assume you want to create a Matlab-specific batch file. We’ll use asm2tex.bat as a template.

Run your batch file


Appendix A Using CTAN

Here’s how to get files from CTAN, the Comprehensive TeX Archive Network: in this case we want the lgrind files.

Appendix B Changing your path

B.1 WinNT, Win2k, WinXP

B.2 Win95, Win 98

On these operating systems, the path is given in the file config.sys in your root directory.To change the path: