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.
Text Formatting ⇒ MATLAB code using verbatim
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
You should try either listings or minted to format your code. Both support the Matlab language.
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 2
- Joined: Wed Jun 01, 2011 2:12 am
Re: MATLAB code using verbatim
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!
The listings package worked well!
Thanks for the welcome!
-
- Posts: 87
- Joined: Tue Sep 14, 2010 6:58 pm
Re: MATLAB code using verbatim
Go ahead and mark your first post with the "check mark" icon to show it's been solved.