LyXError Inserting MATLAB code

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
peytonator
Posts: 8
Joined: Fri Dec 04, 2009 1:50 pm

Error Inserting MATLAB code

Post by peytonator »

Hello,

I am trying to insert matlab code using ERT:

Code: Select all

\lstset{language=Matlab,%     
	basicstyle=\ttfamily\singlespacing\footnotesize,     
	breaklines=true,%
	morekeywords={matlab2tikz},     
	keywordstyle=\color{blue},%     
	morekeywords=[2]{1}, 
	keywordstyle=[2]{\color{black}},     
	identifierstyle=\color{black},%     
	stringstyle=\color{mylilas},     
	commentstyle=\color{mygreen},% 
	showstringspaces=false,%without this there will be a symbol in the places where there is a space
	numbers=left,%     
	numberstyle={\tiny\ttfamily\color{black}},% size of the numbers     
	numbersep=5pt, % this defines how far the numbers are from the text     	emph=[1]{for,end,break},emphstyle=[1]\color{red}, %some words to emphasise
	caption=Code used for calculating the grand average of induced potentials.  
}
\lstinputlisting{MATLAB_FILE.m}
I have the following in my preamble:

Code: Select all

\usepackage{listings} 
\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
But I get the following error:

Code: Select all

Undefined control sequence.

\lstinputlisting{MATLAB_FILE.m}
                                                \selectlanguage{english}%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
I am using the article document class.

Could you please help?

Recommended reading 2024:

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

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

Post Reply