I know there is available in the MATLAB Central File Exchange site the mcode.sty package, which allows to put MATLAB codes into TeX files.


However, there is also available in LaTeX a package called listings.sty, which I guess does pretty much the same thing.


What is the difference between them? Are there any advantages or disadvantages?

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
    – Ruben
    Nov 29, 2014 at 22:40

1 Answer 1


mcode is customized to write matlab codes. It too uses listings for this job. Hence it is like a ready made shirt, you just wear it. listings is like cloth from which you have to stitch the shirt yourself. It is a general package for typesetting codes. You have to define the setting for matlab yourself and use it.

Hence the bottom line is, with mcode you have predefined settings for matlab code while with listings you have to define them. It is listings that is in action with both packages.

PS: There is matlab-prettifier by jubobs, that is recent and has much more than mcode to offer. I advice to try it for typesetting matlab codes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.