Skip to content Accesskey=4Skip to sub-navigation Accesskey=3View our Accessibility Options MIT Information Systems Home About IS&T Contact IS&T Site Map Search Advanced Search
Getting StartedGetting Services by Topic or Alphabetically Getting Help

On This Page

[Help]

  

Quick Links

Top Level

Related Links

Ask OLC a question

Athena Consulting Homepage

Helpdesk Stock Answers (for Mac/PC questions)


How to format Matlab code for LATEX

A program called tgrind is available in the sipb locker to help you
convert matlab program listings to a form easily includable in a LaTeX
document. To use this program, type at the prompt:

    athena% add sipb
    athena% add consult
    athena% tgrind -d /mit/consult/lib/matlab/vgrindefs -latex
                -lmatlab filename.m  > filename.tex
Type the above two lines all on one line -----^

To include this file in your document:

o Edit the output from tgrind to remove the first ("\input tgrindmac") and
last ("\vfill\eject\end") lines from the file.

o Make sure you have the tgrind documentstyle option specified.  (Include
tgrind in the square brackets in the \documentstyle command at the top of your
file.)

o Place the line

    \tgrindfile{mycode.m.tex}

in your .tex file where you want to insert the formatted code.

That's all there is to it. For more information on using tgrind to
format other languages, refer to the following stock answer.

     10. LATEX Answers
     21. How to include SOURCE CODE in documents

For other general information, type 'man tgrind' at the athena prompt
(after typing add sipb).


last updated: 5/09/96

MIT Home | Getting Started | Getting Services | Getting Help | About IS&T | Accessibility
Ask a technology question or send a comment about this web page.