Text FormattingMATLAB code using verbatim

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
bernard_kusel
Posts: 2
Joined: Wed Jun 01, 2011 2:12 am

MATLAB code using verbatim

Post by bernard_kusel »

Hi, I would like to include a section of a MATLAB code in my .tex file. I thought on using the verbatim environment, yet I realized it would be quite hard to include the colors for the reserved words.

Is there an easy way to do this, so that the MATLAB code appears just like it does on the MATLAB editor?

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

MATLAB code using verbatim

Post by localghost »

You should try either listings or minted to format your code. Both support the Matlab language.


Best regards and welcome to the board
Thorsten
bernard_kusel
Posts: 2
Joined: Wed Jun 01, 2011 2:12 am

Re: MATLAB code using verbatim

Post by bernard_kusel »

Thanks for the tips. The minted package didn't work here. I read the package source code pdf and tried to install the additional software required, Pygments. Yet, I couldn't make it work in Windows... It seemed pretty easy for the Unix platform though...

The listings package worked well!

Thanks for the welcome!
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

Re: MATLAB code using verbatim

Post by west.logan »

Go ahead and mark your first post with the "check mark" icon to show it's been solved.
Post Reply