1

I am trying to make a simple document, showing MATLAB code, and some images. This is my template that I am using.

\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amsfonts}

% Correct bad hyphenation here
\hyphenation{}

\begin{document}

I want to put MATLAB code here.

\begin{figure}[H]
\begin{center}
\includegraphics[width=6in]{case2Rect.png}
\caption{Blah}
\label{fig1}
\end{center}
\end{figure}


\end{document}

The problem is that MATLAB code is full of comments that use '%', and so when I try to compile using pdfLaTeX, it crashes. I am using TexMaker btw. Anyway, I was wondering what technique might be used to go around this problem. I simply need to show MATLAB code, along with some images. I am relatively new to LaTeX.

Thanks.

8
2

You can use the Listings package to include all kinds of code into Latex. The listings package supports syntax highlighting of a number of languages. You can also define own styles.

A good place to start

1
  • 1
    I think what you wrote in your answer has been extensively said in the above comments... Sep 30 '13 at 20:15

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